fix dashboard collapsed output previews

This commit is contained in:
ejclaw
2026-04-29 19:49:33 +09:00
parent 166557bf32
commit 4aca45ca23
2 changed files with 59 additions and 6 deletions

View File

@@ -115,6 +115,53 @@ describe('RoomCardV2', () => {
expect(html).toContain('prod 배포 완료'); expect(html).toContain('prod 배포 완료');
}); });
it('uses canonical room messages for collapsed previews when outputs are empty', () => {
const html = renderToStaticMarkup(
createElement(RoomCardV2, {
activity: activity({
messages: [
{
id: 'bot-1',
sender: 'bot-1',
senderName: 'owner',
content: 'TASK_DONE\n\nprod 배포 완료',
timestamp: '2026-04-28T02:00:00.000Z',
isFromMe: false,
isBotMessage: true,
sourceKind: 'bot',
},
],
pairedTask: {
id: 'task-1',
title: 'Deploy production',
status: 'completed',
roundTripCount: 1,
updatedAt: '2026-04-28T02:01:00.000Z',
currentTurn: null,
outputs: [],
},
}),
activityLoading: false,
busy: false,
draft: '',
entry,
expanded: false,
inboxItems: [],
locale: 'ko',
onDraftChange: () => {},
onSendMessage: () => {},
onToggle: () => {},
pinned: false,
t,
...formatters,
}),
);
expect(html).toContain('TASK_DONE');
expect(html).toContain('prod 배포 완료');
expect(html).not.toContain(t.rooms.noActivity);
});
it('localizes protocol role and verdict labels in Korean rooms', () => { it('localizes protocol role and verdict labels in Korean rooms', () => {
const html = renderToStaticMarkup( const html = renderToStaticMarkup(
createElement(RoomCardV2, { createElement(RoomCardV2, {

View File

@@ -234,6 +234,7 @@ export function RoomCardV2({
turn={turn} turn={turn}
/> />
<CollapsedOutputPreview <CollapsedOutputPreview
agentMessages={agentMessages}
expanded={expanded} expanded={expanded}
isProcessing={isProcessing} isProcessing={isProcessing}
latestOutput={latestOutput} latestOutput={latestOutput}
@@ -251,8 +252,8 @@ export function RoomCardV2({
activityLoading={activityLoading} activityLoading={activityLoading}
expanded={expanded} expanded={expanded}
isProcessing={isProcessing} isProcessing={isProcessing}
latestOutput={latestOutput}
t={t} t={t}
visibleActivityCount={agentMessages.length + watcherMessages.length}
/> />
{expanded ? ( {expanded ? (
<RoomExpandedContent <RoomExpandedContent
@@ -541,18 +542,23 @@ function LiveProgressBody({ text }: { text: string }) {
} }
function CollapsedOutputPreview({ function CollapsedOutputPreview({
agentMessages,
expanded, expanded,
isProcessing, isProcessing,
latestOutput, latestOutput,
}: { }: {
agentMessages: RoomThreadEntry[];
expanded: boolean; expanded: boolean;
isProcessing: boolean; isProcessing: boolean;
latestOutput: RoomOutput | null; latestOutput: RoomOutput | null;
}) { }) {
if (expanded || !latestOutput || isProcessing) return null; const latestThreadEntry = agentMessages.at(-1) ?? null;
const previewText =
latestOutput?.outputText ?? latestThreadEntry?.content ?? null;
if (expanded || !previewText || isProcessing) return null;
return ( return (
<div className="room-preview"> <div className="room-preview">
<ParsedBody text={latestOutput.outputText} truncate={140} /> <ParsedBody text={previewText} truncate={140} />
</div> </div>
); );
} }
@@ -592,18 +598,18 @@ function CollapsedEmptyState({
activityLoading, activityLoading,
expanded, expanded,
isProcessing, isProcessing,
latestOutput,
t, t,
visibleActivityCount,
}: { }: {
activity: DashboardRoomActivity | undefined; activity: DashboardRoomActivity | undefined;
activityLoading: boolean; activityLoading: boolean;
expanded: boolean; expanded: boolean;
isProcessing: boolean; isProcessing: boolean;
latestOutput: RoomOutput | null;
t: Messages; t: Messages;
visibleActivityCount: number;
}) { }) {
if (expanded) return null; if (expanded) return null;
if (!latestOutput && !isProcessing && !activityLoading) { if (visibleActivityCount === 0 && !isProcessing && !activityLoading) {
return <p className="room-empty">{t.rooms.noActivity}</p>; return <p className="room-empty">{t.rooms.noActivity}</p>;
} }
if (activityLoading && !activity) { if (activityLoading && !activity) {