mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat(web): make grouped tool summaries specific (#1134)
This commit is contained in:
@@ -141,6 +141,33 @@ describe('isEligibleForToolGrouping', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('Codex activity headings', () => {
|
||||
it('associates only an immediately preceding reasoning heading', () => {
|
||||
const reasoning = makeToolBlock('reasoning-1', 'CodexReasoning', { title: 'Inspecting authentication' })
|
||||
const visible = buildVisibleChatBlocks([
|
||||
reasoning,
|
||||
makeToolBlock('read-1', 'Read', { file_path: 'auth.ts' }),
|
||||
makeToolBlock('read-2', 'Read', { file_path: 'session.ts' }),
|
||||
], { hasMoreMessages: false })
|
||||
|
||||
expect(visible).toHaveLength(2)
|
||||
expect(isToolGroupBlock(visible[1])).toBe(true)
|
||||
expect(isToolGroupBlock(visible[1]) ? visible[1].activityTitle : null).toBe('Inspecting authentication')
|
||||
})
|
||||
|
||||
it('does not carry a heading across a text boundary', () => {
|
||||
const visible = buildVisibleChatBlocks([
|
||||
makeToolBlock('reasoning-1', 'CodexReasoning', { title: 'Inspecting authentication' }),
|
||||
makeTextBlock('text-boundary'),
|
||||
makeToolBlock('read-1', 'Read', { file_path: 'auth.ts' }),
|
||||
makeToolBlock('read-2', 'Read', { file_path: 'session.ts' }),
|
||||
], { hasMoreMessages: false })
|
||||
|
||||
const group = visible.find(isToolGroupBlock)
|
||||
expect(group?.activityTitle).toBeNull()
|
||||
})
|
||||
})
|
||||
|
||||
describe('buildVisibleChatBlocks', () => {
|
||||
it('groups contiguous eligible root tool cards', () => {
|
||||
const visible = buildVisibleChatBlocks([
|
||||
|
||||
@@ -30,6 +30,7 @@ export type ToolGroupBlock = {
|
||||
defaultOpen: boolean
|
||||
historyState: 'complete' | 'needs-older-history'
|
||||
needsOlderHistory: boolean
|
||||
activityTitle?: string | null
|
||||
summary: ToolGroupSummary
|
||||
}
|
||||
|
||||
@@ -258,6 +259,11 @@ export function buildVisibleChatBlocks(
|
||||
|
||||
const startsAtOldestVisibleBoundary = visibleBlocks.length === 0
|
||||
const needsOlderHistory = options.hasMoreMessages && startsAtOldestVisibleBoundary
|
||||
const previousBlock = visibleBlocks.at(-1)
|
||||
const activityTitle = previousBlock?.kind === 'tool-call'
|
||||
&& previousBlock.tool.name === 'CodexReasoning'
|
||||
? getInputStringAny(previousBlock.tool.input, ['title'])
|
||||
: null
|
||||
visibleBlocks.push({
|
||||
kind: 'tool-group',
|
||||
id: createToolGroupId(tools, needsOlderHistory, previousGroups),
|
||||
@@ -269,6 +275,7 @@ export function buildVisibleChatBlocks(
|
||||
defaultOpen: false,
|
||||
historyState: needsOlderHistory ? 'needs-older-history' : 'complete',
|
||||
needsOlderHistory,
|
||||
activityTitle,
|
||||
summary: summarizeToolGroup(tools)
|
||||
})
|
||||
index = cursor - 1
|
||||
|
||||
Reference in New Issue
Block a user