Files
PaperClipAI/ui/src/lib/issue-chat-human-author.ts
T
DottaandPaperclip 26d71d8def Fix human author identity and viewer-relative alignment in task chat (#15494)
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>
2026-10-09 17:04:20 -05:00

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,
};
}