Skip to content

fix(session): two threads fighting over one claude session - #223

Merged
klNuno merged 1 commit into
masterfrom
fix/session-steal-loop
Aug 31, 2026
Merged

fix(session): two threads fighting over one claude session#223
klNuno merged 1 commit into
masterfrom
fix/session-steal-loop

Conversation

@klNuno

@klNuno klNuno commented Aug 28, 2026

Copy link
Copy Markdown
Member

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::contains walked 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 at std::process::id(), checked after the root test so a tree rooted at boite itself still works.

find_claude_session_blocking asks the registry for the exact pid before falling back to that walk. .find() over read_dir order was picking an arbitrary entry even without the cycle.

session-monitor.svelte.ts refuses to take one id off the same sibling twice. one logger.warn, no toast, no steal, and the first legitimate handover is untouched.

the rust guard has a regression test in session/mod.rs that 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.

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
@klNuno
klNuno merged commit f1caf58 into master Aug 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant