Skip to content

feat(session): retry failed renderer session writes and verify local folder PTYs (#16741 T2 P9) - #24406

Merged
OrcaWin merged 2 commits into
mainfrom
OrcaWin/node-rt-p3-t2-p9
Oct 1, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
OrcaWin/node-rt-p3-t2-p9

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​508 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​502
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​92 $\color{#cf222e}{\Huge{\mathbf{−}}}$​18 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​74

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):

  • Before: createSessionWriteSubscriber fired persist() and forgot it. The fields that write carried were retired at once, so a rejected local patch lost them.
  • After: persist() returns the local patch promise (patchWorkspaceSessionByHost already returned it; use-app-session-persistence now passes it through). While that write is in flight, no second write starts.
    • On success, any edits that arrived meanwhile are flushed.
    • On rejection, the fields go back into the pending set without overwriting newer edits to the same fields. The error is logged, and the next store update or gate opening retries the write. There is no retry loop.
    • Remote-host partition uploads keep their own fire-and-forget handling.

What "accepted" means: main's session:patch handler calls store.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 through session:flush.

Folder workspace PTY hydration (main):

  • Before: a folder workspace counted as local when its id was unique and its own executionHostId/connectionId said local. That ignored the project group's SSH connection.

  • After: the new getVerifiedLocalFolderWorkspaceKeys accepts a folder only when its id is unique and either:

    • it is pinned local, or
    • it has no pin, its scope resolves to local through resolveFolderWorkspaceHost (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 resolveFolderWorkspaceHost with 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:

  • Skipped durable-file-write.ts and the path exports in terminal-scrollback-snapshots.ts. Their only users are the orcad migration (T6) and the PTY ownership-transfer and durable scrollback artifact code (T7).
  • Skipped retainedRefs in terminal-scrollback-snapshot-async-migration.ts. Only the T7 snapshot publication passes it.
  • Skipped validateSnapshot in web-runtime-session-snapshot.ts and its web-runtime-session test. Only the orcad migration refresh (T6) uses it. The web and mobile session snapshot code is unchanged.
  • Skipped the ptyId === null scrollback preservation in workspace-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.
  • Test split: the branch's two new folder hydration tests moved into hydrate-local-pty-registry-folder-workspaces.test.ts, so the existing test file stays under the lint line limit. I added an ssh: 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-acknowledgment and -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.
    • folder hydration tests: a local folder PTY hydrates without Git; deleted, runtime and SSH re-pins after inventory are refused.
    • web-session-split-pane-retirement-fences.
  • Regression:

    • all of src/main/memory;
    • every session-related test in renderer lib, app-shell and runtime, and in src/shared.
    • 253 files, 2861 passed.
  • macOS locally.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

…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).

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 — createSessionWriteSubscriber now serializes writes behind an in-flight flag, awaits the returned persist promise, and on rejection merges the write's fields back into pendingChangedFields (without clobbering newer edits); use-app-session-persistence returns the local write and logs failures.
  • Verified local folder PTY hydration — new getVerifiedLocalFolderWorkspaceKeys accepts a folder only when its id is unique and it is pinned local, or unpinned with a fully local scope; hydrate-local-pty-registry consumes it and drops the old inline folder loop.
  • Tests — new acknowledgment, folder-verification, folder-hydration and split-pane-retirement suites; the allocation test's persist was given a block body to satisfy the widened return type.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using 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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Adds retry logic and verification to session persistence.

The PR is not yet safe to merge because an in-flight edit can remain unwritten after its preceding patch rejects.

Findings

  1. P1 In-flight edits can stall. ▶

Summary

The PR retains failed renderer session writes for a later retry and verifies local folder ownership before hydrating PTYs.

  • Serializes local session patches and merges rejected fields back into pending changes.
  • Uses project-group and repo scope when deciding whether a folder PTY is local.
  • Adds acknowledgment, ownership, hydration, and split-pane regression tests.

Reviews (2) · Last reviewed commit: "test(memory): build typed folder-workspa..."

Comment on lines +181 to +188
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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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!

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 96cc0352-19e3-428c-b34e-d9cef2778678

📥 Commits

Reviewing files that changed from the base of the PR and between 2ff9481 and 29d3976.

📒 Files selected for processing (2)
  • src/main/memory/hydrate-local-pty-registry.test.ts
  • src/main/memory/verified-local-folder-workspaces.test.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 3b4f06a1-b99e-418b-9687-9fab2b4b9dd6

📥 Commits

Reviewing files that changed from the base of the PR and between c991893 and 2ff9481.

📒 Files selected for processing (10)
  • src/main/memory/hydrate-local-pty-registry-folder-workspaces.test.ts
  • src/main/memory/hydrate-local-pty-registry.test.ts
  • src/main/memory/hydrate-local-pty-registry.ts
  • src/main/memory/verified-local-folder-workspaces.test.ts
  • src/main/memory/verified-local-folder-workspaces.ts
  • src/renderer/src/app-shell/use-app-session-persistence.ts
  • src/renderer/src/lib/session-write-subscriber-acknowledgment.test.ts
  • src/renderer/src/lib/session-write-subscriber-allocation.test.ts
  • src/renderer/src/lib/session-write-subscriber.ts
  • src/renderer/src/runtime/web-session-split-pane-retirement-fences.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The 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 2ff94

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 Review

Security architecture risk: 🔵 Low · up to 2ff94

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected sensitive outcomes are registration of existing profile-local daemon terminals and updates to host-partitioned session state. Remote session updates remain reachable through the existing partition and upload paths; local acknowledgment does not extend its guarantee to those writes.

Trust Boundaries and Controls

  • observed — The new folder-workspace eligibility path rejects duplicate workspace IDs and explicit SSH, runtime, or invalid pins. Without a pin, it requires local resolved scope and local ownership of every candidate repository before a daemon session ID can authorize registration through that path.

Resilience and Maintainability Implications

  • observed — Gate closure preserves pending intent rather than acknowledging it. Disposal clears pending work and prevents late promise settlement from reviving the subscriber. Rejection restores fields but does not create an automatic retry loop, containing repeated failure without weakening the scheduling gate.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.22% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 10 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies both primary changes: failed renderer session-write retries and verified local folder PTY hydration. It is concise and specific.
Description check ✅ Passed The description is mostly complete. It includes the ELI5, What Changed, Why, Linked Issue, Visual Proof, Testing, and Agent skill boundary sections, with detailed behavior and test coverage. The Revie…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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's folder/repo/projectGroup helpers now build complete values instead of casting partial objects; deliberately invalid stored host ids still reach the parser via Object.assign rather than a widened assertion.
  • Lint disable on the store stub — hydrate-local-pty-registry.test.ts's return store as Store now carries the line-specific SAFETY: 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.

Pullfrog  | Fix it ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit d23ecef into main Oct 1, 2026
54 of 57 checks passed
OrcaWin added a commit that referenced this pull request Oct 2, 2026
* 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]>
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