From 1fe67837563e9037e2588adbb90d5594bffbcd35 Mon Sep 17 00:00:00 2001 From: iris Date: Sat, 4 Jul 2026 11:46:15 +0200 Subject: [PATCH] feat(agent-term): show compact_boundary details in per-agent terminal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compact_boundary events currently render as the generic "⚙ compact_boundary" muted note. The event carries useful metadata — pre/post token counts, duration and trigger — that are invisible to the operator. With this change the row reads: · ⚙ compact · manual · 772k→6k tokens · 101s Fields rendered (all guarded — missing fields are silently omitted): - trigger ("manual" or "auto") - pre_tokens→post_tokens (formatted with k/M suffixes) - duration_ms (ms or s) Closes #2187. --- frontend/packages/agent/src/app.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/frontend/packages/agent/src/app.js b/frontend/packages/agent/src/app.js index 80c7b15a..013fe80b 100644 --- a/frontend/packages/agent/src/app.js +++ b/frontend/packages/agent/src/app.js @@ -1837,6 +1837,27 @@ window.marked = marked; api.details('note', summary, body); return; } + // compact_boundary: claude completed a compaction pass. The metadata + // carries pre/post token counts, duration, and the trigger (manual vs + // auto). Show a single summary line so the operator can gauge how much + // context was shed. + if (v.subtype === 'compact_boundary') { + const m = v.compact_metadata || {}; + const parts = ['⚙ compact']; + if (m.trigger) parts.push(m.trigger); + if (m.pre_tokens != null && m.post_tokens != null) { + const fmtTok = (n) => n >= 1_000_000 ? (n / 1_000_000).toFixed(1) + 'M' + : n >= 1_000 ? Math.round(n / 1000) + 'k' + : String(n); + parts.push(fmtTok(m.pre_tokens) + '→' + fmtTok(m.post_tokens) + ' tokens'); + } + if (m.duration_ms != null) { + const ms = m.duration_ms; + parts.push(ms < 1000 ? ms + 'ms' : (ms / 1000).toFixed(1) + 's'); + } + api.row('note', parts.join(' · ')); + return; + } // Other system subtypes (context_window_exceeded, etc.) — render a // muted note with the subtype label; reserve the loud orange `sys` // catch-all for truly unrecognised top-level types.