Repository navigation
feat(session): retry failed renderer session writes and verify local folder PTYs (#16741 T2 P9) - #24406
Conversation
…folder PTYs (#16741 T2 P9) The renderer's session write subscriber now waits for the local session patch to be accepted by main. While a write is in flight no second write starts; if it rejects, the fields it carried go back into the pending set (newer edits to the same fields are not overwritten) and the next store or gate wake retries them instead of silently dropping them. Boot PTY hydration verifies a folder workspace as local only when its id is unique and it is pinned local, or its legacy scope resolves local with no remote candidate repo. A folder under an SSH project group is never verified. Ported by hunk from #16741 (a68b6f3).
There was a problem hiding this comment.
Important
pnpm run check:code-quality:changed fails on this branch: 5 new typescript/consistent-type-assertions findings in the two test files below. That is the CI-enforced changed-lines gate, so it needs to be resolved before merge — add the line-specific SAFETY: disables or drop the casts.
Reviewed changes
- Renderer session-write acknowledgment —
createSessionWriteSubscribernow serializes writes behind an in-flight flag, awaits the returnedpersistpromise, and on rejection merges the write's fields back intopendingChangedFields(without clobbering newer edits);use-app-session-persistencereturns the local write and logs failures. - Verified local folder PTY hydration — new
getVerifiedLocalFolderWorkspaceKeysaccepts a folder only when its id is unique and it is pinned local, or unpinned with a fully local scope;hydrate-local-pty-registryconsumes it and drops the old inline folder loop. - Tests — new acknowledgment, folder-verification, folder-hydration and split-pane-retirement suites; the allocation test's
persistwas given a block body to satisfy the widened return type.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
| pendingChangedFields.add(field) | ||
| } | ||
| // A rejection waits for the next store/gate wake, not a retry loop. | ||
| onPersistError?.(error) |
There was a problem hiding this comment.
A rejection arms no timer, so the patch is re-attempted on the next store wake — and evaluateSessionState's fast path re-arms on essentially any store update, which is frequent. A persistently refused write (e.g. main's profile store frozen during maintenance) would then issue an IPC session:patch plus a console.warn on nearly every tick; worth considering a bounded backoff rather than treating every wake as a fresh attempt.
|
| if (failed) { | ||
| for (const field of changed) { | ||
| pendingChangedFields.add(field) | ||
| } | ||
| // A rejection waits for the next store/gate wake, not a retry loop. | ||
| onPersistError?.(error) | ||
| } else if (pendingChangedFields.size > 0) { | ||
| armFlushTimer() |
There was a problem hiding this comment.
In-flight edits can stall. If a session field changes while a local patch is in flight, the new timer guard discards the wake for that edit. If the patch then rejects, this failure path restores the failed fields but schedules nothing. In a quiet session, both the failed write and the newer edit remain unwritten until another store update or gate opening occurs.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (10)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review. 📝 WalkthroughWalkthroughThe change adds verification for local folder workspaces during PTY registry hydration. It updates the session write subscriber to handle asynchronous writes, preserve pending edits after failures, and report persistence errors. It also adds tests for split-pane retirement behavior across snapshot and transport states. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The changes tighten local PTY hydration and retain session edits after rejected writes. No actionable merge-blocking risk remains in the supplied evidence; merge after normal checks pass. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The changes strengthen local-workspace checks and failed-save recovery. No introduced security issue was established, but conflicting ownership metadata and some write-authorization guarantees remain only partially verified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 new issues found in this delta.
Reviewed changes
This run reviewed the delta since the prior pullfrog review (2ff94817ea → 29d39769bd), which resolves the changed-code quality gate that had blocked the PR.
- Typed folder-workspace fixtures —
verified-local-folder-workspaces.test.ts'sfolder/repo/projectGrouphelpers now build complete values instead of casting partial objects; deliberately invalid stored host ids still reach the parser viaObject.assignrather than a widened assertion. - Lint disable on the store stub —
hydrate-local-pty-registry.test.ts'sreturn store as Storenow carries the line-specificSAFETY:rationale.
pnpm run check:code-quality:changed reports 0 findings across all 10 changed files, and the 3 affected memory suites pass (54 tests). This is a non-approving review only because the earlier session-write-subscriber.ts retry-cadence thread is still open and untouched by this delta; that pre-existing design suggestion is not re-raised here.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
* Revert "feat(orcad): source-side dormant export of a relay-hosted SSH target (#16741 T6-8) (#24519)" This reverts commit 783101b. * Revert "feat(ssh): update, roll back, recover and stop a managed orcad server (#16741 T6-5 follow-up) (#24463)" This reverts commit 38c2d1d. * Revert "feat(ssh): deploy and pair an empty managed orcad server over SSH (#16741 T6-5) (#24453)" This reverts commit 8b76683. * Revert "fix(ssh): orcad GC honors the activation journal; readiness requires proven daemon coverage (#16741 T6 follow-up) (#24451)" This reverts commit d3f8c50. * Revert "feat(ssh): remote orcad stop by request file and journaled decommission (#16741 T6-4) (#24449)" This reverts commit 43d9b43. * Revert "feat(orcad): supervisable server: stop requests, managed stop receipts and a lifetime that keeps its lock on failed teardown (#16741 T6-3) (#24433)" This reverts commit b093d3a. * Revert "feat(ssh): crash-safe orcad activation, rollback and recovery (#16741 T6-2) (#24423)" This reverts commit 1a9ac0e. * Revert "feat(runtime): SSH access links for paired servers in a downgrade-safe sidecar (#16741 T5-1+T5-2) (#24420)" This reverts commit 99db2bf. * Revert "feat(relay): capability-gated owner reset with a durable preparation journal (#16741 T3 R1) (#24418)" This reverts commit 34a582b. * Revert "feat(ssh): track connection-manager drains, test probes and provider continuations (#16741 T2 P3+P8a) (#24407)" This reverts commit d53063d. * Revert "feat(daemon): idle retirement, session census and recovery-only provider (#16741 T2 P4b) (#24409)" This reverts commit ff212db. * Revert "feat(ssh): add pty.resumeClient and split SSH PTY process listing (#16741 T2 P5+P6) (#24414)" This reverts commit 92cb717. * Revert "feat(relay): await owned watcher and agent children on shutdown (#16741 T2 P1) (#24400)" This reverts commit 6b36e4f. * Revert "feat(session): retry failed renderer session writes and verify local folder PTYs (#16741 T2 P9) (#24406)" This reverts commit d23ecef. * Revert "feat(ssh): remote orcad primitives on the pinned Node runtime (#16741 T6-1) (#24419)" This reverts commit dd87ae5. * Revert "fix(runtime): fence runtime-environment subscriptions and status probes by identity (#16741 T5-3) (#24421)" This reverts commit ece9e4d. * Revert "feat(orcad): migration manifest and dormant-state contracts (#16741 T6-7) (#24422)" This reverts commit 3fbdaba. * Revert "feat(ssh): wire SshConnection through the work and transport close ledgers (#16741 T2 P2) (#24401)" This reverts commit 4e8edc8. * Revert "feat(profiles): carry markdown frontmatter visibility in project transfers (#16741 T2 P7) (#24405)" This reverts commit 60c9326. * Revert "fix(runtime): project the PTY incarnation onto mobile session tabs (#24413)" This reverts commit 99e0303. * Revert "feat(daemon): tag daemon stream data with the PTY incarnation id (#16741 T2 P4a) (#24402)" This reverts commit 817af76. * Revert "feat(ssh): port the SSH connection work ledger and transport close ledger (#16741 T2) (#24210)" This reverts commit c991893. * Revert "feat(relay): fence and drain file and git response streams on shutdown (#24185)" This reverts commit dc08ffe. * Revert "refactor(runtime-rpc): extract the Node WebSocket lifecycle; opt-in pinned port (#24186)" This reverts commit a789233. * Revert "feat(relay): route relay handlers through work admission; producer publication drain (#24181)" This reverts commit 0b812bd. * Revert "feat(relay): land the #16741 T1 seam (work drain, publication drain, release gate) (#24156)" This reverts commit 3aa2d3a. --------- Co-authored-by: m4air <[email protected]>

ELI5
Orca saves your open tabs and layout every time something changes. If one of those saves failed, the change it carried was forgotten and only came back if you touched the same thing again. Now a failed save puts its changes back in line, so the next save tries them again.
Separately, after a restart Orca reconnects terminals that were still running. It now recognises terminals that belong to a local folder workspace more carefully, and never mistakes a remote (SSH) folder for a local one.
This is the T2 P9 slice of porting #16741 (session write acknowledgment and verified local folder workspaces).
What Changed
Session writes (renderer):
createSessionWriteSubscriberfiredpersist()and forgot it. The fields that write carried were retired at once, so a rejected local patch lost them.persist()returns the local patch promise (patchWorkspaceSessionByHostalready returned it;use-app-session-persistencenow passes it through). While that write is in flight, no second write starts.What "accepted" means: main's
session:patchhandler callsstore.patchWorkspaceSession, which updates main's in-memory session and schedules the debounced save. It throws when the profile store refuses writes (maintenance, frozen or finalizing, #23202). That reaches the renderer as an IPC rejection, and so do a lost main process and validation errors. The later disk save is unchanged and still reports its own failures throughsession:flush.Folder workspace PTY hydration (main):
Before: a folder workspace counted as local when its id was unique and its own
executionHostId/connectionIdsaid local. That ignored the project group's SSH connection.After: the new
getVerifiedLocalFolderWorkspaceKeysaccepts a folder only when its id is unique and either:local, orresolveFolderWorkspaceHost(which includes the project group's connection), and no candidate repo is remote.A folder workspace on an SSH or runtime host is never verified. Git worktrees keep the existing metadata-based check.
Why
Losing a session change without any trace is the worst failure mode for persistence. Merging the fields back keeps the existing identity-based change detection correct: the pending set is the only record of what is still owed. Giving each write its own lane, rather than queueing several, keeps writes ordered.
For folders, sharing
resolveFolderWorkspaceHostwith the rest of the app means hydration agrees with how the UI decides where a folder lives. That closes the SSH-group gap.Adapted from #16741 (a68b6f3), by hunk:
durable-file-write.tsand the path exports interminal-scrollback-snapshots.ts. Their only users are the orcad migration (T6) and the PTY ownership-transfer and durable scrollback artifact code (T7).retainedRefsinterminal-scrollback-snapshot-async-migration.ts. Only the T7 snapshot publication passes it.validateSnapshotinweb-runtime-session-snapshot.tsand itsweb-runtime-sessiontest. Only the orcad migration refresh (T6) uses it. The web and mobile session snapshot code is unchanged.ptyId === nullscrollback preservation inworkspace-session-terminal-buffers.ts. It would keep capped scrollback in the session file for every local tab without a live PTY. It serves dormant migrated tabs (T6), and it isn't part of this slice's behavior.hydrate-local-pty-registry-folder-workspaces.test.ts, so the existing test file stays under the lint line limit. I added anssh:case to them.Linked Issue
Part of the Node runtime plan (Phase 3), porting #16741.
Visual Proof
N/A. Nothing in the UI changes. The differences are a retried background save and a stricter boot-time ownership check.
Testing
New and ported:
session-write-subscriber-acknowledgmentand-allocation: a failed write merges its fields back without clobbering newer edits, and only one write runs at a time.verified-local-folder-workspaces: local, pinned, legacy, SSH-group and duplicate-id cases.web-session-split-pane-retirement-fences.Regression:
src/main/memory;lib,app-shellandruntime, and insrc/shared.macOS locally.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.