Skip to content

test(e2e): check same-path editor models across two real hosts - #39208

Merged
nwparker merged 1 commit into
mainfrom
nwparker/nightly-e2e-editor-model-host-isolation
Nov 6, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/nightly-e2e-editor-model-host-isolation

Conversation

@nwparker

@nwparker nwparker commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

A nightly test checks that when the same file path is open on two different machines, each copy keeps its own text and its own Undo history. The test faked the second machine. Since late October, Orca refuses to read a file from a machine other than the one the tab belongs to, so the fake tab showed an error and the test failed every night. The test now uses a real second machine.

Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​141 $\color{#cf222e}{\Huge{\mathbf{−}}}$​92 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13

What Changed

tests/e2e/editor-model-host-isolation.spec.ts is rewritten:

  • Before: one Orca window opened the same local file twice. It labelled the second tab as belonging to an SSH host (ssh:fixture-target) that doesn't exist, then relied on the file read quietly falling back to the local disk. Since Support automations in Orca Mobile #31617, the file loader reads only from the host the tab belongs to. That host can't be verified, so the tab showed "Unable to load file. Couldn't verify which host owns this file." and the editor never mounted.
  • After: the spec launches a second Orca app that pairs with the test host as a remote runtime, the same way the other paired-* specs do. That client adds the same checkout as a local project too, so one window has the same file path open on two real hosts. The test then:
    1. types ! in the local copy
    2. checks the remote copy still shows the original text
    3. checks Undo in the remote copy doesn't remove the local !
    4. types ? in the remote copy and undoes it
    5. checks the local copy still shows !
  • It reads each host's editor by its model address: file: for local, and a host-specific vscode-remote: address for the runtime. So it also checks that the remote copy gets its own model instead of sharing the local one. Each project keeps its own editor mounted, so the old single global probe (__monacoEditorE2E) could point at whichever editor mounted last.
  • New PR routing rule editor.host-model-identity: changes to the editor model identity code, the editor file loader, or editor file ownership now run this spec. Before, no source change selected it. Covered in pr-e2e-gate-contract.test.mjs.

Why

The product behavior is correct. A tab that belongs to one host must never quietly read another host's disk. The test was depending on that leak. I considered keeping the fake tab and loosening the owner check for it, but that means changing product code to make a test pass. A paired runtime is the cheapest real second host CI already runs (no Docker or SSH needed), and on one machine both hosts see the same path. That is exactly the collision this feature guards against.

Linked Issue

N/A (nightly E2E failure, maintainer)

Visual Proof

N/A. Test-only change; the app behaves the same.

Testing

  • Old spec on current main: fails locally the same way it does in CI (Received: undefined, screenshot shows the owner-verification error).

  • New spec: ORCA_BACKGROUND_LAUNCH=1 pnpm run test:e2e tests/e2e/editor-model-host-isolation.spec.ts --repeat-each=3 passed 3/3 on macOS. If the two hosts shared one model, the vscode-remote: editor would never appear, and the remote copy would show MARKER!.

  • pnpm test config/scripts/workflow/source-routing/, pnpm tc, pnpm run check:code-quality:changed pass.

  • I manually tested these changes locally

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

  • Every added test fails without this change and avoids the test anti-patterns

Risk

Low. Test and CI routing only. The spec now starts a second Electron app, which adds roughly 20 seconds. Undo with a plain revert.

Level: Low

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.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I stated the risk
  • N/A with reason for visuals
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered
  • Typecheck and tests pass locally

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

The E2E test now opens the same file through local and runtime worktrees, then checks that edits and undo operations remain isolated between the two editor models. A new source route selects this test for specified editor product-source changes, and routing tests check the included source paths and an excluded unit-test path.

Merge Risk: Low · up to 85db1

This change only adds and reroutes an E2E test and does not alter product behavior. The test may be flaky on Windows because of path comparison. The route entry for the owner file is also not covered by a test. It is mergeable, with these items worth fixing.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly describes the main E2E test change.
Description check Passed The description is mostly complete. Add the Review and Notes sections, clarify lint and build status, and correct the routing test filename if needed.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 3 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
  • 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

@nwparker
nwparker force-pushed the nwparker/nightly-e2e-editor-model-host-isolation branch from 642f36a to 5ed1207 Compare November 6, 2026 23:07
@nwparker
nwparker enabled auto-merge (squash) November 6, 2026 23:07

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

Nitpick comments: 1

config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs: 1

196-200: Trivial · Maintainability & Code Quality · Low value

Add a routing case for editor-file-operation-owner.ts.

The route includes the owner path, but this test does not check it. Removing that entry would not fail this test.

Suggested fix

     'src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts',
+    'src/renderer/src/lib/editor-file-operation-owner.ts',
     'src/renderer/src/lib/editor-file-operation-provenance.ts'
Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45dfadf7-497a-48fd-b489-a5b8c48e799f
Commits

Reviewing files that changed from the base of the PR and between dbf5634 and 5ed1207.

Files selected for processing: 3

  • config/scripts/workflow/source-routing/pr-e2e-gate-contract.test.mjs
  • config/scripts/workflow/source-routing/pr-editor-preview-e2e-source-routes.mjs
  • tests/e2e/editor-model-host-isolation.spec.ts

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

The spec forged an SSH owner for a local file and relied on the read
falling back to local transport. Since #31617 a tab reads only from its
captured owner, so the forged tab correctly shows 'Couldn't verify which
host owns this file'. Use a paired client that opens the same checkout
locally and on its runtime host instead, and route editor model identity
sources to the spec.
@nwparker
nwparker force-pushed the nwparker/nightly-e2e-editor-model-host-isolation branch from 5ed1207 to 85db192 Compare November 6, 2026 23:18

@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: 1

Nitpick comments: 1

config/scripts/workflow/source-routing/pr-editor-host-model-e2e-route.test.mjs: 1

6-12: Trivial · Maintainability & Code Quality · Low value

Add a route test case for editor-file-operation-owner.ts.

The route includes this path, but the test does not exercise it. A typo or removal of the entry would not fail the test.

Suggested fix

     'src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts',
+    'src/renderer/src/lib/editor-file-operation-owner.ts',
     'src/renderer/src/lib/editor-file-operation-provenance.ts'

Optionally, add a negative case for an unrelated editor source to check that the route stays narrow.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 80fa5fda-2185-4457-9d86-175d0944e117
Commits

Reviewing files that changed from the base of the PR and between 5ed1207 and 85db192.

Files selected for processing: 3

  • config/scripts/workflow/source-routing/pr-editor-host-model-e2e-route.test.mjs
  • config/scripts/workflow/source-routing/pr-editor-preview-e2e-source-routes.mjs
  • tests/e2e/editor-model-host-isolation.spec.ts

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

Comment on lines +61 to +69
const findRemoteWorktreeId = (): Promise<string | null> =>
page.evaluate(
(repoPath) =>
window.__store
?.getState()
.allWorktrees()
.find((worktree) => worktree.path === repoPath)?.id ?? null,
testRepoPath
)

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.

Major · Functional Correctness · Quick win

Supported by static analysis

Script executed:

git diff d5d92649ac134331c88874414c03caf403a93b4f 85db192bdcdc7feea3677947f8381bda525b9a18 -- tests/e2e/editor-model-host-isolation.spec.ts
nl -ba tests/e2e/editor-model-host-isolation.spec.ts | sed -n '1,240p'
rg -n -F -e 'createSeededTestRepo' -e 'provideWorkerTestRepository' -e 'createPaired' -- tests/e2e/helpers/orca-app.ts tests/e2e/editor-model-host-isolation.spec.ts

Repository: stablyai/orca

Length of output: 16581


Script executed:

sed -n '1,160p' tests/e2e/helpers/orca-app.ts
sed -n '200,290p' tests/e2e/helpers/orca-app.ts
rg -n -F -e 'function createSeededTestRepo' -e 'function provideWorkerTestRepository' -e 'testRepoPath:' -- tests/e2e/helpers
rg -n -F -e 'realpath' -e 'worktree list' -e 'isMainWorktree' -- src/main/git/worktree-list-reader.ts src/main/git/worktree-listing.ts src/main/ipc/worktree-metadata-merge.ts

Repository: stablyai/orca

Length of output: 10086


Script executed:

nl -ba tests/e2e/helpers/seeded-test-repo.ts | sed -n '1,220p'
rg -n -F -e 'isMainWorktree:' -e 'git worktree list' -e 'realpathSync' -- src/main/git src/main/ipc/worktree-metadata-merge.ts
rg -n -F -e 'allWorktrees:' -e 'allWorktrees()' -- src/renderer/src/store/slices/worktrees

Repository: stablyai/orca

Length of output: 7957


Script executed:

rg -n -F -e 'seedTestRepository' -e 'TEST_REPO_PATH_FILE' -e 'realpath' -e 'mkdtemp' -- tests/e2e/global-setup.ts
nl -ba tests/e2e/global-setup.ts | sed -n '1,210p'
rg -n -F -e 'isMainWorktree' -e 'realpath' -e 'path:' -e 'normalize' -- src/main/git/worktrees/catalog/worktree-listing.ts src/main/git/worktrees/catalog/worktree-list-porcelain.ts src/main/ipc/worktree-metadata-merge.ts
rg -n -F -e 'allWorktrees:' -e 'allWorktrees =' -- src/renderer/src/store

Repository: stablyai/orca

Length of output: 9496


Script executed:

nl -ba src/main/git/worktrees/catalog/worktree-listing.ts | sed -n '1,180p'
rg -n -F -e 'parseWorktree' -e 'isMainWorktree' -e 'translateWorktreePath' -- src/main/git/worktrees/catalog
rg -n -F -e 'createAllWorktrees' -- src/renderer/src/store/slices
rg -n -F -e 'normalizeRuntimePathSeparators' -e 'gitWorktree' -- src/main/git/worktrees/catalog src/shared/path*

Repository: stablyai/orca

Length of output: 12046


Script executed:

nl -ba src/main/git/worktrees/catalog/worktree-path-comparison.ts | sed -n '1,210p'
nl -ba src/main/git/worktrees/catalog/worktree-list-reader.ts | sed -n '155,310p'
nl -ba src/shared/git/worktrees/git-worktree-porcelain-parser.ts | sed -n '1,220p'
nl -ba src/renderer/src/store/slices/worktrees/session/worktree-slice-lookups.ts | sed -n '115,175p'

Repository: stablyai/orca

Length of output: 17380


Script executed:

rg -n -i -e 'git (for windows|on windows|returns|reports|outputs|emits).*(slash|separator|path)' -e '(forward|back)slash.*(git|worktree)' -e 'worktree.*(forward slash|backslash|separator)' -- src/main/git src/shared/git tests/e2e config | sed -n '1,120p'
nl -ba src/main/git/command-runner/wsl-path-translation.ts | sed -n '1,200p'
nl -ba src/main/ipc/worktree-metadata-merge.ts | sed -n '1,65p'

Repository: stablyai/orca

Length of output: 45665


Script executed:

rg -n -i --glob '*.ts' --glob '*.md' -e 'git.{0,80}(forward slash|backslash|separator)' -e '(forward slash|backslash|separator).{0,80}git' -- src/main/git src/shared/git tests/e2e || test "$?" -eq 1
rg -n -F -e 'windows-latest' -e 'windows-2022' -e 'windows-2025' -- .github/workflows | rg -i 'e2e|playwright|test' || test "$?" -eq 1
nl -ba src/main/git/repo-detection.ts | sed -n '205,250p'

Repository: stablyai/orca

Length of output: 6935


Web query:

git for windows git worktree list --porcelain output forward slash path Windows backslash

Result:

Sources consulted:
- Documentation/git-worktree.txt - pub/scm/git/git - Git at Google — https://kernel.googlesource.com/pub/scm/git/git/%2B/a296bc01329b9e2aa91255c88626e8c8f831e428/Documentation/git-worktree.txt
- Documentation/git-worktree.txt - pub/scm/git/git - Git at Google — https://kernel.googlesource.com/pub/scm/git/git/%2B/cccf74e2da85808478c784e403a69bbfe2b9f518/Documentation/git-worktree.txt
- Documentation/git-worktree.txt - third_party/git - Git at Google — https://fuchsia.googlesource.com/third_party/git/%2B/c3befaeab9ebd0def9f03d434a52cf40614c65f9/Documentation/git-worktree.txt
- git-worktree.txt - external/gitster/git-htmldocs - Git at Google — https://chromium.googlesource.com/external/gitster/git-htmldocs/%2B/4200b6a69a140b13fd148e59f0d01edeeb40fef9/git-worktree.txt
- Documentation/git-worktree.txt - git - Git at Google — https://code.googlesource.com/git/%2B/8da1481bdcd6c85a0e8839df61a16180b9434f10/Documentation/git-worktree.txt
- …and 28 more

Script executed:

nl -ba src/main/git/worktrees/removal/worktree-removal-real-git.test.ts | sed -n '1,135p'
rg -n -F -e 'mergeWorktree(' -e 'listWorktreesStrictAllowingTrueEmpty(' -- src/main/runtime src/main/ipc/worktrees/listing src/main/ipc/worktree*.ts | grep -v '\.test\.' 
rg -n -F -e 'worktree.list' -e 'listWorktrees' -- src/renderer/src/store/slices/worktrees/listing/fetch-worktrees.ts src/main/runtime/rpc/methods/worktree.ts | sed -n '1,100p'

Repository: stablyai/orca

Length of output: 9053


Script executed:

nl -ba src/main/runtime/workspaces/catalog/runtime-managed-worktree-queries.ts | sed -n '1,230p'
rg -n -F -e 'getManagedWorktrees' -e 'listManagedWorktrees' -e 'runtime-managed-worktree-queries' -- src/main/runtime/workspaces src/main/runtime/rpc src/main/runtime/orca-runtime.ts | sed -n '1,140p'
nl -ba src/renderer/src/store/slices/worktrees/listing/fetch-worktrees.ts | sed -n '1,180p'

Repository: stablyai/orca

Length of output: 21941


Script executed:

rg -n -F -e 'scanRepo:' -e 'scanRepo =' -e 'new RuntimeManagedWorktreeQueries' -- src/main/runtime | grep -v '\.test\.'
rg -n -F -e 'listWorktreesStrict' -e 'scanLocal' -- src/main/runtime/workspaces/catalog src/main/runtime/orca-runtime.ts | grep -v '\.test\.'

Repository: stablyai/orca

Length of output: 1826


Script executed:

rg -n -F -e 'listRepoWorktreesForListing' -e 'scanLocalRepoWorktreesForResolution' -- src/main/runtime --glob '*.ts' | grep -v '\.test\.'
nl -ba src/main/runtime/workspaces/catalog/repo-worktree-resolution-scan.ts | sed -n '1,100p'
nl -ba src/main/runtime/workspaces/catalog/workspace-repo-scan-refresh.ts | sed -n '125,190p'

Repository: stablyai/orca

Length of output: 6319


Script executed:

rg -n -F -e 'toDetectedWorktree(' -- src/shared/worktree/ownership* src/main/runtime/workspaces/catalog/runtime-managed-worktree-queries.ts
rg -n -F -e 'path:' -e 'worktrees.map' -e 'worktree:' -- src/renderer/src/store/slices/worktrees/listing/fetched-worktree-merge.ts src/renderer/src/store/slices/worktrees/listing/detected-worktree-refresh.ts src/shared/worktree/ownership*
nl -ba src/main/runtime/workspaces/catalog/workspace-catalog.ts | sed -n '225,255p'
nl -ba src/main/runtime/rpc/methods/workspaces/worktree-catalog-methods.ts | sed -n '1,110p'

Repository: stablyai/orca

Length of output: 13552


Script executed:

rg -n -F -e 'function preserveFolderUpgradeWorktreePath' -e 'preserveFolderUpgradeWorktreePath' -- src/main/runtime/workspaces/catalog src/main/workspaces
nl -ba src/shared/worktree/ownership.ts | sed -n '157,220p'
nl -ba src/renderer/src/store/slices/worktrees/listing/fetched-worktree-merge.ts | sed -n '160,260p'

Repository: stablyai/orca

Length of output: 9966


Normalize Windows paths in the remote lookup.

On Windows, Git can report the checkout with forward slashes while testRepoPath uses backslashes. The strict comparison can then time out even when the runtime has the worktree.

Suggested fix

-        (repoPath) =>
-          window.__store
+        ({ repoPath, isWindows }) => {
+          const pathKey = (value: string) =>
+            isWindows ? value.replace(/\\/g, '/').toLowerCase() : value
+          return window.__store
             ?.getState()
             .allWorktrees()
-            .find((worktree) => worktree.path === repoPath)?.id ?? null,
-        testRepoPath
+            .find((worktree) => pathKey(worktree.path) === pathKey(repoPath))?.id ?? null
+        },
+        { repoPath: testRepoPath, isWindows: process.platform === 'win32' }
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
const findRemoteWorktreeId = (): Promise<string | null> =>
page.evaluate(
(repoPath) =>
window.__store
?.getState()
.allWorktrees()
.find((worktree) => worktree.path === repoPath)?.id ?? null,
testRepoPath
)
const findRemoteWorktreeId = (): Promise<string | null> =>
page.evaluate(
({ repoPath, isWindows }) => {
const pathKey = (value: string) =>
isWindows ? value.replace(/\\/g, '/').toLowerCase() : value
return window.__store
?.getState()
.allWorktrees()
.find((worktree) => pathKey(worktree.path) === pathKey(repoPath))?.id ?? null
},
{ repoPath: testRepoPath, isWindows: process.platform === 'win32' }
)

@nwparker
nwparker merged commit cf47e79 into main Nov 6, 2026
48 checks passed
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