feat: add microcompact_boundary event handling in web UI

Adds support for Claude Code's microcompact_boundary system message type to display context microcompaction events with token savings information in the chat UI. Shows a package icon with formatted token count (e.g., "Context compacted (saved 32K tokens)"). close #108
This commit is contained in:
weishu
2026-01-26 10:30:27 +08:00
parent e53abfb840
commit 8137ce4f23
3 changed files with 23 additions and 0 deletions
+5
View File
@@ -58,6 +58,11 @@ export function getEventPresentation(event: AgentEvent): EventPresentation {
const ms = typeof event.durationMs === 'number' ? event.durationMs : 0
return { icon: '⏱️', text: `Turn: ${formatDuration(ms)}` }
}
if (event.type === 'microcompact') {
const saved = typeof event.tokensSaved === 'number' ? event.tokensSaved : 0
const formatted = saved >= 1000 ? `${Math.round(saved / 1000)}K` : String(saved)
return { icon: '📦', text: `Context compacted (saved ${formatted} tokens)` }
}
try {
return { icon: null, text: JSON.stringify(event) }
} catch {