Repository navigation
app: leave without waiting for crew member opens - #2016
Merged
Merged
Conversation
AbirAbbas
force-pushed
the
fix/app-leave-with-crews
branch
2 times, most recently
from
October 28, 2026 20:41
eb162d2 to
e0d6430
Compare
Quitting's optional file cleanup took every agent's gate, so a crew member still opening (its host's welcome slow or missing) held the engine past the desktop's stop. Clean up only conversations whose gate is free; a pending open keeps its files. Held conversations keep the quit and resume road. Closing the app's stdin now arms the leave bound at Close entry, before the backend lock, as the first SIGTERM does; before, EOF armed it only after taking that lock. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
AbirAbbas
force-pushed
the
fix/app-leave-with-crews
branch
from
October 28, 2026 21:13
e0d6430 to
3a119f0
Compare
This was referenced Oct 29, 2026
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.
From Santosh's feedback: "cmd q quit seems to take a really long time". Found while measuring quits on a real crew.
What was wrong (app mode)
closeReferences,reapBlank) took every agent's gate. A crew member whose open was waiting on a slow or missing host welcome owned its gate, soClosewaited on it, past the desktop's stop. Reproduced on Linux by withholding the member host's welcome: both app/v3 and this branch's base stayed alive until a diagnostic SIGQUIT. The goroutine dump showsCloseindetachReferenceson the member's gate, which the crew-hold goroutine owns while waiting inremote.Client.attach.Close, which tookb.mufirst. A held lock left an EOF-only leave unbounded. This matters on Windows, where the desktop can only close stdin.What changes
Close's first step, beforeb.mu. EOF, shutdown and the first signal now arm the same watchdog. Signals are still counted, so a second SIGTERM still ends the process at once.markQuit, interruption, release, final saves, service cleanup and the overall leave allowance keep their order and size. The terminal is unchanged.Manual verification (Linux, real binaries, isolated homes, loopback stub)
Stalled member host: app/v3 and the unfixed branch needed SIGQUIT after 2 s for both EOF and SIGTERM. The fixed binary exits 0 in 4 ms on EOF and 27 ms on SIGTERM; the member's transcript and queued task stay on disk.
Matrix, 3 trials each, EOF only and SIGTERM only: no chats, idle chat, working chat, one held crew, crew member mid-turn, question-blocked chat.
The Windows quit kill is fixed by #2009, not by this PR
On Windows every quit used to end in "codeaf did not end; killed (SIGKILL) after 7.0 s". A goroutine dump from a diagnostic Windows build showed
Closewaiting on a release, which waited oncellstore.Recorder.Drainfor the final capture of a workspace that was the whole user profile. #2009 (now on app/v3) seals only the chat's own folder for home and drive-root workspaces. Re-measured on Windows with an engine built from app/v3 d902739, using the same crew/home-folder home: stdin close → exit in 119–161 ms, and a desktop quit of a home-folder chat ends in 0.1 s. This PR stays for what #2009 does not cover: the stdin watchdog gap and a crew member's pending open.Checks
gofmt,go vet ./cmd/codeaf, and named tests:appcrewleave_test.go(the leave bound with the backend lock held, a pending crew open skipped by cleanup with its files kept) plus the neighbouring quit/close tests. One adversarial review: merge-ready. CI (ci.yml,ci-full.yml) has been dispatched; it is judged against an app/v3 Full baseline.Merge order: after #2009. Keep #2009's final-save defer, its fresh save contexts and its
appLeaveWait + 3*cellstore.SealWithin; this change only moves when the watchdog is armed and narrows optional cleanup. It also stops quit cleanup waiting behind the host-welcome stall that #2014 bounds.🤖 Generated with Claude Code