Files
openclaude/scripts
beardthelionandGitHub 716c1d47f6 feat(compact): auto-compact prompt on /resume + determinate progress bar (#1386)
* feat(compact): auto-compact prompt on /resume + determinate progress bar

On /resume, if the conversation exceeds 70% of the auto-compact threshold,
a dialog appears offering to compact before continuing. Shows token count,
context window usage, and effective window percentage. Also adds a
determinate progress bar during compaction that advances as the summary
streams in.

- Add RESUME_COMPACT_PROMPT feature flag (enabled)
- Add shouldPromptCompactOnResume() threshold gate
- Add ResumeCompactPrompt dialog component
- Emit compact_progress events during streaming in compact service
- Render ProgressBar next to spinner during compaction in REPL
- Add 5 tests for threshold gating logic

* feat(compact): determinate progress bar via streamed text deltas

Wire compact_progress events from streamed summary output (forkedAgent
onStreamEvent forwards text deltas) and render a determinate ProgressBar
in the REPL, replacing the indeterminate spinner during compaction.
Extracts the bar into a CompactProgressBar component shared by manual
/compact and the resume-triggered path. Emits coarse hooks/start ticks
on the session-memory path so the bar moves immediately.

* fix(compact): keep spinner visible and use bracketed progress bar

Render the "Compacting conversation" spinner throughout compaction with
the progress bar beneath it, instead of swapping the spinner out for the
bar. Redraw the bar as a bracketed fill ([███····]) with no background
rectangle, so it no longer reads as one solid block.

* docs: remove resume-compact-prompt plan file

Per PR review feedback — drop the planning doc from the PR.

* fix(compact): prompt to compact on CLI --continue/--resume startup

Startup resume paths (--continue, --resume <id>, ResumeConversation
screen) install initialMessages via the initial useState rather than
the resume() callback, so the threshold check never ran. Schedule the
prompt from the mount-time initialMessages effect as well.

* fix(compact): use MessageType alias for resumeCompactPending state

main aliases the message type import as `Message as MessageType`; the
rebased resumeCompactPending state still referenced the bare `Message`.

* fix(compact): always close session-memory progress and fix progress-ratio units

- Wrap the session-memory compaction attempt in try/finally so compact_end
  is always emitted, even when it returns null or throws, preventing a stuck
  progress bar/spinner.
- Clear compactProgressRatio in resetLoadingState so an aborted or errored
  compaction does not leave the progress bar rendered in the idle UI.
- Fix the progress denominator unit mismatch: estimatedOutputChars now uses a
  token-to-char converted estimate (preCompactTokenCount) instead of the
  token-scale preCompactTokenCount * 0.25, so progress no longer advances too
  fast and hits the cap prematurely.
2026-06-14 11:26:28 +08:00
..