Repository navigation
feat(agent): accept a prompt during manual compaction and run it after - #1680
Merged
Merged
Conversation
`compact` acknowledged and then summarised on its own worker, but that worker held a read guard on the session for the whole summary — minutes on a long conversation. Every mutating command queued behind it, so the dispatcher refused prompts outright with `session_busy` for that window and every surface greyed out its send button. The window is exactly when a reader, watching a long conversation be summarised, writes their next message. The summary now runs without the session lock: `StandaloneCompaction` captures the handles it needs (all of them Arc clones the live session shares) under one short guard, and the worker drops the guard before the model call. A prompt written into the session meanwhile is accepted, receipted and queued exactly like one written behind a run. `compaction_in_progress` still fences the transcript — the summary's snapshot and its commit must not disagree — so the queued prompt starts when the worker opens the fence and hands the session's scheduler a turn through the channel the completion monitor already uses (`SchedulerWake::CompactionFinished`). The fence is read after the acceptance, so a compaction that settles in between cannot leave a prompt queued forever: its wake runs under the same session lock and either sees this prompt or has already cleared the flag, in which case the prompt starts itself. The client-side holds from the previous commit go away: mobile, desktop and the TUI send as usual during a compaction, and their composers keep showing it as information rather than as a block. A history reset still refuses prompts — a half-replaced transcript is no place for a queued message — and the other transcript mutators (`set_model`, `set_tools`, `fork`, `abort_session`, …) keep failing fast with `session_busy`.
huichen
enabled auto-merge (squash)
November 24, 2026 02:25
huichen
added a commit
that referenced
this pull request
Nov 25, 2026
…nding it to the queue A manual compaction owns the session for as long as the summary takes — minutes on a long conversation. The Agent takes a prompt written meanwhile and runs it when the fence opens (#1680), but that leaves the message in a queue this window says nothing about: the draft vanished from the box and nothing arrived, which reads as "my message disappeared". Take the click instead, the way the phone already does (#1679): the draft stays in the box, the send control reads busy, the control row says 压缩完成后发送…, and the words that were there when the button was pressed go out when the compaction ends. Four endings are not a send and all keep the draft — edited during the wait (text, attachments or the card's answer), switched conversation, a run taking the session meanwhile, or the window closing. The wait is local state, not the Agent's queue: a held message dies with the window, which is the behaviour the user picked for this surface. The send path itself is untouched: compaction still is not a reason to disable the button, and nothing about the Agent's compaction or queue semantics changes. Verified: tsc --noEmit, eslint, and the whole desktop suite (442 files / 6296 tests) green; the new `Composer.compaction.test.tsx` fails outright with the hold removed and separately with the "edited meanwhile" comparison removed. Captured against the demo data in headless Chrome: the same click before (draft gone, message queued silently) and after (draft kept, control busy, hint shown).
huichen
added a commit
that referenced
this pull request
Nov 25, 2026
…nding it to the queue (#1696) A manual compaction owns the session for as long as the summary takes — minutes on a long conversation. The Agent takes a prompt written meanwhile and runs it when the fence opens (#1680), but that leaves the message in a queue this window says nothing about: the draft vanished from the box and nothing arrived, which reads as "my message disappeared". Take the click instead, the way the phone already does (#1679): the draft stays in the box, the send control reads busy, the control row says 压缩完成后发送…, and the words that were there when the button was pressed go out when the compaction ends. Four endings are not a send and all keep the draft — edited during the wait (text, attachments or the card's answer), switched conversation, a run taking the session meanwhile, or the window closing. The wait is local state, not the Agent's queue: a held message dies with the window, which is the behaviour the user picked for this surface. The send path itself is untouched: compaction still is not a reason to disable the button, and nothing about the Agent's compaction or queue semantics changes. Verified: tsc --noEmit, eslint, and the whole desktop suite (442 files / 6296 tests) green; the new `Composer.compaction.test.tsx` fails outright with the hold removed and separately with the "edited meanwhile" comparison removed. Captured against the demo data in headless Chrome: the same click before (draft gone, message queued silently) and after (draft kept, control busy, hint shown).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
A manual (standalone) context compaction used to hold a read guard on the session for the entire summary — minutes of model time on a long conversation. Every mutating command queued behind it, the dispatcher refused prompts with
session_busyfor that window, and all three client surfaces greyed out Send. That window is exactly when a reader watching a long conversation being summarised writes the next message.The summary now runs without the session lock:
StandaloneCompactioncaptures the handles it needs under one short guard and drops it before the model call, so the session stays addressable and its queue keeps accepting prompts. A prompt written meanwhile is accepted and queued like one written behind a run, and starts when the checkpoint commits (SchedulerWake::CompactionFinished).compaction_in_progressstill fences the transcript, so the summary's snapshot and its commit cannot disagree: a history reset still refuses prompts, andset_model/set_tools/fork/abort_sessionkeep failing fast withsession_busy. The client-side holds are removed — mobile, desktop and the TUI send as usual during a compaction, and their composers keep showing it as information rather than as a block.Commits
Verification
Local, on the branch tip
88702172c(Rust pinned to 1.99.1 perrust-toolchain.toml; Homebrew's 1.96.0 shadows it, so the pinned bin went first onPATH;ulimit -n 8192):cargo fmt --all -- --check→ cleancargo check -p future-agent -p future-tui --all-targets→ cleancargo clippy -p future-agent -p future-tui --all-targets -- -D warnings→ cleancargo test -p future-agent --lib→ 3129 passed, 0 failed, 7 ignoredcargo test -p future-tui --lib→ 1849 passed, 0 failed, 4 ignored on re-run. The first run had one failure,workbench::run::driver_tests::menus_and_verbs::the_worktree_verbs_plan_create_and_refuse_a_second_copy, panicking onfailed to spawn git: No such file or directory (os error 2); that individual test passes in isolation and the whole suite passes on re-run at the same SHA,tui/src/workbench/run.rsis untouched by this branch, and the hazard is documented in that file (sibling tests swap the process-globalPATHfor stub and empty directories while a repository test spawnsgitby name). Known cross-testPATHrace, not this change.desktop:tsc --noEmitclean;eslinton the touched files clean;vitest run src/features/agent/Composer.delivery.test.tsx→ 9 passedmobile:tsc --noEmitclean;npx jest --runInBandon the five touched suites → 181 passedUser-visible changes
Prompting while a manual compaction runs, on mobile, desktop and the TUI:
session_busy.88702172c(with the mergeb32b0bb33that carried it into this branch).bin/notice.pydoes not exist in this repository, so this section is the record.