Repository navigation
fix(desktop): one unreadable value in desktop-settings.json no longer resets every desktop setting - #28682
fix(desktop): one unreadable value in desktop-settings.json no longer resets every desktop setting#28682only21mil wants to merge 1 commit into
Conversation
… resets every desktop setting Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — Unreadable desktop settings now fall back individually, preserving other saved preferences. Existing defaults and validation remain unchanged, with no new operational behavior introduced. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Per-field settings decoding apps/desktop/src/settings/DesktopAppSettings.ts, apps/desktop/src/settings/DesktopAppSettings.test.ts |
The decoder applies dropUnreadableKey to each settings field. The test checks that unsupported updateChannel and wslOnly values leave their defaults intact. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
pingdotgg/t3code#26144— This issue concerns persistence oflocalEnvironmentEnabled; the change allows other settings fields to continue decoding when one field is unreadable.
Suggested reviewers: juliusmarminge, t3dotgg
Merge Risk: 
Minimal · up to a3ca0
-
The settings change has no remaining actionable merge risk.
Pre-merge checks: 
4
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
|
Note Written by Verified in a real dev environmentverified head reproduced on {"localEnvironmentEnabled":false,"updateChannel":"beta","wslOnly":"yes","mainWindowBounds":{"x":120,"y":80,"width":1280,"height":900}}
the development harness requests relaunch by exiting with code 75; i relaunched the identical electron command after each restart request. session d-bus was isolated to avoid configuring the vm's keyring.
before, main: after, this head with the same input: Not verifiedmacos, windows/wsl, native ios/android, packaged installers, tailscale exposure, remote/relay connections, and update downloads were not exercised on this linux vm. linux keyring integration was not exercised. invalid update-channel and wsl values were hand-written to reproduce the reported file corruption; project, thread, and provider data were created through the real app. |




Problem
If
desktop-settings.jsonholds one value this build can't read, the desktop app ignores the whole file and starts from defaults. For example,"updateChannel": "beta"or"wslOnly": "yes", which can come from a hand edit or from another build. Local environment, network access, Tailscale, WSL and window settings all go back to defaults, and the next settings save writes those defaults over the file, so the user's choices are gone for good.normalizeDesktopSettingsDocumentalready falls back field by field. The strict document decode inreadSettingsfails first, though, andEffect.orElseSucceedswaps in the defaults for every field.Change
The document decode now drops a key whose value it can't read, so that field falls back to its default and every other field still loads. It maps the existing document schema's fields through
Schema.catchDecoding. Field types, defaults, the normalizer and the write path are unchanged. Malformed JSON, or a file that isn't an object, still falls back to defaults as before.Mapping the fields, instead of rewriting each one, also covers any field added later.
A value the build can't read is still not kept. The next save rewrites the file from the loaded settings, the same as for values the normalizer already replaces, such as an out-of-range Tailscale port.
Scope and approval
This is a small, focused fix for an obvious bug, so it needs no prior issue under CONTRIBUTING.md's prior-approval rules: one bad field should not throw away the other valid settings, and the normalizer already treats fields independently. It doesn't redesign the settings schema or defaults.
Possibly related: #26144, where
localEnvironmentEnabled: falsedisappeared fromdesktop-settings.json. The run below shows the same symptom from a file with one unreadable value, but that report doesn't say what the file held, so this PR doesn't claim to fix it.Verification
vp test run apps/desktop/src/settings/DesktopAppSettings.test.ts: I added"updateChannel": "beta"and"wslOnly": "yes"to the existing lenient-JSON load case. On main it fails, because every field comes back as its default (serverExposureMode: "local-only",tailscaleServePort: 443,mainWindowBounds: null). With the fix, 12/12 pass and the valid fields load.vp run check:changed 8760d063e9: format, lint, knip, typecheck (2 packages) and tests pass.Real desktop app, base vs this branch, unpackaged Electron 44 with an isolated home, on Linux, macOS 27 and Windows 11. Before each launch I wrote the same
desktop-settings.json:{ "localEnvironmentEnabled": false, "updateChannel": "beta" }The result was the same on all three. On main the local backend started and Settings → Environments showed Local environment on, and after a normal close the saved file held only
mainWindowBounds, solocalEnvironmentEnabledwas gone. With this PR the app showed "This computer is off", the toggle was off, and the saved file kept"localEnvironmentEnabled": false(updateChannelwas dropped).Linux, before (main): Local environment is on after loading the file.
Linux, after (this PR): Local environment stays off.
macOS, before (main): Local environment is on after loading the file.
macOS, after (this PR): Local environment stays off.
Windows, before (main): Local environment is on after loading the file.
Windows, after (this PR): Local environment stays off.
Not checked: packaged installers, and settings files from real older or newer builds. The runs used a hand-written unreadable value.
Prior PRs
None make this fix. #3265, #3379 and #3432 by juliusmarminge reworked how desktop settings errors are structured and diagnosed. #26757 by t3dotgg adds a field to the same document schema and benefits from this without changes.
Generated with Claude Opus 5.5 and GPT-6.1 Terra and GPT-6.1 Sol in T3 Code Nightly