Repository navigation
Conversation
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between b55deef0afdd055a548ca953a955d0009756c0d3 and 5a301d9. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughWhen Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to This change keeps a dead legacy daemon from blocking worktree removal. Other errors still fail closed. No concrete merge-blocking risk was identified in the reviewed changes. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is narrowly limited to old terminal connections and preserves blocking failures for the active connection. Risk remains low rather than minimal because connection failure alone does not establish session absence, and some retirement and recovery edge cases remain unresolved. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
ℹ️ No critical issues — the fix targets the reported failure correctly. One design question inline, plus a scope note and a nitpick below.
Reviewed changes
- A gone legacy endpoint becomes an empty inventory:
DaemonPtyRouter.listProcessesnow wraps each adapter call. When a legacy adapter rejects withisDaemonEndpointGoneError(connectECONNREFUSED/ connectENOENT), it is spliced out ofthis.legacy,disconnectOnly()is fired best-effort, and it contributes[]instead of failing the whole list. - Fail-closed is preserved everywhere else: the current adapter and every other error (token-file open
ENOENT,ECONNRESET, timeouts, protocol errors) still reject the list, and the legacy adapter stays registered on those errors. - Regression test added:
daemon-pty-router-legacy-gone.test.tspins both the drop-and-do-not-ask-again behavior and the fail-closed cases.isDaemonEndpointGoneErrormatches the real error shapeDaemonClient.ensureConnectedthrows (client.test.ts:323), and worktree teardown reaches the router in normal launch, so the test exercises the reported path.
ℹ️ The same dead-legacy pattern still fails closed in degraded mode
DegradedDaemonPtyProvider.listProcesses (src/main/daemon/degraded-daemon-pty-provider.ts:211) also fans out to the legacy adapters and rejects on a connect error, so a stale legacy socket would still block worktree rm in degraded-new-pty-fallback launch mode. That path is only reached after a preserve/fallback decision (daemon-provider-init.ts:123), and an existing test (degraded-daemon-pty-provider.test.ts:673) deliberately pins the fail-closed behavior — so this may be intentional. Worth confirming the degraded provider is out of scope for #24281.
Technical details
# Degraded-mode inventory unaffected by the fix
## Affected sites
- `src/main/daemon/degraded-daemon-pty-provider.ts:211` — `Promise.all(this.allProviders()...)`; `allProviders()` includes every legacy adapter, so one `ECONNREFUSED` rejects the whole call.
- `src/main/daemon/daemon-provider-init.ts:123` — degraded provider is installed only for `mode === 'degraded-new-pty-fallback'`.
## Open question for the human
- Should the gone-legacy handling be shared between `DaemonPtyRouter` and `DegradedDaemonPtyProvider`, or is the degraded-mode fail-closed behavior intentionally retained?ℹ️ Nitpicks
void Promise.resolve().then(() => adapter.disconnectOnly()).catch(() => undefined)—disconnectOnly()isasync, sovoid adapter.disconnectOnly().catch(() => undefined)is equivalent and reads more directly.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
4757c2e to
b55deef
Compare
Sync update (
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Owner resolution now drops the gone adapter:
DaemonSessionOwnerResolverkeeps its provider list in a private array and exposesdropProvider, which splices the adapter out and invalidates cached inventory/routes so later inventories and probe/attach resolution never re-query the dead socket. - Subscription fanout now drops the gone adapter:
DaemonPtyAdapterSubscriptionFanoutstores its adapters and exposesdropAdapter, so a freshonBackgroundStreamEvent/onWriteUnavailablesubscription skips the dropped socket. - Router wires the deregistration: after splicing a refused/missing legacy adapter out of
this.legacy,listProcessescallsownerResolver.dropProviderandsubscriptions.dropAdapter(the best-effortdisconnectOnlyis unchanged). - Regression test extended: the legacy-gone test now asserts a later
discoverLegacySessionsand a new background-stream subscription never reach the dropped adapters, while the current adapter still does — this is exactly what fails if either drop is removed.
This closes the prior review's inline thread (the resolver and fanout were built from a copy of allAdapters(), so splicing this.legacy alone left them querying the dead socket). The remaining open item — DegradedDaemonPtyProvider still failing closed in degraded-new-pty-fallback mode — is unchanged and explicitly out of scope for #24281.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
worktree rm lists every routed daemon and fails closed if any list fails. A leftover socket from a previous app version answers with ECONNREFUSED or connect ENOENT, which blocked removal of every clean worktree. Treat only that dead connect as an empty inventory and forget the adapter. The current daemon, a missing token file, and every other error still fail closed.
The owner resolver and subscription fanout kept the adapter list they copied at startup, so a dropped socket was still treated as an unknown session owner. Co-authored-by: Cursor <[email protected]>
Removing it from the adapter list left the data and exit listeners attached, so a gone socket could still forward events. Co-authored-by: Cursor <[email protected]>
b55deef to
5a301d9
Compare
Sync update (
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- A dropped adapter's listeners are now detached:
DaemonPtyAdapterSubscriptionFanout.dropAdapterrecords each adapter'sonData/onExit/ identity unsubscribers in a newadapterUnsubscribersmap, invokes them when the adapter is dropped, and removes them from the global list so a laterdispose()never calls them twice. Previously the per-adapter closures stayed attached, so a gone socket could still forward data and exit events throughthis.dataListeners/this.exitListeners. - Regression test added:
daemon-pty-adapter-subscription-fanout.test.tspins that data and exit events from a dropped adapter are no longer forwarded, the surviving adapter's events still are, anddispose()leaves the dropped adapter's unsubscribe count unchanged.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Thank you for tracking this down, @innocarpe, and for the careful scoping. |

Description
After an app update, a preserved terminal daemon can die and leave its socket registered.
worktree rmlists every routed daemon and fails closed when that leftover answersECONNREFUSEDorconnect ENOENT, so every clean worktree is stuck until the app restarts.Focused fix
ECONNREFUSEDorENOENT(isDaemonEndpointGoneError), report an empty inventory, drop that adapter, and ignore a faileddisconnectOnly. The next list does not ask it again.discoverLegacySessions.Preserves
ECONNREFUSED.ENOENTwith syscallopen),ECONNRESET, timeouts, and protocol errors still fail closed.Evidence
node node_modules/vitest/vitest.mjs run --config config/vitest.config.ts src/main/daemon/daemon-pty-router-legacy-gone.test.ts src/main/daemon/daemon-pty-router.test.tsUser-regression-tradeoffs
Fixes #24281