From 3c5ab701c7ab0b11f2a38ab281ffd701b2373b84 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 14 Aug 2026 16:45:47 +0200 Subject: [PATCH] Keep the menu populated across git swaps of its definition file 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 --- shell/plugins/menu/Menu.qml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/shell/plugins/menu/Menu.qml b/shell/plugins/menu/Menu.qml index 044d4bbc0c69..858c8b54b10f 100644 --- a/shell/plugins/menu/Menu.qml +++ b/shell/plugins/menu/Menu.qml @@ -924,10 +924,26 @@ Item { path: root.defaultMenuPath watchChanges: true printErrors: false - onLoaded: { root.defaultMenuItems = root.parseMenuJsonc(text()); root.rebuildItemsFromSources() } + onLoaded: { + // Git replaces the file by inode swap, so a reload can catch the gap + // 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 } + root.defaultMenuItems = items + root.rebuildItemsFromSources() + } + onLoadFailed: defaultMenuRetry.restart() onFileChanged: reload() } + Timer { + id: defaultMenuRetry + interval: 500 + repeat: false + onTriggered: defaultMenuFile.reload() + } + FileView { id: userMenuFile path: root.userMenuPath