Stop the tree flickering on zombie intermediate parents; skip dead sessions in parent auto-detect - #4
Draft
curusarn wants to merge 1 commit into
Draft
Stop the tree flickering on zombie intermediate parents; skip dead sessions in parent auto-detect#4curusarn wants to merge 1 commit into
curusarn wants to merge 1 commit into
Conversation
…p auto-detecting dead parents Two fixes for zombie (killed) sessions that live sessions still reference as parent: 1. BuildTree now drops Virtual rows from its input. The TUI re-feeds BuildTree its own output (remote-session merges, ctrl+h fold rebuilds), and a stale virtual row registered as an active session: the dead parent stopped being virtual, picked up its own recorded parent from the DB, and its whole subtree re-nested one level deeper — so the list flickered between two shapes on alternating local/remote refreshes. 2. Parent auto-detection (crabctl new, TUI spawn flows) now checks that the detected parent actually has a live tmux session. CRABCTL_NAME env outlives the session it came from, so spawns kept recording edges to long-dead sessions. A dead candidate is rerouted to its nearest live ancestor via the recorded parent chain (top level if the chain is dead). Explicit -p is still trusted as-is. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
When an intermediate parent in the session hierarchy is a zombie (killed session that live sessions still reference as parent, e.g.
crab-t-10026-workerreferenced bycrab-u7449-conflict), the TUI session list flickered between two shapes:Shape A (correct) — dead parent as a dimmed virtual root:
Shape B (glitched, ~1.5s after every remote poll) — the zombie re-nests under its own recorded parent, children pushed a level deeper, roots reorder:
Root causes
Flicker: the
remoteSessionsMsghandler (and the ctrl+h fold path) re-feedBuildTreeits own previous output, which contains the syntheticVirtualrow for the dead parent. InsideBuildTreethat stale row registered as an active session, so it stopped being a virtual root, picked up its own DB parent, and re-nested its subtree. The next local refresh dropped it again — flicker on alternating refreshes. Fix:BuildTreedropsVirtualrows from its input (they are derived placeholders, always re-created).Zombie edges keep being created:
DetectParenttrustedCRABCTL_NAME(which outlives the tmux session it came from) with no liveness check, so spawns recorded parents that had been dead for an hour. Fix: all auto-detect call sites (crabctl new, TUI/new, dir-picker, orchestrator spawn) reroute a dead detected parent to its nearest live ancestor via the recorded parent chain (top level if the whole chain is dead, cycle-safe). Explicit-pis still trusted as-is.Tests
TestBuildTreeZombieIntermediateParent— A live ← B dead ← C live: B renders as virtual root, C nested, no rows lostTestBuildTreeRebuildFromOutputStable— the regression: rebuilding from previous output is shape-stable (failed before the fix with exactly the depth shifts seen live)TestBuildTreeWholeChainDead— only the direct dead parent materializesTestNearestLiveAncestor— live candidate, dead→live walk, all-dead chain, cycle safety, unknown candidatego test ./...andgo vet ./...green.Verification against the live tmux server
CRABCTL_NAME=crab-t-10026-worker crabctl new zzz-test-child(stale env pointing at the dead session) resolvedParent: crab-orchestrator— the nearest live ancestor.🤖 Generated with Claude Code