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 배포 완료');
});
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', () => {
const html = renderToStaticMarkup(
createElement(RoomCardV2, {

View File

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