Skip to content

Commit 7382e92

Browse files
fix(desktop): honor the telemetry opt-out from the shell profile
The desktop app starts from a GUI launcher, so T3CODE_TELEMETRY_ENABLED exported in ~/.zshrc never reached the bundled server. Import it from the login shell like the other env vars, and forward it into WSL backends. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent aad7329 commit 7382e92

5 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎apps/desktop/src/backend/DesktopBackendConfiguration.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,16 +961,20 @@ describe("DesktopBackendConfiguration", () => {
961961

962962
const previousWslEnv = process.env.WSLENV;
963963
const previousDisabled = process.env.OTEL_SDK_DISABLED;
964+
const previousTelemetry = process.env.T3CODE_TELEMETRY_ENABLED;
964965
try {
965966
delete process.env.WSLENV;
966967
process.env.OTEL_SDK_DISABLED = "true";
968+
process.env.T3CODE_TELEMETRY_ENABLED = "false";
967969

968970
yield* Effect.gen(function* () {
969971
const configuration = yield* DesktopBackendConfiguration.DesktopBackendConfiguration;
970972
const config = yield* configuration.resolveWsl({ port: 5050, distro: null });
971973

972974
assert.equal(config.env.OTEL_SDK_DISABLED, "true");
973975
assert.include((config.env.WSLENV ?? "").split(":"), "OTEL_SDK_DISABLED");
976+
assert.equal(config.env.T3CODE_TELEMETRY_ENABLED, "false");
977+
assert.include((config.env.WSLENV ?? "").split(":"), "T3CODE_TELEMETRY_ENABLED");
974978
}).pipe(
975979
Effect.provide(
976980
DesktopBackendConfiguration.layer.pipe(
@@ -991,6 +995,7 @@ describe("DesktopBackendConfiguration", () => {
991995
} finally {
992996
restoreEnv("WSLENV", previousWslEnv);
993997
restoreEnv("OTEL_SDK_DISABLED", previousDisabled);
998+
restoreEnv("T3CODE_TELEMETRY_ENABLED", previousTelemetry);
994999
}
9951000
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
9961001
);

‎apps/desktop/src/backend/DesktopBackendConfiguration.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ const DESKTOP_BACKEND_ENV_NAMES = [
9595
const WSL_FORWARDED_ENV_NAMES = [
9696
"OPENAI_API_KEY",
9797
"ANTHROPIC_API_KEY",
98+
"T3CODE_TELEMETRY_ENABLED",
9899
// Otherwise the WSL server keeps exporting to endpoints from the bootstrap.
99100
"T3CODE_OTEL_SDK_DISABLED",
100101
"OTEL_SDK_DISABLED",

‎apps/desktop/src/shell/DesktopShellEnvironment.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,13 @@ describe("DesktopShellEnvironment", () => {
268268
envOutput({
269269
PATH: "/home/linuxbrew/.linuxbrew/bin:/usr/bin",
270270
SSH_AUTH_SOCK: "/tmp/secretive.sock",
271+
T3CODE_TELEMETRY_ENABLED: "false",
271272
}),
272273
});
273274

274275
assert.equal(env.PATH, "/home/linuxbrew/.linuxbrew/bin:/usr/bin");
275276
assert.equal(env.SSH_AUTH_SOCK, "/tmp/secretive.sock");
277+
assert.equal(env.T3CODE_TELEMETRY_ENABLED, "false");
276278
}),
277279
);
278280

‎apps/desktop/src/shell/DesktopShellEnvironment.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const LOGIN_SHELL_ENV_NAMES = [
8585
"XDG_SESSION_DESKTOP",
8686
"XDG_SESSION_TYPE",
8787
"WAYLAND_DISPLAY",
88+
"T3CODE_TELEMETRY_ENABLED",
8889
] as const;
8990
const WINDOWS_PROFILE_ENV_NAMES = ["PATH", "FNM_DIR", "FNM_MULTISHELL_PATH"] as const;
9091
const LOCALE_ENV_NAMES = ["LANG", "LC_ALL", "LC_CTYPE"] as const;
@@ -450,6 +451,8 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
450451
"XDG_DATA_HOME",
451452
"XDG_RUNTIME_DIR",
452453
"WAYLAND_DISPLAY",
454+
// The telemetry opt-out is documented as a shell variable; GUI launches never see it.
455+
"T3CODE_TELEMETRY_ENABLED",
453456
] as const) {
454457
if (!config.env[name] && shellEnvironment[name]) {
455458
config.env[name] = shellEnvironment[name];

‎docs/user/telemetry.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ raw provider events, or child-agent output. Child-agent token use is excluded fr
99

1010
To disable collection, set `T3CODE_TELEMETRY_ENABLED=false` in the server's environment before
1111
starting it. This stops product events from being recorded or sent.
12+
13+
The desktop app reads the variable from your shell profile (for example `~/.zshrc`) on macOS and
14+
Linux, so export it there and restart the app. On Windows, set it as a user environment variable.

0 commit comments

Comments
 (0)