@devries-cameron20 / t3code-1 / commits / 4d6ebbdba8
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(wsl): label WSL environments with their Windows host on every client (#22629)

Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Julius Marminge <julius0216@outlook.com>

Robbie committed Nov 14, 2026 at 15:50 UTC 4d6ebbdba855c7941966c50d3749f4eecc533488
2 files changed +67
apps/server/src/environment/ServerEnvironmentLabel.test.ts
+51
@@ -50,3 +50,54 @@ it.effect("falls back to the hostname when hostnamectl never answers", () =>
50 assert.equal(yield* Fiber.join(label), "devbox");
51 }),
52 );
53 +
54 +const exitsWithFailure = ProcessRunner.ProcessRunner.of({
55 + run: () =>
56 + Effect.succeed({
57 + stdout: "",
58 + stderr: "",
59 + code: ChildProcessSpawner.ExitCode(1),
60 + timedOut: false,
61 + stdoutTruncated: false,
62 + stderrTruncated: false,
63 + stdoutInvalidUtf8: false,
64 + stderrInvalidUtf8: false,
65 + }),
66 +});
67 +
68 +it.effect("qualifies the inherited Windows hostname only inside WSL", () =>
69 + Effect.gen(function* () {
70 + const cases = [
71 + {
72 + kernel: "6.6.87.2-microsoft-standard-WSL2",
73 + machineInfo: null,
74 + expected: "DESKTOP-PC WSL (Ubuntu)",
75 + },
76 + { kernel: "6.8.0-45-generic", machineInfo: null, expected: "DESKTOP-PC" },
77 + {
78 + kernel: "6.6.87.2-microsoft-standard-WSL2",
79 + machineInfo: 'PRETTY_HOSTNAME="Work WSL"',
80 + expected: "Work WSL",
81 + },
82 + ];
83 + for (const { kernel, machineInfo, expected } of cases) {
84 + const files: Record<string, string | null> = {
85 + "/proc/sys/kernel/osrelease": `${kernel}\n`,
86 + "/etc/machine-info": machineInfo,
87 + };
88 + const label = yield* resolveServerEnvironmentLabel({ cwdBaseName: "project" }).pipe(
89 + Effect.provideService(HostProcess.Platform, "linux"),
90 + Effect.provideService(HostProcess.Hostname, "DESKTOP-PC"),
91 + Effect.provideService(HostProcess.Environment, { WSL_DISTRO_NAME: "Ubuntu" }),
92 + Effect.provideService(ProcessRunner.ProcessRunner, exitsWithFailure),
93 + Effect.provide(
94 + FileSystem.layerNoop({
95 + exists: (path) => Effect.succeed(files[path] != null),
96 + readFileString: (path) => Effect.succeed(files[path] ?? ""),
97 + }),
98 + ),
99 + );
100 + assert.equal(label, expected, kernel);
101 + }
102 + }),
103 +);
apps/server/src/environment/ServerEnvironmentLabel.ts
+16
@@ -181,6 +181,17 @@ const resolveFriendlyHostLabel = Effect.fn("resolveFriendlyHostLabel")(function*
181 return null;
182 });
183
184 +const isWsl = Effect.fn("isWsl")(function* () {
185 + if ((yield* HostProcess.Platform) !== "linux") {
186 + return false;
187 + }
188 + const fileSystem = yield* FileSystem.FileSystem;
189 + const kernelRelease = yield* fileSystem
190 + .readFileString("/proc/sys/kernel/osrelease")
191 + .pipe(Effect.orElseSucceed(() => ""));
192 + return kernelRelease.toLowerCase().includes("microsoft");
193 +});
194 +
195 export const resolveServerEnvironmentLabel = Effect.fn("resolveServerEnvironmentLabel")(function* (
196 input: ResolveServerEnvironmentLabelInput,
197 ) {
@@ -191,6 +202,11 @@ export const resolveServerEnvironmentLabel = Effect.fn("resolveServerEnvironment
202
203 const hostname = normalizeLabel(yield* HostProcess.Hostname);
204 if (hostname) {
205 + // WSL inherits the Windows hostname, so qualify it to tell the two environments apart.
206 + if (yield* isWsl()) {
207 + const distro = normalizeLabel((yield* HostProcess.Environment).WSL_DISTRO_NAME);
208 + return distro ? `${hostname} WSL (${distro})` : `${hostname} WSL`;
209 + }
210 return hostname;
211 }
212