Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(chat): summarise a collapsed tool run by call count alone (#19387)

Arvin Xu349f3d2892d0
diff --git a/locales/en-US/chat.json b/locales/en-US/chat.json
index aefe97e93df..c724bc4c9c6 100644
--- a/locales/en-US/chat.json
+++ b/locales/en-US/chat.json
@@ -2241,8 +2241,8 @@
"workflow.collapse": "Collapse",
"workflow.expandFull": "Expand fully",
"workflow.failedSuffix": "(failed)",
- "workflow.summaryAcrossTools": "across {{count}} tools",
- "workflow.summaryCallsLead": "{{count}} calls: {{tools}}",
+ "workflow.summaryCallsTotal_one": "{{count}} call",
+ "workflow.summaryCallsTotal_other": "{{count}} calls",
"workflow.summaryFailed": "{{count}} failed",
"workflow.thoughtForDuration": "Thought for {{duration}}",
"workflow.toolDisplayName.activateDevice": "Activated device",
diff --git a/locales/zh-CN/chat.json b/locales/zh-CN/chat.json
index b343bf88935..5dace004841 100644
--- a/locales/zh-CN/chat.json
+++ b/locales/zh-CN/chat.json
@@ -2241,8 +2241,8 @@
"workflow.collapse": "收起",
"workflow.expandFull": "全部展开",
"workflow.failedSuffix": "(失败)",
- "workflow.summaryAcrossTools": "等 {{count}} 种工具",
- "workflow.summaryCallsLead": "{{count}} 次调用:{{tools}}",
+ "workflow.summaryCallsTotal_one": "共 {{count}} 次调用",
+ "workflow.summaryCallsTotal_other": "共 {{count}} 次调用",
"workflow.summaryFailed": "{{count}} 次失败",
"workflow.thoughtForDuration": "思考了 {{duration}}",
"workflow.toolDisplayName.activateDevice": "激活了设备",
diff --git a/packages/locales/src/default/chat.ts b/packages/locales/src/default/chat.ts
index acf3e06fccb..560a5f2fc93 100644
--- a/packages/locales/src/default/chat.ts
+++ b/packages/locales/src/default/chat.ts
@@ -2525,8 +2525,8 @@ export default {
'viewSwitcher.page': 'Page',
'viewSwitcher.task': 'Task',
'workflow.failedSuffix': '(failed)',
- 'workflow.summaryAcrossTools': 'across {{count}} tools',
- 'workflow.summaryCallsLead': '{{count}} calls: {{tools}}',
+ 'workflow.summaryCallsTotal_one': '{{count}} call',
+ 'workflow.summaryCallsTotal_other': '{{count}} calls',
'workflow.summaryFailed': '{{count}} failed',
'workflow.thoughtForDuration': 'Thought for {{duration}}',
'workflow.toolDisplayName.activateDevice': 'Activated device',
diff --git a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts
index 441dcbce7b9..01eadba4658 100644
--- a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts
+++ b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.test.ts
@@ -21,7 +21,7 @@ describe('tool display names', () => {
expect(getToolDisplayName('web_search')).toBe('Searched the web');
});
- it('uses friendly Codex labels in workflow summaries', () => {
+ it('summarises a workflow as the total call count only', () => {
const summary = getWorkflowSummaryText([
blk({
id: '0',
@@ -29,53 +29,33 @@ describe('tool display names', () => {
{ apiName: 'command_execution', id: 'tool-1', result: { content: 'ok' } } as any,
{ apiName: 'command_execution', id: 'tool-2', result: { content: 'ok' } } as any,
{ apiName: 'file_change', id: 'tool-3', result: { content: 'ok' } } as any,
- { apiName: 'mcp_tool_call', id: 'tool-4', result: { content: 'ok' } } as any,
- { apiName: 'web_search', id: 'tool-5', result: { content: 'ok' } } as any,
],
}),
+ blk({
+ id: '1',
+ tools: [{ apiName: 'web_search', id: 'tool-4', result: { content: 'ok' } } as any],
+ }),
]);
- expect(summary).toContain('Ran a command (2)');
- expect(summary).toContain('Edited a file');
- expect(summary).toContain('Called MCP tool');
- expect(summary).toContain('Searched the web');
- expect(summary).not.toContain('Command_execution');
- expect(summary).not.toContain('File_change');
- expect(summary).not.toContain('Mcp_tool_call');
- expect(summary).not.toContain('Web_search');
+ // No per-tool breakdown in the fold — the expanded list already has it.
+ expect(summary).toBe('4 calls');
});
- it('leads the summary with the total call count and appends the tool-kind count when truncated', () => {
- const tools = [
- ...Array.from({ length: 6 }, (_, i) => ({ apiName: 'a', id: `a-${i}` })),
- ...Array.from({ length: 4 }, (_, i) => ({ apiName: 'b', id: `b-${i}` })),
- ...Array.from({ length: 2 }, (_, i) => ({ apiName: 'c', id: `c-${i}` })),
- { apiName: 'd', id: 'd-0' },
- { apiName: 'e', id: 'e-0', result: { error: { message: 'boom' } } },
- { apiName: 'f', id: 'f-0' },
- ];
- const summary = getWorkflowSummaryText([blk({ id: '0', tools: tools as any })]);
+ it('counts a single call too, instead of naming the tool', () => {
+ const summary = getWorkflowSummaryText([
+ blk({ id: '0', tools: [{ apiName: 'command_execution', id: 'tool-1' }] as any }),
+ ]);
- // total calls (15) leads, "calls total" / "共" wording is gone
- expect(summary.startsWith('15 calls:')).toBe(true);
- expect(summary).not.toContain('calls total');
- // truncated tool list is followed by the kind count; failures stay in the details
- expect(summary).toContain('across 6 tools');
- expect(summary).not.toContain('failed');
+ // Plural form depends on the active language (the test i18n runs zh rules).
+ expect(summary).toMatch(/^1 calls?$/);
});
- it('omits the total call count when each tool is called once', () => {
+ it('falls back to reasoning time when a workflow has no tool calls', () => {
const summary = getWorkflowSummaryText([
- blk({
- id: '0',
- tools: [
- { apiName: 'a', id: 'a-0' },
- { apiName: 'b', id: 'b-0' },
- ] as any,
- }),
+ blk({ id: '0', reasoning: { content: '', duration: 21_000 } as any }),
]);
- expect(summary).not.toContain('calls:');
+ expect(summary).toBe('Thought for 21s');
});
it('uses friendly labels for Linear MCP tool names', () => {
diff --git a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts
index d1d98384065..772b06d3389 100644
--- a/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts
+++ b/src/features/Conversation/Messages/AssistantGroup/toolDisplayNames.ts
@@ -332,71 +332,31 @@ export const formatReasoningDuration = (ms: number): string => {
return seconds > 0 ? `${minutes}m ${seconds}s` : `${minutes}m`;
};
-const WORKFLOW_SUMMARY_TOP_N = 3;
-
+/**
+ * Collapsed-workflow summary: the total number of tool calls, nothing more.
+ * A per-tool breakdown ("Ran a command (62), Read output (2)") is detail the
+ * expanded list already carries — the fold only needs the scale of the work.
+ */
export const getWorkflowSummaryText = (blocks: AssistantContentBlock[]): string => {
- const tools = blocks.flatMap((b) => b.tools ?? []);
-
- const groups = new Map<string, { count: number }>();
- for (const tool of tools) {
- const existing = groups.get(tool.apiName) || { count: 0 };
- existing.count++;
- groups.set(tool.apiName, existing);
- }
+ const totalCalls = blocks.reduce((sum, block) => sum + (block.tools?.length ?? 0), 0);
- const entries = [...groups.entries()];
- const totalKinds = entries.length;
- const totalCalls = entries.reduce((sum, [, { count }]) => sum + count, 0);
-
- const formatToolPart = ([apiName, info]: [string, { count: number }]): string => {
- const name = getToolDisplayName(apiName);
- return info.count > 1 ? `${name} (${info.count})` : name;
- };
-
- // List all kinds when few; truncate to top N (by call count) when many.
- // "+1 more" reads awkwardly, so we only collapse when there are ≥2 extra kinds beyond top N.
- const displayedEntries =
- totalKinds <= WORKFLOW_SUMMARY_TOP_N + 1
- ? entries
- : [...entries].sort(([, a], [, b]) => b.count - a.count).slice(0, WORKFLOW_SUMMARY_TOP_N);
-
- // The tool list, e.g. "Task Create (5), Edit (4), Read (2)".
- let toolsText = displayedEntries.map(formatToolPart).join(', ');
-
- // Append "across N tools" when the list is truncated — otherwise it duplicates the visible list.
- if (displayedEntries.length < totalKinds) {
- toolsText += ` ${t('workflow.summaryAcrossTools', {
- count: totalKinds,
- defaultValue: 'across {{count}} tools',
+ if (totalCalls > 0)
+ return t('workflow.summaryCallsTotal', {
+ count: totalCalls,
+ defaultValue_one: '{{count}} call',
+ defaultValue_other: '{{count}} calls',
ns: 'chat',
- })}`;
- }
-
- // Lead with the total call count when a tool was called more than once — it's the most
- // useful signal, so it goes first ("15 calls: …"). When totalCalls equals totalKinds the
- // count is redundant with the list, so we just show the list.
- const segments: string[] =
- totalKinds > 1 && totalCalls > totalKinds
- ? [
- t('workflow.summaryCallsLead', {
- count: totalCalls,
- defaultValue: '{{count}} calls: {{tools}}',
- ns: 'chat',
- tools: toolsText,
- }),
- ]
- : [toolsText];
-
- let result = segments.join(' · ');
+ });
+ // Thinking-only workflows have no calls to count — fall back to the reasoning time
+ // so the collapsed row is never blank.
const totalReasoningMs = blocks.reduce((sum, b) => sum + (b.reasoning?.duration ?? 0), 0);
- if (totalReasoningMs > 0) {
- result += ` · ${t('workflow.thoughtForDuration', {
+ if (totalReasoningMs > 0)
+ return t('workflow.thoughtForDuration', {
defaultValue: 'Thought for {{duration}}',
duration: formatReasoningDuration(totalReasoningMs),
ns: 'chat',
- })}`;
- }
+ });
- return result;
+ return '';
};