Skip to content

feat(wsl-host): a paired phone reaches the desktop's WSL host and never starts its distro (E6) - #33911

Merged
nwparker merged 9 commits into
mainfrom
nwparker/wsl-e6-phone-relay
Oct 29, 2026
Merged

nwparker merged 9 commits into
mainfrom
nwparker/wsl-e6-phone-relay

Conversation

@nwparker

@nwparker nwparker commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Do not merge yet: this still needs the real-device phone check in Testing. It is marked ready only so the full CI runs.

Files Added Deleted Net
Test 12 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​891 $\color{#cf222e}{\Huge{\mathbf{−}}}$​116 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​775
Prod 15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​378 $\color{#cf222e}{\Huge{\mathbf{−}}}$​55 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​323

ELI5

On Windows, Orca can now run your projects inside a WSL distro (the "WSL host", behind an internal switch). Until now a phone paired with that computer simply couldn't see those projects. With this change the phone sees and uses them through the computer, the same way it already uses a remote server the computer is connected to. One hard rule: the phone never starts a stopped distro. If it isn't running, the phone says so and tells you to start it on the computer.

What Changed

Before (switch on): WSL host projects, terminals and agent launches were missing on the phone and in the phone's sidebar, and a push for an agent there had nothing to open.

After (switch on):

  • The phone lists the WSL host next to the computer's other servers and can list its projects, open files, run terminals and launch agents there. All of it goes through the computer.
  • Once the computer has confirmed the distro stopped, its rows on the phone carry a "Start on computer" badge, and calls are refused with "The WSL host Ubuntu isn't running. Open one of its projects on your computer to start it." While it's starting, reconnecting or can't be confirmed, the phone gets a neutral "isn't available from your phone right now" message and no badge. Either way, nothing gets started.
  • A push for an agent on the WSL host already names that host (executionHost, from feat(push): accept a notification's workspace server #26516), so tapping it opens the worktree through the computer.

Mechanism:

  • Every call the computer passes along for a phone (resolve, call, watchChanges, and status.get) carries a "never start" flag. For a WSL host, it goes through a new WslHostPhoneGate (src/main/wsl/wsl-host-phone-reach.ts). The gate reuses the focus check from the change that boots only the focused WSL host. If this process has no bridge to the distro, the call is refused right away, without spawning wsl.exe. Otherwise it reads reachability(). Only available serves the call; a confirmed stopped is remembered for the phone's copy; anything else gets the neutral message. This holds even while the computer has open work for that host.
  • Phones don't see WSL hosts while the Experimental switch is off or a Remove is pending, not only while the internal gate is closed.
  • A WSL host's last status counts only while the computer holds it ready, so it never shows as stale-ready.
  • The computer's background list of each server's workspaces (the source of the main-computed sidebar feed the phone reads) now includes the WSL host like any other server. It only watches a host while it's connected, and every fetch uses the never-start flag. On the computer's own sidebar this changes nothing while that feed is off, which it is in shipped builds. With it on, the WSL host's rows come from the same feed as every other server's.
  • The host list sent to the phone gains two optional flags: stoppedOnDesktop: true for a confirmed stop (badge "Start on computer"), and unavailableOnDesktop: true for a WSL host this computer isn't connected to and doesn't know is stopped (badge "Open on computer"). A confirmed stop is tied to that host's own last status and lapses when the host publishes any new status.

Why

The relay, delegated phone devices, workspace rows, terminals, agent launch and push routing already work for managed SSH servers, and this is the same server code. The only WSL-specific risk was waking the distro, so the change is one "never start" switch on the relay's call path instead of a separate phone path. Starting a distro from the phone was left out on purpose. If it's wanted later, it should be a prompt on the computer, never a silent start.

Supersedes the draft prototype #31490, rebased on current main with the remaining work done.

Mixed versions:

  • No new stream opcode or RPC method. stoppedOnDesktop and unavailableOnDesktop are optional.
  • An older phone ignores both flags (its parser keeps unknown keys). It shows a stopped or not-connected WSL host as "Connecting" indefinitely. That's cosmetic: those phones can't start anything, and every call is refused with the message.
  • A newer phone paired with an older computer gets no marker and no WSL host, and draws exactly as before (tested).
  • isConnected on the WSL service is untouched; the phone's view is WslHostPhoneGate.reach.

Linked Issue

N/A (internal WSL host work, gate E6).

Visual Proof

N/A. The only visible change is the text of an existing badge on a phone row ("Start on computer"), and it shows only with the internal WSL switch on and a stopped distro. Unit tests cover it, and the real-device check is listed below.

Testing

  • I manually tested these changes locally (phone + Windows real-device check still to do, listed below)

  • Automated tests added/updated

  • Unit: a phone's status.get checks only a WSL host; SSH-managed and plain paired servers reach the status probe exactly as on main (no reconnect or redeploy); a stopped reading is dropped if the host turned ready during the check, and a check that finds the host answering clears an earlier stop; managed tunnel no-start branch; WslHostPhoneGate (stopped only for a confirmed stop, neutral otherwise, no running-list read without a bridge, hidden while the switch is off or a Remove is pending, a ready status clears a stop); relay hosts (switch closed hides WSL hosts, switch open lists them, no-start flag on every path, status only while connected); new: a no-start status.get is refused before the status probe dials; new: the background rows list carries a WSL host's rows, keeps them as unverifiable once it stops, and makes no further calls; push host id for a WSL worktree.

  • Mobile: new: reads stoppedOnDesktop from a newer computer and ignores a bad value; an older computer's list (no marker, no WSL host) shows only the usual health word; "Start on computer" appears only for a stop the computer confirmed (not while starting or reconnecting).

  • E2E tests/e2e/wsl-host-paired-phone.spec.ts (fake WSL transport): the phone lists the host, lists its project, reads a directory, creates a terminal and launches an agent. Then the distro "stops": calls are refused with the message, the host lists as unavailable, and no new start is logged. A second refused call replaces the old 2-second sleep.

  • Local runs: pnpm tc, tc:web, typecheck:ci, oxlint on touched files and check:code-quality:changed pass, along with the touched unit suites (desktop 175 tests over 15 files, mobile 23 tests). The e2e spec wasn't re-run locally because the machine was under heavy load; CI covers it.

  • The paired-phone e2e also checks that distros.json still reads stopped at the end, since the fake boots a distro by rewriting that file.

  • The wait-for-prompt fix to wsl-host-fake-transport.spec.ts landed on main separately in test(wsl-host): type into the WSL host terminal only after its shell prompt #34607. The underlying dropped input is a separate follow-up.

Real-device check (needs a Windows box with a phone):

  1. With the switch on and the distro running, pair a phone. On the phone, open a WSL project, run a terminal, launch an agent.
  2. Let the agent finish and tap the push. It should open that worktree.
  3. Run wsl --terminate Ubuntu with the project closed on the computer. On the phone, open the row: once the computer notices the stop you should see the "Start on computer" badge and the "isn't running" message. Before that, you'll see the neutral message. wsl --list --running must stay empty.
  4. Repeat step 3 with the project open on the computer. The computer may restart the distro for its own work; the phone must not.

AI Disclosure

Review

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

  • SSH: the never-start flag does nothing for SSH-managed and paired servers.
  • Folder workspaces: rows are the server's own worktree.ps rows, folder workspaces included.
  • Known limit: a stop is noticed on the next call or status event, not instantly. A call already in flight when the distro stops could still dial its bridge. That window is milliseconds, and the next call is refused.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • 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 (typecheck and touched tests locally; full lint/test left to CI per load rule)

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent 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: 17477847-2cf1-4b7d-9f39-210663a1d3f4
Commits

Reviewing files that changed from the base of the PR and between 0fbb6c3 and aa8127e.

Files selected for processing: 1
  • tests/e2e/wsl-host-fake-transport.spec.ts

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

Walkthrough

The change adds a WSL phone reachability gate and passes no-start preparation options through managed runtime resolution, calls, and subscriptions. Relay listings expose stopped or unavailable state for WSL hosts. The mobile client uses that state to label worktree rows. Tests cover reachability, transport routing, relay listings, and paired-phone access before and after a WSL distro stops.

Priority: Normal

Merge Risk: Low · previous review aa812

The E2E helper should explicitly force background mode before merging.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly identifies the main change: enabling paired phones to reach a desktop WSL host without starting its distro.
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.
Description check Passed The description covers the required sections, explains the change and rationale, and documents testing. It clearly states that the Windows real-device phone check remains pending and that the PR shoul…
Full details: Description check

Explanation

The description covers the required sections, explains the change and rationale, and documents testing. It clearly states that the Windows real-device phone check remains pending and that the PR should not be merged until that check is complete.

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


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: 19a46afa-bc2a-4094-a91e-7aeabf580eef
Commits

Reviewing files that changed from the base of the PR and between 887b781 and 8e16a02.

Files selected for processing: 27
  • mobile/src/host-screen/use-host-display-worktrees.ts
  • mobile/src/worktree/server-workspace-operations.ts
  • mobile/src/worktree/server-workspaces.test.ts
  • mobile/src/worktree/server-workspaces.ts
  • mobile/src/worktree/worktree-host-context-labels.ts
  • src/main/ipc/runtime-environments/runtime-environment-managed-tunnel.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-managed-tunnel.ts
  • src/main/ipc/runtime-environments/runtime-environment-mobile-relay-hosts.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-mobile-relay-hosts.ts
  • src/main/ipc/runtime-environments/runtime-environment-transport-routing-no-start.test.ts
  • src/main/ipc/runtime-environments/runtime-environment-transport-routing.ts
  • src/main/ipc/wsl-host-handlers.ts
  • src/main/runtime/mobile-desktop-relay/mobile-desktop-relay-hosts.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.test.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-catalog.ts
  • src/main/runtime/mobile-desktop-relay/mobile-relay-host-descriptions.ts
  • src/main/runtime/sidebar-inputs/paired-server-rows-producer.test.ts
  • src/main/wsl/wsl-host-add-admission.ts
  • src/main/wsl/wsl-host-e2e-fake-connector.ts
  • src/main/wsl/wsl-host-phone-reach.test.ts
  • src/main/wsl/wsl-host-phone-reach.ts
  • src/main/wsl/wsl-host-service-instance.ts
  • src/shared/mobile-relay-hosts-contract.ts
  • src/shared/notification-source.test.ts
  • tests/e2e/helpers/wsl-host-fake-desktop.ts
  • tests/e2e/wsl-host-fake-transport.spec.ts
  • tests/e2e/wsl-host-paired-phone.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 thread src/main/wsl/wsl-host-phone-reach.ts Resolved
Comment on lines +57 to +60
const app = await electron.launch({
args: getOrcaElectronLaunchArgs(path.join(process.cwd(), 'out', 'main', 'index.js'), false),
env: { ...isolation.env, NODE_ENV: 'development', ORCA_E2E_HEADLESS: '1' }
})

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.

Minor · Maintainability & Code Quality · Quick win

Supported by static analysis

Script executed:

sed -n '45,76p' tests/e2e/helpers/wsl-host-fake-desktop.ts
rg -n 'ORCA_BACKGROUND_LAUNCH|ORCA_E2E_HEADLESS|ORCA_E2E_FOREGROUND' src/main/window/foreground-activation-policy.ts tests/AGENTS.md

Repository: stablyai/orca

Length of output: 2065


Script executed:

set -u
rg -n 'ORCA_BACKGROUND_LAUNCH|ORCA_E2E_HEADLESS|ORCA_E2E_HEADFUL|ORCA_E2E_FOREGROUND' tests/e2e/helpers/ || test "$?" -eq 1
echo '--- electron-home-isolation.ts ---'
sed -n '1,80p' tests/e2e/helpers/electron-home-isolation.ts
echo '--- wsl-host-fake-desktop.ts 1-45 ---'
sed -n '1,45p' tests/e2e/helpers/wsl-host-fake-desktop.ts
echo '--- foreground-activation-policy.ts 1-45 ---'
sed -n '1,45p' src/main/window/foreground-activation-policy.ts

Repository: stablyai/orca

Length of output: 8748


Set ORCA_BACKGROUND_LAUNCH=1 explicitly in this raw electron.launch() call.

The tests/** guideline requires raw electron.launch() calls to pass ORCA_BACKGROUND_LAUNCH=1 explicitly. This env sets ORCA_E2E_HEADLESS only. The variable reaches the second desktop only when the runner's inherited environment already sets it. Set it in this call so an inherited ORCA_E2E_FOREGROUND=1 cannot remove background mode. Background launch takes precedence over the foreground override, but only when the variable is set explicitly.

🛡️ Proposed fix
-    env: { ...isolation.env, NODE_ENV: 'development', ORCA_E2E_HEADLESS: '1' }
+    env: {
+      ...isolation.env,
+      NODE_ENV: 'development',
+      ORCA_E2E_HEADLESS: '1',
+      ORCA_BACKGROUND_LAUNCH: '1'
+    }

Per the tests/** guideline: "Set ORCA_BACKGROUND_LAUNCH=1 for all tests and agent-launched apps... raw electron.launch() calls must pass the env explicitly."

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const app = await electron.launch({
args: getOrcaElectronLaunchArgs(path.join(process.cwd(), 'out', 'main', 'index.js'), false),
env: { ...isolation.env, NODE_ENV: 'development', ORCA_E2E_HEADLESS: '1' }
})
const app = await electron.launch({
args: getOrcaElectronLaunchArgs(path.join(process.cwd(), 'out', 'main', 'index.js'), false),
env: {
...isolation.env,
NODE_ENV: 'development',
ORCA_E2E_HEADLESS: '1',
ORCA_BACKGROUND_LAUNCH: '1'
}
})

@nwparker
nwparker force-pushed the nwparker/wsl-e6-phone-relay branch from bd44311 to e36d21e Compare October 27, 2026 07:25
@blacksmith-sh

This comment has been minimized.

@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issue was found; the previous test-coverage gap remains non-blocking.

Findings

  1. P2 Open connections lack stop coverage ▶

Summary

Lets paired phones reach the desktop’s WSL hosts through the existing relay.

  • Paired phones use a running WSL host through the desktop without starting it.
  • Phone worktree rows show when a WSL host needs the computer.

nwparker acknowledges the brief gate-to-dial timing window as a known limit.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Phone[Paired phone] --> Desktop[Desktop relay]
  Desktop --> Gate[WSL phone gate]
  Gate --> Ready{Host answers?}
  Ready -->|Yes| WSL[Existing WSL bridge]
  Ready -->|Confirmed stopped| Stopped[Refuse and show Start on computer]
  Ready -->|Unknown or unavailable| Unavailable[Refuse without starting]
Loading

Reviews (2) · Last reviewed commit: "test(wsl-host): the startup reconcile su..." · Reviewed by Greptile

Comment on lines +199 to +206
} finally {
socket.close()
}

// The distro stops. A phone asking now is told to start it on the computer, and nothing starts.
writeFileSync(distrosFile, JSON.stringify([{ ...UBUNTU, state: 'stopped' }]))
const connectsBeforeStop = fakeWslConnects(connectLogFile)
const stopped = await phone.openSocket()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Open connections lack stop coverage

The test closes the working phone socket before stopping the distro, then opens a fresh socket. This checks WslHostPhoneGate during setup, but misses a phone that already has the project open. MobileDesktopRelay.linkFor reuses an existing link without calling hosts.resolve, so that flow depends on the bridge closing correctly.

Keep the original socket open across the stop and check that another call is refused without starting the distro. The fake connector also needs to end its existing link when the distro stops; removing its saved bridge alone leaves the direct connection to the fixture server usable.

nwparker and others added 9 commits October 28, 2026 17:54
…er starts its distro (E6)

Behind ORCA_INTERNAL_WSL_HOSTS and the Experimental switch. The desktop relay
lists its WSL hosts to phones. Every relayed call (resolve, call, watchChanges,
status.get) passes a never-start check, and a WSL host serves a phone only
while it already runs.

- WslHostPhoneGate holds the phone's view. The call check reuses E9's
  focusReachability, so with no bridge in this process it refuses without a
  running-list read. A host shows as "stopped" only on a confirmed stop
  (liveness's distro-stopped, or a running list read by the check); anything
  else gets a neutral "isn't available" message. Hosts are hidden from phones
  while the Experimental switch is off or a Remove is pending.
- The relay host list sends optional `stoppedOnDesktop` only for a confirmed
  stop. The phone badges those rows "Start on computer"; older peers ignore
  the field.
- The paired-server rows producer carries WSL hosts like any server, so the
  main-computed sidebar feed a phone reads has their rows.
- The paired-phone e2e drives a WSL host project end to end and asserts a
  stopped distro is never started.
…nd a stale stop off a ready host

- status.get runs the no-start check only for a WSL host, through a
  check-only helper. SSH-managed and paired servers reach the status owner
  exactly as on main: no reconnect, no redeploy, and the manual-disconnect,
  coalescing and repair handling stay in place. The preparation option is
  stripped before the probe.
- WslHostPhoneGate drops a 'stopped' read when a ready status arrived while it
  ran (a per-host ready generation), and clears a recorded stop when a check
  finds the host answering.
- A phone asking about a host that is switched off or being removed gets copy
  that says so, not "open one of its projects".
…, and label a host not connected

- A stop a phone's check confirmed is stored with that host's own status
  object and holds only while that status is current. Another host's change no
  longer clears it. Any status of its own (ready, a disable's closed, a failed
  Remove's closed) does. A read never records a stop over a ready status, so a
  read shared with one begun before ready can't. Removed hosts drop their
  entry. The generation map and status listener are gone.
- The relay sends optional `unavailableOnDesktop` for a WSL host this desktop
  isn't connected to and doesn't know is stopped. New phones badge it "Open on
  computer"; older ones still show Connecting.
- The relay list reads the WSL host records once per poll (reachAll).
…-phone e2e

toMatchObject({ stoppedOnDesktop: undefined }) requires the key to be
present, and the desktop omits an unset flag, so the ready poll could never
match. The poll now compares relay plus both flags read as booleans.
…topped distro's bridge as closed

Main's fake connector (#34573) now publishes 'closed' when a stopped distro's
bridge drops, not liveness's 'distro-stopped'. So the phone's check reads the
stop under a ready status and doesn't claim it. The phone gets the neutral
copy and unavailableOnDesktop; the confirmed-stop copy stays unit-tested.
…, and checks nothing booted the distro

Main's fake now publishes 'distro-stopped' when it drops a stopped distro's
bridge (#34624), as liveness does, so the phone gets "isn't running" and
stoppedOnDesktop. The spec also checks distros.json still reads 'stopped' at
the end: the fake boots a distro by rewriting it.
…t beside the service

The reconcile still runs before the connector exists; the suite only lacked the new
setWslHostPhoneGate export on its service-instance mock.

Co-Authored-By: Claude <[email protected]>
@nwparker
nwparker force-pushed the nwparker/wsl-e6-phone-relay branch from 94b4a19 to 1416b0b Compare October 29, 2026 00:55
@nwparker
nwparker merged commit c14c99b into main Oct 29, 2026
60 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