feat(core,cli): prioritize summary for topics (#24608) (#24609)

This commit is contained in:
Abhijit Balaji
2026-04-03 12:26:38 -04:00
committed by GitHub
parent ca0e6f9bd9
commit beaa2a968b
3 changed files with 42 additions and 45 deletions

View File

@@ -10,6 +10,7 @@ import { ToolGroupMessage } from './ToolGroupMessage.js';
import { import {
UPDATE_TOPIC_TOOL_NAME, UPDATE_TOPIC_TOOL_NAME,
TOPIC_PARAM_TITLE, TOPIC_PARAM_TITLE,
TOPIC_PARAM_SUMMARY,
TOPIC_PARAM_STRATEGIC_INTENT, TOPIC_PARAM_STRATEGIC_INTENT,
makeFakeConfig, makeFakeConfig,
CoreToolCallStatus, CoreToolCallStatus,
@@ -257,42 +258,15 @@ describe('<ToolGroupMessage />', () => {
unmount(); unmount();
}); });
it('renders update_topic tool call using TopicMessage', async () => { it('renders update_topic tool call prioritizing summary over strategic_intent', async () => {
const toolCalls = [ const toolCalls = [
createToolCall({ createToolCall({
callId: 'topic-tool', callId: 'topic-tool-priority',
name: UPDATE_TOPIC_TOOL_NAME, name: UPDATE_TOPIC_TOOL_NAME,
args: { args: {
[TOPIC_PARAM_TITLE]: 'Testing Topic', [TOPIC_PARAM_TITLE]: 'Testing Topic',
[TOPIC_PARAM_STRATEGIC_INTENT]: 'This is the description', [TOPIC_PARAM_SUMMARY]: 'This is the summary',
}, [TOPIC_PARAM_STRATEGIC_INTENT]: 'This should be ignored',
}),
];
const item = createItem(toolCalls);
const { lastFrame, unmount } = await renderWithProviders(
<ToolGroupMessage {...baseProps} item={item} toolCalls={toolCalls} />,
{
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',
}, },
}), }),
]; ];
@@ -309,6 +283,34 @@ describe('<ToolGroupMessage />', () => {
const output = lastFrame(); const output = lastFrame();
expect(output).toContain('Testing Topic: '); expect(output).toContain('Testing Topic: ');
expect(output).toContain('This is the summary'); 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(
<ToolGroupMessage {...baseProps} item={item} toolCalls={toolCalls} />,
{
config: baseMockConfig,
settings: fullVerbositySettings,
},
);
const output = lastFrame();
expect(output).toContain('Testing Topic: ');
expect(output).toContain('Fallback intent');
unmount(); unmount();
}); });
@@ -319,7 +321,7 @@ describe('<ToolGroupMessage />', () => {
name: UPDATE_TOPIC_TOOL_NAME, name: UPDATE_TOPIC_TOOL_NAME,
args: { args: {
[TOPIC_PARAM_TITLE]: 'Testing Topic', [TOPIC_PARAM_TITLE]: 'Testing Topic',
[TOPIC_PARAM_STRATEGIC_INTENT]: 'This is the description', [TOPIC_PARAM_SUMMARY]: 'This is the summary',
}, },
}), }),
createToolCall({ createToolCall({

View File

@@ -26,19 +26,20 @@ export const isTopicTool = (name: string): boolean =>
export const TopicMessage: React.FC<TopicMessageProps> = ({ args }) => { export const TopicMessage: React.FC<TopicMessageProps> = ({ args }) => {
const rawTitle = args?.[TOPIC_PARAM_TITLE]; const rawTitle = args?.[TOPIC_PARAM_TITLE];
const title = typeof rawTitle === 'string' ? rawTitle : undefined; const title = typeof rawTitle === 'string' ? rawTitle : undefined;
const rawIntent = const rawDescription =
args?.[TOPIC_PARAM_STRATEGIC_INTENT] || args?.[TOPIC_PARAM_SUMMARY]; args?.[TOPIC_PARAM_SUMMARY] || args?.[TOPIC_PARAM_STRATEGIC_INTENT];
const intent = typeof rawIntent === 'string' ? rawIntent : undefined; const description =
typeof rawDescription === 'string' ? rawDescription : undefined;
return ( return (
<Box flexDirection="row" marginLeft={2} flexWrap="wrap"> <Box flexDirection="row" marginLeft={2} flexWrap="wrap">
<Text color={theme.text.primary} bold wrap="truncate-end"> <Text color={theme.text.primary} bold wrap="truncate-end">
{title || 'Topic'} {title || 'Topic'}
{intent && <Text>: </Text>} {description && <Text>: </Text>}
</Text> </Text>
{intent && ( {description && (
<Text color={theme.text.secondary} wrap="wrap"> <Text color={theme.text.secondary} wrap="wrap">
{intent} {description}
</Text> </Text>
)} )}
</Box> </Box>

View File

@@ -78,7 +78,7 @@ exports[`<ToolGroupMessage /> > Golden Snapshots > renders header when scrolled
exports[`<ToolGroupMessage /> > Golden Snapshots > renders mixed tool calls including update_topic 1`] = ` exports[`<ToolGroupMessage /> > 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 │ │ ✓ read_file Read a file │
@@ -142,12 +142,6 @@ exports[`<ToolGroupMessage /> > Golden Snapshots > renders two tool groups where
" "
`; `;
exports[`<ToolGroupMessage /> > Golden Snapshots > renders update_topic tool call using TopicMessage > update_topic_tool 1`] = `
"
Testing Topic: This is the description
"
`;
exports[`<ToolGroupMessage /> > Golden Snapshots > renders with limited terminal height 1`] = ` exports[`<ToolGroupMessage /> > Golden Snapshots > renders with limited terminal height 1`] = `
"╭──────────────────────────────────────────────────────────────────────────╮ "╭──────────────────────────────────────────────────────────────────────────╮
│ ✓ tool-with-result Tool with output │ │ ✓ tool-with-result Tool with output │