(sessions): probe descriptor liveness on both sides, verify the pid before a tmux attach - #262
Merged
Merged
Conversation
…efore a tmux attach A killed local CLI leaves its descriptor behind and read as busy until the app restarted; getStatus now re-probes the pid lazily, throttled. The remote inventory prints an ALIVE marker per descriptor from /proc so dead CLIs are dropped without a second ssh. The attach probe checks /proc/<pid>/cmdline is a claude CLI before attaching to a recycled pid, and probe/restore ssh calls get ConnectTimeout=5. Comment sweep on the activity files merged in #259.
This was referenced Sep 11, 2026
Merged
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.
Audit 2026-09-11, findings 2, 9, 10 and 6 (
.work-files/switchboard/audit-fable-2026-09-11.md, local note), plus the comment sweep owed on #259.Why
~/.claude/sessions/<pid>.jsonbehind; since (sidebar): show CLI status and age for local sessions too #254 its laststatussurfaced on the row and nothing ever re-checked the pid —busy · Nhuntil the app restarted.TMUX=socket and attached (and, when solo, reconfigured) whatever session had the old name there.ConnectTimeout.What
cli-session-state.js:getStatus()keeps the pid and re-probes liveness lazily, throttled per pid (5 s, injectable clock); a dead pid drops the entry.remote-transport.js:LIST_COMMANDprints an STX-prefixedALIVE:0|1marker after each descriptor from/proc/<pid>— same ssh round-trip;parseSessionsdrops dead ones and reports the count, an older host output without markers is kept as before.remote-attach.js: the probe appends whether/proc/<pid>/cmdlinenames a claude CLI; an explicit "no" refuses the attach before anysetorspawnPty(pid N now belongs to a process that is not a claude CLI).procStartmatching was not used: the CLI's value is a Windows-style start time, not comparable to Linuxstarttimewithout a format the repo has not measured.ConnectTimeout=5on the non-interactive ssh calls.Proof
Mutations on the shipped modules: disable the lazy re-probe → "dead between two calls" test red; drop the ALIVE filter → dead-descriptor test red (the shell test runs the real
LIST_COMMANDundersh -cwith a live and a dead pid); drop the cmdline check → refuse test red.task check(two-stage runner from #261): 1155 pass + 119 pass, 0 fail, 8 pre-existing skips.Not verified on the wire: the ALIVE marker and cmdline segment against the real host (tests only).