Skip to content

Commit d06c68c

Browse files
fix(desktop): Local environment off survives an unreadable value in desktop-settings.json
One value this build could not decode (for example from another build) made the whole desktop-settings.json load as defaults, with saving still on, so Local environment came back on and the next save dropped localEnvironmentEnabled from disk. Each key now falls back on its own. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 289b671 commit d06c68c

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

‎apps/desktop/src/settings/DesktopAppSettings.ts‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,25 @@ const DesktopWindowBoundsDocument = Schema.Struct({
9090
height: Schema.Number,
9191
});
9292

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+
9398
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),
107112
});
108113

109114
type DesktopSettingsDocument = typeof DesktopSettingsDocument.Type;

0 commit comments

Comments
 (0)