Skip to content

feat(tui): show compaction summary in context dialog - #3877

Merged
Sayt-0 merged 1 commit into
mainfrom
feat/3870-context-compaction-summary
Jul 31, 2026
Merged

feat(tui): show compaction summary in context dialog#3877
Sayt-0 merged 1 commit into
mainfrom
feat/3870-context-compaction-summary

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • expose the latest compaction summary through the context breakdown
  • display the full summary in the scrollable /context dialog
  • include the verbatim summary in /context clipboard output
  • derive the displayed summary and prompt messages from the same session-history snapshot

Closes #3870.

Preview

Approximate plain-text rendering of /context after a compaction. The actual TUI applies the existing category colors, border, usage bar, and scrollbar styles.

╭────────────────────────────────────────────────────────────────────╮
│ Context Window                                                     │
│ openai/gpt-4o  •  limit: 128.0K tokens                             │
├────────────────────────────────────────────────────────────────────┤
│ █████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
│ ~25.4K of 128.0K tokens (20%)                                      │
│                                                                    │
│ ■ System prompt          1.2K    <1%  (3 messages)                 │
│ ■ Tool definitions       8.4K     7%  (23 tools)                   │
│ ■ Prompt files            600    <1%  (1 file)                     │
│ ■ Messages               6.1K     5%  (12 messages)                │
│ ■ Tool results           8.2K     6%  (18 results)                 │
│ ■ Compaction summary      900    <1%  (1 summary)                  │
│ ■ Free space           102.6K    80%                               │
│                                                                    │
│ Latest compaction summary                                          │
│ The user is implementing issue #3870. The chosen UX is to expose   │
│ the latest compaction summary from the /context dialog. The        │
│ implementation must preserve scrolling and clipboard support.      │
│ Tests and linting currently pass.                                  │
│                                                                    │
│ Token counts are estimates; the provider's tokenizer may count     │
│ differently.                                                       │
│                                                                    │
│ ↑↓ scroll                         c copy                  Esc close │
╰────────────────────────────────────────────────────────────────────╯

When live sessions or file inventories exist, the summary is placed after those selectable sections so their navigation mapping remains unchanged:

Live sessions
▶ root       a81c04f2  25.4K of 128.0K (20%)  (current)
  developer  531cb912  12.1K of 128.0K (9%)

Attached files
  main.go     2.1K   2%  /project/main.go

Latest compaction summary
The latest summary wraps to the dialog width and remains scrollable.

The section is omitted when the session has never been compacted. Pressing c copies the same summary verbatim as plain text.

Issue expectations

Expectation Implementation
View a compaction result summary /context renders the latest stored compaction summary
Understand what the model retained The exact summary injected into subsequent model context is shown verbatim
Preserve usability for long summaries Text wraps to the dialog width and remains inside the existing scroll view
Work after session persistence/resume The view reads the already persisted session summary

A semantic retained-versus-dropped diff and agent-level persistent compaction instructions are intentionally excluded. FirstKeptEntry identifies the verbatim retained message boundary, but it cannot prove which facts a summarizing model preserved semantically.

Validation

  • task test
  • go test -race ./pkg/session ./pkg/runtime ./pkg/tui/dialog
  • ./scripts/build.sh
  • golangci-lint run
  • go run ./lint .
  • go mod tidy --diff
  • gofmt -l .

@Sayt-0
Sayt-0 requested a review from a team as a code owner July 31, 2026 12:07
@aheritier aheritier added area/core Core agent runtime, session management area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Jul 31, 2026
@Sayt-0
Sayt-0 merged commit 8003b63 into main Jul 31, 2026
15 checks passed
@Sayt-0
Sayt-0 deleted the feat/3870-context-compaction-summary branch July 31, 2026 15:17
trungutt pushed a commit to trungutt/docker-agent that referenced this pull request Aug 3, 2026
…dialog

Reflects changes from docker#3877.
Source PR: docker#3877

The /context dialog now displays the verbatim text of the most recent
compaction summary when a session has been compacted. Updated the TUI
features documentation and compaction guide to reflect this new capability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Core agent runtime, session management area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/sessions For features/issues/fixes related to session lifecycle (resume, persistence, export) area/tui For features/issues/fixes related to the TUI kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to view compaction summary

3 participants