Skip to content

feat: unified collapse bars for thinking, tool calls, and compaction - #1084

Closed
mitchellkager wants to merge 5 commits into
agegr:mainfrom
mitchellkager:hide-compact
Closed

mitchellkager wants to merge 5 commits into
agegr:mainfrom
mitchellkager:hide-compact

Conversation

@mitchellkager

Copy link
Copy Markdown
Contributor

What

Unifies the collapse/expand UI for thinking blocks, tool calls, and compaction entries into shared top/bottom collapse bars, and adds post-compaction token estimates and elapsed time to the compaction header.

Why

The compaction summary, thinking blocks, and tool call cards each had their own inconsistent expand/collapse affordance (native <details>, separate bars). A single shared pattern is easier to scan and keeps the UI consistent across message types. The compaction header also previously gave no sense of what the compaction did — now it shows the token reduction and how long it took.

Implementation Notes

  • lib/message-display.ts: shared collapse bar helpers; compaction gets a single inline header (compaction (size; X → Y tokens) elapsed) expanding via the top bar and collapsing via either bar.
  • Thinking blocks converted to the same top/bottom bar pattern with duration in the meta column; tool call cards gain a collapse bottom bar under the existing chevron header.
  • lib/session-reader.ts: walks the kept entry chain (firstKeptEntryId → compaction entry's parent) to estimate the post-compaction token count, and derives elapsed time from the entry timestamp gap, so loaded sessions show the estimate inline; live-streamed entries degrade gracefully. systemMessage added to the local CompactionEntry type.
  • Refinement pass: top bar chevron moves right (matching tool-call headers), bottom bar chevron points up, compaction header padding aligned with tool-call headers, compaction summary renders as a code-style block.

Testing

  • New tests in lib/session-reader.test.mjs for the token-estimate/elapsed-time computation.
  • tsc --noEmit, npm run lint, and node --test pass (against the known 7 environment-dependent failures that also fail on main).

- Compaction card gets a single inline header: compaction (size; X -> Y tokens) elapsed, expanding via the top bar and collapsing via top or bottom bar
- Thinking block converted to the same top/bottom bar pattern with duration in the meta column
- Tool call cards gain a collapse bottom bar under the existing chevron header
- Compaction file metadata uses the shared collapse bars instead of native <details>
- session-reader precomputes post-compaction token estimates and elapsed time for loaded sessions; live-streamed entries degrade gracefully
session-reader walks the kept entry chain (firstKeptEntryId to the
compaction entry's parent) to estimate the post-compaction token count
and derives elapsed time from the entry timestamp gap, so the inline
compaction header can show 'X -> Y tokens' and the duration for loaded
sessions; live-streamed entries degrade gracefully. Also adds the
systemMessage field to the local CompactionEntry type.
- top bar chevron moves to the right, matching the tool-call headers
- bottom bar chevron points up (collapses the section upward)
- thinking block title reverts to the Thinking icon (plus dimmed preview)
- compaction top bar gets the same horizontal padding as the tool-call header
- compaction summary renders as a code-style block (mono, subtle background)
@agegr

agegr commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Thanks. I'm not going to take this one. It changes behaviour: compaction is now collapsed by default and its summary is shown as raw <pre> text instead of rendered Markdown.

The new "X → Y tokens" and elapsed time in the compaction header are also wrong in cases I tried: a fully emptied kept range shows ~200k instead of ~100 tokens, tool-call arguments are read from the wrong fields (a 40k-character write counts as ~100 tokens), and idle time before a manual compaction is counted as compaction time.

@agegr agegr closed this Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants