11import * as React from "react" ;
22import { Bot , Brain , ChevronDown , Radio , TerminalSquare } from "lucide-react" ;
33
4+ import {
5+ resolveUserLabel ,
6+ type UserProfileLookup ,
7+ } from "@/features/profile/lib/identity" ;
48import { cn } from "@/shared/lib/cn" ;
59import { Markdown } from "@/shared/ui/markdown" ;
10+ import { UserAvatar } from "@/shared/ui/UserAvatar" ;
611import type { TranscriptItem } from "./agentSessionTypes" ;
712import { ToolItem } from "./AgentSessionToolItem" ;
813import { formatTranscriptTime } from "./agentSessionUtils" ;
@@ -12,10 +17,12 @@ export function AgentSessionTranscriptList({
1217 agentName,
1318 emptyDescription,
1419 items,
20+ profiles,
1521} : {
1622 agentName : string ;
1723 emptyDescription : string ;
1824 items : TranscriptItem [ ] ;
25+ profiles ?: UserProfileLookup ;
1926} ) {
2027 if ( items . length === 0 ) {
2128 return (
@@ -31,12 +38,16 @@ export function AgentSessionTranscriptList({
3138 < div
3239 aria-label = "Live ACP transcript"
3340 aria-live = "polite"
34- className = "mx-auto w-full max-w-3xl py-1"
41+ className = "w-full py-1"
3542 role = "log"
3643 >
3744 { items . map ( ( item ) => (
3845 < div className = "mt-4 first:mt-0" key = { item . id } >
39- < TranscriptItemView agentName = { agentName } item = { item } />
46+ < TranscriptItemView
47+ agentName = { agentName }
48+ item = { item }
49+ profiles = { profiles }
50+ />
4051 </ div >
4152 ) ) }
4253 </ div >
@@ -46,12 +57,16 @@ export function AgentSessionTranscriptList({
4657const TranscriptItemView = React . memo ( function TranscriptItemView ( {
4758 agentName,
4859 item,
60+ profiles,
4961} : {
5062 agentName : string ;
5163 item : TranscriptItem ;
64+ profiles ?: UserProfileLookup ;
5265} ) {
5366 if ( item . type === "message" ) {
54- return < MessageItem agentName = { agentName } item = { item } /> ;
67+ return (
68+ < MessageItem agentName = { agentName } item = { item } profiles = { profiles } />
69+ ) ;
5570 }
5671 if ( item . type === "tool" ) {
5772 return < ToolItem item = { item } /> ;
@@ -68,24 +83,44 @@ const TranscriptItemView = React.memo(function TranscriptItemView({
6883function MessageItem ( {
6984 agentName,
7085 item,
86+ profiles,
7187} : {
7288 agentName : string ;
7389 item : Extract < TranscriptItem , { type : "message" } > ;
90+ profiles ?: UserProfileLookup ;
7491} ) {
7592 const isAssistant = item . role === "assistant" ;
7693 const text = item . text . trim ( ) ;
94+ const authorProfile = item . authorPubkey
95+ ? profiles ?. [ item . authorPubkey . toLowerCase ( ) ]
96+ : null ;
97+ const authorLabel = item . authorPubkey
98+ ? resolveUserLabel ( {
99+ pubkey : item . authorPubkey ,
100+ fallbackName : item . title ,
101+ profiles,
102+ } )
103+ : item . title || "User" ;
104+
77105 return (
78106 < div
79107 className = { cn (
80- "flex px-1 py-1 animate-in fade-in duration-200 motion-reduce:animate-none" ,
81- isAssistant ? "flex-row" : "ml-auto flex-row-reverse" ,
108+ "flex flex-row px-1 py-1 animate-in fade-in duration-200 motion-reduce:animate-none" ,
82109 ) }
83110 data-role = { isAssistant ? "assistant-message" : "user-message" }
84111 >
112+ { ! isAssistant ? (
113+ < UserAvatar
114+ avatarUrl = { authorProfile ?. avatarUrl ?? null }
115+ className = "mr-2 mt-1 h-5 w-5 shrink-0 rounded-full text-[8px]"
116+ displayName = { authorLabel }
117+ size = "xs"
118+ />
119+ ) : null }
85120 < div
86121 className = { cn (
87- "group relative min-w-0 flex flex-col gap-1" ,
88- isAssistant ? "w-full items-start " : "max-w-[85%] items-end " ,
122+ "group relative min-w-0 flex flex-col items-start gap-1" ,
123+ isAssistant ? "w-full" : "max-w-[85%]" ,
89124 ) }
90125 >
91126 { isAssistant ? (
@@ -182,7 +217,7 @@ function LifecycleItem({
182217 return (
183218 < div
184219 className = { cn (
185- "flex items-center justify-center gap-1.5 px-4 py-2 text-center text-xs" ,
220+ "flex items-center justify-start gap-1.5 px-1 py-2 text-left text-xs" ,
186221 isError ? "text-destructive" : "text-muted-foreground" ,
187222 ) }
188223 >
0 commit comments