Skip to content

fix(slash): preserve /compact ordering and resume state#80

Merged
hakula139 merged 8 commits into
mainfrom
fix/compact-review-followups
May 12, 2026
Merged

fix(slash): preserve /compact ordering and resume state#80
hakula139 merged 8 commits into
mainfrom
fix/compact-review-followups

Conversation

@hakula139
Copy link
Copy Markdown
Owner

Summary

Hardens /compact after review so compact boundaries flush before queued writes, summarization keeps every streamed text fragment, and resume reconstructs the compact tail without replaying stale pre-compact messages.

The pass also normalizes prompt / comment prose around instruction text, removes avoidable lint suppressions through smaller helpers, and tightens shared TUI rendering code that the compact block depends on.

Design decisions

  • Make compact a session-writer barrier. SessionCmd::Compact now forces the actor batch to flush before later queued commands run, so prompts typed during compaction cannot share the same buffered write after the boundary.
  • Load compact entries as generation boundaries. The store keeps CompactInfo for resume display, resets sidecars at the boundary, and only accepts messages from the new compact tail. This preserves archival JSONL while keeping the active replay chain compact-aware.
  • Collect stream start-frame text. Compaction now reads text from both content_block_start and content_block_delta, matching the wire protocol rather than assuming all text arrives as deltas.
  • Prefer small refactors over lint suppressions. The loader state, app constructor, shared bar prefix, and checked dimension casts remove local #[expect] use where the code was reducible.

Changes

File Description
agent/compaction.rs Collect start-frame text, use raw strings for escaped block-kind checks, tighten the stripped request shape, and normalize compaction instructions.
session/actor.rs, session/state.rs, session/handle.rs Treat compact as a flush barrier, keep compact state changes transactional, and trim comments to the invariants worth keeping.
session/entry.rs, session/store.rs Add CompactInfo, load compact boundaries explicitly, filter stale old-chain writes, and extract the compact-aware loader builder.
agent/event.rs, main.rs, tui/app.rs, tui/components/chat.rs Carry compact metadata through resume and render the boundary block while hiding the synthetic root from visible chat.
tui/components/chat/blocks*, tui/components/input.rs Share accent-bar continuation rendering and replace unchecked dimension casts with saturating conversions.
prompt/sections.rs, prompt/instructions.rs, session/title_generator.rs, slash/init.rs, docs/design/slash/compact.md Rewrap instruction prose at the project width, remove semicolon-heavy phrasing, and align the compact design doc with current behavior.

Test plan

  • cargo fmt --all --check
  • cargo build
  • cargo clippy --all-targets -- -D warnings: zero warnings
  • cargo test: 1919 tests pass
  • cargo llvm-cov --ignore-filename-regex 'main\.rs': 98.62% line coverage
  • pnpm lint
  • pnpm spellcheck

@hakula139 hakula139 added bug Something isn't working documentation Improvements or additions to documentation labels May 12, 2026
@hakula139 hakula139 self-assigned this May 12, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hakula139 hakula139 merged commit f790200 into main May 12, 2026
4 checks passed
@hakula139 hakula139 deleted the fix/compact-review-followups branch May 12, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant