Skip to content

Never overwrite a shell.json the shell could not read - #14534

Merged
ryanrhughes merged 5 commits into
quattrofrom
fix/issue-7100
Oct 27, 2026
Merged

ryanrhughes merged 5 commits into
quattrofrom
fix/issue-7100

Conversation

@omarchybot

@omarchybot omarchybot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

A ~/.config/omarchy/shell.json that fails to parse, or parses without version: 1, makes applyShellConfig() run the shell on the shipped defaults. Every bar change goes through persistShellConfig(), 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 or omarchy bar set replaced 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, and persistShellConfig(), 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.sh drops the closing brace from its scratch shell's shell.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.json that 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

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>
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

The PR keeps nonempty, unusable shell.json files untouched while still applying bar changes for the session.

  • The shell keeps unusable configuration text until the user fixes it.

Reviews (4) · Last reviewed commit: "Wait for Elsewhen's first-run save befor..." · Reviewed by Greptile

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

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 applyShellConfig()/persistShellConfig() in shell/shell.qml, so whichever lands second will need a rebase, and the combined behavior is worth testing once.

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>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 16, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator Author

Reviewed and verified on an Omarchy worker VM, against current quattro (51bfd1d) as well as this branch's own base.

One fix pushed, to the test only (22de887). Since this branch was cut, the omarchy.elsewhen bar widget started saving its default zones into shell.json about half a second after the shell loads. The test dropped the closing brace during that window, so the startup write replaced the broken file and the test failed whether or not the fix was there. It now waits until nothing has written the file for 1.5 seconds before breaking it. It also checks that a change refused on disk still applies in memory, as the description says it does, which Greptile pointed out was unchecked. shell/shell.qml is unchanged.

What ran, on the worker:

  • test/shell.d/shell-config-unreadable-test.sh fails on quattro because the broken file is overwritten with defaults. It passes on this head and on this head merged onto current quattro, and fails again with the shell.qml change reverted.
  • ./test/cli, bar-test.sh, bar-widget-contract-test.sh and config-test.sh pass on this head and on the merge.

The bug is worse on current quattro than #7100 describes. That same startup write means a shell started on an already-broken shell.json overwrites it with the defaults within five seconds, without any click. I reproduced that on quattro; with this change the file is left untouched.

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: omarchy-shell-config's commit() runs jq on the file, which fails on broken JSON before anything is replaced. Its review read the same evidence summarised here, so its agreement is not guaranteed to be independent.

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 wait_for_position top step in this test needs to expect the previous position instead.

This now waits on the maintainer.

ryanrhughes and others added 3 commits October 26, 2026 23:21
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>
@ryanrhughes
ryanrhughes merged commit 463a9a1 into quattro Oct 27, 2026
2 checks passed
dmkenney added a commit to dmkenney/omarchy that referenced this pull request Oct 28, 2026
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.
dmkenney pushed a commit to dmkenney/omarchy that referenced this pull request Oct 28, 2026
* 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)
dmkenney added a commit to dmkenney/omarchy that referenced this pull request Oct 28, 2026
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)
dmkenney added a commit to dmkenney/omarchy that referenced this pull request Oct 28, 2026
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.
omarchybot added a commit to surim0n/omarchy that referenced this pull request Nov 1, 2026
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>
omarchybot added a commit to sprajs/omarchy that referenced this pull request Nov 1, 2026
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.
omarchybot added a commit to sam-bee/omarchy that referenced this pull request Nov 1, 2026
Brings in omacom#14534's userConfigUnreadable guard, which the read-error guard builds on.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Malformed shell.json reverts the bar to defaults, and the next click overwrites the user's config with them

3 participants