Repository navigation
Answer an abandoned menu request before starting the next one - #9056
FernandoJVideira wants to merge 6 commits into
Conversation
open() dispatches to openDmenu() or openExistingMenu() (via openRoute()), and both unconditionally overwrite selectionFile/doneFile/requestActive without finishing any request already in flight. A summon that arrives before the prior select/input request was answered — e.g. a keybinding like Super+K repeated in quick succession — orphans that request's doneFile forever, so bin/omarchy-menu-select's polling loop (`while [[ ! -e $done_file ]]; do sleep 0.05; done`) never exits and the process leaks indefinitely. Finish any active request as cancelled at the top of open(), before dispatching to either path, mirroring what cancel() already does for dmenuActive.
There was a problem hiding this comment.
Pull request overview
This PR prevents orphaned omarchy-menu-select processes by ensuring any in-flight select/input request is finished (as cancelled) before a new menu summon overwrites its doneFile/selectionFile state in the menu plugin.
Changes:
- Cancel/finish any active select/input request at the start of
Menu.open()to ensure the previous caller’sdoneFileis written. - Add inline documentation describing the stuck-process failure mode and why the pre-cancel is necessary.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // A select/input request left in flight when a new summon arrives | ||
| // (e.g. the trigger key repeated before the prior one was answered) | ||
| // would otherwise have its doneFile silently abandoned by | ||
| // openDmenu/openExistingMenu below, leaving the caller that's still | ||
| // polling for it (bin/omarchy-menu-select) blocked forever. Answer it | ||
| // as cancelled first so every summon always resolves. | ||
| if (root.requestActive) root.finishRequest(null) | ||
|
|
There was a problem hiding this comment.
Verdict: approve-with-comments — I verified the fix live against the real shell, and traced the blast radius of answering inside open(). Re-checked on the current head b7bd59c4.
The attached 78-second narrated video runs the real shell with real callers on quattro c05d9019, the first commit 0b4fe29 (the guard only) and the head b7bd59c4, with the SHAs on screen: two overlapping requests, then a burst of 20 and Escape.
pr-9056-supersession.mp4
- Two requests: on
quattro, caller A is never answered and keeps waiting; on0b4fe29andb7bd59c4, B's summon answers A as cancelled and both exit1. - Burst of 20: 19 callers still waiting on
quattro, 11 on0b4fe29, 0 onb7bd59c4. A real selection still returns its value (alpha, exit0).
Many summons at once — fixed by b7bd59c4 (thanks @omarchybot, who found it and pushed the fix). Copilot flagged this race on the first commit; my earlier two-answer test missed it. With a single shared Process for answers, a burst of summons stranded callers: when the queue drains, several answers are started while the first write is still running, and those starts are ignored. I re-ran it on a live session (20 concurrent omarchy-menu-select, then Escape on the visible menu; two sessions of 3 runs each):
| Tree | Callers still waiting (of 20) |
|---|---|
quattro c05d9019 |
19 in all 6 runs |
0b4fe29 (guard only) |
12, 11, 10, 7, 10, 9 |
b7bd59c4 |
0 in all 6 runs |
b7bd59c4 merged onto c05d9019 |
0 in all 6 runs |
The two-summon case exits cleanly on b7bd59c4 (A 1, B 1), and a real selection still returns its value (alpha, exit 0).
Blast radius — checked, safe. The one concern with answering inside open() is whether any path calls open() intending to keep an in-flight request (a refresh/redraw would now wrongly cancel it). I traced every entry point:
open()has exactly one caller — the summon queue drain inshell.qml. All summon paths (omarchy-menu summon,omarchy-menu-select,omarchy-menu-input,omarchy-agent) are genuine new requests, where supersession is the intent.toggle(and the default keybinds) while a request is active goes throughclose()→cancel(), which already answers viafinishRequest(null)— behavior unchanged there.refreshnever touchesopen()— it routes torefresh()(Menu.qml:46), which only reloads the two JSONC files. No theme-change or watcher-triggered re-open exists anywhere in bin/ or default/.open()only callsfinishRequest(null)when a request is in flight (therequestActiveguard), so flows with nothing pending are unaffected.- Removing
resultProcalso removes itsonExited, which only setopened = false;cancel(),applyDmenuSelection(),applySelected()and the app-launch path already set it themselves.
Two comments:
-
This fixes the supersession trigger only. If the menu process dies after the summon (Quickshell crash/restart) instead of being superseded,
open()never runs again and the caller still polls forever — same leak, different trigger (details on #9057).bin/omarchy-menu-selectis unchanged by this PR. A bounded wait there (deadline + diagnostic + exit 1) covers both. Non-blocking for this PR, but the pair should land together, or the issue should stay open for the peer-death half. -
Please add a regression test. The new
menu-test.shassertions check the source text ofopen()andfinishRequest(); nothing yet runs two overlapping requests, which is the gap greptile also points out. A two-summon test is cheap in the existing shell test harness and prevents a silent revert the next timeopen()is refactored.Here is one for
test/shell.d/that needs no compositor. It runs the realopen/finishRequest/openDmenu/openExistingMenu/openRoutebodies fromMenu.qmlunder Node and records every answer write, whether it goes throughQuickshell.execDetachedor a sharedProcess(modelled as it behaves live: a start while it is still running is ignored). Feel free to add it to this PR as is.
What the test reports on each tree
| Tree | Result |
|---|---|
quattro c05d9019 (and 8b4eae6) |
exit 1 — stops at not ok - a second summon answers the active request |
0b4fe29 (guard only) |
exit 1 — 7 ok, then not ok - back-to-back answers are all written, none dropped while an earlier write runs |
this branch (b7bd59c4) |
8 / 8 ok |
this branch merged onto c05d9019 |
8 / 8 ok |
The four cases cover a picker superseded by a second picker, a picker superseded by a route summon, a summon with nothing active (which must write nothing), and three pickers summoned back to back (every answer must be written).
test/shell.d/menu-summon-cancel-test.sh (run with bash test/shell.d/menu-summon-cancel-test.sh)
#!/bin/bash
set -euo pipefail
# #9057: a summon while a select request is active must answer the earlier
# request (as a cancel) instead of orphaning its done file, and answers given
# back to back must all be written. Runs the real open / finishRequest /
# openDmenu / openExistingMenu / openRoute bodies from Menu.qml under node vm
# and records every answer write. A shared Process is modelled as it behaves
# live: a start while it is still running is ignored.
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"
run_node_test <<'JS'
function requestHarness() {
const vm = require('vm')
const fs = require('fs')
const qml = fs.readFileSync(path.join(root, 'shell/plugins/menu/Menu.qml'), 'utf8')
const names = ['open', 'finishRequest', 'openDmenu', 'openExistingMenu', 'openRoute']
const src = names.map(name => {
const m = qml.match(new RegExp('\\n function ' + name + '\\([^)]*\\) \\{[\\s\\S]*?\\n \\}\\n'))
if (!m) throw new Error(name + ' not found in Menu.qml')
return m[0]
}).join('\n')
const writes = []
let busy = false
const resultProc = { command: [], set running(v) { if (v && !busy) { busy = true; writes.push(this.command.slice()) } }, get running() { return busy } }
const Quickshell = { execDetached(command) { writes.push(command.slice()) } }
const r = {
opened: false, mode: 'menu', requestSerial: 0, applySerial: 0, requestActive: false, selectionFile: '', doneFile: '',
dmenuPrompt: '', dmenuOptions: [], dmenuWidth: 300, dmenuMaxHeight: 0, activeMenu: 'root', navStack: [],
filterText: '', selectedIndex: 0, cursorActive: true, fontFamily: '', pendingInitialMenu: 'root', appLibrary: null,
items: { root: { id: 'root', kind: 'menu' } }, itemOrder: ['root'],
item(id) { return this.items[id] || null },
resolveRoute(input) { return input },
disarmPointer() {}, evaluateGuards() {}, rebuildDisplay() {}, invalidateVolatileProvider() {}, loadProviderForMenu() {},
cancel() { this.finishRequest(null) }, runAction() {}
}
const fns = vm.runInNewContext(`(function() { with (root) { ${src}; return { ${names.join(', ')} } } })()`, {
root: r, resultProc, Quickshell, keyCatcher: { forceActiveFocus() {} }, Qt: { callLater() {} },
Util: { shellQuote: s => "'" + String(s).replace(/'/g, "'\\''") + "'" }, JSON, Math, Number, String, Array
})
for (const n of names) r[n] = fns[n]
return { r, writes }
}
const selectPayload = tag => JSON.stringify({ mode: 'select', prompt: 'Pick ' + tag, options: ['a', 'b'], selectionFile: '/tmp/sel-' + tag, doneFile: '/tmp/done-' + tag })
{
const { r, writes } = requestHarness()
r.open(selectPayload('first'))
r.open(selectPayload('second'))
assertEqual(writes.length, 1, 'a second summon answers the active request')
assertEqual(writes[0][2], ": > '/tmp/done-first'", 'the superseded request is answered as cancelled (done file only)')
assertEqual(r.doneFile, '/tmp/done-second', 'the new request owns its own done file')
assertEqual(r.requestActive, true, 'the new request stays active')
}
{
const { r, writes } = requestHarness()
r.open(selectPayload('pending'))
r.open(JSON.stringify({ menu: 'root' }))
assertEqual(writes.length, 1, 'a route summon answers a pending picker')
assertEqual(r.requestActive, false, 'no request stays active after a route summon')
}
{
const { r, writes } = requestHarness()
r.open(selectPayload('clean'))
assertEqual(writes.length, 0, 'a summon with no active request writes nothing')
}
{
const { r, writes } = requestHarness()
for (const tag of ['b1', 'b2', 'b3']) r.open(selectPayload(tag))
r.finishRequest(null)
assertEqual(writes.map(w => w[2]).join(' | '), ": > '/tmp/done-b1' | : > '/tmp/done-b2' | : > '/tmp/done-b3'",
'back-to-back answers are all written, none dropped while an earlier write runs')
}
JSUnrelated, in the neighborhood: the menu's JSONC parsing has pre-existing edges (#13250, #13492, #13493), fixed together in #13968. None is caused by this change.
Verified by driving the real shell; the video above is the actual run, not a mock.
Independent verification: the requirement map, test results and behaviour-change analysis for this PR at b7bd59c4.
Updated 2026-10-02: re-checked on b7bd59c4 (thanks @omarchybot and Copilot): the burst case is fixed; new video on all three commits; this review now holds everything.
|
Folded into my review above. It now carries the live video on Updated 2026-10-02: folded into the review above. |
finishRequest() sent every answer through one shared Process. Setting a command and running = true on a Process that is still running is ignored, so when a second answer came before the first write exited (several summons arriving together, as when a menu key is pressed repeatedly) it was dropped and its caller polled for a done file that never came. With 20 selects summoned at once, about half stayed stuck after the open() guard. Quickshell.execDetached starts a fresh process per answer, so none can be lost. The Process's onExited only closed the menu again after the selection path had already closed it, so it goes, along with the serials that existed only to feed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed and reproduced on a disposable Omarchy VM, running the real shell from this branch. The guard in What was found. What changed. What ran, on the worker: the two-summon case (A now exits 1), the 20-way burst (0 left), three summons back to back (all exit), and a real selection, which still returns its value. Also Second opinion: none. The configured reviewer (Codex Medium) answers, but omabot's review budget for the day was spent, so this was checked by one model, Claude Opus 5.5, and nothing else. Not covered here: a caller still waits forever if the shell dies after it summons, as noted on #9057. A bounded wait in This waits on a second-opinion review of b7bd59c, then on the maintainer. |
[Medium impact] The change affects menu requests and their callers across the desktop workflow. Fix the leftover FindingsSummaryThe PR answers an abandoned menu request before opening its replacement.
Reviews (5) · Last reviewed commit: "Merge branch 'quattro' into fix-menu-sum..." · Reviewed by Greptile |
| /if \(root\.requestActive\) root\.finishRequest\(null\)/.test(openBody) | ||
| && openBody.indexOf('root.finishRequest(null)') < openBody.indexOf('root.openDmenu(payload)'), | ||
| 'menu answers a request still in flight before a new summon replaces it' | ||
| ) | ||
| const finishBody = menuQml.match(/function finishRequest\(selection\) \{([\s\S]*?)\n \}/)[1] | ||
| assert( | ||
| (finishBody.match(/Quickshell\.execDetached\(/g) || []).length === 2 && !/\.running = true/.test(finishBody), |
There was a problem hiding this comment.
Overlapping requests remain untested The new assertions inspect QML text but never run two overlapping select/input requests. A regression could leave the first caller waiting for its
doneFile while these checks still pass. A runtime test that supersedes an active request and verifies both callers exit would cover the behavior this PR fixes.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Thanks @omarchybot for |
test/reports/*.sh run through test/node/report-reproducers.test.mjs, which is in scope, so the JUnit report has no testcase per script. In scope, the engine counted a traced reproducer as a test of its own with no observed outcome: on the omacom#9056 mirror, which edits the omacom#9057 reproducer, that was a test_outcome_unobserved disclosure for SYS-REQ-260922-X6Z5 although the script ran and passed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Front page: omacom#9057 row says omacom#9056 fixes the re-summon trigger only (a menu process that dies mid-request still strands the caller); omacom#13492 row says label-only array elements stay hidden; omacom#13493 row says every entry in that file; omacom#13250 row covers actions; omacom#10340 reproduces but is a ranking-policy change (omacom#12223). - Clip notes: this branch carries upstream 821ae58 (was e332dc9); ff77cd0 is the first commit of omacom#13968 (head b2dae8d), with the reproducers re-run on 821ae58 and b2dae8d; no internal branch names; the omacom#13012 back-from-search note names the KI-MENU-BACK-FILTERED-INDEX test instead of a removed script.
- KI-MENU-JSONC-ARRAY-ROOT: the title says an array root is read as entries with ids 0, 1, ...; label-only elements stay hidden and the rest show under the user's own labels, so nothing says the file is wrong (omacom#13492). - KI-MENU-REQUEST-LIFECYCLE: nothing bounds the wait; a superseded caller, or one whose menu process dies, polls forever (19 of 20 in a burst on quattro c05d901). omacom#9056 (b7bd59c) answers a superseded request and fixes the busy-writer race; a deadline in omarchy-menu-select is still needed for a dead menu process. - KI-MENU-JSONC-INLINE-COMMENT: the missing entries are visible, but nothing says why (omacom#13493). - Fix lines name the requirement in the proof layer. - Plain-language customer impact on the five menu known issues. - Evidence refreshed (reproducers re-run); front page names engine 2dabc50.
Applies the full upstream PR diff (158e8cf..b7bd59c: 0b4fe29 "Answer an abandoned menu request before starting the next one" + b7bd59c "Write each menu answer in a process of its own") with a 3-way apply. Conflicts: Menu.qml - the deleted resultProc Process block carried the baseline annotation "// Implements: SW-REQ-260922-FGZQ"; it is deleted with the block (FGZQ stays implemented by applyDmenuSelection). menu-test.sh - the PR's two source assertions are kept right after the "mouse activation" assert, ahead of the baseline proof witness blocks. Product diff vs baseline is line for line the upstream diff, plus that one removed annotation line. menu-test.sh: 210 ok. Upstream-Head: b7bd59c Baseline: 1e43373 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…t (superseded caller fixed, dead menu process open) The baseline merge carried quattro's description, mitigation and customer impact, which say a superseded caller waits forever. On this mirror omacom#9056 answers the superseded caller as cancelled; the hang remains only when the menu process dies (omarchy-menu-select has no deadline), as posted on omacom#9056 and omacom#9057. The first note names this mirror's baseline, quattro-proof 41076fd. Evidence refreshed (box). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ro-proof 1e43373) Mirror of omacom#9056 at head b7bd59c: the upstream change applied onto quattro-proof 1e43373, followed by the proof work for the review. This commit changes no file; it records the mirror at the branch tip, where the review pipeline reads it (Proof-* trailers). Proof-Change-Key: pr/9056 Proof-Upstream-Repo: github.com/omacom/omarchy Proof-Mirror-Of: refs/pull/9056/head Proof-Upstream-Head: b7bd59c Proof-Head-Ref: fix-menu-summon-orphans-request Proof-Change-Base: 158e8cf Proof-Base-Ref: quattro Proof-Baseline: 1e43373 Proof-Baseline-Ref: quattro-proof Proof-Previous-Mirror: b1fd500
…ow the PR's displaced-request answer - test/reports/report-cmulr95nw0kqr1gw46i7f50xj.sh keeps a stand-in shell alive and puts the tree's bin/ on PATH (the callers now look up the shell that took their request), and also runs the releaseProc writes of a revision that answers a displaced request through finishDoneFile. On this tree it exits 0: both callers are answered. - test/node/report-reproducers.test.mjs: the omacom#9057 expectation flips to the fixed behaviour (as on the omacom#9056 mirror). - KI-MENU-REQUEST-LIFECYCLE: note on the two legs omacom#9031 fixes (re-summon, dead menu process) and the one it leaves (busy resultProc); mitigation and customer impact for this mirror; reproducer back to the static green tripwire pocs/menu-qml-static.sh. - test/bdiff/harness.mjs: Verifies annotation for the replay of the displaced-request answer (SW-REQ-260922-C8HX). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The merge from quattro brought in selectionProc, which queues root.requestSerial with every immediate-save toggle and assigns it to an int property before starting the save. This branch had removed requestSerial along with the shared answer process, so each toggle queued undefined, the assignment threw, and no checkbox change in a menu like the typing pickers was ever saved. requestSerial and its two increments are back. The merge also brought back resultProc, which nothing starts any more and which still read the removed applySerial, and it dropped the two menu-test assertions that guard the open() answer and the per-answer process. resultProc goes again, the assertions return, and a third pins requestSerial in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The merge from What was wrong. What changed. What ran, on the worker:
Second opinion: Codex Medium reviewed the pull request as it now stands and found no defects. It agreed that nothing else depends on the removed process closing the menu, and that no path calls This is waiting on CI, then on the maintainer. |
|
This branch no longer merges with The conflict. It is only in The competing fix. #7826 (wico216, opened 2026-08-22, already labelled Second opinion: Codex Medium and muse-wonder via pi (thinking high) were each given both pull requests without my conclusion. Both found that each one fixes the cause and breaks nothing, including the on-change checkbox saves, and both picked #7826 under the rule that the older fix wins unless the newer one is clearly better. Their answers matched mine, so their independence is not guaranteed. This was source review only, and nothing ran on a worker this time. This is waiting on the maintainer to choose between #7826 and this one. |
|
Thanks for merging What the merge changed. The The competing fix. #7826 (wico216, opened 2026-08-22) fixes the same stranded I didn't run this head on a worker this time. Its Next: it waits on the maintainer to choose between the two. You don't need to do anything unless they ask for this one. |
| property int requestSerial: 0 | ||
| property int applySerial: 0 | ||
| property var items: ({}) |
There was a problem hiding this comment.
Removing applySerial breaks choosing a row in the keybindings menu. activateIndex() still runs applySerial = requestSerial before closing the menu or running the chosen command. Assigning to that undeclared name raises a QML error, so clicking a row or pressing Enter leaves the menu open and does nothing.
Remove the leftover assignment along with the unused resultProc, or restore the property.
|
At There is one piece of coverage to preserve from this branch: its active-request guard in I compared the current diffs of #7826, #9031, #9056 and #17239. Opus 5.5 High and muse-wonder via pi, thinking high, also reviewed them and selected the older #7826 with that coverage folded in. That agrees with my source review as GPT-6 in Codex (effort not exposed); independence is not guaranteed. This pull request stays open, waiting on the maintainer’s choice between the competing fixes. Nothing was pushed or marked verified in this run. |
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>
Summary
Repeating a menu-summoning keybinding (e.g.
Super+Kfor the Keybindingscheat sheet) before the previous popup was answered leaks a permanently
stuck
omarchy-menu-selectprocess per extra press. On a real system thisaccumulates into hundreds of orphaned processes over time.
Fixes #9057.
Root cause
bin/omarchy-menu-selectcreates adoneFile, asks the shell to summonomarchy.menu, then polls for that file:In
shell/plugins/menu/Menu.qml,open(payloadJson)dispatches to eitheropenDmenu()(select/input requests) oropenRoute()→openExistingMenu()(plain menu routes). Both unconditionally overwrite
selectionFile/doneFile/requestActivewith the new request's values:If a request is already in flight (its caller is still polling for a
doneFilethat hasn't been written yet), neither function finishes it —they just drop the reference to its files. Nothing will ever create that
doneFile, so the earlieromarchy-menu-selectprocess spins in itssleep 0.05loop forever.cancel()already handles this correctly for the normal close path:open()just doesn't call it before replacing the in-flight request.Fix
Finish any active request as cancelled at the top of
open(), beforedispatching to either
openDmenu()oropenRoute():This reuses the existing
finishRequest()plumbing (same ascancel()),so the superseded request's
doneFileis always written and its callerexits (with an empty selection, i.e. as if cancelled) instead of hanging.
Repro
Before this change, that count grows by one per invocation and never
drops. Full diagnostics and root-cause writeup are in #9057.
Test plan
keybinding several times without dismissing, then check
ps aux | grep omarchy-menu-selectdrops back to 0 shortly after.omarchy restart shellafter the change, exercise the menu normally(open, select, cancel, reopen) to confirm no regression to the usual
flow.
./test/alland the graphical acceptance suite, which peragents/skills/acceptance-tests.mdrequire a disposable VM via thesibling
omarchy-isorepo, not available in this environment.