Skip to content

feat(wsl-mover): copy in-app browser logins into the WSL host on a move (D1b-7f) - #31400

Closed
nwparker wants to merge 1 commit into
nwparker/wsl-mover-d1b-7e-orchestration-historyfrom
nwparker/wsl-mover-d1b-7f-browser-logins
Closed

nwparker wants to merge 1 commit into
nwparker/wsl-mover-d1b-7e-orchestration-historyfrom
nwparker/wsl-mover-d1b-7f-browser-logins

Conversation

@nwparker

@nwparker nwparker commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​890 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​890
Prod 14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​647 $\color{#cf222e}{\Huge{\mathbf{−}}}$​23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​624

ELI5

When a project moves from the Windows desktop to a WSL host (the internal-only "lossless mover", off unless ORCA_INTERNAL_WSL_HOSTS is set), its in-app browser tabs now open on the WSL host. Those tabs use a separate cookie jar, so today the user would be signed out of every site after a move. This PR copies the desktop's browser cookies into the WSL host's jar once, when the move finishes. If that can't be done safely, the host starts with an empty jar and the move records why.

Builds on #29610's merged design: a WSL host Orca deployed keeps one browser partition across orcad relaunches and re-pairs (environment id + host key; bindings carry an alias fingerprint).

What Changed

Before: after a WSL move, the moved project's in-app browser pages on the WSL host started signed out everywhere.
After: they stay signed in. The first move into a host copies each in-app browser profile's cookies into that host's partition. Later moves into the same host leave its jar alone.

Mechanism:

  • New ledgered rewrite store browser-cookies on the D1b-7b registry (wsl-move-browser-cookie-store.ts, wsl-move-browser-cookie-copy.ts). It runs at most once per move: run, then flush the cookie store to disk, then the ledger entry. A crash before the ledger entry re-runs it, and the merge finds every cookie already present.
  • wsl-host-browser-route-partition.ts resolves the host's partition from the environment record alone, so no live connection or open page is needed. It uses the same identity, compatible identity and alias binding as page creation (derivePairedRuntimeBrowserAuthorityIdentity + resolveBrowserRoutePartitionBinding), so the copy lands where the host's first page will look. A test drives the real client-host runtime through two orcad relaunches/re-pairs and checks the partitions match.
  • browser-partition-cookie-copy.ts reads both jars and writes through CDP (Network.getAllCookies / Network.setCookie, via the existing hidden, never-shown debugger window in browser-cookie-clear-store.ts). Electron's cookies.get/set drop the partition key, so they are not used. It merges: a cookie the host already holds keeps the host's value. The desktop's own partition is only read.
  • The outcome goes into the move journal as an optional browserCookieCopy field, either copied with per-profile counts, or fresh-partition with a reason. previewWslMoveBrowserCookieCopy gives the move preview the same reason ahead of time.
  • Startup: the store waits for browser sessions to start (the pending cookie-import replay must happen first) and for an app window to exist, because on Windows, destroying the last hidden window would quit Orca. The startup pass therefore pauses it, and a pass after the first window shows finishes it.
  • WSL_MOVE_DESKTOP_REWRITE_REGISTRY_COMPLETE stays false. A one-line note sits where the registry is defined. The flip waits for 7c–7e.

Shared paths touched

  • Browser session path:
    • browser-cookie-clear-store.ts (new read-only readAllCdpCookies; the CDP cookie type moved to browser-cdp-cookie.ts);
    • browser-cookie-import-clear.ts (type only);
    • browser-session-startup.ts (a browserSessionsInitialized() getter).
  • Startup: main-process-ready-foundation.ts registers the store; main-process-ready-runtime.ts schedules one gated pass after the first window (next to the other first-window chores). With the gate closed, that pass does nothing.
  • Move journal schema: an optional, leniently parsed field. An unknown value from a newer build reads as absent, never as an unreadable journal.

Feasibility of copying each cookie kind (Electron 43)

Cookie kind Copied? How
httpOnly Yes CDP reads and sets it (so does Electron's cookies API)
Partitioned (CHIPS) Yes CDP carries partitionKey; Electron's cookies API would silently drop it and make the cookie cross-site
Session-only Yes Written without an expiry, same lifetime as on the desktop
__Host- / __Secure-, host-only vs domain Yes Host-only cookies are set without a domain, so the prefix rules still hold
Opaque partition key No (counted) No write can address it again
google.com No (counted) Same exclusion the existing import uses: Google binds sessions to the jar that minted them, and a copy can sign out both
Already in the host jar No (counted) The host's value wins
Refused by the cookie store (e.g. an invalid value) No (counted) Reported as rejected

When the move uses a fresh partition instead, the journal says why:

Reason When
no-stable-partition The destination environment has no deployment link, so its partition names the pairing and would move on the next orcad relaunch
destination-not-wsl-host The destination is a managed SSH host
destination-environment-missing The destination environment was removed
destination-partition-conflict Another identity owns the partition name

Why

Owner decision 3 (2026-10-16): (a) copy once at move time where feasible, otherwise (b) start fresh and say why. Literally binding the host to the desktop's partition is impossible. The binding store only accepts persist:orca-browser-v1-<hex> names, and route sessions put a SOCKS proxy on the whole session, so the desktop jar can't double as the host's jar.

Scope: whole jar, once per host. Cookies aren't scoped per project. A browser profile's jar is shared by every project, so there is nothing per-project to pick out. So each profile's jar is copied once into its partition on that host, by the first move into the host. Later moves skip partitions an earlier, ledgered move already copied into, so they never bring back a login the user signed out of on the host.

CDP over Electron's cookies API. Electron's API loses partition keys. Copying a partitioned cookie through it would quietly widen it to every site, which is a privacy regression rather than a lossless copy.

Merge, never overwrite. This makes a re-run after a crash harmless and keeps any session the user already started on the host.

The source is never written. There is no reverse mover (decision 2), so the desktop jar stays the safety net.

Linked Issue

N/A (internal WSL mover step D1b-7f, maintainer PR).

Visual Proof

N/A. This is a gated-dark, main-process data copy with no UI. The move preview UI that shows the reason is D1b-9.

Testing

  • Automated tests added/updated
    • wsl-host-browser-route-partition.test.ts:
      • the copy target matches the partition the real client-host runtime's pages resolve, across orcad relaunches and re-pairs;
      • it adopts the jar the host already uses;
      • it keeps one partition per browser profile;
      • it keeps its own partition after an older build drops the alias;
      • no deployment link means no stable partition;
      • a managed SSH host is never resolved.
    • browser-partition-cookie-copy.test.ts:
      • httpOnly, partitioned and session cookies are copied faithfully;
      • the skips: already present, google.com, opaque key, unreadable;
      • a refused write is counted;
      • the source jar is unchanged;
      • hidden windows are never shown and are always destroyed;
      • a re-run writes nothing twice.
    • wsl-move-browser-cookie-copy.test.ts (through the real D1b-7b driver and journal):
      • a feasible copy into the host, with every other jar unchanged;
      • each fresh-partition reason is recorded and nothing is copied;
      • an idempotent re-run after a crash between the copy and the ledger entry;
      • the store waits for browser sessions;
      • a second move into the same host leaves the host jar alone;
      • no behaviour when no move journal exists, or when the gate is closed;
      • a journal written by a newer build still reads.
  • Locally green:
    • pnpm tc;
    • pnpm run check:code-quality:changed;
    • check-focus-read-ratchet;
    • check-layout-writer-ratchets;
    • the touched tests and their neighbours (browser cookie/partition/paired-runtime, moving-wsl-projects, shared/wsl-move).
  • No baselines changed. Not manually run in the app: the path is unreachable with the gate off, and the move wiring that triggers it comes in a later step.

Review

An adversarial reviewer found one HIGH and one MEDIUM issue; both are fixed here.

  • HIGH: on Windows, the copy's hidden windows could quit Orca at startup. It now waits for an app window.
  • MEDIUM: a closed journal union could make older builds unable to read the journal. The field is now lenient.
  • Remaining LOWs, accepted:
    • An older build that rewrites a journal drops the field, which loses the once-per-host marker for that move.
    • Live host pages don't take the cookie mutation lock, so a cookie set in the instant between read and write can be overwritten by the desktop value.
    • Copied cookies get the default port and priority. This matches the existing import path.

Agent skill upstream boundary

  • Not applicable.

Notes

  • Security: desktop logins only ever go to the WSL host's partition for this environment, which already isolates by environment and host key. Sites that bind sessions to their jar are excluded. Nothing is copied off the machine; the WSL host's pages already egress through this desktop's partition.
  • Cross-platform: paths come from Electron. The hidden-window quit hazard on Windows is handled.
  • SSH: managed SSH, plain SSH, paired and local partitions are never written (tested).
  • Backwards compatibility: the new journal field is optional and parsed leniently; no RPC or wire change.
  • Performance: a one-off copy per host, run after the first window shows.

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 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 4 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: 571e4fc1-1938-433f-84f0-f6ba48ec5e87
📥 Commits

Reviewing files that changed from the base of the PR and between 57a2667 and 4cf77a5.

⛔ Files ignored due to path filters: 2
  • src/main/ssh/__snapshots__/orcad-migration-manifest-collector-golden.test.ts.snap is excluded by !**/*.snap
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 158
  • config/main-layout-writer-baseline.txt
  • config/scripts/vitest-sqlite-runtime-files.mjs
  • src/main/automations/automation-wsl-move-refusal.test.ts
  • src/main/ipc/register-core-handlers/register-core-handlers.ts
  • src/main/ipc/repos.ts
  • src/main/ipc/repos/repo-catalog-handlers.ts
  • src/main/ipc/session.ts
  • src/main/ipc/wsl-move-handlers.test.ts
  • src/main/ipc/wsl-move-handlers.ts
  • src/main/persistence-workspace-session-scrollback.test.ts
  • src/main/persistence/__fixtures__/wsl-mover/wsl-move-cutover-fixture.ts
  • src/main/persistence/loading-store/session-host-partitions.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-automation-state.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-client-state.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-dormant-state.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-export.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-left-behind-session-rows.test.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-scope.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-scrollback-cleanup.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-session-copy-resolution.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-session-partitions.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-workspace-session-eligibility.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-workspace-session.ts
  • src/main/persistence/migrating-orcad-catalog/orcad-source-worktree-metadata.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-cutover-journal.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-cutover-journal.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite-stores.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-fence.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-host-owned-chat-tabs.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-main-rewrite-stores.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-main-rewrite-stores.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-manifest-budget.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-manifest-budget.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-manifest-export.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-manifest-export.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestration-history-rewrite.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-orchestration-history-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-path-rewriter.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-preflight.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-reset.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-reset.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-restore-hints.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-rewrite-ledger.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-rewrite-scope.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope-roots.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope-roots.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-scope.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-session-freeze.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-session-freeze.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-session-rewrite.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-session-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-startup-rewrite.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-startup-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-ui-routing-rewrite.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-ui-routing-rewrite.ts
  • src/main/persistence/moving-wsl-projects/wsl-moved-projects.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-moved-projects.ts
  • src/main/persistence/restoring-sessions/cross-host-pane-tab-ids.ts
  • src/main/runtime/host-terminal-scrollback-read.test.ts
  • src/main/runtime/host-terminal-scrollback-read.ts
  • src/main/runtime/orca-runtime-migration-catalog.ts
  • src/main/runtime/orcad-migration-catalog-import.test.ts
  • src/main/runtime/orcad-migration-catalog-import.ts
  • src/main/runtime/orchestration/db/orchestration-db-file.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/runtime/rpc/methods/session-terminal-scrollback.test.ts
  • src/main/runtime/rpc/methods/session-terminal-scrollback.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-mobile-method-routing.ts
  • src/main/runtime/runtime-store-contract.ts
  • src/main/runtime/runtime-visible-catalog.test.ts
  • src/main/runtime/workspaces/persisted-surfaces/automation-operations.ts
  • src/main/runtime/wsl-moved-project-chat-runtime.test.ts
  • src/main/ssh/orcad-migration-cutover-coordinator.ts
  • src/main/ssh/orcad-migration-manifest-collector-golden.test.ts
  • src/main/ssh/orcad-migration-manifest-export.ts
  • src/main/ssh/orcad-migration-path-rewrite.ts
  • src/main/startup/main-process-ready-foundation.ts
  • src/main/startup/main-process-ready-phase-ordering.test.ts
  • src/main/startup/main-process-ready.ts
  • src/main/startup/main-process-state.ts
  • src/main/terminal-scrollback-snapshot-nonblocking-reads.ts
  • src/main/terminal-scrollback-snapshots.ts
  • src/preload/api/repos-bridge.ts
  • src/preload/api/repository-api.ts
  • src/preload/api/session-bridge.ts
  • src/preload/api/workspace-session-api.ts
  • src/renderer/src/App.tsx
  • src/renderer/src/app-shell/startup-runtime-session-hosts.ts
  • src/renderer/src/app-shell/use-app-startup-hydration.ts
  • src/renderer/src/components/editor/file-view-preference-storage.ts
  • src/renderer/src/components/editor/ipynb-kernel-store.ts
  • src/renderer/src/components/sidebar/Sidebar.test.tsx
  • src/renderer/src/components/sidebar/WslMovedProjectsSection.test.tsx
  • src/renderer/src/components/sidebar/WslMovedProjectsSection.tsx
  • src/renderer/src/components/sidebar/index.tsx
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/use-host-terminal-scrollback-hold.test.ts
  • src/renderer/src/components/terminal-pane/use-host-terminal-scrollback-hold.ts
  • src/renderer/src/components/use-terminal-workspace-foundation.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/fr.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/activate-ai-vault-structured-session.ts
  • src/renderer/src/lib/quick-open-file-history.ts
  • src/renderer/src/lib/setup-script-prompt.ts
  • src/renderer/src/lib/workspace-session-host-hydration.ts
  • src/renderer/src/lib/workspace-session-hydration-keys.ts
  • src/renderer/src/lib/wsl-move-renderer-store-keys.test.ts
  • src/renderer/src/lib/wsl-move-renderer-store-keys.ts
  • src/renderer/src/lib/wsl-move-renderer-store-rewrites.test.ts
  • src/renderer/src/lib/wsl-move-renderer-store-rewrites.ts
  • src/renderer/src/lib/wsl-moved-chat-activation.ts
  • src/renderer/src/runtime/host-terminal-scrollback-hydration.test.ts
  • src/renderer/src/runtime/host-terminal-scrollback-hydration.ts
  • src/renderer/src/runtime/runtime-compatibility-cache.ts
  • src/renderer/src/runtime/runtime-rpc-client-capability-peek.test.ts
  • src/renderer/src/runtime/runtime-rpc-client.ts
  • src/renderer/src/store/repos/all-host-repo-catalog-actions.ts
  • src/renderer/src/store/repos/repo-catalog-actions.ts
  • src/renderer/src/store/repos/repo-state.ts
  • src/renderer/src/store/repos/runtime-repo-catalog-actions.ts
  • src/renderer/src/store/repos/wsl-moved-local-session-rows.test.ts
  • src/renderer/src/store/repos/wsl-moved-local-session-rows.ts
  • src/renderer/src/store/repos/wsl-moved-projects.ts
  • src/renderer/src/store/repos/wsl-moved-repo-ui-retention.test.ts
  • src/renderer/src/store/repos/wsl-moved-repo-ui-retention.ts
  • src/renderer/src/store/slices/repos.ts
  • src/renderer/src/store/slices/tabs-hydration.ts
  • src/renderer/src/store/slices/tabs/tabs-session-actions.ts
  • src/renderer/src/store/slices/ui/ui-slice-hydration-actions.ts
  • src/renderer/src/store/slices/worktrees/listing/fetch-all-worktrees.ts
  • src/renderer/src/store/slices/wsl-moved-project-chat-hydration.test.ts
  • src/renderer/src/store/slices/wsl-moved-project-chat-purge.test.ts
  • src/renderer/src/web/preload-api/web-repositories-api.ts
  • src/renderer/src/web/preload-api/web-workspace-session-api.ts
  • src/shared/orcad-migration/orcad-migration-catalog-reference-abort.test.ts
  • src/shared/orcad-migration/orcad-migration-catalog-state.ts
  • src/shared/orcad-migration/orcad-migration-manifest.ts
  • src/shared/rpc-contract/session-terminal-scrollback-params.ts
  • src/shared/session-tabs-runtime-capabilities.ts
  • src/shared/workspace-session-host-records.ts
  • src/shared/workspace-session-tab-filter.ts
  • src/shared/worktree/id.ts
  • src/shared/wsl-move/wsl-move-cutover.ts
  • src/shared/wsl-move/wsl-move-dispositions.ts
  • src/shared/wsl-move/wsl-move-out-of-store-dispositions.ts
  • src/shared/wsl-move/wsl-move-renderer-rewrite-scope.ts
  • src/shared/wsl-move/wsl-move-renderer-rewrite-types.ts
  • src/shared/wsl-move/wsl-move-storage-dispositions.ts
  • src/shared/wsl-move/wsl-moved-project.ts
  • src/shared/wsl-paths.ts
  • tests/e2e/wsl-move-moved-project-chats.spec.ts
📝 Walkthrough

The change adds CDP cookie types, cookie reads, and partition-copy operations. It adds stable WSL host browser partition resolution and records browser-cookie copy outcomes in WSL move journals. The move store is registered during startup and runs after browser sessions initialize, with a first-window trigger and a 15-second fallback. Tests cover cookie planning, copying, partition binding, journal behavior, retries, and readiness conditions.

Priority: ➖ Normal

Merge Risk: 🔵 Low · up to 57a26

Most moves remain unaffected, but some users may need another launch or see stale cookies restored in unusually large profile sets.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 42.42% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 33 functions across 17 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: copying in-app browser logins into the WSL host during a move.
Description check Passed The description is complete and aligned with the template. It explains the user impact, implementation, rationale, linked issue context, visual proof, testing, review findings, compatibility considera…
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: Description check

Explanation

The description is complete and aligned with the template. It explains the user impact, implementation, rationale, linked issue context, visual proof, testing, review findings, compatibility considerations, and checklist status.

✨ Finishing Touches: 💡 1
📝 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

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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e9c8f390-d8f2-4232-90ff-c11008c937ce
📥 Commits

Reviewing files that changed from the base of the PR and between fa35698 and 6e81d2ed973af661a5bb258acb7aceea74c76f41.

📒 Files selected for processing: 16
  • src/main/browser/browser-cdp-cookie.ts
  • src/main/browser/browser-cookie-clear-store.ts
  • src/main/browser/browser-cookie-import-clear.ts
  • src/main/browser/browser-partition-cookie-copy.test.ts
  • src/main/browser/browser-partition-cookie-copy.ts
  • src/main/browser/browser-session-startup.ts
  • src/main/browser/wsl-host-browser-route-partition.test.ts
  • src/main/browser/wsl-host-browser-route-partition.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-browser-cookie-copy.test.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-browser-cookie-copy.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-browser-cookie-store.ts
  • src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite-stores.ts
  • src/main/startup/main-process-ready-foundation.ts
  • src/shared/wsl-move/wsl-move-browser-cookie-copy.ts
  • src/shared/wsl-move/wsl-move-cutover.ts
  • src/shared/wsl-move/wsl-move-out-of-store-dispositions.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 +302 to +307
// The startup pass ran before browser sessions and any window existed, so `browser-cookies` paused.
runAfterFirstWindowShown(() => {
void runGatedWslMoveDesktopRewritePass({
userDataPath: getAppEnvironment().getPath('userData')
})
}, WSL_MOVE_BROWSER_COOKIES_FALLBACK_MS)

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

rg -n 'runAfterFirstWindowShown' src --type=ts -g '!**/*.test.ts' | head -20
rg -n -A30 'export function runAfterFirstWindowShown' src
sed -n '1,60p' src/main/persistence/moving-wsl-projects/wsl-move-browser-cookie-store.ts
sed -n '290,312p' src/main/startup/main-process-ready-foundation.ts
rg -n 'sessions_not_ready|destination-committed|fence' src/main/persistence/moving-wsl-projects/*.ts | head -40

Repository: stablyai/orca

Length of output: 12143


🏁 Script executed:

set +e
rg -n -F --glob '*.ts' \
  -e 'runGatedWslMoveDesktopRewritePass' \
  -e 'wsl_move_browser_sessions_not_ready' \
  -e 'destination-committed' \
  -e 'setInterval' \
  -e 'runWslMoveDesktopRewritePass' \
  src/main/persistence/moving-wsl-projects src/main/startup
printf '\n--- rewrite runner definitions ---\n'
rg -n -A100 -B15 'function runGatedWslMoveDesktopRewritePass|export .*runGatedWslMoveDesktopRewritePass|runGatedWslMoveDesktopRewritePass' src/main/persistence/moving-wsl-projects src/main/startup
printf '\n--- browser cookie copy ---\n'
rg -n -A120 -B20 'runWslMoveBrowserCookieCopy|wsl_move_browser_sessions_not_ready' src/main/persistence/moving-wsl-projects
printf '\n--- fence and journal consumers ---\n'
rg -n -A80 -B20 -e 'destinationCommitted' -e 'destination-committed' -e 'sessionFrozen' -e 'fenced' src/main/persistence/moving-wsl-projects/wsl-move-fence.ts src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts
printf '\n--- startup and periodic move processing ---\n'
rg -n -A80 -B20 -e 'registerWslMoveDesktopRewriteStore' -e 'process.*move' -e 'rewrite.*pass' -e 'desktop.*rewrite' src/main/persistence/moving-wsl-projects src/main/startup

Repository: stablyai/orca

Length of output: 45663


🏁 Script executed:

printf '%s\n' '--- wsl-move-desktop-rewrite.ts ---'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite.ts | sed -n '1,230p'
printf '%s\n' '--- wsl-move-desktop-rewrite-stores.ts ---'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-desktop-rewrite-stores.ts | sed -n '1,180p'
printf '%s\n' '--- wsl-move-browser-cookie-copy.ts ---'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-browser-cookie-copy.ts | sed -n '55,215p'
printf '%s\n' '--- wsl-move-background-backoff.ts ---'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-background-backoff.ts | sed -n '1,240p'
printf '%s\n' '--- wsl-move-fence.ts ---'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-fence.ts | sed -n '1,180p'
printf '%s\n' '--- scope guard phase handling ---'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts | sed -n '1,165p'
nl -ba src/main/persistence/moving-wsl-projects/wsl-move-scope-guard.ts | sed -n '250,335p'

Repository: stablyai/orca

Length of output: 38409


🏁 Script executed:

printf '%s\n' '--- startup call sites ---'
nl -ba src/main/startup/main-process-ready-foundation.ts | sed -n '145,180p'
nl -ba src/main/startup/main-process-ready-foundation.ts | sed -n '292,312p'
rg -n -F --glob '*.ts' --glob '!**/*.test.ts' -- 'runWslMoveDesktopRewritePass(' src
rg -n -F --glob '*.ts' --glob '!**/*.test.ts' -- 'runGatedWslMoveDesktopRewritePass(' src
printf '%s\n' '--- first-window deferral implementation and tests ---'
nl -ba src/main/startup/first-window-deferral.ts | sed -n '1,100p'
rg -n -A100 -B20 -F -- 'runAfterFirstWindowShown' src/main/startup --glob '*test.ts'
printf '%s\n' '--- deferred startup call-site context ---'
nl -ba src/main/startup/main-process-ready-runtime.ts | sed -n '70,112p'
nl -ba src/main/host/deferred-secret-protection-report.ts | sed -n '55,85p'
printf '%s\n' '--- move commit and post-commit triggers ---'
rg -n -F --glob '*.ts' --glob '!**/*.test.ts' -e 'phase: '\''destination-committed'\''' -e 'destination-committed' -e 'recordWslMoveRendererStoreRewritten' src/main src/shared

Repository: stablyai/orca

Length of output: 42425


Retry the deferred pass if the fallback fires before a window exists.

runAfterFirstWindowShown runs its task once. If the 30-second fallback runs before a window exists, sessionsReady() returns false, and runWslMoveBrowserCookieCopy throws wsl_move_browser_sessions_not_ready. The pass then stops before later stores, and no other production caller retries it during that launch. The move remains at destination-committed until a later startup pass.

This does not keep the projects in the pre-commit fenced state. destination-committed places them in the post-commit hidden state and keeps their sessions frozen. The browser-cookie rewrite still remains incomplete.

The fallback is intentionally allowed to run without a window for GPU-failure and headless startup. Preserve that behavior, but retry this browser-dependent pass on the next window's ready-to-show event when the fallback finds no live window.

🐛 Suggested fix
-import { app, session } from 'electron'
+import { app, BrowserWindow, session } from 'electron'
...
   // The startup pass ran before browser sessions and any window existed, so `browser-cookies` paused.
+  const runDeferredWslMovePass = (): void => {
+    void runGatedWslMoveDesktopRewritePass({
+      userDataPath: getAppEnvironment().getPath('userData')
+    })
+  }
   runAfterFirstWindowShown(() => {
-    void runGatedWslMoveDesktopRewritePass({
-      userDataPath: getAppEnvironment().getPath('userData')
-    })
+    if (BrowserWindow.getAllWindows().some((window) => !window.isDestroyed())) {
+      runDeferredWslMovePass()
+      return
+    }
+    app.once('browser-window-created', (_event, window) => {
+      window.once('ready-to-show', runDeferredWslMovePass)
+    })
   }, WSL_MOVE_BROWSER_COOKIES_FALLBACK_MS)

@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7f-browser-logins branch from 6e81d2e to 57a2667 Compare October 21, 2026 04:49

@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 (1)

🟡 Minor · Limit the profile list before copying. · wsl-move-browser-cookie-copy.ts:153-173

src/main/persistence/moving-wsl-projects/wsl-move-browser-cookie-copy.ts:153-173
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Limit the profile list before copying.

When more than 256 browser profiles exist, runWslMoveBrowserCookieCopy binds and copies every profile but records only the first 256. A later move into the same host does not find recorded partitions beyond that prefix, so it can copy those profiles again. If a user signed out on the host, the second move can restore the desktop cookie.

Suggested fix
-  const profiles = dependencies.listBrowserProfiles()
+  const profiles = dependencies
+    .listBrowserProfiles()
+    .slice(0, WSL_MOVE_BROWSER_COOKIE_COPY_MAX_PROFILES)

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0e812120-a6c4-4656-bed5-bfa638909c6b
📥 Commits

Reviewing files that changed from the base of the PR and between 6e81d2ed973af661a5bb258acb7aceea74c76f41 and 57a2667.

📒 Files selected for processing: 2
  • src/main/startup/main-process-ready-foundation.ts
  • src/main/startup/main-process-ready-runtime.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.

…ve (D1b-7f)

A committed WSL move now copies each in-app browser profile's cookies once into
the WSL host's stable route partition (owner decision 3a), merging without
overwriting what the host jar holds and never touching the source. Where that
is infeasible (no deployment link so no stable partition, the destination is
not a WSL host or is gone, or the partition name is held by another identity)
the host starts fresh and the move journal records why (3b). Registered as the
ledgered browser-cookies rewrite store; it runs only once browser sessions and
an app window exist. WSL_MOVE_DESKTOP_REWRITE_REGISTRY_COMPLETE stays false.
@nwparker
nwparker force-pushed the nwparker/wsl-mover-d1b-7f-browser-logins branch from 57a2667 to 4cf77a5 Compare October 21, 2026 07:46
@nwparker
nwparker changed the base branch from main to nwparker/wsl-mover-d1b-7e-orchestration-history October 21, 2026 07:47
@nwparker

Copy link
Copy Markdown
Contributor Author

Contained in the dark landing PR #34059 (its head commit is an ancestor of the landing branch). Closing in favour of it; branch kept.

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

1 participant