Show live context compaction status in the TUI (#42319)

## Why

Context compaction was only reported after it completed, so the TUI did not
show when compaction was actively making room to continue.

## What changed

- Show `Compacting context` as soon as manual or server-driven compaction
  starts, with an elapsed timer independent of the current turn timer.
- Preserve the compaction status across follow-up input and transient activity,
  while still allowing retry errors to take precedence.
- Restore in-progress compaction timing from thread snapshots and add the live
  duration to the completion message.
- Clear stale compaction state when the turn starts, completes, or terminates.

## Testing

Added TUI tests covering manual and server-driven compaction, narrow rendering,
follow-up input, replay and task switching, retry status, timer preservation,
and turn termination.

GitOrigin-RevId: 804e1bc553315da24ff1f99462e8e282818cada3
This commit is contained in:
Eric Traut authored and copyberry committed 2026-09-02 18:03:55 +00:00
1 parent a94a5db629
commit a526f54b00
17 files changed
+392 -8

No files matched your search

@@ -0,0 +1,5 @@
---
source: tui/src/chatwidget/tests/compaction_tests.rs
expression: normalize_compaction_snapshot(lines_to_single_string(&lines))
---
• Context compacted · <elapsed>
@@ -0,0 +1,11 @@
---
source: tui/src/chatwidget/tests/compaction_tests.rs
expression: "normalize_compaction_snapshot(render_bottom_popup(&chat, 80))"
---
• Compacting context (<elapsed> • esc to interrupt)
└ Making room to continue.
› Ask Codex to do anything
gpt-5.6-sol default · /tmp/project
@@ -0,0 +1,11 @@
---
source: tui/src/chatwidget/tests/compaction_tests.rs
expression: "normalize_compaction_snapshot(render_bottom_popup(&chat, 40))"
---
• Compacting context (<elapsed> • esc to i…
└ Making room to continue.
› Ask Codex to do anything
gpt-5.6-sol default · /tmp/project
@@ -0,0 +1,11 @@
---
source: tui/src/chatwidget/tests/compaction_tests.rs
expression: "normalize_compaction_snapshot(render_bottom_popup(&chat, 80))"
---
• Compacting context (<elapsed> • esc to interrupt)
└ Making room to continue.
› Ask Codex to do anything
gpt-5.6-sol default · /tmp/project