Fix chat comment alignment, avatars, and layout polish

- Agent messages: avatar outside left (matching feed items alignment),
  always shown, consistently uses icon avatar instead of initials
- User messages: avatar outside right, action bar moved below the
  gray bubble, gray darkened to bg-muted
- System events: right-aligned when actor is the current user
- Run messages: use agent icon avatar consistently
- Pass actorType/actorId in event metadata for current-user detection

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-04-06 16:24:09 -05:00
parent 9131cc0355
commit 94652c6079
2 changed files with 204 additions and 163 deletions

View file

@ -360,13 +360,14 @@ function IssueChatUserMessage() {
return ( return (
<MessagePrimitive.Root id={anchorId}> <MessagePrimitive.Root id={anchorId}>
<div className="flex justify-end"> <div className="group flex items-end justify-end gap-2">
<div className="flex max-w-[85%] flex-col items-end">
<div <div
className={cn( className={cn(
"group relative max-w-[85%] min-w-0 overflow-hidden rounded-2xl px-4 py-2.5", "min-w-0 overflow-hidden rounded-2xl px-4 py-2.5",
queued queued
? "bg-amber-50/80 dark:bg-amber-500/10" ? "bg-amber-50/80 dark:bg-amber-500/10"
: "bg-muted/60", : "bg-muted",
pending && "opacity-80", pending && "opacity-80",
)} )}
> >
@ -397,8 +398,9 @@ function IssueChatUserMessage() {
}} }}
/> />
</div> </div>
</div>
<div className="mt-1 flex items-center justify-end gap-1.5 opacity-0 transition-opacity group-hover:opacity-100"> <div className="mt-1 flex items-center justify-end gap-1.5 px-1 opacity-0 transition-opacity group-hover:opacity-100">
<Tooltip> <Tooltip>
<TooltipTrigger asChild> <TooltipTrigger asChild>
<a <a
@ -432,6 +434,10 @@ function IssueChatUserMessage() {
</button> </button>
</div> </div>
</div> </div>
<Avatar size="sm" className="mb-6 shrink-0">
<AvatarFallback>You</AvatarFallback>
</Avatar>
</div> </div>
</MessagePrimitive.Root> </MessagePrimitive.Root>
); );
@ -453,9 +459,11 @@ function IssueChatAssistantMessage() {
: typeof custom.runAgentName === "string" : typeof custom.runAgentName === "string"
? custom.runAgentName ? custom.runAgentName
: "Agent"; : "Agent";
const authorAgentId = typeof custom.authorAgentId === "string" ? custom.authorAgentId : null;
const runId = typeof custom.runId === "string" ? custom.runId : null; const runId = typeof custom.runId === "string" ? custom.runId : null;
const runAgentId = typeof custom.runAgentId === "string" ? custom.runAgentId : null; const runAgentId = typeof custom.runAgentId === "string" ? custom.runAgentId : null;
const runAgentIcon = runAgentId ? agentMap?.get(runAgentId)?.icon : undefined; const agentId = authorAgentId ?? runAgentId;
const agentIcon = agentId ? agentMap?.get(agentId)?.icon : undefined;
const commentId = typeof custom.commentId === "string" ? custom.commentId : null; const commentId = typeof custom.commentId === "string" ? custom.commentId : null;
const notices = Array.isArray(custom.notices) const notices = Array.isArray(custom.notices)
? custom.notices.filter((notice): notice is string => typeof notice === "string" && notice.length > 0) ? custom.notices.filter((notice): notice is string => typeof notice === "string" && notice.length > 0)
@ -476,18 +484,18 @@ function IssueChatAssistantMessage() {
return ( return (
<MessagePrimitive.Root id={anchorId}> <MessagePrimitive.Root id={anchorId}>
<div className="min-w-0 overflow-hidden rounded-sm p-3"> <div className="flex items-start gap-2.5 py-1.5">
<div className="mb-2 flex items-center justify-between gap-3"> <Avatar size="sm" className="mt-0.5 shrink-0">
<div className="flex items-center gap-2"> {agentIcon ? (
{runAgentId ? ( <AvatarFallback><AgentIcon icon={agentIcon} className="h-3.5 w-3.5" /></AvatarFallback>
<Avatar size="sm">
{runAgentIcon ? (
<AvatarFallback><AgentIcon icon={runAgentIcon} className="h-3.5 w-3.5" /></AvatarFallback>
) : ( ) : (
<AvatarFallback>{initialsForName(authorName)}</AvatarFallback> <AvatarFallback>{initialsForName(authorName)}</AvatarFallback>
)} )}
</Avatar> </Avatar>
) : null}
<div className="min-w-0 flex-1">
<div className="mb-1.5 flex items-center justify-between gap-3">
<div className="flex items-center gap-2">
<span className="text-sm font-medium text-foreground">{authorName}</span> <span className="text-sm font-medium text-foreground">{authorName}</span>
{isRunning ? ( {isRunning ? (
<span className="inline-flex items-center gap-1 rounded-full border border-cyan-400/40 bg-cyan-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-cyan-700 dark:text-cyan-200"> <span className="inline-flex items-center gap-1 rounded-full border border-cyan-400/40 bg-cyan-500/10 px-2 py-0.5 text-[10px] font-medium uppercase tracking-[0.14em] text-cyan-700 dark:text-cyan-200">
@ -569,6 +577,7 @@ function IssueChatAssistantMessage() {
) : null} ) : null}
</div> </div>
</div> </div>
</div>
</MessagePrimitive.Root> </MessagePrimitive.Root>
); );
} }
@ -803,6 +812,8 @@ function IssueChatSystemMessage() {
const runAgentName = typeof custom.runAgentName === "string" ? custom.runAgentName : null; const runAgentName = typeof custom.runAgentName === "string" ? custom.runAgentName : null;
const runStatus = typeof custom.runStatus === "string" ? custom.runStatus : null; const runStatus = typeof custom.runStatus === "string" ? custom.runStatus : null;
const actorName = typeof custom.actorName === "string" ? custom.actorName : null; const actorName = typeof custom.actorName === "string" ? custom.actorName : null;
const actorType = typeof custom.actorType === "string" ? custom.actorType : null;
const actorId = typeof custom.actorId === "string" ? custom.actorId : null;
const statusChange = typeof custom.statusChange === "object" && custom.statusChange const statusChange = typeof custom.statusChange === "object" && custom.statusChange
? custom.statusChange as { from: string | null; to: string | null } ? custom.statusChange as { from: string | null; to: string | null }
: null; : null;
@ -814,15 +825,13 @@ function IssueChatSystemMessage() {
: null; : null;
if (custom.kind === "event" && actorName) { if (custom.kind === "event" && actorName) {
return ( const isCurrentUser = actorType === "user" && !!currentUserId && actorId === currentUserId;
<MessagePrimitive.Root id={anchorId}> const isAgent = actorType === "agent";
<div className="flex items-start gap-2.5 py-1.5"> const agentIcon = isAgent && actorId ? agentMap?.get(actorId)?.icon : undefined;
<Avatar size="sm" className="mt-0.5">
<AvatarFallback>{initialsForName(actorName)}</AvatarFallback>
</Avatar>
<div className="min-w-0 flex-1 space-y-1.5"> const eventContent = (
<div className="flex flex-wrap items-baseline gap-x-1.5 gap-y-1 text-sm"> <div className="min-w-0 space-y-1.5">
<div className={cn("flex flex-wrap items-baseline gap-x-1.5 gap-y-1 text-sm", isCurrentUser && "justify-end")}>
<span className="font-medium text-foreground">{actorName}</span> <span className="font-medium text-foreground">{actorName}</span>
<span className="text-muted-foreground">updated this task</span> <span className="text-muted-foreground">updated this task</span>
<a <a
@ -834,8 +843,8 @@ function IssueChatSystemMessage() {
</div> </div>
{statusChange ? ( {statusChange ? (
<div className="flex flex-wrap items-center gap-2 text-sm"> <div className={cn("flex flex-wrap items-center gap-2 text-sm", isCurrentUser && "justify-end")}>
<span className="w-14 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground"> <span className="text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground">
Status Status
</span> </span>
<span className="text-muted-foreground">{humanizeValue(statusChange.from)}</span> <span className="text-muted-foreground">{humanizeValue(statusChange.from)}</span>
@ -845,8 +854,8 @@ function IssueChatSystemMessage() {
) : null} ) : null}
{assigneeChange ? ( {assigneeChange ? (
<div className="flex flex-wrap items-center gap-2 text-sm"> <div className={cn("flex flex-wrap items-center gap-2 text-sm", isCurrentUser && "justify-end")}>
<span className="w-14 text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground"> <span className="text-[10px] font-medium uppercase tracking-[0.14em] text-muted-foreground">
Assignee Assignee
</span> </span>
<span className="text-muted-foreground"> <span className="text-muted-foreground">
@ -859,18 +868,48 @@ function IssueChatSystemMessage() {
</div> </div>
) : null} ) : null}
</div> </div>
);
if (isCurrentUser) {
return (
<MessagePrimitive.Root id={anchorId}>
<div className="flex items-start justify-end gap-2.5 py-1.5">
{eventContent}
</div>
</MessagePrimitive.Root>
);
}
return (
<MessagePrimitive.Root id={anchorId}>
<div className="flex items-start gap-2.5 py-1.5">
<Avatar size="sm" className="mt-0.5">
{agentIcon ? (
<AvatarFallback><AgentIcon icon={agentIcon} className="h-3.5 w-3.5" /></AvatarFallback>
) : (
<AvatarFallback>{initialsForName(actorName)}</AvatarFallback>
)}
</Avatar>
<div className="flex-1">
{eventContent}
</div>
</div> </div>
</MessagePrimitive.Root> </MessagePrimitive.Root>
); );
} }
const displayedRunAgentName = runAgentName ?? (runAgentId ? agentMap?.get(runAgentId)?.name ?? runAgentId.slice(0, 8) : null); const displayedRunAgentName = runAgentName ?? (runAgentId ? agentMap?.get(runAgentId)?.name ?? runAgentId.slice(0, 8) : null);
const runAgentIcon = runAgentId ? agentMap?.get(runAgentId)?.icon : undefined;
if (custom.kind === "run" && runId && runAgentId && displayedRunAgentName && runStatus) { if (custom.kind === "run" && runId && runAgentId && displayedRunAgentName && runStatus) {
return ( return (
<MessagePrimitive.Root id={anchorId}> <MessagePrimitive.Root id={anchorId}>
<div className="flex items-center gap-2.5 py-1.5"> <div className="flex items-center gap-2.5 py-1.5">
<Avatar size="sm"> <Avatar size="sm">
{runAgentIcon ? (
<AvatarFallback><AgentIcon icon={runAgentIcon} className="h-3.5 w-3.5" /></AvatarFallback>
) : (
<AvatarFallback>{initialsForName(displayedRunAgentName)}</AvatarFallback> <AvatarFallback>{initialsForName(displayedRunAgentName)}</AvatarFallback>
)}
</Avatar> </Avatar>
<div className="min-w-0 flex-1"> <div className="min-w-0 flex-1">

View file

@ -235,6 +235,8 @@ function createTimelineEventMessage(args: {
anchorId: `activity-${event.id}`, anchorId: `activity-${event.id}`,
eventId: event.id, eventId: event.id,
actorName, actorName,
actorType: event.actorType,
actorId: event.actorId,
statusChange: event.statusChange ?? null, statusChange: event.statusChange ?? null,
assigneeChange: event.assigneeChange ?? null, assigneeChange: event.assigneeChange ?? null,
}, },