From beaa2a968b1844ff4a72b95cbec4fdbd5d2bebc3 Mon Sep 17 00:00:00 2001 From: Abhijit Balaji Date: Fri, 3 Apr 2026 12:26:38 -0400 Subject: [PATCH] feat(core,cli): prioritize summary for topics (#24608) (#24609) --- .../messages/ToolGroupMessage.test.tsx | 66 ++++++++++--------- .../ui/components/messages/TopicMessage.tsx | 13 ++-- .../ToolGroupMessage.test.tsx.snap | 8 +-- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/packages/cli/src/ui/components/messages/ToolGroupMessage.test.tsx b/packages/cli/src/ui/components/messages/ToolGroupMessage.test.tsx index 7108d76154..2f0ec8101b 100644 --- a/packages/cli/src/ui/components/messages/ToolGroupMessage.test.tsx +++ b/packages/cli/src/ui/components/messages/ToolGroupMessage.test.tsx @@ -10,6 +10,7 @@ import { ToolGroupMessage } from './ToolGroupMessage.js'; import { UPDATE_TOPIC_TOOL_NAME, TOPIC_PARAM_TITLE, + TOPIC_PARAM_SUMMARY, TOPIC_PARAM_STRATEGIC_INTENT, makeFakeConfig, CoreToolCallStatus, @@ -257,42 +258,15 @@ describe('', () => { unmount(); }); - it('renders update_topic tool call using TopicMessage', async () => { + it('renders update_topic tool call prioritizing summary over strategic_intent', async () => { const toolCalls = [ createToolCall({ - callId: 'topic-tool', + callId: 'topic-tool-priority', name: UPDATE_TOPIC_TOOL_NAME, args: { [TOPIC_PARAM_TITLE]: 'Testing Topic', - [TOPIC_PARAM_STRATEGIC_INTENT]: 'This is the description', - }, - }), - ]; - const item = createItem(toolCalls); - - const { lastFrame, unmount } = await renderWithProviders( - , - { - config: baseMockConfig, - settings: fullVerbositySettings, - }, - ); - - const output = lastFrame(); - expect(output).toContain('Testing Topic: '); - expect(output).toContain('This is the description'); - expect(output).toMatchSnapshot('update_topic_tool'); - unmount(); - }); - - it('renders update_topic tool call with summary instead of strategic_intent', async () => { - const toolCalls = [ - createToolCall({ - callId: 'topic-tool-summary', - name: UPDATE_TOPIC_TOOL_NAME, - args: { - [TOPIC_PARAM_TITLE]: 'Testing Topic', - summary: 'This is the summary', + [TOPIC_PARAM_SUMMARY]: 'This is the summary', + [TOPIC_PARAM_STRATEGIC_INTENT]: 'This should be ignored', }, }), ]; @@ -309,6 +283,34 @@ describe('', () => { const output = lastFrame(); expect(output).toContain('Testing Topic: '); expect(output).toContain('This is the summary'); + expect(output).not.toContain('This should be ignored'); + unmount(); + }); + + it('renders update_topic tool call falling back to strategic_intent', async () => { + const toolCalls = [ + createToolCall({ + callId: 'topic-tool-fallback', + name: UPDATE_TOPIC_TOOL_NAME, + args: { + [TOPIC_PARAM_TITLE]: 'Testing Topic', + [TOPIC_PARAM_STRATEGIC_INTENT]: 'Fallback intent', + }, + }), + ]; + const item = createItem(toolCalls); + + const { lastFrame, unmount } = await renderWithProviders( + , + { + config: baseMockConfig, + settings: fullVerbositySettings, + }, + ); + + const output = lastFrame(); + expect(output).toContain('Testing Topic: '); + expect(output).toContain('Fallback intent'); unmount(); }); @@ -319,7 +321,7 @@ describe('', () => { name: UPDATE_TOPIC_TOOL_NAME, args: { [TOPIC_PARAM_TITLE]: 'Testing Topic', - [TOPIC_PARAM_STRATEGIC_INTENT]: 'This is the description', + [TOPIC_PARAM_SUMMARY]: 'This is the summary', }, }), createToolCall({ diff --git a/packages/cli/src/ui/components/messages/TopicMessage.tsx b/packages/cli/src/ui/components/messages/TopicMessage.tsx index 0aea7f5dbd..b91b04b5be 100644 --- a/packages/cli/src/ui/components/messages/TopicMessage.tsx +++ b/packages/cli/src/ui/components/messages/TopicMessage.tsx @@ -26,19 +26,20 @@ export const isTopicTool = (name: string): boolean => export const TopicMessage: React.FC = ({ args }) => { const rawTitle = args?.[TOPIC_PARAM_TITLE]; const title = typeof rawTitle === 'string' ? rawTitle : undefined; - const rawIntent = - args?.[TOPIC_PARAM_STRATEGIC_INTENT] || args?.[TOPIC_PARAM_SUMMARY]; - const intent = typeof rawIntent === 'string' ? rawIntent : undefined; + const rawDescription = + args?.[TOPIC_PARAM_SUMMARY] || args?.[TOPIC_PARAM_STRATEGIC_INTENT]; + const description = + typeof rawDescription === 'string' ? rawDescription : undefined; return ( {title || 'Topic'} - {intent && : } + {description && : } - {intent && ( + {description && ( - {intent} + {description} )} diff --git a/packages/cli/src/ui/components/messages/__snapshots__/ToolGroupMessage.test.tsx.snap b/packages/cli/src/ui/components/messages/__snapshots__/ToolGroupMessage.test.tsx.snap index 270f8e1b8f..a3cf745607 100644 --- a/packages/cli/src/ui/components/messages/__snapshots__/ToolGroupMessage.test.tsx.snap +++ b/packages/cli/src/ui/components/messages/__snapshots__/ToolGroupMessage.test.tsx.snap @@ -78,7 +78,7 @@ exports[` > Golden Snapshots > renders header when scrolled exports[` > Golden Snapshots > renders mixed tool calls including update_topic 1`] = ` " - Testing Topic: This is the description + Testing Topic: This is the summary ╭──────────────────────────────────────────────────────────────────────────╮ │ ✓ read_file Read a file │ @@ -142,12 +142,6 @@ exports[` > Golden Snapshots > renders two tool groups where " `; -exports[` > Golden Snapshots > renders update_topic tool call using TopicMessage > update_topic_tool 1`] = ` -" - Testing Topic: This is the description -" -`; - exports[` > Golden Snapshots > renders with limited terminal height 1`] = ` "╭──────────────────────────────────────────────────────────────────────────╮ │ ✓ tool-with-result Tool with output │