Commit da29e23
committed
fix(config): prevent "app won't reopen" crash after deleting last provider
Installed v0.1.0 became unlaunchable if the user deleted providers down
to an empty state: the app wrote activeModel='' to config.toml,
readConfig rejected it on next boot (zod min(1)), loadConfigOnBoot
threw, and the main process died before any BrowserWindow could be
created — so clicking the dock icon did nothing.
Three-part fix:
- packages/shared/src/config.ts — drop the .min(1) invariant on
activeProvider and activeModel. Empty strings are the LEGAL "no
active provider" state; downstream consumers (toState,
resolveActiveCredentials, Settings UI) already branch on
hasKey/undefined-entry for it. Making the empty state
unrepresentable on disk was the trap.
- apps/desktop/src/main/onboarding-ipc.ts — in runDeleteProvider's
nextActive === null branch, reset activeProvider to '' too (previously
it preserved cfg.activeProvider, leaving a dangling reference to the
just-deleted provider id).
- apps/desktop/src/main/config.ts — validate with ConfigV3Schema.parse
BEFORE writing. Write-time validation converts silent disk corruption
into a surfaced error on the originating action, where it can be
retried or reported.
User impact: installed-app unstick requires one-time manual edit of
~/.config/open-codesign/config.toml (set activeModel to any non-empty
string). After upgrading to the next build, the empty state survives
round-tripping cleanly.1 parent bc32b4b commit da29e23
3 files changed
Lines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
72 | 78 | | |
73 | 79 | | |
74 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
328 | 333 | | |
329 | 334 | | |
330 | | - | |
| 335 | + | |
331 | 336 | | |
332 | 337 | | |
333 | 338 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
128 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
| |||
0 commit comments