Skip to content

Finish superseded menu-select requests so their waiters exit - #7826

Open
wico216 wants to merge 8 commits into
omacom:quattrofrom
wico216:fix/menu-select-supersede-leak
Open

wico216 wants to merge 8 commits into
omacom:quattrofrom
wico216:fix/menu-select-supersede-leak

Conversation

@wico216

@wico216 wico216 commented Aug 22, 2026 •

Copy link
Copy Markdown

Fixes #7818

Problem

Superseding a pending omarchy-menu-select leaks its waiter forever: the bash script polls a done file at 20 Hz that nothing will ever write. Reproduced here on 4.0.0-1 before touching anything:

LEAK CONFIRMED: waiter alive after supersede + Escape-dismissed menu (hyprctl layers 1 -> 0)
    PID ELAPSED STAT WCHAN     COMMAND
      8       4 S    do_wait   /bin/bash /usr/share/omarchy/bin/omarchy-menu-select ReproTest ...

unique child processes spawned in 3s: 48 (~16/sec)   # sleep 0.05, one per poll

Each leak also strands its mktemp files for the life of the session, since the trap ... EXIT cleanup never runs.

Root cause

Two paths discard a live select/input request without finishing it, and both neutralize every escape hatch:

  • openExistingMenu() clears requestActive, selectionFile and doneFile outright. The later dismiss can't help (cancel() guards on dmenuActive, which the mode = "menu" reassignment just turned false), and finishRequest() would early-return anyway on the cleared handles.
  • openDmenu() overwrites those same properties when a new select/input supersedes an active one — identical leak through a sibling trigger.

Fix

Both functions now call root.finishRequest(null) before reassigning state, so a displaced request gets its done file written (empty selection -> waiter exits 1). Safe to call unconditionally because finishRequest() already early-returns when nothing is pending, and resultProc.onExited is serial-guarded so the cancellation write cannot close the menu taking over.

Since several supersedes can land within the few milliseconds one completion spawn takes, finishRequest() no longer reassigns the shared resultProc directly — writes push onto a pendingDoneWrites queue drained from onExited with a running guard, mirroring the existing releaseNextDoneFile pattern in ImagePicker.qml. No visual change in any flow — only hidden bookkeeping writes are added, which is why there are no screenshots to attach.

Test

New test/shell.d/menu-select-supersede-test.sh (compositor-gated, skips cleanly without quickshell) drives the real Menu.qml through both supersede paths via a fixture under test/shell.d/fixtures/menu-select-supersede/. Scenario A supersedes a live select by opening the regular menu; scenario B opens four selects back-to-back with no delay, displacing three requests synchronously while an earlier completion write may still be spawning. The runner asserts every displaced done file was written and empty.

  • Watched it fail first: with unfixed code the done files stay unwritten and the test reports superseding a pending menu select strands its waiter; with the fix it passes, including four consecutive clean runs of the back-to-back scenario.
  • ./test/all: 183/189 files pass. The 6 failing files (config-test, launch-about-test, runtime-smoke-test, screenshot-sanity-test, snapper-test, unowned-system-paths-test) fail identically on pristine quattro on this machine — pre-existing environment issues, unrelated to this change.

Copilot AI balanced review requested due to automatic review settings August 22, 2026 22:27

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

Fixes leaked omarchy-menu-select waiters when requests are superseded.

Changes:

  • Completes displaced menu requests.
  • Adds compositor-backed regression coverage for both supersede paths.

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.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
shell/plugins/menu/Menu.qml Finishes superseded requests.
test/shell.d/menu-select-supersede-test.sh Runs and validates the regression fixture.
test/shell.d/fixtures/menu-select-supersede/shell.qml Exercises both supersede paths.

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

Comment thread shell/plugins/menu/Menu.qml Outdated
function openDmenu(payload) {
// Same contract as openExistingMenu: a request displaced by a newer one
// still gets its done file written, or the waiting script never exits.
root.finishRequest(null)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 833e51e by queueing completion writes through the single process, mirroring the releaseNextDoneFile pattern in ImagePicker.qml: finishRequest() pushes onto pendingDoneWrites, runNextDoneWrite() guards on resultProc.running, and onExited drains the next entry. The fixture now opens four requests back-to-back with no delay and asserts every displaced done file (b, c, d) lands.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review labels Sep 27, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed, and the fix holds. Nothing found to change.

Reproduced on a worker built from the Omarchy ISO, with its compositor serving the tree under test. I ran real omarchy-menu-select waiters against the live shell rather than relying on the included test: one superseded by summoning the regular menu, and one superseded by three selects fired back to back.

  • On current quattro (97a9fce), all four displaced waiters were still polling afterwards, while a select dismissed normally exited as it should.
  • With this branch merged onto that quattro (it merges cleanly despite being 559 commits behind), every displaced waiter exited with status 1, only the newest request stayed live, and nothing was left running.
  • With the Menu.qml change reverted and the new test kept, the waiters leaked again and menu-select-supersede-test.sh failed on done-a through done-d. So the test catches the bug rather than passing either way.

One side effect checked. When nothing is pending, finishRequest() sets opened = false. That means re-summoning an already-open menu now toggles it off and back on within the same call. I re-summoned an open menu 20 times while sampling hyprctl layers about 1,100 times, and the menu layer never left full size, so nothing visible flickers. The toggle does clear a stale uninstall confirmation and moves the menu to the focused monitor, which seems right for a fresh open.

Suite: ./test/cli and ./test/shell ran on the worker with the branch merged onto quattro. Neither is fully green, but the failures are the same 1 CLI and 62 shell failures that quattro shows on that worker. 58 of them are node missing from the worker, which also means menu-test.sh could not run on either tree. The new test passes. This PR has no CI checks reported.

Second opinion: Codex at medium effort reviewed the diff without running it and found nothing actionable. It judged the queue necessary rather than excess, since two synchronous supersedes would otherwise reuse a running resultProc and drop a completion. It found no other path that discards a live request, and it read the opened toggle the same way. That is agreement with this review, and its independence is not guaranteed.

This fixes #7818, which is already linked. It is labelled verified and now waits on the maintainer.

nocstah added a commit to nocstah/omarchy that referenced this pull request Oct 18, 2026
The previous commit took a missing selection file for a caller that
gave up, so a caller that leaves creating the file to the shell waited
forever for a done file that never came. Nothing in the tree calls the
menu that way, but the test in omacom#7826 does, and a plugin could. Note at
the summon whether the selection file exists, and skip the answer only
when it did and has gone since. A request whose rows cannot be read is
answered as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
omarchybot and others added 2 commits November 16, 2026 19:16
quattro added `altHeld = false` at the top of openExistingMenu(); keep it after the finishRequest(null) this branch adds there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The hand-rolled runner reported a missing Quickshell as a pass rather than a skip, and its cleanup stopped only Quickshell, leaving any process the fixture started behind. require_quickshell and run_qml_fixture in base-test.sh do both properly and replace the copied setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Codex Medium <noreply@openai.com>
Co-Authored-By: muse-wonder via pi, thinking high <noreply@pi.dev>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 16, 2026
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

The PR finishes displaced select and input requests before another menu takes over.

  • Menu takeovers finish the requests they replace.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Another menu opens] --> B[Finish the displaced request]
  B --> C[Queue its completion write]
  C --> D{Writer running?}
  D -->|No| E[Start next write]
  D -->|Yes| F[Wait for writer to exit]
  F --> E
  E --> G[Waiter sees its done file and exits]
Loading

Reviews (3) · Last reviewed commit: "Check selected values queued behind supe..." · Reviewed by Greptile

@omarchybot omarchybot added the ready Good to merge label Nov 16, 2026
The house rules ask for an area's existing test file to be extended rather than a new one added, so the check now runs at the end of menu-test.sh, after its headless checks, and skips there without a compositor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

This branch had stopped merging with quattro, so I merged current quattro into it and pushed that, plus two small changes to the test. The fix itself is unchanged, and it still holds on today's quattro.

The merge (629771f). The only conflict was at the top of openExistingMenu(): quattro added altHeld = false where this branch calls root.finishRequest(null). Both lines are kept, the reset after the finish.

Reproduced again on a worker built from the Omarchy ISO, with its compositor serving each tree. I ran real omarchy-menu-select waiters: one displaced by summoning the regular menu, then three selects fired back to back and displaced by a fourth.

  • On quattro (dceae18), all four displaced waiters were still polling afterwards. A select closed normally exited as it should.
  • With this branch, every displaced waiter exited with status 1, only the newest select stayed live, and nothing was left running. Picks still return their value: one made with the keyboard printed bravo, and one made in a select that had displaced another printed charlie (the displaced caller exited 1).
  • With only the Menu.qml change reverted, all four waiters leaked again.

The test (207e8d3, 5f66a7c). The runner reported a missing Quickshell as a pass rather than a skip. Its cleanup also stopped only Quickshell, so any process the fixture started was left running. It now goes through require_quickshell and run_qml_fixture from base-test.sh. quattro's AGENTS.md asks for the area's existing test file to be extended, so the check now sits at the end of test/shell.d/menu-test.sh, and menu-select-supersede-test.sh is gone. The fixture is unchanged. On the worker, menu-test.sh passes with this branch (117 checks), fails at done-a with Menu.qml reverted, and without a compositor it runs its headless checks and skips this one. The pull request description still mentions the separate file.

Suite: ./test/cli passed, and so did every menu test file (menu, menu-plugin, keybindings-menu, menu-guards, menu-images, menu-open-budget, menu-guard-budget, tray-menu). The full ./test/shell had 5 failures (ascii, branding-about-animation, first-run, provision-owner-keyboard, runtime-smoke). All 5 fail the same way on quattro on the same worker, so this branch didn't cause them.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the merged tree and found no defect in the fix on current quattro, including the on-change multi-select path, altHeld, and the uninstall confirmation. Both flagged the skip that was reported as a pass, which is fixed above. They then reviewed each test change and found nothing further. Greptile raised the separate test file.

Competing fixes. #9031, #9056 and #17239 also fix this stranding. Both reviewers were given all four diffs without my answer, and both picked this one: it is the oldest, and none of the newer ones handles a case of this bug that it misses. That matches my reading and earlier triage comments on #9031 and #9056, so their independence isn't guaranteed. What #9031 and #17239 add beyond it is about a different failure, the shell exiting or restarting while a caller waits, plus a --timeout option in #17239. Those are separate from #7818 and can be judged on their own.

This fixes #7818, which is already linked. It is labelled verified and ready, and waits on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 23, 2026
nocstah added a commit to nocstah/omarchy that referenced this pull request Nov 25, 2026
The previous commit took a missing selection file for a caller that
gave up, so a caller that leaves creating the file to the shell waited
forever for a done file that never came. Nothing in the tree calls the
menu that way, but the test in omacom#7826 does, and a plugin could. Note at
the summon whether the selection file exists, and skip the answer only
when it did and has gone since. A request whose rows cannot be read is
answered as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
nocstah added a commit to nocstah/omarchy that referenced this pull request Nov 25, 2026
The previous commit took a missing selection file for a caller that
gave up, so a caller that leaves creating the file to the shell waited
forever for a done file that never came. Nothing in the tree calls the
menu that way, but the test in omacom#7826 does, and a plugin could. Note at
the summon whether the selection file exists, and skip the answer only
when it did and has gone since. A request whose rows cannot be read is
answered as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
omarchybot and others added 3 commits November 26, 2026 17:14
Keep the menu payload and snapshot-provider tests alongside the runtime supersede regression.
Carry the active-request guard from omacom#9056 across all three entry points. The native keybindings menu now clears request state too, and must answer the displaced caller first. Guarding the finish also avoids closing and reopening an idle menu.

Extend the runtime fixture to cover a select displaced by keybindings and check that delayed writes leave the replacement open.

Co-Authored-By: FernandoJVideira <03.pleaser-minster@icloud.com>

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
Exercise a selected value while cancellations still occupy the completion writer, as the panel review suggested. Preserve the payload tests’ existing scratch cleanup when the QML fixture installs its cleanup handler.

Co-Authored-By: muse-wonder via pi, thinking high <noreply@openrouter.ai>

Co-Authored-By: GPT-6 (Codex) <noreply@openai.com>
@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 26, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

The branch is brought onto quattro at 155c4b4c, with the native-keybindings takeover covered alongside the ordinary menu and replacement selects. That coverage comes from #9056, credited to @FernandoJVideira. Each entry point finishes an active request before clearing its files; opening an idle menu leaves it open.

On a disposable worker built from the Omarchy ISO, real omarchy-menu-select callers left five displaced waiters running on the base, zero on this head, and five again with Menu.qml reverted. The regression in test/shell.d/menu-test.sh fails at done-a on the base, at done-f with only the keybindings guard removed, and at done-c with the completion queue removed. It also checks that a selected value queued behind cancellation writes returns bravo.

./test/cli passed (143 checks), as did all eight focused menu test files (219 checks). A real keyboard selection returned bravo, and an immediate-save checkbox wrote its selection through the callback. The test preserves both scratch-directory cleanup handlers. The worker has been destroyed.

Checked by GPT-6 in Codex (effort not exposed), with final source reviews by Opus 5.5 High and muse-wonder via pi, thinking high. Both final reviews found no actionable defect; their agreement is not guaranteed to be independent. The panel contributed the queued-selection coverage. Its proposed completion-queue stall was checked against a real Quickshell process on the worker: running was already false inside onExited, consistent with the passing runtime test.

Greptile reviewed this head at 5/5 with no new findings. It is labelled verified. GitHub Actions is waiting for maintainer approval to run Tests and Check translation structure, so ready was refused; it waits on those workflows. The description still names the former standalone test runner.

nocstah added a commit to nocstah/omarchy that referenced this pull request Dec 2, 2026
The previous commit took a missing selection file for a caller that
gave up, so a caller that leaves creating the file to the shell waited
forever for a done file that never came. Nothing in the tree calls the
menu that way, but the test in omacom#7826 does, and a plugin could. Note at
the summon whether the selection file exists, and skip the answer only
when it did and has gone since. A request whose rows cannot be read is
answered as before.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Dec 2, 2026
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.

Superseding a pending omarchy-menu-select leaks a permanent 20 fork/sec busy-wait loop

3 participants