Skip to content

Open a menu route summoned during startup once the menu files load - #15519

Open
omarchybot wants to merge 4 commits into
quattrofrom
omabot/pr-14055
Open

omarchybot wants to merge 4 commits into
quattrofrom
omabot/pr-14055

Conversation

@omarchybot

Copy link
Copy Markdown
Collaborator

A menu route summoned while the shell is starting (Super+Escape or the power key right after login, or just after omarchy-restart-shell, which omarchy update runs) reaches Menu.qml's open() before either JSONC FileView has loaded. openRoute() cannot resolve the route against an empty item set, openExistingMenu() falls back to root, and nothing opens the route once the files land: openRoute() still writes pendingInitialMenu, but nothing has read it since the bash menu went away. An action alias summoned in that window (Super+Ctrl+R, Super+Ctrl+Space, Super+Shift+Ctrl+Space) never runs. Fixes #14053.

This reads pendingInitialMenu again. openExistingMenu() keeps the route only when it fell back to root before both menu files had answered. At the end of rebuildItemsFromSources(), once both have answered, the pending route gets one try through openRoute(), so aliases, links, action aliases and the user's overrides behave as they do after startup, and is cleared whatever happens. Typing (setFilter()) or opening another menu (setActiveMenu(), which goBack() goes through) drops it, so a late load never pulls the user out of where they went. A summon after startup never waits.

"Both have answered" is defaultMenuSettled && userMenuSettled, the flags quattro already keeps so the guard batch runs once at startup (#15048). The default file's onLoadFailed now rebuilds, as the user file's already does, so a pending route gets its try the moment the second file answers, loaded or failed, and nothing later (a catalog load, a language change, a default file that reappears) can replay it. rebuildItemsFromSources() still evaluates guards only once both have settled, so the guard batch runs when it did; menu-test.sh's text check of that handler follows the new line.

test/shell.d/menu-startup-route-test.sh runs Menu.qml's own open, openRoute, openExistingMenu, openDmenu, cancel, rebuildItemsFromSources, setFilter, setActiveMenu and goBack bodies and the FileView handlers in a node vm context against the shipped JSONC files, in each load order, including a default file that fails after the user file.

Supersedes #14055 by @buger, whose commits this carries unchanged, with the fixes above on top.

buger and others added 4 commits October 2, 2026 15:22
A summon that arrives while the shell starts reaches the menu before
either JSONC file has loaded, so its route can't resolve and the menu
falls back to root. Nothing opens the route when the files land, so
Super+Escape right after login or a shell restart shows the main menu,
and an action alias like reminder-set never runs.

openRoute already records the route in pendingInitialMenu, which nothing
has read since the bash menu's replay went away. Keep it only when the
menu fell back to root, and open it once a load makes it resolve, while
the menu still shows root and nothing has been typed into it.
The route was opened as soon as it resolved, which could be against the
default file alone: an early summon of about ran the default command
even when the user file overrides it. It also stayed pending after the
user had opened another menu and gone back to root, so a later load, or
a live edit that adds a route that was missing, could still open it.

Give the route one try, once the default file has loaded and the user
file has loaded or failed, and drop it as soon as the user types or
opens another menu. A route summoned after both files have answered
does not wait at all.
Menu.qml on quattro now tracks defaultMenuSettled and userMenuSettled for the guard batch (#15048), which already answer whether both menu files have loaded or failed. menuFilesAnswered() reads those instead of the branch's own userMenuFailed flag, and the startup route test seeds them and the new menu catalog from Menu.qml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
menuFilesAnswered() reads the settled flags quattro keeps for the guard batch, but a default file that failed set defaultMenuSettled without rebuilding, so a route pending at that moment was left for a later catalog load, language change or a default file that reappeared to replay. The default file's failure handler now rebuilds, as the user file's already does: the route gets its try the moment both have answered, whatever the answer, and is cleared. rebuildItemsFromSources() still evaluates the guards only once both have settled, so the guard batch runs exactly when it did, and menu-test.sh's check of the handler follows the new text.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Menu startup route handling during file load.

The PR appears safe to merge, with a non-blocking issue that repeats startup guard checks.

Findings

  1. P2 Startup checks run twice ▶

Summary

Retries a menu route requested before the menu files finish loading.

  • Startup routes get one chance to open after both menu files answer.

Acknowledged intent: omarchybot explicitly limits waiting to routes that fell back to root. Routes that already resolve continue to open immediately.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Early route request] --> B[Fall back to root and remember route]
  B --> C{Both files answered?}
  C -->|No| D[Keep waiting]
  D --> C
  B --> E[User types or changes menus]
  E --> F[Forget pending route]
  C -->|Yes| G[Clear pending route]
  G --> H{Still open and route exists?}
  H -->|Yes| I[Open route or run action]
  H -->|No| J[Do nothing]
Loading

Reviews (1) · Last reviewed commit: "Give a startup route its one try once bo..." · Reviewed by Greptile

var pending = root.pendingInitialMenu
if (pending && root.menuFilesAnswered()) {
root.pendingInitialMenu = ""
if (root.opened && !root.dmenuActive && root.item(root.resolveRoute(pending))) root.openRoute(pending)

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.

P2 Startup checks run twice

Replaying a pending submenu runs the guard batch twice. rebuildItemsFromSources() already calls evaluateGuards() before this line. Calling openRoute(pending) then reaches openExistingMenu(), which calls it again. The first batch is still running, so the second call sets guardsPending and queues another full batch.

This adds avoidable work during startup. Skip the second evaluation when replaying a route from this rebuild.

@omarchybot

Copy link
Copy Markdown
Collaborator Author

Not reviewed yet: its classification is unsettled, so it carries no class label. Claude Opus 5.5 read the diff and #14053 and takes it for a bug fix. Every class needs a second model's agreement, though, and the configured reviewer (Codex Medium) did not run because today's review budget was already used up. Nothing has been run on a worker, and it has no verified or ready label.

No other open pull request fixes #14053; #14055 is closed and this one carries it forward. It waits on the classification being settled, either by a later pass once a second opinion is available or by the maintainer.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Menu: a route summoned while the shell starts opens the main menu instead

2 participants