fix(ui-conversation): ignore legacy compact events without ids

This commit is contained in:
imccyu
2026-08-09 20:21:49 +08:00
parent fcbc97a88d
commit 0cfe852c2d
2 changed files with 23 additions and 1 deletions
@@ -39,7 +39,9 @@ export const compactionDefinition: ConversationNodeDefinition<CompactionState> =
|| event.type === 'compact/summary'
|| event.type === 'compact/end') {
if (event.data.sourceCommandId !== undefined) return null
return { id: String(event.data.compactionId), role: event.type === 'compact/start' ? 'start' : 'update' }
const compactionId: unknown = event.data.compactionId
if (typeof compactionId !== 'string' || compactionId === '') return null
return { id: compactionId, role: event.type === 'compact/start' ? 'start' : 'update' }
}
return null
},
@@ -698,6 +698,26 @@ describe('built-in conversation node Definitions', () => {
})
})
it('ignores legacy compaction transactions without correlation ids', () => {
const value = assembler([
at(10, 'compact/start', { turn: null }),
at(11, 'compact/end', { turn: null, error: 'This operation was aborted' }),
at(20, 'compact/start', { turn: null }),
at(21, 'compact/summary', {
summary: [{ type: 'text', text: 'legacy summary' }],
shadowedSeqs: [1, 2, 3],
shadowedTokenCount: 42,
}),
at(22, 'user/message', {
...textMessage('legacy-checkpoint', 'checkpoint'),
source: { kind: 'plugin', plugin: 'compact' },
}, { surfaceOp: { op: 'replace', start: 1, end: 3 } }),
at(23, 'compact/end', { turn: null }),
], true)
expect(node(snapshot(value), 'compaction')).toBeUndefined()
})
it('suppresses a turn error when the loaded tail contains only a later retry attempt', () => {
const value = assembler([
at(5, 'llm/retry', {