Skip to content

Keep the menu populated across git swaps of its definition file - #6871

Open
dhh wants to merge 1 commit into
quattrofrom
menu-survive-file-swap
Open

dhh wants to merge 1 commit into
quattrofrom
menu-survive-file-swap

Conversation

@dhh

@dhh dhh commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

The menu watches omarchy-menu.jsonc so live edits apply without a shell restart, but git updates the file by inode swap, and a reload can land in the gap: the read comes back empty or fails outright, the menu blanks, and no further watch event arrives to recover it. Dev-channel machines hit this every time a checkout or rebase touches the file.

This treats a failed load or an empty parse of the default file as a torn read: keep the current rows and arm a 500ms retry instead of blanking the menu — the same retry-timer idiom Style.qml already uses for its watched files. The user-extension file keeps its existing behavior, since that file legitimately may not exist.

Verified live: moved the definition file away for two seconds and back (a harsher version of git's swap — the exact sequence that emptied the menu on my machine today); the menu recovered on its own and summoned fully populated. ./test/shell passes.

🤖 Generated with Claude Code

The menu watches omarchy-menu.jsonc so live edits apply without a shell
restart, but git updates the file by inode swap, and a reload could land
in the gap: the read came back empty or failed outright, the menu
blanked, and no further watch event arrived to recover it. Dev-channel
machines hit this every time a checkout or rebase touched the file.

Treat a failed load or an empty parse of the default file as a torn
read: keep the current rows and retry shortly, the same retry-timer
idiom Style.qml uses for its watched files.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 14, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents the menu from blanking during Git inode swaps by retaining existing rows and retrying failed or empty default-menu loads.

Changes:

  • Preserve the last valid default menu.
  • Retry loading after 500 ms.
  • Leave user-extension loading unchanged.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

// and read nothing. The shipped menu is never empty: keep the current
// rows and retry instead of blanking the menu until a shell restart.
var items = root.parseMenuJsonc(text())
if (items.length === 0) { defaultMenuRetry.restart(); return }
@ryanrhughes
ryanrhughes self-requested a review as a code owner September 8, 2026 16:50
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 3c5ab70, run on a worker built from the Omarchy ISO with the shell loaded from this branch. Nothing found that needs changing.

Reproduction. Deleting default/omarchy/omarchy-menu.jsonc and recreating it empty for a moment — the window a checkout leaves between unlinking the file and writing the new one — blanks the menu on quattro (3faafba) and on this branch with the fix reverted: summoned during that window it shows "Nothing here yet". On this head the menu keeps its rows through the same window, and an in-place edit made afterwards (a relabelled row) still shows up, so the watch stays live.

What I could not reproduce is the menu staying blank once the file has settled. On quattro it came back every time: after six real git checkout swaps of the file, after thirty-five tight delete/empty/write cycles, after the full file arriving by rename, and after the file vanishing straight after an empty read. So the evidence here is for the transient blank; the stuck case is plausible rather than shown. Codex offered a mechanism for it — Quickshell's FileView ignores a change notification that arrives while a load of the same path is still in flight, so the last event can be lost behind a bad read — which is timing-dependent, and would explain why a VM did not hit it. The retry covers that case either way.

Tests. ./test/cli and the full ./test/shell (2190 passed, 0 failed, none skipped) on the worker, with this branch's shell running.

Second opinion. Codex at medium effort reviewed the diff and found no correctness problem; independence from this review is not guaranteed. It noted two things I am leaving as they are, since neither changes what a user sees: a default file that stays missing or malformed is retried every 500ms indefinitely, and a successful reload does not cancel a retry already pending, which costs one redundant rebuild. It also pointed out that git's checkout unlinks and rewrites rather than swapping inodes by rename, so "inode swap" in the description is loose, though the gap it describes is real.

The change is proportionate: a retry on the one file that must never be empty, in the idiom Style.qml already uses. Labelled verified and ready; it waits on the maintainer.

@omarchybot omarchybot added ready Good to merge and removed ready Good to merge labels Sep 28, 2026
@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 12, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This no longer merges into quattro, so verified has come off. The head is unchanged at 3c5ab70; quattro moved under it.

What conflicts. #15048 (f3cdce2, "Run the menu's guard batch once at startup") rewrote the same two handlers this changes, defaultMenuFile.onLoaded and onLoadFailed in shell/plugins/menu/Menu.qml: each now sets defaultMenuSettled, and startup holds guard evaluation until both menu files have answered. The rest of this diff, including the retry timer, merges cleanly.

The fix is still needed. quattro still assigns an empty parse straight to defaultMenuItems and rebuilds (Menu.qml:1088), so the torn read this guards against still blanks the menu, and a failed load still has no retry.

Why I have not resolved it. Combining the two takes a decision rather than a merge: whether a torn read or a failed load counts as the default file having answered. If it does not, a default file that stays missing leaves the startup guards held until the menu is opened, since openExistingMenu evaluates them regardless (Menu.qml:899). If it does, guards are evaluated against whatever rows are there and again once the retry succeeds. Whichever is chosen, the assertion #15048 added in test/shell.d/menu-test.sh (around line 776) checks the exact one-line form of both handlers and will need to change with them.

Checked by reading the source and a three-way merge of this head against quattro at 4c1b4cb. No worker run this time, since nothing about this head changed. Codex at medium effort reviewed the conflict separately and agreed on all three points; independence from this review is not guaranteed. It leans towards counting both outcomes as settled and releasing held guards once, not on every 500ms retry.

Waiting on the author to resolve the conflict. Once it merges cleanly it will be run on a worker again.

@chessing234 chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an empty or unreadable menu restarts defaultMenuRetry from onLoaded with no cap. a file that stays empty reloads every 500ms for the life of the shell. stop after a few tries and keep the last good rows.

@omarchybot

Copy link
Copy Markdown
Collaborator

quattro now fixes the bug this pull request was opened for, so I recommend closing it. The head is unchanged at 3c5ab70 and still conflicts with quattro.

What landed. #16268 (c39fd2a, merged 2026-10-22) keeps the menu's rows when a read of omarchy-menu.jsonc is not a whole menu. On quattro at 967bbdd, defaultMenuFile.onLoaded passes the text through MenuModel.keepMenuRows(..., true) (Menu.qml:1154), which keeps the previous rows for an empty, malformed or truncated read of the shipped menu (MenuModel.js:82). onLoadFailed no longer clears them. Opening the menu while it has no shipped rows also re-reads the file (Menu.qml:29), which covers a shell that started mid-update. Together these handle the torn read that blanks the menu, the case this pull request reproduced on a worker.

What this one still adds. Only the 500ms re-read. After a torn read, quattro keeps showing the previous rows until the next change notification. This branch would re-read on its own and pick up the new file even if that notification never arrives. The stuck case was never reproduced: an earlier worker run found the menu always recovered once the file settled. #16268's description also says it tried re-reading torn files on a timer and removed that, because keeping the last good rows already fixes the empty menu. If you still want the retry, it would be a small change on top of quattro's handlers, not a resolution of this conflict.

Checked by reading quattro's Menu.qml and MenuModel.js against this diff. Nothing was run on a worker, since the question was whether the change is still needed, not whether it works. Codex at medium effort compared the two fixes separately. It found that quattro does not blank the menu on an empty read, a malformed read or a failed load, and it identified the stale-rows-after-a-lost-notification case as the one remaining difference. It suggested porting the retry; I'm leaving that to you because #16268 dropped it deliberately. Its independence from this review is not guaranteed.

This waits on the maintainer: close it, or say if the retry should come across to quattro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants