Skip to content

fix(runtime): resolve session tab workspace path aliases - #27264

Closed
SimonSQLML wants to merge 1 commit into
stablyai:mainfrom
SimonSQLML:fix/remote-session-tabs-windows-paths
Closed

SimonSQLML wants to merge 1 commit into
stablyai:mainfrom
SimonSQLML:fix/remote-session-tabs-windows-paths

Conversation

@SimonSQLML

@SimonSQLML SimonSQLML commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A Windows workspace can be visible remotely while all of its existing terminal/conversation tabs appear missing. If the client spells the workspace path with / but the host stored it with \, the host currently returns an empty tab list. Resolve that spelling to the host's existing session identity so its tabs can be listed and activated.

What Changed

Scope: 13 files: 10 existing production files (+138/-28 lines) and 3 test files (+512/-4). Several production files only change one selector call, and three only add the abstract declaration that main's split runtime classes need. Listing, tab actions, terminal polling, and subscription cleanup must agree on the workspace identity because clients keep sending the requested spelling.

  • Match explicit session workspace IDs against published snapshots, saved tabs in the owning host partition, and surviving renderer-owned terminals using the existing worktreeIdsEqual comparison.
  • Keep exact stored identities, including authoritative empty snapshots; reject ambiguous aliases and preserve separate repositories, POSIX case, and folder instance suffixes.
  • Use the same path comparison for subscription cleanup keys; deliver late canonical publications to early alias subscribers without a false empty frame.
  • Reject alias adoption when the terminal host contradicts the resolved local, SSH, or paired-runtime owner. Read the target leaf's layout binding when its direct PTY ID is absent. For runtime owners, compare the environment encoded in the PTY ID; a same-named client SSH connection is not the server's nested target. Re-resolve the selector after activation waits for inventory, since a renderer publication can arrive during that wait.
  • Keep the full worktree resolver unchanged. Cover listing, activation without respawn, startup publication, local/SSH/runtime ownership, folder instances, ambiguity, and subscription cleanup with regressions.

Why

The explicit-ID fast path bypasses the full selector resolver and looks up exact map keys. Reusing the existing comparison fixes that boundary without rewriting persisted/live PTY identities or adding Git/SSH scans to polling.

The requested issue severity is High: for an affected remote workspace, every existing conversation/terminal can become inaccessible even though the workspace remains visible and its processes remain alive. On the reported running Windows host, changing only separators returns 11 tabs versus 0, with a successful response rather than an actionable error. This blocks resuming existing work through the affected client flow. Host access and alternate CLI selectors are diagnostic workarounds, not recovery within that flow. No data loss or universal remote outage is claimed; the affected client's exact outgoing request remains uncaptured.

Linked Issue

Fixes #27260

Closest prior reports: #15598 (Windows slash/backslash identities; related PR #15616), #12303 (Windows path selectors), #19092 and #15710 (workspace visible but live remote tabs missing), #23429 (older live tabs omitted by another hydration path), and #10750 (folder instance identity). The implementation reuses the comparison introduced by #16494.

The related-report inventory links 37 related reports, their differences, and previous fixes. Those reports are context and regression boundaries, not additional fixes claimed by this PR.

Visual Proof

Controlled before/after reproduction with real paired Windows hosts and the same built mobile session screen. Each isolated host starts with two real terminal sessions. The screen opens the backslash alias of the stored slash ID. Before: the workspace is visible with 0 tabs. After: both existing tabs appear; list and subscription replies retain their original tab IDs.

Before ? installed Orca 1.4.224 After ? this PR's development host
Before: stock-trading-demo shows 0 tabs After: stock-trading-demo shows 2 existing tabs

Captured via Playwright/CDP in hidden Electron windows. A test bridge forwards the mobile screen's RPC requests and subscriptions to each real paired host, without replacing its tab responses. Only the initial route is seeded with the alternate spelling. Temporary profiles and a disposable repository keep the user's sessions untouched. This demonstrates tab recovery for the controlled alias input; it is not a capture of the original client's request, a physical-phone test, or proof of chat-transcript rendering.

Actual host comparison Stored ID Separator alias
Reported running Windows host 1.4.224 11 tabs 0 tabs
Isolated installed host 1.4.224 2 tabs 0 tabs
Isolated patched development host 2 tabs Same 2 tabs

To repeat: create two terminals in an isolated Windows host, obtain the stored ID via session.tabs.list with a path: selector, change only separators in its path portion, and open that ID in the mobile session route. Compare list/subscription tab IDs and the rendered tab count between hosts.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Tested on native Windows. Direct Vitest execution passed 214 tests across 14 suites. The session-tab entry point now covers POSIX trailing/repeated slashes, macOS NFC/NFD Unicode spelling, and WSL UNC aliases, alongside the Windows regression. These include direct, layout-bound, and unpublished PTYs; both local/SSH directions; matching and different runtime environments; a same-named client SSH impostor; legitimate plain runtime handles; ambiguous ownership; and the activation publication race. They are fixture and string tests executed on Windows, not native macOS/Linux or actual SSH execution.

pnpm exec vitest run --config config/vitest.config.ts \
  src/main/runtime/orca-runtime-session-tabs-path-alias.test.ts \
  src/main/runtime/orca-runtime-headless-hydration-repo-gate.test.ts \
  src/main/runtime/orca-runtime-cold-restore-terminal-membership.test.ts \
  src/main/runtime/rpc/methods/session-tabs.test.ts \
  src/main/runtime/rpc/methods/session-tabs-unsubscribe.test.ts \
  src/main/runtime/rpc/methods/session-tabs-subscribe-admission.test.ts \
  src/main/runtime/session-tabs-empty-worktree-publication.test.ts \
  src/main/runtime/session-tabs-inventory-publication.test.ts \
  src/main/runtime/worktree-rm-id-selector-path-spelling.test.ts \
  src/main/runtime/worktree-path-selector-wsl-posix.test.ts \
  src/main/runtime/workspace-session-worktree-id.test.ts \
  src/main/runtime/orca-runtime-terminal-cwd.test.ts \
  src/shared/worktree/id.test.ts \
  src/shared/cross-platform-path.test.ts

Also passed pnpm tc:node, pnpm run check:code-quality:changed upstream/main, changed-file formatting, and git diff --check. Tests run with ORCA_BACKGROUND_LAUNCH=1.

Also built the Electron main/preload/renderer in E2E mode, the CLI, and the paired web bundle. Rebuilt the latest Electron main and mobile web bundle; the real paired-host screen comparison above passed with 0 tabs before and 2 after. Electron 43.7.5 native preflight passed using matching native artifacts copied from the installed Orca into ignored local dependency directories. This validates that local runtime setup, not compilation of the native modules; the Visual Studio C++ toolchain is absent. No binaries or evidence scripts are committed. The standard full test wrapper, full packaged-app build, full test suite, native macOS/Linux, physical mobile devices, actual SSH, and recovery of the original incident were not validated. The rendered UI comparison was automated; the manual-testing box remains unchecked.

Rebased onto main ebef2ea9 (2026-10-15). main's runtime refactor moved 9 of the touched files into session-tabs/, session-lifecycle/, terminal/launch/ and construction/. The conflicts were import paths plus the new options argument to getMobileSessionTabsForWorktree. The rebase is squashed into one commit. It adds a reverse-direction row (stored /, requested \, as reported in #27260 by @DaveDev42) and fails without the fix. Re-verified on macOS: pnpm tc (all projects); oxlint, anti-slop, native-plugin, type-aware and changed-code quality; the max-lines, ts-nocheck, runtime-Electron, focus-read and layout-writer ratchets; reliability gates; the RPC params catalog. The 14 suites above pass (230 tests), as does everything under src/main/runtime + src/shared/worktree (12,766 passed, 29 skipped, 0 failed). The visual before/after comparison was not re-captured after the rebase.

AI Disclosure

Implemented with OpenAI Codex (GPT-6). Independent pre-PR review by Claude Code (claude-fable-5-1 / Claude Fable 5.1); two review passes completed before opening this PR. Rebase onto main and the reverse-direction regression row by Claude Code (Claude Opus 5.5).

Review

Claude Code independently reviewed the implementation, scope, cross-platform risks, and the follow-up review fixes. The new activation fix only repeats resolution after the await; it adds no new restoration behavior. Five short JSDoc comments document the touched selector and test helpers without changing the docstring threshold. Final follow-up review found no blocking findings.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No RPC schema changes or new client capabilities. Published/saved workspace identity remains host-owned. Alias-based terminal listings report that existing host spelling as well. The host-conflict guard applies only to newly adopted aliases with known host ownership, including encoded runtime environment IDs. Alias requests whose repository rows name conflicting hosts intentionally return worktree_execution_host_unresolved, including initial subscription requests. Existing exact-ID, exact-empty, and unknown-evidence behavior is preserved; plain handles remain accepted under runtime owners because local connection metadata cannot establish their remote owner; this does not redesign the host-blind snapshot map. The live host's alias mismatch is reproduced; the affected client's precise outgoing request was not captured, so full incident recovery is not claimed from unit tests alone.

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)

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: f2e61249-16d1-468c-ba8a-10ad75a45e21
📥 Commits

Reviewing files that changed from the base of the PR and between 8eb02ac40ffecf1d24eedce9c84d19c80c93a6f2 and 5dda2bf9b1fd12b02addb870fad2d410a1c734f9.

📒 Files selected for processing (2)
  • src/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.ts
  • src/main/runtime/orca-runtime-session-tabs-path-alias.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.ts
  • src/main/runtime/orca-runtime-session-tabs-path-alias.test.ts

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

📝 Walkthrough

Runtime selector resolution now recognizes equivalent known worktree ID spellings and reports ambiguity when multiple known IDs match. Mobile-session operations use this selector, and session-tab subscriptions use normalized worktree keys to match updates and perform cleanup. Tests cover path aliases, tab listing and activation, PTY recovery, persisted-tab ownership, and subscription behavior.

Fixed issue severity: Medium

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 5dda2

This change lets equivalent spellings of a workspace path find the same session tabs. No actionable merge-blocking risk is evident from the supplied review.

Pre-merge checks: Passed 5
Check name Status Explanation
Linked Issues check Passed The changes meet the coding requirements in [#27260]. getExplicitSessionWorktreeIdSelector compares explicit IDs with worktreeIdsEqual across published session snapshots, saved host-session tabs, …
Out of Scope Changes check Passed The changes remain within [#27260]. Production edits apply alias resolution to explicit session worktree selectors and related publication and subscription paths. The tests verify the required path-id…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 13 files.
Title check Passed The title clearly and concisely describes the main change: resolving session-tab workspace path aliases at runtime.
Description check Passed The description follows the repository template and provides clear user impact, implementation details, rationale, linked issue, visual proof, testing results and limitations, AI disclosure, review no…
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (2)

🟡 Minor · Apply the execution-host boundary to live alias… · orca-runtime-resolve-browser-network-execution-host-for-worktree.ts:241-259

src/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.ts:241-259
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Apply the execution-host boundary to live alias candidates.

When equivalent worktree IDs exist on different local or SSH hosts, this selector can match the foreign host because knownIds includes all live tab and PTY candidates. worktreeIdsEqual does not compare execution hosts. Activation can therefore select the foreign tab, and the selected terminal handle routes both output and input to that foreign PTY.

Filter live snapshot and PTY candidates by the requested execution host before exact-key and alias matching. Keep ambiguity handling for candidates on that host.

🟡 Minor · Re-resolve the worktree after refreshing during… · orca-runtime-perform-mobile-session-pty-records-refresh.ts:111-117

src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts:111-117
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Re-resolve the worktree after refreshing during activation.

When no equivalent ID is known before refresh, getExplicitSessionWorktreeIdSelector keeps the requested alias. The refresh can register the discovered PTY under the canonical worktree ID. Activation then looks up the snapshot with the stale alias and can throw tab_not_found.

Use the same post-refresh resolution and paired-terminal restoration as listing.

Suggested fix
-    const worktreeId =
+    let worktreeId =
       explicitWorktreeId ?? (await this.resolveWorktreeSelector(worktreeSelector)).id
     this.hydrateHeadlessMobileSessionTabsFromWorkspaceSession(worktreeId)
     await this.refreshMobileSessionPtyRecords(worktreeId)
+    worktreeId =
+      this.getExplicitSessionWorktreeIdSelector(worktreeSelector) ?? worktreeId
+    this.restoreLivePairedRendererSessionOwnedMobileTerminals(worktreeId)
     const snapshot = this.mobileSessionTabsByWorktree.get(worktreeId)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df112034-5da9-4faa-9431-a4eeb8df3d36
📥 Commits

Reviewing files that changed from the base of the PR and between acdfdaf40d987f0cc30159e5d816f42671e5f476 and c83110a18bfa5b7786afd367c6bc165bbbde94a0.

📒 Files selected for processing (1)
  • src/main/runtime/orca-runtime-session-tabs-path-alias.test.ts

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

@SimonSQLML

Copy link
Copy Markdown
Contributor Author

@coderabbitai run pre-merge checks

Updated in 8eb02ac4 after reading the latest review and obtaining an independent Claude review before changes.

Both outside-diff findings have focused follow-ups:

  • Host ownership: before adopting a non-exact alias, the existing host resolver checks repository ownership and the actual host encoded by snapshot-referenced / surviving renderer-owned PTYs, with registered connection metadata as fallback. Positive local/SSH conflicts and ambiguous repository ownership fail with worktree_execution_host_unresolved; returning an empty alias would let the existing rescue path adopt the conflicting PTY again. Tests cover both local/SSH directions, distinct SSH targets, published/unpublished PTYs, and same-host controls. Exact IDs, runtime-host ownership, and unknown evidence retain their existing behavior; this is not a redesign of the host-blind snapshot map.
  • Activation: resolve again after the asynchronous inventory refresh. The regression publishes a real renderer graph during that await: canonical activation passed while alias activation failed before the fix; both now pass. No new activation restore behavior was added.

The four newly introduced functions and changed subscription fixture now have concise JSDoc. The coverage threshold and bot configuration are unchanged. 194 tests / 14 suites, Node typecheck, changed-code quality, and the JS app build pass. The latest development host also returns the same two existing terminals for both separator spellings in an isolated real-app RPC check. Claude's final review found no blockers.

Please also reassess Severity of issue fixed as High, separately from merge risk. The reported failure blocks access to all existing conversations/terminals in an affected remote workspace: the same running Windows host returns 11 tabs for its stored ID and 0 for the alternate spelling, silently, while the processes remain alive. This prevents resuming existing work through the affected client flow. A fresh isolated comparison returns 2/0 before and 2/2 after. Host access or alternate CLI selectors bypass the lookup but do not recover that client flow.

This request is scoped to the demonstrated Windows identity failure. No data loss, all-user outage, native macOS/Linux validation, or end-to-end paired-client UI recovery is claimed; the original client's outgoing request and reproducing UI screenshot remain outstanding. The PR and linked issue now state both the impact and these limits.

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eeb754bb-93a6-4d81-a268-9623ff878b6c
📥 Commits

Reviewing files that changed from the base of the PR and between c83110a18bfa5b7786afd367c6bc165bbbde94a0 and 8eb02ac40ffecf1d24eedce9c84d19c80c93a6f2.

📒 Files selected for processing (4)
  • src/main/runtime/orca-runtime-perform-mobile-session-pty-records-refresh.ts
  • src/main/runtime/orca-runtime-resolve-browser-network-execution-host-for-worktree.ts
  • src/main/runtime/orca-runtime-session-tabs-path-alias.test.ts
  • src/main/runtime/rpc/methods/session-tabs-unsubscribe.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/rpc/methods/session-tabs-unsubscribe.test.ts

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

@coderabbitai

coderabbitai Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 10, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Running Pre-merge checks. Results will be posted in the summary comment once complete.

@SimonSQLML

SimonSQLML commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@OrcaWin @nwparker Could you review this when you have time? Your recent session-tab recovery, host-ownership, and cross-platform work (#27094, #27246, #17159) looks directly relevant.

This fixes #27260: a Windows workspace remains visible remotely, but a separator-only difference in its explicit ID hides its existing tabs. On the reported host, the stored ID returns 11 tabs while the alternate spelling returns 0. The fix reuses the existing workspace-ID comparison and preserves the host's stored identity, without adding a subsystem or migrating session IDs. Most added lines are regression tests.

Please focus on alias resolution across repository, folder-instance, and execution-host boundaries, including nested SSH/runtime ownership and compatibility with macOS/Linux clients.

Current head: 5dda2bf9. Claude reviewed the changes; all 214 focused tests across 14 suites, Node typecheck, and changed-code quality pass. CodeRabbit resolved both findings and all five pre-merge checks pass. The PR includes actual before/after mobile-screen captures against isolated Windows hosts (0 tabs before, the same 2 existing tabs after). Native macOS/Linux and live SSH execution remain unverified.

We also documented why losing access to every existing tab in an affected workspace may warrant High issue severity; your assessment of that impact would be welcome. Thanks!

CI workflow approval needed: The four GitHub Actions runs for 5dda2bf9 are blocked with action_required; the PR Checks run has no jobs yet. The five passing checks above are CodeRabbit's pre-merge checks, not executed GitHub Actions CI.

Could either of you approve the pending workflows via Awaiting approval, then Approve workflows to run on this PR?

This PR does not change any workflow files. My account has read access to the upstream repository and cannot approve these fork runs. Thank you!

An explicit worktree ID that differs from the host's stored spelling only
by Windows path separators (or another worktreeIdsEqual-equivalent form)
returned an empty session tab snapshot, hiding a workspace's existing
tabs from paired clients.

Resolve explicit session selectors against the IDs the host already
knows (published snapshots, saved session tabs, surviving renderer-owned
PTYs) with the shared worktreeIdsEqual comparison, keep the host's
stored spelling, reject ambiguous aliases, and refuse alias adoption
across execution hosts. Session-tab subscriptions match and clean up by
the normalized key.

Fixes stablyai#27260

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@SimonSQLML
SimonSQLML force-pushed the fix/remote-session-tabs-windows-paths branch from 5dda2bf to cc8bff9 Compare October 15, 2026 18:14
nwparker added a commit that referenced this pull request Oct 16, 2026
…nder local owners

Addresses Codex review of the #27264 alias resolver.
@nwparker

Copy link
Copy Markdown
Contributor

Thanks @SimonSQLML. Fork CI couldn't run here, so your commit has been carried, with you as its author, into #29543. That PR is rebased onto current main and adds one review follow-up: an exact live-PTY spelling is never rewritten, and an unattributed remote PTY under a local repository is rejected. This PR will be closed once #29543 lands.

nwparker added a commit that referenced this pull request Oct 16, 2026
* fix(runtime): resolve session tab workspace path aliases

An explicit worktree ID that differs from the host's stored spelling only
by Windows path separators (or another worktreeIdsEqual-equivalent form)
returned an empty session tab snapshot, hiding a workspace's existing
tabs from paired clients.

Resolve explicit session selectors against the IDs the host already
knows (published snapshots, saved session tabs, surviving renderer-owned
PTYs) with the shared worktreeIdsEqual comparison, keep the host's
stored spelling, reject ambiguous aliases, and refuse alias adoption
across execution hosts. Session-tab subscriptions match and clean up by
the normalized key.

Fixes #27260

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(runtime): keep exact live PTY spellings and reject foreign PTYs under local owners

Addresses Codex review of the #27264 alias resolver.

---------

Co-authored-by: Simon Cho <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
@nwparker

Copy link
Copy Markdown
Contributor

Landed on main via #29543 with your commit and authorship intact (Co-authored-by on the squash), plus one review follow-up. Thank you, @SimonSQLML!

@nwparker nwparker closed this Oct 16, 2026
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.

[Bug]: Windows remote workspace tabs disappear when explicit IDs use forward slashes

2 participants