Repository navigation
Stop keybinding scans from looping on mocked APIs - #8876
yashranaway wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Prevents mocked Lua API results from causing infinite ipairs() scans.
Changes:
- Return
nilfor numeric fallback-proxy indexes. - Add a timeout-backed regression scenario.
- The test must still validate timeout success explicitly.
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 1 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
bin/omarchy-menu-keybindings |
Terminates numeric fallback iteration. |
test/shell.d/keybindings-menu-test.sh |
Adds the regression scenario and timeout. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The appended loop never executed. The scan stops at the config's first Lua error, and Omarchy's own defaults raise one at default/hypr/qconsole.lua:64 while `require("default.hypr.omarchy")` runs on hyprland.lua:14 — sixteen lines before the end of the file. Reverting the sentinel change left the test at 15 passed in 0.3s, so it proved nothing about the fix it was added for.
Prepending the loop puts it ahead of that abort: the test now times out at 5s without the sentinel change and passes with it.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Reviewed at head 62db589, with the tests run on a disposable Omarchy VM rather than locally. The hang is real and the mechanism you chose is the right one, but the regression test that shipped with it did not exercise the fix — I pushed a one-line correction for that. The rest below is for the maintainer to decide, not for you to action. The mechanism is correct, and it is the only one that works. I probed the alternatives on a worker: The regression test passes on the unfixed code. Mutation-tested: with your I pushed 6197459, which prepends the loop instead of appending it. It now times out at 5s with the sentinel change reverted and passes in under a second with it, so A consequence of that same abort: #8819's own repro does not reproduce on quattro. The reporter's loop sits in The abort is a bug of its own and costs users their bindings today. With an The change has a cost worth naming. Before it, There is a competing PR: #7564. It makes the same numeric-nil change and additionally gives the sentinel One shape neither this PR nor the sentinel closes. Checked by me and by codex at xhigh reasoning as an independent second reviewer. Codex reached the same two conclusions I did — its independence is not currently guaranteed, since it can read this session's own files — but it contributed two things I had not reasoned about. First, overriding Tests: |
|
Thanks, I reviewed the prepended regression and will leave the sentinel tradeoff and #7564 choice to maintainers. |
|
Re-reviewed at 6197459, unchanged since the last pass. This only answers the review thread above, and corrects something I got wrong in my own last comment. Copilot's comment does not hold at this head, and your fix does work — though not for the reason either of you gave. The strict mode does stop the test on a timeout. Bash's rule is that a simple command consisting only of an assignment takes the exit status of its last command substitution, so Proven by mutation on a disposable Omarchy VM rather than argued: reverting the numeric-nil guard in The partial-output scenario could not have happened even before you added strict mode. Two barriers, either one enough. The Lua scan's Strict mode is still worth keeping. It fails at the assignment rather than relying on the next assertion happening to be the emptiness check, and it time-boxes all eight scans in the file rather than one. I overstated something last time. I wrote that returning nil for numeric keys "is the only thing that works". That is right about the sentinel's own metamethods — local builtin_ipairs = ipairs
ipairs = function(value)
if value == noop then
return function() return nil end, value, 0
end
return builtin_ipairs(value)
endChecked on the same VM under Lua 5.5: Nothing else changed, and nothing is needed from you. Still waiting on the maintainer. Reviewed by Claude Opus 5 in Claude Code with a second opinion from Codex at xhigh reasoning, tests run on a disposable Omarchy VM rather than locally. Codex's first run reviewed the wrong commit and was re-run pinned to this head; the |
|
Confirming this fixes the reported case on Lua 5.5.1 — with this patch applied, Two other stubs in the same file have the identical shape and aren't covered by patching Tested with exactly this PR's change applied (only
The same guard on those two -- ipairs() stops at the first nil, so a stub whose __index answers every key is
-- an endless sequence and iterating one never terminates. Integer keys have to
-- report "no such element" instead.
local function sequence_probe(key)
return math.type(key) == "integer"
endTwo things worth recording, both dead ends on 5.5.1 — I tried them before landing on the same approach you took:
One symptom I didn't see mentioned in this PR or the linked issues: the hang doesn't only burn CPU, it silently truncates the menu. Any Verified no regression either way: against a real config the scan emits an identical 227 bindings before and after. |
|
This nil-for-numeric-index change is the right fix for the Stock #10388 (closed as a duplicate of this) added comparison and arithmetic metamethods on the noop and a regression that a user bind after If this is the one that merges, please take the qconsole stub and that user-bind assertion from #10388. Happy to reopen #10388 as a follow-up on top of this if you would rather keep this PR to the ipairs guard only. |
|
You're right about the qconsole abort; the updated scanner skips monitor sizing when no compositor is present, and a regression now checks a user bind after qconsole. |
|
Re-reviewed at 42b43b3, merged locally onto current The head fixes what it says. One side effect is new at this head.
"Aborts" means the The competing fix is #7564. It makes the same numeric-nil change on My recommendation is #7564, with this PR's No second opinion ran on this pass. The configured reviewer, Codex Medium, refused because today's review budget was already spent. Everything above is one model's review (Claude Opus 5.5 in Claude Code), checked against the worker runs described here. Waiting on the maintainer; nothing is needed from you. |
|
Confirmed the nil monitor stub can abort user configurations before later binds are recorded. I'm closing this in favor of #7564; the small numeric guards for hl and hl.dsp can be carried over if needed. |
The keybindings menu can hang on
ipairs(hl.get_monitors())and miss user bindings after loading Omarchy's console config. This fixes both paths. Addresses #8819 and #7025.<<<< AI wording below >>>>
Problem
The offline Lua scanner returns a fallback object for every unknown key.
ipairs()never seesniland can loop forever. The same scan also reachesqconsole.luawithout an active monitor; its mock raises during a numeric comparison, so the scanner stops before loading the user's bindings.Fix
Return
nilfor numeric indexes on the fallback, API, and dispatcher mocks. Returnnilfor runtime workspace and active-monitor queries while scanning config offline, allowing the console setup to skip sizing and continue to user bindings.Verification
The keybindings menu test passes in an Alpine container with Lua 5.4 and
xkbcli. It checks all three iterable mocks and confirms a user binding after Omarchy's console config renders with its chord. Shell syntax, command-style checks, andgit diff --checkpass.