Repository navigation
Never overwrite a shell.json the shell could not read - #14534
Conversation
When shell.json fails to parse, or lacks version: 1, the shell runs on the shipped defaults, and every bar change persisted them over the user's file. Keep applying changes in memory but leave the file untouched until it loads again. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; no new blocking issue was found. SummaryThe PR keeps nonempty, unusable
Reviews (4) · Last reviewed commit: "Wait for Elsewhen's first-run save befor..." · Reviewed by Greptile |
|
FYI, #7723 ("Keep last good shell config when user shell.json fails to parse") is the other half of #7100. It keeps the last good config in memory, and its review notes that the "next click writes defaults over the file" half still needs a refuse-to-persist guard, which is this PR. The two look complementary, but both touch |
The elsewhen widget saves its default zones into shell.json about half a second after the shell loads, so dropping the brace straight after the position check raced that write and lost on every tree. Wait for the file to settle first, and check that the blocked change still applies in memory, as the fix says it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and verified on an Omarchy worker VM, against current One fix pushed, to the test only (22de887). Since this branch was cut, the What ran, on the worker:
The bug is worse on current Second opinion: Codex Medium reviewed the fix, the test change and its scope, and found no defects. It agreed that the shell has no other automatic writer of the file: Related: #7723 is the other half of #7100. It keeps the last good config in memory instead of falling back to defaults. Both models read the two as complementary rather than competing: #7723 alone still lets the defaults overwrite a file that was already broken when the shell started. If both land, the This now waits on the maintainer. |
The separate test started a second shell to break shell.json, and on today's quattro Elsewhen's first-run save could land between the break and the shell's reload, writing valid JSON back before the guard ran. The runtime smoke test already runs a scratch shell with curl stubbed, and by the time it reaches its shell.json checks that save is long done. AGENTS.md asks for the area's existing test file over a new one. Co-authored-by: Codex High (GPT-6.1-sol) <noreply@openai.com>
Co-authored-by: Codex High (GPT-6.1-sol) <noreply@openai.com>
git and some editors replace shell.json by deleting it and writing a new file. The shell reloaded in that gap, found no text and fell back to the defaults; the next settings save then wrote the defaults over the new file, losing the user's bar. omacom#14534 covered a file that cannot be parsed, not one that is briefly missing. Once a valid shell.json has been read, an empty or missing one now keeps the loaded config and holds saves until the file is back.
* Never overwrite a shell.json the shell could not read When shell.json fails to parse, or lacks version: 1, the shell runs on the shipped defaults, and every bar change persisted them over the user's file. Keep applying changes in memory but leave the file untouched until it loads again. Co-Authored-By: Codex Medium <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Let the shell finish its startup writes before breaking shell.json The elsewhen widget saves its default zones into shell.json about half a second after the shell loads, so dropping the brace straight after the position check raced that write and lost on every tree. Wait for the file to settle first, and check that the blocked change still applies in memory, as the fix says it does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Check the unreadable shell.json guard in the runtime smoke test The separate test started a second shell to break shell.json, and on today's quattro Elsewhen's first-run save could land between the break and the shell's reload, writing valid JSON back before the guard ran. The runtime smoke test already runs a scratch shell with curl stubbed, and by the time it reaches its shell.json checks that save is long done. AGENTS.md asks for the area's existing test file over a new one. Co-authored-by: Codex High (GPT-6.1-sol) <noreply@openai.com> * Wait for Elsewhen's first-run save before breaking shell.json Co-authored-by: Codex High (GPT-6.1-sol) <noreply@openai.com> --------- Co-authored-by: Omarchybot <317366263+omarchybot@users.noreply.github.com> Co-authored-by: Codex Medium <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Ryan Hughes <ryan@heyoodle.com> (cherry picked from commit 463a9a1)
git and some editors replace shell.json by deleting it and writing a new file. The shell reloaded in that gap, found no text and fell back to the defaults; the next settings save then wrote the defaults over the new file, losing the user's bar. omacom#14534 covered a file that cannot be parsed, not one that is briefly missing. Once a valid shell.json has been read, an empty or missing one now keeps the loaded config and holds saves until the file is back. (cherry picked from commit 554f2a7)
git and some editors replace shell.json by deleting it and writing a new file. The shell reloaded in that gap, found no text and fell back to the defaults; the next settings save then wrote the defaults over the new file, losing the user's bar. omacom#14534 covered a file that cannot be parsed, not one that is briefly missing. Once a valid shell.json has been read, an empty or missing one now keeps the loaded config and holds saves until the file is back. The file watch ends with the deleted file (and never sees the new one when shell.json is a link to a file elsewhere, as in a dotfiles repo), so the shell also reads it again every 200 ms for up to five seconds.
quattro now has omacom#14534, which runs the shell on the defaults in memory and refuses to write while shell.json has text that does not parse. Keep that for unparseable text, and keep the last loaded config only when the file is emptied, where omacom#14534 still let the next bar change write the defaults over it. A missing file still resets to defaults. quattro removed tests that only read source text (omacom#16334), so the shell.qml regex checks go with them. The CLI check that a 0-byte shell.json is refused moves to config-test.sh, beside the other omarchy-shell-config checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the conflicts with omacom#14534 and the bar's drag-off removal. Mutations keep reading shell.json fresh through ShellConfigStore, and when the shell is running on defaults because shell.json is unreadable, a change still applies for the session and the file is left as the user left it, as omacom#14534 does. The removal path shares writeLayout with drags, so both now return whether anything was saved and skip the write when nothing changed.
Brings in omacom#14534's userConfigUnreadable guard, which the read-error guard builds on.
A
~/.config/omarchy/shell.jsonthat fails to parse, or parses withoutversion: 1, makesapplyShellConfig()run the shell on the shipped defaults. Every bar change goes throughpersistShellConfig(), which wrote whatever was in memory to the file unconditionally. So after a hand-edit typo, the next right-click on the clock, widget drag, tray pin oromarchy bar setreplaced the user's whole configuration with the defaults, with no backup and only a journal warning to show for it.applyShellConfig()now records when the file has text it could not use, andpersistShellConfig(), the one place the shell writes that file, leaves it alone while that holds. The change still applies in memory for the session. Once the user fixes the file, the file watch reloads it, their configuration takes over again, and changes are saved as before. An empty or missing file is unaffected, so first runs still create it.test/shell.d/runtime-smoke-test.shdrops the closing brace from its scratch shell'sshell.json, makes a bar change over IPC, and requires the file to be byte-for-byte what was left. It then restores the brace and requires the next change to be saved. With the guard removed, it fails on the byte-for-byte check.Two narrower windows predate this and stay open: a
shell.jsonthat exists but cannot be read (load fails and leaves empty text), and a change made in the moment between a file being corrupted and the shell's asynchronous reload of it.Fixes #7100