feat(agent-term): show compact_boundary details in per-agent terminal

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.
This commit is contained in:
iris 2026-07-04 11:46:15 +02:00 committed by mara
commit 1fe6783756

View file

@ -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.