Skip to content
Source
Sign inSign up
pingdotgg/t3code

Desktop: parallel WSL + Windows backends with mode picker #2751

MergedJgratton24(GitHub profile, opens in a new tab)merged 170 commits intomain fromrefs/pull/2751/headmerged by juliusmarminge View on GitHub

The desktop app's earlier WSL support (#2353, now closed and superseded by this PR) let users pick one backend at a time — Windows or WSL, swap to switch. This PR makes them run side by side so projects on both sides are always reachable, and makes the WSL backend work in packaged release builds, not just from a dev checkout. It targets main and stands on its own — #2353 is not required.

What Changed

  • Run the Windows backend and a WSL backend in parallel. Each project is routed to the backend it lives on; opening a Windows project doesn't tear down the WSL one, and vice versa.
  • Added a Run WSL only mode for users who develop entirely inside WSL and don't want a second backend process. T3 Code restarts when the mode changes so the new primary takes effect cleanly.
  • New mode-choice modal when enabling WSL: pick Run both backends (the new default) or Use only WSL upfront.
  • Consolidated the previous separate "WSL backend" switch and "WSL distro" picker into a single dropdown. "Off" stops the backend, picking a distro starts it on that distro.
  • Confirmation dialogs before destructive transitions (disable, distro switch, mode change) when there's saved-env state on the host that could be affected.
  • Sidebar indicator while the secondary WSL backend is cold-booting.
  • Packaged-build support. The WSL backend now starts in installed builds, not just dev — see Release / packaging below.
  • WSL preflight handling. Node is resolved through the distro's version manager (nvm / fnm / asdf / etc.), not just the bare login PATH. A fatal preflight failure (e.g. no Node) on the WSL-only primary surfaces a dialog and falls back to the Windows backend instead of crash-looping; in dual-backend mode it's shown inline in Connections settings, and the retry loop is capped.
  • The WSL environment's row in Connections is read-only (Connect/Disconnect/Remove disabled, with a tooltip explaining it's managed by the WSL picker), and the redundant "Open WSL folder" command was dropped in favor of the unified "Add project" flow.
  • Provider updates work across both backends — see Provider updates below. One-click provider updates (Codex, Claude, etc.) now run on the Windows backend (the npm launcher shim wasn't resolving), and the update popover lets you update each environment independently.

Why

The earlier WSL support (#2353) treated the backends as mutually exclusive: switching from Windows to WSL stopped one and started the other. That works if you only work on one side, but in a mixed workflow you constantly have projects on both. Swapping interrupted whatever was running on the other backend and forced you to wait for the new one to come up before you could open anything.

Running them in parallel removes the swap entirely. The Windows backend stays primary for Windows projects, a WSL backend runs alongside it for projects that live on the Linux side, and the renderer routes per-project. The "Run WSL only" mode is the escape hatch for users who don't want two processes at all.

Release / packaging

This is the riskiest part of the PR, so calling it out explicitly for reviewers. The WSL backend runs the server with the distro's own Linux Node, which needs a Linux node-pty binary — but node-pty ships no Linux prebuilt (on Linux it compiles from source at install time), and the packaged app seals the server bundle + node-pty inside app.asar, which a plain WSL Node can't read.

Compiling native modules on the user's machine at first launch would require Python, a C/C++ toolchain, node-gyp, and often network — too fragile for an IDE. Instead:

  • CI builds the Linux node-pty on a Linux runner (build_wsl_node_pty) and the Windows packaging job consumes it as an artifact (--wsl-prebuild), dropping it into the bundled node-pty's prebuilds/linux-x64/. No cross-compiling on Windows.
  • The server bundle and its full node_modules are asarUnpack'd so the WSL-side Node can resolve every import on the real filesystem — the bundle externalizes deps like effect to node_modules rather than inlining them. The Windows primary still reads the asar via ELECTRON_RUN_AS_NODE.
  • node-pty is N-API, so one Linux binary works across all WSL Node versions.
  • Runtime compile is kept as a dev-only path; in a packaged build a binary that can't load surfaces a clear arch/distro diagnostic rather than silently compiling.

Net effect: the Windows release artifact now depends on a Linux build artifact, but installed WSL backends start with no compiler, node-gyp, or network on first launch.

Provider updates

With two backends, each runs its own provider CLIs (Codex, Claude, …) on its own side, so "update available" and "update" are now per-environment.

  • Windows updates actually run. On the Windows backend the update command (npm install -g …) failed with npm: NotFound because a bare-name spawn doesn't resolve the npm.cmd launcher shim via PATHEXT. It now runs through the shell on Windows, matching how every other provider command is spawned — fixing updates for every npm/pnpm-managed provider, not just Codex.
  • Per-environment update popover (when WSL is present). Instead of one "update everything everywhere" button, the launch popover shows one row per local environment (e.g. Windows and WSL), each with its own Update trigger that targets only that backend. Rows are labeled by platform (WSL is detected by its backend instance id), and the popover is deferred until every local backend finishes connecting (with a safety cap) so it reflects both environments instead of appearing from the primary alone while WSL is still booting.
  • Honest results. Each row resolves from both the update RPC's own result and live server state, so it lands correctly whether a secondary backend's config doesn't re-sync or the RPC response is lost to a reconnect. A backend whose update failed or stayed outdated is reported as such, not silently treated as success.
  • No change for non-WSL users. The per-environment split is gated behind WSL presence; without a WSL backend the popover keeps the original single-prompt flow.

UI Changes

Enable-mode picker (shown when the user picks a distro from the Off state):

electron_xZfqTanAmi

Connections settings panel with the consolidated WSL backend picker and "Run WSL only" row:

electron_6fhHUp0m5h

Sidebar indicator while the WSL backend is cold-booting:

electron_dGOvMHhVog

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes (n/a)

Note

High Risk Large desktop startup/shutdown and WSL spawn-path changes plus a new Windows release dependency on a Linux native artifact; regressions could break backend readiness, auth bootstrap tokens, or packaged WSL on Windows.

Overview Replaces the singleton desktop backend manager with a backend pool and per-instance factory: the primary starts through DesktopBackendPool, WSL reconcile runs in parallel on boot, shutdown stops every instance, and WSL-only mode can show a connecting splash before the WSL primary is ready.

WSL launch and configuration split into resolvePrimary / resolveWsl / resolvePrimaryLabel, including distro preflight (node-pty, paths, fatal vs transient retries), shared bootstrap tokens, WSLENV secret forwarding, unpacked app.asar entry paths, renderer URLs via distro IP or mirrored loopback, and bootstrap delivery over fd3 (Windows) vs stdin (wsl.exe).

Child process management gains configurable args/env (extendEnv), preflight failure caps with optional onPreflightFailed fallback, and per-instance rotating logs via DesktopBackendOutputLogFactory (with instanceId in annotations) instead of the removed standalone output-log module.

Release pipeline adds a Linux CI job that builds node-pty for WSL, uploads it as an artifact, and the Windows packaging step bundles it with --wsl-prebuild so packaged installs do not compile native modules on first launch.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 8357f467322152c26f44175f793662da71af36df. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add parallel WSL + Windows backend support with mode picker to desktop app

  • Introduces a DesktopBackendPool that manages multiple independent backend instances concurrently; the primary backend can now be either a Windows process or a WSL Linux process selected at runtime via persisted settings.
  • Adds a WSL backend orchestrator (DesktopWslBackend) with a preflight check that validates WSL availability, distro selection, path translation, and node-pty readiness before launching the WSL backend.
  • Exposes new IPC endpoints (getWslState, setWslBackendEnabled, setWslDistro, setWslOnly) and renames the bootstrap IPC from a nullable single value to a getLocalEnvironmentBootstraps() array; the preload and renderer auth are updated accordingly.
  • Adds a 'Connecting to WSL' splash window shown during cold boot when WSL-only mode is active, and updates the Connections settings page with a WSL backend picker and confirmation dialogs for destructive changes.
  • Adds WSL-aware folder picker routing in the command palette and settings, translating UNC paths to Linux paths and routing picks to the correct backend filesystem.
  • Windows packaging now bundles unpacked server modules and Linux (glibc x64) native binaries (including an optional prebuilt node-pty) so the WSL backend can load Node modules from the ASAR.
  • Desktop bootstrap grants are now reusable and valid for 24 hours (previously single-use, short TTL) to support renderer re-exchanges.
  • Risk: getLocalEnvironmentBootstrap is removed; any consumer not updated to call getLocalEnvironmentBootstraps() and select by id === PRIMARY_LOCAL_ENVIRONMENT_ID will break.
Macroscope summarized 8357f46.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 146fe5fe-b286-4299-ae4d-3bd0e889737b

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: aebb4fa3e5

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟢 Low

      https://github.com/pingdotgg/t3code/blob/aebb4fa3e566abd9c9872d32548fe2006d13bccd/apps/desktop/src/app/DesktopObservability.ts#L384

      Different instance IDs that differ only in non-alphanumeric characters sanitize to the same filename, causing multiple RotatingLogFileWriter instances to write to the same file concurrently. For example, forInstance("foo/bar") and forInstance("foo_bar") both produce server-child-foo_bar.log, but the factory cache (keyed by original id) creates separate writers with independent currentSize tracking. This leads to log interleaving and potential file corruption as both writers race on the same file. Consider including the original ID in the cache key check after sanitization, or keying the cache by sanitized filename instead.

      No longer relevant as of c3374a85ca55eb6a8dbc76de4ccc4a27a0cebc7a

    5. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      Diff is too large for automated approval analysis. A human reviewer should evaluate this PR.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    6. Fixed in c3374a85 — cache keyed by the resolved file path (backendLogFilePathForInstance(...)) so colliding sanitizations share the same writer.

    7. Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    8. UtkarshUsername(GitHub profile, opens in a new tab)commented

      Hey @Jgratton24, I was working #2402. Coincidentally, we both started working on WSL support at the same time.

      I saw your PR later, but I was still going to continue mine because it supported parallel WSL and Windows work. I was going to resolve its conflicts today, and continue it. But you have solved that point in this PR.

      So, now only one reason remains for me to prefer mine. It's that, it supports WSL projects in the server mode too, and not only in the desktop app. Do you think that is something which you can make possible in yours? If not, I can continue mine.

    9. Hey @UtkarshUsername, thanks for the heads up, appreciate you reaching out.

      I looked through it a bit more, and I don’t think pulling the server-mode side into this PR is very feasible as a small follow-up. It looks like that needs an ExecutionTarget concept threaded through git, terminal, provider sessions, file ops, persistence, etc., which is basically the shape of your PR already. I think the two PRs are aimed at slightly different cases: this one is desktop-focused, with a second backend process running in WSL and projects routed between Windows/WSL. Yours seems like the better fit for server-mode / hosted / npx flows where there isn’t a desktop process to spin up another backend.

      So I’d rather not try to absorb that here and risk duplicating your work or making this PR much harder to review. Probably best for the maintainers to decide whether these should land separately, be sequenced, or consolidate around one direction

      cc: @juliusmarminge

    10. @Jgratton24 as a mainly MacOS user I don't know what flows / UX windows devs expect. I trust you and @UtkarshUsername to know better here so I'll let you have the say.

      As for the PR, let me know what PRs to review and when they're ready. I've been busy with other stuff lately but ultimately want to get better Windows support in sooner than later, so just let me know which direction you feel is better!

      Tag me on discord for faster responses, my github feed is a bit overwhelming at times so some stuff gets lost in the noise...

    11. UtkarshUsername(GitHub profile, opens in a new tab)commented

      Hello, I tested this. Here's some feedback. The app didn't start after switching to the WSL only mode.

      1. I investigated and found that it wasn't starting because it doesn't check for node versions managed by nvm (and probably fnm and asdf too) because they are under the Interactive shell guard. bash -l -s is non-interactive, so .bashrc returns before reaching any nvm sourcing. The login shell falls through to the system-installed Node at /usr/bin/node (typically an old version from apt), even when the user has a modern Node via nvm/fnm.

      Suggested fix: Prepend an explicit nvm (and other node managers) source to every script, and then pipe it before every script.

      1. And another thing. When this happens, there's no visible error. No window opens but Task Manager shows it's running. That's because the backend preflight failure triggers an infinite restart loop with no attempt cap, so the process stays alive retrying forever without ever calling onReady, so no window.

      Suggested fix: If preflight fails (no node at all, missing build tools, outdated version), the app should stop silently looping after a few tries, show a visible error dialog and fall back to Windows mode.

    12. @UtkarshUsername thanks for taking the time to test this and the detailed write up.

      I addressed both issues:

      • WSL node detection now uses the apps SSH node resolver.
      • The silent hang should be fixed too. Fatal preflight failures now stop instead of looping forever, show a visible error, and fall back to the Windows backend so a window still opens.

      If you get a chance to re-run this against your nvm setup, let me know if you run into any other issues. Would love to get this landed before the next round of merge conflicts 😅

    13. Thank you @Jgratton24. I re-ran it. There is still one problem. The nvm preamble script is designed so that if it finds any Node.js, it skips loading nvm entirely. The real engine range is not passed to the preamble. The fix is to pass it so that the shell script sees the real engine range and correctly falls through to source nvm when system Node is too old.

Sign in to join this conversation.