Skip to content

fix(desktop): WSL backend honors T3CODE_HOME from the distro's login shell - #39771

Merged
juliusmarminge merged 1 commit into
mainfrom
factory/issue-39758
Nov 20, 2026
Merged

juliusmarminge merged 1 commit into
mainfrom
factory/issue-39758

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

When the Windows desktop app ran its backend inside WSL, it ignored a T3CODE_HOME exported in the distro's shell profile and always created and used ~/.t3. The backend now uses that home for its database, caches and the WSL runtime cache.

  • The WSL login-shell probes report T3CODE_HOME alongside PATH, keeping it only when it is an absolute path.
  • The launcher passes it to the server as T3CODE_HOME=… in the wsl.exe --exec env command.
  • The runtime install and prune scripts put the cache under <T3CODE_HOME>/wsl-runtime, and still use ~/.t3/wsl-runtime when it is not set.
  • The probe now runs before the runtime is staged, so the invalidateRuntime step it made unreachable is removed.

Fixes #39758

Reproduction on main

Leased Windows Server 2025 machine with WSL2 Ubuntu 24.04. Installed the official T3-Code-0.1.11-x64.exe silently (the reporter's version). Current origin/main 391f93f has no commits since v0.1.11 under apps/desktop/src/backend or apps/desktop/src/wsl, so the installed app runs main's WSL launch code; a desktop build of main itself was not made. In WSL: appended export XDG_CONFIG_HOME="$HOME/.config" and export T3CODE_HOME="$XDG_CONFIG_HOME/t3" to ~/.profile and ~/.bashrc, deleted ~/.t3; bash -lc 'echo $T3CODE_HOME' printed /root/.config/t3. On Windows: wrote %USERPROFILE%.t3\userdata\desktop-settings.json = {"wslBackendEnabled":true,"wslDistro":"Ubuntu","wslOnly":true} and launched the app on the interactive desktop; it showed 'Welcome to T3 Code – Setting up … WSL (Ubuntu)'. Then in WSL: ~/.t3 had been created (userdata/statev2.sqlite, server-owner.sqlite, caches/, worktrees/, wsl-runtime/sha256-…); ~/.config/t3 did not exist. The backend process (/root/.t3/wsl-runtime/sha256-…/t3 --bootstrap-fd 0) had no T3CODE_HOME in /proc//environ and held /root/.t3/userdata/statev2.sqlite open.

Evidence

Windows Server 2025 desktop, Ubuntu 24.04 WSL2, 1920×1080, light theme; fresh state on both sides.

  1. Export XDG_CONFIG_HOME="$HOME/.config" and T3CODE_HOME="$XDG_CONFIG_HOME/t3" in .profile and .bashrc; confirm the login shell reports /root/.config/t3.
  2. Begin with neither WSL T3 home present and enable the Ubuntu WSL-only desktop backend.
  3. Launch each packaged source build with the same driver, wait for the connected welcome screen, and inspect the backend environment, runtime executable and open database through /proc.
Before After
Before: profile home ignored After: profile home honored
97e7834f4b bc71fbfa2f
Backend T3CODE_HOME unset; runtime and open database under /root/.t3; configured home absent. Backend T3CODE_HOME=/root/.config/t3; runtime and open database under that home; /root/.t3 absent.
Before recording After recording

Both stills followed identical screenshot pairs 500 ms apart. Recordings are uncut 150-second desktop captures sampled at 2 fps. Drivers, audits, runtime transcript and build provenance.

Build note: unsigned packaged source builds used pinned Electron 44.10.1 and official unchanged native dependencies. The common server/web archive was built from source; those sources are identical between base and head.

Not shown:

  • The signed NSIS installer was not rebuilt; proof ran unsigned packaged source builds with pinned stock Electron and official unchanged native dependencies.
  • Unset or relative T3CODE_HOME, paths containing spaces, existing-runtime pruning, and the unbundled server-tree fallback were not exercised.

Tests

  • vp test run src/backend/DesktopBackendConfiguration.test.ts src/wsl/DesktopWslEnvironment.test.ts src/backend/DesktopBackendManager.test.ts (apps/desktop): 3 files, 52 tests passed
  • vp run typecheck (apps/desktop): no errors
  • vp run check:changed: format, lint, knip, typecheck and tests all passed
  • CI on bc71fbf: all 7 required checks passed

Not in this change

  • An existing ~/.t3 database in WSL is not migrated when a profile T3CODE_HOME starts being honored.
  • There is no setting in the desktop app to choose the WSL backend's home; it comes only from the distro's login shell.
  • A relative T3CODE_HOME in the distro profile is ignored, and the backend falls back to ~/.t3.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

…shell

The WSL backend launches with `wsl.exe --exec env PATH=... t3`, which skips
the distro's profile, so a T3CODE_HOME exported there never reached the
server and it fell back to ~/.t3. The runtime cache scripts also hard-coded
$HOME/.t3/wsl-runtime.

The login-shell probe that already captures PATH now also reports an absolute
T3CODE_HOME. The launcher passes it to the server, and the runtime install
and prune scripts put the cache under it. The probe now runs before staging,
so the invalidate step for a staged runtime whose probe failed is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

WSL probes now report T3CODE_HOME. Runtime staging and pruning use the corresponding WSL runtime directory when available. Backend preflight passes the discovered home through preparation and startup, and falls back to the mounted server tree when probing or staging fails.

Changes: WSL runtime home

Layer / File(s) Summary
WSL home discovery and runtime paths
apps/desktop/src/wsl/DesktopWslEnvironment.ts, apps/desktop/src/wsl/DesktopWslEnvironment.test.ts
Probe results include an absolute T3CODE_HOME when available. Runtime installation and pruning use its wsl-runtime directory, or the default directory when it is absent. The invalidateRuntime API and its tests were removed. Tests cover a home path containing a space.
Backend preflight and launch
apps/desktop/src/backend/DesktopBackendConfiguration.ts, apps/desktop/src/backend/DesktopBackendManager.ts, apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
Preflight probes before staging and passes the discovered home to runtime preparation. Probe or staging failures use the mounted server tree. Startup sets T3CODE_HOME when available, and runtime pruning receives the home. Tests cover staging inputs, launch configuration, and probe-failure fallback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant DesktopBackendConfiguration
  participant DesktopWslEnvironment
  participant WSL
  DesktopBackendConfiguration->>DesktopWslEnvironment: Probe WSL runtime and T3CODE_HOME
  DesktopWslEnvironment->>WSL: Run login-shell probe
  WSL-->>DesktopWslEnvironment: PATH and T3CODE_HOME
  DesktopWslEnvironment-->>DesktopBackendConfiguration: Probe result
  alt Probe succeeds
    DesktopBackendConfiguration->>DesktopWslEnvironment: Prepare runtime with T3CODE_HOME
    DesktopWslEnvironment->>WSL: Stage runtime under selected home
    WSL-->>DesktopWslEnvironment: Runtime preparation result
    DesktopBackendConfiguration->>WSL: Launch backend with T3CODE_HOME
  else Probe fails
    DesktopBackendConfiguration->>WSL: Use mounted server tree
  end
Loading

Possibly related PRs

  • pingdotgg/t3code#20956: Changes the WSL runtime probe and preparation contract, including the order of probing and staging.

Suggested labels: bugfix

Suggested reviewers: maria-rcks, t3dotgg

Merge Risk: Minimal · up to bc71f

The change makes the Windows desktop app's WSL backend honor an absolute T3CODE_HOME exported by the distro's login shell. Runtime staging, launch and pruning now use that home instead of always using ~/.t3. No blocking risk was found. Relative values still fall back to ~/.t3, and existing ~/.t3 data is not migrated, as the PR states.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the WSL backend now honors T3CODE_HOME from the distro's login shell. It follows the conventional commit format and matches the changeset, which adds login-shell probi…
Linked Issues check Passed Issue #39758 is the only directly linked issue, and it is open. Its expected behavior is that the WSL backend uses the directory from T3CODE_HOME, or that the desktop app offers a way to set the WSL…
Out of Scope Changes check Passed The changes stay within the reported scope. The main changes are the T3CODE_HOME probe and launch path, the runtime cache paths in the install and prune scripts, and the wslT3Home plumbing through…
Description check Passed The description covers the problem (WSL backend ignores a profile-exported T3CODE_HOME and always uses ~/.t3), the change (probes report T3CODE_HOME, launcher passes it, runtime install and prune scri…
Full details: Title check

Explanation

The title names the main change: the WSL backend now honors T3CODE_HOME from the distro's login shell. It follows the conventional commit format and matches the changeset, which adds login-shell probing of T3CODE_HOME, passes it to the server, and uses it for runtime cache paths.

Full details: Linked Issues check

Explanation

Issue #39758 is the only directly linked issue, and it is open. Its expected behavior is that the WSL backend uses the directory from T3CODE_HOME, or that the desktop app offers a way to set the WSL backend home. The PR takes the first route. The launcher reads T3CODE_HOME from the distro login shell, and the PATH probes report it alongside PATH, keeping it only when absolute (parseT3Home). The launcher passes it to the server as T3CODE_HOME=... in the wsl.exe --exec env command. The runtime install and prune scripts use &lt;T3CODE_HOME&gt;/wsl-runtime, and fall back to ~/.t3/wsl-runtime when unset. Tests cover a shell-executed case with a T3CODE_HOME that contains a space. The required behavior is implemented in the summarized changes. The evidence came from the PR summary and the test and file summaries. I did not inspect the diff hunks directly. The pending real-app evidence section is a manual verification step, not a coding requirement.

Full details: Out of Scope Changes check

Explanation

The changes stay within the reported scope. The main changes are the T3CODE_HOME probe and launch path, the runtime cache paths in the install and prune scripts, and the wslT3Home plumbing through DesktopBackendConfiguration.ts and DesktopBackendManager.ts. The removal of invalidateRuntime and its script builder follows from moving the probe before staging, which the PR states makes that step unreachable. Test changes update fixtures and expectations for the new arguments and cover the new behavior. The PR description states that migration of existing ~/.t3 data and a desktop setting are not included. Those exclusions match the change set, so no unrelated change was found. This assessment uses the summary and not a full diff read.

Full details: Description check

Explanation

The description covers the problem (WSL backend ignores a profile-exported T3CODE_HOME and always uses ~/.t3), the change (probes report T3CODE_HOME, launcher passes it, runtime install and prune scripts use it, invalidateRuntime removed), a linked issue (#39758), and detailed verification with before/after evidence and test commands. It also lists what was not exercised and what is out of scope. The template's sections (Problem, Change, Scope, Verification) are all present. The Scope section links the issue but does not explicitly say why a small bug fix needs no issue, which is not needed since an issue is linked. The reproduction and evidence are thorough, and the author notes the signed installer was not rebuilt. The description is mostly complete and meets the template.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between fe9baf8 and bc71fbf.

Files selected for processing: 5

  • apps/desktop/src/backend/DesktopBackendConfiguration.test.ts
  • apps/desktop/src/backend/DesktopBackendConfiguration.ts
  • apps/desktop/src/backend/DesktopBackendManager.ts
  • apps/desktop/src/wsl/DesktopWslEnvironment.test.ts
  • apps/desktop/src/wsl/DesktopWslEnvironment.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.

@juliusmarminge
juliusmarminge merged commit 905346e into main Nov 20, 2026
39 checks passed
@juliusmarminge
juliusmarminge deleted the factory/issue-39758 branch November 20, 2026 15:25
HNRow pushed a commit to HNRow/r3code that referenced this pull request Nov 20, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Nov 20, 2026
**v0.1.12-nightly.20261120.5009** · 30 changes from 9 contributors

- **Secret cards.** Enter multiple secret values in one card and show or hide masked values on the web.
- **Shared Antigravity skills.** Use Antigravity skills registered in shared or external directories.
- **Thread failure reasons.** See why the latest thread run failed when checking it from the command line.
- **Draft pull requests.** Create draft pull requests directly without briefly announcing them as ready for review or starting unnecessary CI runs.
- **Azure DevOps Bugs.** Read and edit Bug descriptions stored in Repro Steps from Issues.
- **Stable file previews.** Keep HTML previews and attachments open while agents work, without losing form input to unnecessary reloads.
- **T3 Connect port forwarding.** Forward ports to your machine when connected to another machine through T3 Connect.

### Plus 21 more bug fixes and performance improvements.

<details>
<summary>Full changelog</summary>

## What's Changed
* fix(server): Claude gateway cooldown survives an untyped SDK rejection by @juliusmarminge in pingdotgg/t3code#39695
* fix(release): Windows resource monitor starts without the Visual C++ runtime by @jieyuexing in pingdotgg/t3code#39683
* fix(server): turn authorship works on Git before 2.36 by @juliusmarminge in pingdotgg/t3code#39702
* fix(mobile): new thread says the host has no model instead of asking to connect by @juliusmarminge in pingdotgg/t3code#39713
* fix(antigravity): keep truncated command text valid Unicode by @Lucenx9 in pingdotgg/t3code#39697
* fix(antigravity): honor the saved thinking level in text generation by @Lucenx9 in pingdotgg/t3code#39720
* fix(azure-devops): read and edit a Bug's text in Repro Steps by @juliusmarminge in pingdotgg/t3code#39738
* fix(web): stop reloading unchanged file previews during agent commands by @juliusmarminge in pingdotgg/t3code#39736
* fix(server): a released provider session ends its tool call nodes too by @jieyuexing in pingdotgg/t3code#39734
* fix(server): watch_pull_request says a merge or close wakes the agent by @juliusmarminge in pingdotgg/t3code#39739
* fix(server): replace the device hub when emulator camera support changes by @juliusmarminge in pingdotgg/t3code#39764
* fix(desktop): Cmd+T opens the new-tab menu from a focused browser page by @juliusmarminge in pingdotgg/t3code#39769
* fix(server): port refusals survive T3 Connect's relay by @juliusmarminge in pingdotgg/t3code#39763
* fix(server): Antigravity links and discovers skills from skills.json by @mameli in pingdotgg/t3code#39765
* fix(desktop): WSL backend honors T3CODE_HOME from the distro's login shell by @juliusmarminge in pingdotgg/t3code#39771
* fix(server): pull_request_create opens a draft PR as a draft on GitHub and Azure by @juliusmarminge in pingdotgg/t3code#39772
* fix(server): Antigravity wake runs accept steers again by @juliusmarminge in pingdotgg/t3code#39767
* fix(server): keep DeepSeek ACP probes out of session history by @crisxuan in pingdotgg/t3code#39733
* fix(server): idle threads compact while a delegated task runs by @juliusmarminge in pingdotgg/t3code#39766
* fix(mobile): a settings row an older environment left mixed can be set off by @not-compromised in pingdotgg/t3code#39755
* feat: secret cards get a show/hide toggle and multi-value fields by @gabrielelpidio in pingdotgg/t3code#31257
* fix(ssh): a slow remote server keeps its SSH forward on reconnect by @juliusmarminge in pingdotgg/t3code#39802
* fix(antigravity): a scheduled wake keeps its run open instead of looking finished by @juliusmarminge in pingdotgg/t3code#39806
* fix(ssh): reconnect stops waiting on a remote server that is shutting down by @juliusmarminge in pingdotgg/t3code#39807
* fix(web): open PDF attachments no longer reload while the agent works by @juliusmarminge in pingdotgg/t3code#39815
* perf(linear): overlap issue details and viewer reads by @Adamulek123 in pingdotgg/t3code#39801
* fix(linear): scope issue numbers to the named team by @Adamulek123 in pingdotgg/t3code#39809
* fix(gitlab): pull_request_create opens a draft MR as a draft by @aravhawk in pingdotgg/t3code#39817
* fix(web): scrolling a PR description no longer moves focus to the condensed header by @juliusmarminge in pingdotgg/t3code#39840
* feat(cli): thread show reports why the latest run failed by @juliusmarminge in pingdotgg/t3code#39849

## New Contributors
* @mameli made their first contribution in pingdotgg/t3code#39765
* @crisxuan made their first contribution in pingdotgg/t3code#39733

**Full Changelog**: pingdotgg/t3code@v0.1.12-nightly.20261120.4994...v0.1.12-nightly.20261120.5009

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.12-nightly.20261120.5009
vedprakash2302 added a commit to vedprakash2302/Cody that referenced this pull request Nov 21, 2026
- Superseded nothing this sync; every Cody patch is kept.
- Adapted side chats to upstream's unified side thread panel (pingdotgg#39515): SideChatPane.tsx became SideThreadPane.tsx, so Cody's side chat title menu, bar and composer registry moved into its side chat header and body; side chat tabs are now `thread:<id>` surfaces opened with `openThread`, which sideChats.ts, the palette and the title menu use. upstreamWiring.test.ts now checks SideThreadPane.tsx.
- Adapted the WSL backend to pingdotgg#39771: upstream follows a login-shell T3CODE_HOME for the runtime cache and the server home; Cody pins both to ~/.cody (CODY_WSL_HOME) so a T3 setting never moves Cody's data or prunes T3's runtimes. The packaged-runtime test checks it.
- ProviderTurnStartService: Cody's side chat text feeds upstream's new messageText, which the typed result instructions (pingdotgg#38874) build on.
- Apple Speech (pingdotgg#34027): dev-electron and the desktop artifact build both Cody's Windows sign-in helper and the Apple Speech helper; the speech permission prompt says Cody; Cody's kept packaging test expects the mac resource.
- agentContextBudget.json: upstream's MCP tool list size with Cody's +371 byte instruction sizes.
- Cody's side chat title menu and palette copy go through gt() and <T>, which the commit hook's lint requires once those files change.
- Skill sync notes cover the side thread panel, the WSL home pin and Apple Speech.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Windows desktop with WSL backend ignores T3CODE_HOME set in the WSL environment and creates ~/.t3

1 participant