mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-30 21:49:18 +01:00
Preserve human author identity in task chat and align only the current viewer on the right. Show other humans and agents on the left with their own identity. Include mixed-author Storybook journeys and regression coverage. Co-Authored-By: Paperclip <noreply@paperclip.ing>
24 lines
1016 B
TypeScript
24 lines
1016 B
TypeScript
import type { CompanyUserProfile } from "./company-members";
|
|
|
|
/** Task messages load uploaded Paperclip avatars automatically, never remote URLs. */
|
|
export function paperclipHumanAvatarUrl(value: string | null | undefined): string | null {
|
|
return value && /^\/api\/assets\/[^/?#]+\/content$/.test(value) ? value : null;
|
|
}
|
|
|
|
export function resolveIssueChatHumanAuthor(args: {
|
|
authorName?: string | null;
|
|
authorUserId?: string | null;
|
|
currentUserId?: string | null;
|
|
userProfileMap?: ReadonlyMap<string, CompanyUserProfile> | null;
|
|
}) {
|
|
const { authorName, authorUserId, currentUserId, userProfileMap } = args;
|
|
const profile = authorUserId ? userProfileMap?.get(authorUserId) : null;
|
|
const isCurrentUser = Boolean(authorUserId && currentUserId && authorUserId === currentUserId);
|
|
return {
|
|
isCurrentUser,
|
|
authorName: profile?.label?.trim() || authorName?.trim() ||
|
|
(authorUserId === "local-board" ? "Board" : isCurrentUser ? "You" : "User"),
|
|
avatarUrl: profile?.image ?? null,
|
|
};
|
|
}
|