mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-08 07:17:39 +00:00
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user