Skip to content

fix(runtime): project the PTY incarnation onto mobile session tabs - #24413

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/fix-mobile-session-incarnation
Oct 1, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/fix-mobile-session-incarnation

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​9 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1

This is a small, standalone fix carried over from #16741, where it was one of the T2 "runtime leftovers".

ELI5

Each running terminal has a unique "incarnation" id. A paired client (web or mobile) uses it to make sure that terminal updates come from the exact terminal it is attached to, not from an older one that happened to reuse the same name. The desktop app was supposed to include that id when it listed terminals for paired clients, but it never did. As a result, the client's check never switched on.

What Changed

Before:

  • projectRuntimeMobileSessionTabs never set incarnationId on the terminal tabs it published, even though the shared contract has the field (RuntimeMobileSessionTab.incarnationId, added for host-stamped remote identity in feat(ssh): host-stamped remote foreground identity #18078).
  • remote-runtime-pty-transport.ts reads selected.incarnationId from those tabs. So for a terminal picked from the session list, paired clients always got null, and identity fencing never engaged.

After:

  • The projection publishes the incarnation of the PTY record that owns the issued terminal handle.
  • If that PTY is disconnected, or its incarnation is unknown, no incarnationId is published.
  • The projection never copies a stale incarnation persisted on the tab itself.

Mechanism: the projection now keeps the PTY record it already resolved for the handle, instead of only the handle string, and reads that record's incarnationId.

Why

Taking the id from the same record that owns the handle keeps the two consistent by construction. Copying the tab's stored incarnationId would have been simpler, but it can be stale after a respawn. That is exactly the case the fence exists to catch.

Linked Issue

Follow-up to #18078. Ported from #16741 (a68b6f3), whose remaining T2 "runtime leftovers" were folded into later tracks.

Visual Proof

N/A. This changes data sent to paired clients and has no UI change on its own.

Testing

  • New runtime-mobile-session-incarnation-projection.test.ts covers four cases:

    • a direct PTY and a split-leaf PTY, which publish the live incarnation and not the stale one on the tab;
    • an unknown incarnation and a disconnected PTY, which publish none.
  • The two live cases fail on main without this change.

  • Regression: 42 mobile-session, web-session-terminal and remote-runtime transport test files, 415 tests, all passing.

  • The changed-code quality gate passes.

  • I manually tested these changes locally

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

AI Disclosure

Review

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.

Notes

  • Wire: this adds an optional field the contract already declares. Older clients ignore it, and newer clients already read it.
  • Platforms and SSH: no platform- or SSH-specific behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Paired clients read RuntimeMobileSessionTab.incarnationId to fence remote
identity observations (#18078), but projectRuntimeMobileSessionTabs never set
it, so remote-runtime-pty-transport always saw null and the fence never
engaged. The projection now publishes the incarnation of the PTY record that
owns the issued handle, never a stale incarnation persisted on the tab.

Ported from #16741 (a68b6f3).
@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Changes how terminal session identity is projected to mobile tabs.

The PR appears safe to merge; no actionable regression was identified.

Summary

The PR adds the handle-owning PTY record’s incarnation ID to projected mobile terminal tabs when that ID is known, with tests for direct PTYs, split leaves, unknown incarnations, and disconnected PTYs.

Reviews (1) · Last reviewed commit: "fix(runtime): project the PTY incarnatio..."

@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.

Reviewed changes

  • PTY incarnation on projected mobile session tabs — projectRuntimeMobileSessionTabs now keeps the resolved PTY record (terminalPty) instead of only the handle string, and publishes terminalPty.incarnationId on terminal tabs. The field was already in the shared RuntimeMobileSessionTerminalTab contract but had never been populated, so remote-runtime-pty-transport.ts read selected.incarnationId ?? null and the identity fence never engaged.
  • Absence is deliberate — the incarnation is only emitted when truthy, and is never copied from the snapshot tab's persisted incarnationId (which can be stale after a respawn), matching the intent stated in the PR body.
  • New test — runtime-mobile-session-incarnation-projection.test.ts covers pty, leaf, unknown, and disconnected cases with exact assertions (toHaveProperty('incarnationId', 'live-incarnation') / not.toHaveProperty('incarnationId')), seeding a stale-incarnation on the snapshot that must not surface.

The handle-resolution logic is behavior-preserving (terminalPty = liveLeafPtyId ? recordPty(...) : livePty; handle = terminalPty ? issuePtyHandle(terminalPty) : null), and the source (recordPtyWorktree returning the live record with its incarnationId intact) agrees with the sibling buildPtyTerminalSummary path. Adding an optional field is wire-safe. Verified the new test (4 passed) and orca-runtime-cold-restore-terminal-membership.test.ts (11 passed).

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

@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.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

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: b2d932c6-dafc-4ae3-b198-950bd5540208

📥 Commits

Reviewing files that changed from the base of the PR and between c991893 and 25ca766.

📒 Files selected for processing (2)
  • src/main/runtime/runtime-mobile-session-incarnation-projection.test.ts
  • src/main/runtime/runtime-mobile-session-projection.ts

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


📝 Walkthrough

Walkthrough

projectRuntimeMobileSessionTabs now resolves the terminal PTY before issuing a handle. When the PTY has an incarnation, the projected terminal tab includes it. A parameterized test checks incarnation, status, and handle behavior for PTY, leaf, unknown-incarnation, and disconnected cases.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 25ca7

The change exposes live terminal identity without copying stale tab state or changing readiness behavior. No actionable merge-blocking risk was identified; normal checks should complete before merging.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 25ca7

The projection now pairs terminal handles with their live owner’s identity rather than stale saved identity. Terminal access and readiness behavior are preserved. Whether every subsequent attachment response preserves that identity remains unverified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated effect is on identity metadata for terminal handles already exposed through paired session lists. The inspected change does not add a handle-issuance path or increase terminal authority; broader authentication and deployment exposure were not established by this review.

Security Findings and Attack Paths

  • inferred — Using a saved tab incarnation after terminal replacement is excluded by the changed projection. The downstream possibility of losing incarnation metadata is a contract uncertainty, not a verified new attack path or evidence that this PR weakens a control.

Trust Boundaries and Controls

  • observed — Pane resolution rejects conflicting or unexpected workspace ownership. Before adopting its response, the paired transport checks the selected handle, tab, leaf, and workspace. These controls constrain metadata adoption to the requested terminal surface, although they do not establish incarnation preservation.

Resilience and Maintainability Implications

  • observed — Inspected existing attachment paths use lifecycle and subscription generations to reject stale work, close prior streams during repeated attachment, and either recover or retire attachment state after disconnect. These are existing failure-containment controls, not newly introduced guarantees.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 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 and concisely describes the primary change: projecting the PTY incarnation onto mobile session tabs.
Description check ✅ Passed The description covers the required sections, explains the user-facing behavior and mechanism, links the related issues, provides testing details, marks visual proof as not applicable, and addresses c…
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.
  • Fix all pre-merge checks with AI
✨ 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.

@OrcaWin
OrcaWin merged commit 99e0303 into main Oct 1, 2026
33 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