From da5e3931ca72319e24c36eaa23ca9831146ef371 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Sun, 27 Sep 2026 12:15:14 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20fix:=20Title=20an=20Ope?= =?UTF-8?q?n=20Live=20Card=20Only=20by=20a=20Generated=20Label=20(#16412)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🏷️ fix: Title an Open Live Card Only by a Generated Label An open card still repeated its newest row: a running call's intent was counted as a label and put on the header above the very row that shows it, and with no label at all the header said "Thinking…", which the grouped thought row says too. Open, the header now takes only a generated label from the span, the newest batch label or a thought's label, and otherwise a generic running line that no row uses. A call's intent, a reasoning sentence, commentary and the generic thinking line are all row text and are walked past. * 🧪 test: Pin the Open Card's Title to the Running Line While a Thought Streams --- .../__tests__/ActivityPhaseGroup.test.tsx | 59 ++++++++++++++++++- .../components/Chat/Messages/Content/live.ts | 30 ++++++++-- e2e/specs/mock/activity-thought.spec.ts | 4 +- 3 files changed, 84 insertions(+), 9 deletions(-) diff --git a/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx index 5a3c0de2d5..73bbfc989b 100644 --- a/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx +++ b/client/src/components/Chat/Messages/Content/__tests__/ActivityPhaseGroup.test.tsx @@ -595,7 +595,7 @@ describe('ActivityPhaseGroup open live header', () => { expect(within(header).queryByTitle('Next I check the ordering.')).toBeNull(); }); - test('falls back to the generic thinking line when no label has landed', () => { + test('falls back to a running line no row uses when no label has landed', () => { render(
@@ -603,7 +603,62 @@ describe('ActivityPhaseGroup open live header', () => { ); fireEvent.click(screen.getByRole('button')); settle(); - expect(within(screen.getByRole('button')).getByTitle('com_ui_thinking')).toBeInTheDocument(); + const header = screen.getByRole('button'); + expect(within(header).getByTitle('com_ui_running')).toBeInTheDocument(); + expect(within(header).queryByTitle('com_ui_thinking')).toBeNull(); + }); + + const runningCall = (intent: string): TMessageContentParts => + ({ + type: ContentTypes.TOOL_CALL, + [ContentTypes.TOOL_CALL]: { + id: 'r1', + name: 'list_documents', + args: JSON.stringify({ intent }), + type: 'tool_call', + progress: 0.5, + output: '', + }, + }) as unknown as TMessageContentParts; + const batchLabel = (text: string): TMessageContentParts => + ({ + type: ContentTypes.ACTIVITY_LABEL, + activity_label: text, + activity_label_type: 'batch', + pending: false, + }) as unknown as TMessageContentParts; + + test("does not repeat the newest call's intent, which is its own row", () => { + const intent = 'Reading the roadmap card so edits preserve project choices'; + render( + +
+ , + ); + fireEvent.click(screen.getByRole('button')); + settle(); + const header = screen.getByRole('button'); + expect(within(header).queryByTitle(intent)).toBeNull(); + expect(within(header).getByTitle('com_ui_running')).toBeInTheDocument(); + }); + + test('titles an open card by the newest batch label behind a running call', () => { + render( + +
+ , + ); + fireEvent.click(screen.getByRole('button')); + settle(); + expect(within(screen.getByRole('button')).getByTitle('Found the recap')).toBeInTheDocument(); }); }); diff --git a/client/src/components/Chat/Messages/Content/live.ts b/client/src/components/Chat/Messages/Content/live.ts index 78298412db..dceaaa2d51 100644 --- a/client/src/components/Chat/Messages/Content/live.ts +++ b/client/src/components/Chat/Messages/Content/live.ts @@ -284,11 +284,19 @@ function newestLine( * repeating a line of it under the reader's eyes is noise, so the * header keeps to the thought's label. */ const reasoning = typeof part.think === 'string' ? part.think : (part.think?.value ?? ''); - const sentence = preferLabels ? undefined : lastReasoningSentence(reasoning); + const label = part.reasoning_label?.trim(); + if (preferLabels) { + /** Only a generated label will do: the generic thinking line is what + * the grouped thought row itself says. */ + if (label) { + return { text: label, source: `think:${position}`, comboCount: 1 }; + } + continue; + } + const sentence = lastReasoningSentence(reasoning); if (sentence != null) { return { text: sentence, source: `think:${position}`, comboCount: 1 }; } - const label = part.reasoning_label?.trim(); if (label || reasoning.trim()) { return { text: label || localize('com_ui_thinking'), @@ -315,6 +323,11 @@ function newestLine( return { text: labelText, source: `label:${position}`, comboCount: 1 }; } const toolCall = getStandardToolCall(part); + /** A call's line, intent or generic, is the text of its own row, so an + * open card walks past it to the newest label instead. */ + if (toolCall != null && preferLabels) { + continue; + } if (toolCall != null) { const line = toolCallLine(part, toolCall, localize, serverNames, span); return { @@ -331,6 +344,10 @@ function newestLine( }; } } + /** An open card with no label yet is titled by a line no row uses. */ + if (preferLabels && parts.some((part) => part != null)) { + return { text: localize('com_ui_running'), source: 'running', comboCount: 1 }; + } return { text: '', source: '', comboCount: 1 }; } @@ -350,10 +367,11 @@ export function getLiveActivity( localize: Localize, serverNames: readonly string[], attachmentsById?: Record, - /** Name the span by its newest LABEL: a thought's generated label or the - * generic thinking line, a batch label, a call's line — never a line of - * reasoning or commentary. For a header whose rows are on screen, where - * quoting them back is repetition. */ + /** Name the span by its newest generated LABEL alone: a batch label or a + * thought's label, else a generic running line. Never a call's intent, a + * reasoning sentence, commentary or the generic thinking line, since each + * of those is the text of a row. For a header whose rows are on screen, + * where quoting any of them back is repetition. */ preferLabels = false, ): LiveActivity { const span = summarizeSpan(parts, attachmentsById); diff --git a/e2e/specs/mock/activity-thought.spec.ts b/e2e/specs/mock/activity-thought.spec.ts index 8890ce60f3..3e566689f2 100644 --- a/e2e/specs/mock/activity-thought.spec.ts +++ b/e2e/specs/mock/activity-thought.spec.ts @@ -57,7 +57,9 @@ test.describe('live reasoning', () => { if (process.env.E2E_FOLD_SHOTS) { await page.screenshot({ path: `${process.env.E2E_FOLD_SHOTS}/thought-open.png` }); } - expect(open, 'open card title').not.toMatch(/[a-z]\.$/); + /** No label has landed on this span, so the open card takes the + * generic running line, never a sentence of the thought below. */ + expect(open, 'open card title').toBe('Running...'); expect(await messagesView(page).getByTestId('streaming-thought-peek').count()).toBe(0); } }