Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🏷️ fix: Title an Open Live Card Only by a Generated Label (#16412)

Danny Avilada5e3931ca72
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(
<ActivityPhaseGroup labelPart={makeLabelPart('')} hasContent liveParts={[thought()]}>
<div data-testid="phase-content" />
@@ -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(
+ <ActivityPhaseGroup
+ labelPart={makeLabelPart('')}
+ hasContent
+ liveParts={[runningCall(intent)]}
+ >
+ <div data-testid="phase-content" />
+ </ActivityPhaseGroup>,
+ );
+ 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(
+ <ActivityPhaseGroup
+ labelPart={makeLabelPart('')}
+ hasContent
+ liveParts={[batchLabel('Found the recap'), runningCall('Reading the roadmap card')]}
+ >
+ <div data-testid="phase-content" />
+ </ActivityPhaseGroup>,
+ );
+ 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<string, TAttachment[] | undefined>,
- /** 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);
}
}