fix(session): two threads fighting over one claude session - #223
Merged
Conversation
windows recycles the parent pid of an exited parent, so boite.exe's own ppid can name one of its descendants. `ProcessTree::contains` walked up to boite.exe, sideways through that number and back down into another thread's claude, so every claude answered "ours": two threads held one id and swapped it every 12s, four toasts a minute. the walk now stops at `std::process::id()`, after the root test. `find_claude_session_blocking` also asks the registry for the exact pid before falling back to the walk, where `.find()` over `read_dir` order was already a coin flip. `session-monitor.svelte.ts` refuses to take one id off the same sibling twice: one `logger.warn`, no toast, no steal. Claude-Session: https://claude.ai/code/session_01DvvQwFmyoNME2iwDa4BenN
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.
two threads in two different projects each held the same claude session id and swapped it every 12 seconds, four toasts a minute, with one thread's running dot blinking in lockstep because the status falls back to matching by directory whenever the id is stripped.
windows keeps the parent pid of an exited parent and recycles it, so boite.exe's own ppid can name one of its descendants.
ProcessTree::containswalked up to boite.exe, sideways through that recycled number and back down into another thread's claude, and then answered "ours" for every claude in the registry. the walk now stops atstd::process::id(), checked after the root test so a tree rooted at boite itself still works.find_claude_session_blockingasks the registry for the exact pid before falling back to that walk..find()overread_dirorder was picking an arbitrary entry even without the cycle.session-monitor.svelte.tsrefuses to take one id off the same sibling twice. onelogger.warn, no toast, no steal, and the first legitimate handover is untouched.the rust guard has a regression test in
session/mod.rsthat rebuilds the observed cycle and fails without it. the typescript brake has none: reproducing it means two live threads racing for one id in the running app.