@devries-cameron20 / t3code-1 / commits / c7a3f02e38
Fork 0

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

fix(desktop): Local environment off survives an unreadable value in desktop-settings.json (#36168)

Julius Marminge committed Nov 13, 2026 at 05:32 UTC c7a3f02e3851923ced8ebd000db79f641e11b038
2 files changed +40 -13
apps/desktop/src/settings/DesktopAppSettings.test.ts
+22
@@ -240,6 +240,28 @@ describe("DesktopSettings", () => {
240 ),
241 );
242
243 + it.effect("keeps Local environment off when another value in the file is unreadable", () =>
244 + withSettings(
245 + Effect.gen(function* () {
246 + const environment = yield* DesktopEnvironment.DesktopEnvironment;
247 + const fileSystem = yield* FileSystem.FileSystem;
248 + const settings = yield* DesktopAppSettings.DesktopAppSettings;
249 + yield* fileSystem.makeDirectory(environment.stateDir, { recursive: true });
250 + yield* fileSystem.writeFileString(
251 + environment.desktopSettingsPath,
252 + `{ "localEnvironmentEnabled": false, "serverExposureMode": "tailnet" }\n`,
253 + );
254 +
255 + assert.isFalse((yield* settings.load).localEnvironmentEnabled);
256 + yield* settings.setMainWindowBounds({ x: 10, y: 20, width: 800, height: 600 }, false);
257 + assert.include(
258 + yield* fileSystem.readFileString(environment.desktopSettingsPath),
259 + `"localEnvironmentEnabled":false`,
260 + );
261 + }),
262 + ),
263 + );
264 +
265 it.effect("rejects window bounds that do not satisfy the domain schema", () =>
266 withSettings(
267 Effect.gen(function* () {
apps/desktop/src/settings/DesktopAppSettings.ts
+18 -13
@@ -90,20 +90,25 @@ const DesktopWindowBoundsDocument = Schema.Struct({
90 height: Schema.Number,
91 });
92
93 +// A value this build cannot read drops only its own key, so the rest of the file
94 +// still loads and is written back instead of every setting resetting to defaults.
95 +const optionalReadableKey = <S extends Schema.Top>(schema: S) =>
96 + Schema.optionalKey(schema.pipe(Schema.catchDecoding(() => Effect.succeedNone)));
97 +
98 const DesktopSettingsDocument = Schema.Struct({
94 - localEnvironmentEnabled: Schema.optionalKey(Schema.Boolean),
95 - linuxPasswordStore: Schema.optionalKey(Schema.Unknown),
96 - mainWindowBounds: Schema.optionalKey(Schema.NullOr(DesktopWindowBoundsDocument)),
97 - mainWindowMaximized: Schema.optionalKey(Schema.Boolean),
98 - serverExposureMode: Schema.optionalKey(DesktopServerExposureModeSchema),
99 - tailscaleServeEnabled: Schema.optionalKey(Schema.Boolean),
100 - tailscaleServePort: Schema.optionalKey(Schema.Number),
101 - updateChannel: Schema.optionalKey(DesktopUpdateChannelSchema),
102 - updateChannelConfiguredByUser: Schema.optionalKey(Schema.Boolean),
103 - wslBackendEnabled: Schema.optionalKey(Schema.Boolean),
104 - wslMode: Schema.optionalKey(Schema.Literals(["local", "wsl"])),
105 - wslDistro: Schema.optionalKey(Schema.NullOr(Schema.String)),
106 - wslOnly: Schema.optionalKey(Schema.Boolean),
99 + localEnvironmentEnabled: optionalReadableKey(Schema.Boolean),
100 + linuxPasswordStore: optionalReadableKey(Schema.Unknown),
101 + mainWindowBounds: optionalReadableKey(Schema.NullOr(DesktopWindowBoundsDocument)),
102 + mainWindowMaximized: optionalReadableKey(Schema.Boolean),
103 + serverExposureMode: optionalReadableKey(DesktopServerExposureModeSchema),
104 + tailscaleServeEnabled: optionalReadableKey(Schema.Boolean),
105 + tailscaleServePort: optionalReadableKey(Schema.Number),
106 + updateChannel: optionalReadableKey(DesktopUpdateChannelSchema),
107 + updateChannelConfiguredByUser: optionalReadableKey(Schema.Boolean),
108 + wslBackendEnabled: optionalReadableKey(Schema.Boolean),
109 + wslMode: optionalReadableKey(Schema.Literals(["local", "wsl"])),
110 + wslDistro: optionalReadableKey(Schema.NullOr(Schema.String)),
111 + wslOnly: optionalReadableKey(Schema.Boolean),
112 });
113
114 type DesktopSettingsDocument = typeof DesktopSettingsDocument.Type;