Repository navigation
Stop the keybindings cache key flipping on menu keyboard focus - #8229
HoneyTyagii wants to merge 9 commits into
Conversation
While an Omarchy menu holds exclusive keyboard focus, Hyprland reports no active keymap, so hashing the 'active keymap:' line from hyprctl devices gave every other Super+K a second cache name: a cold rebuild that deleted the cache the next press wanted. Nothing in the built records reads that keymap (keycode resolution goes through xkbcli and the configured XKB defaults), so hash only hyprctl binds.
Quattro moved the cache marker to v14 while still hashing the active keymap, so this fix now bumps it to v15 to keep a key that no longer depends on the keymap distinct from every earlier one. The regression test sits after quattro's new terminal-bind test, since it rewrites the hyprctl stub for the rest of the file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Reviewed and verified on a disposable Omarchy worker running Hyprland 0.56.2. The fix holds. Reproduction. On quattro, dropping just your new test in fails with two cache names for identical binds. On this branch the test passes. I also ran the real script against live Hyprland on the worker, with Pushed. This branch conflicted with quattro, which had since moved the marker to v14 and added a terminal-bind test at the end of the same test file. I merged quattro into the branch (0939ae3) and resolved the conflict. The key still leaves out the keymap line, and the marker is now v15. Your test sits after the terminal-bind test, because it rewrites the hyprctl stub for the rest of the file. No rebase or force-push; your commit is unchanged. Tests. Second opinion. None this run. The configured reviewer (Codex Medium) had reached its daily review limit, so only one model (Claude Opus 5.5) reviewed this change. It waits on that second review before it can go to the maintainer as ready. Nothing is needed from you. |
Pairing and sorting happen before a record reaches the cache, and the cache key hashes only the version, the active keymap and `hyprctl binds`. So on a machine whose keymap and binds have not moved, the menu goes on serving the rows the previous version laid out and none of the sorting above reaches the user until something unrelated happens to change their binds. The version skips v15 on purpose: omacom#7564 and omacom#8229 are both open and both take it, and a merge that agrees on the same literal from both sides resolves silently into no bump at all.
The scan folds a tab in a description to a space so the record it prints keeps its fields, but the menu looked the bind up by the description `hyprctl binds` reported, tab and all, so the two keys could never meet: the bind came back with no id and no dispatcher. The reported description reaches the tab delimited record too, where the menu reads the back half of a label as the dispatcher it would run -- a bind labelled "Tabbed\tkillactive" dispatches killactive when it is picked, on quattro as much as here. So fold the delimiters out of the reported description the same way, and cut the scan's copy at the first newline, which is where hyprctl's own output cuts the description it reports. Bump the cache version, or an install that already cached a broken record keeps serving it. The literal skips to v17 because v15 is taken by omacom#7564 and omacom#8229 and v16 by omacom#13888, all open: two branches setting that line to the same value merge with no conflict and leave no bump at all. A comma in a label still shifts the fields of the intermediate record, here and on quattro alike. That one is the record format itself, not this lookup.
The records are sorted before they are cached, and the cache key hashes the version literal, the active keymap and `hyprctl binds` -- none of which moves when this script's sort does. So an install that already has a cache keeps serving the order it was written with, and since en_US.UTF-8 is the default locale that is most installs: the pinned order would arrive later, at some unrelated moment when a bind or the keymap changed. Measured over one cache directory and the two chords that swap, the new script printed the old script's en_US order byte for byte. Bump the version so that cache is retired, and plant a record under the key the previous version would have written, so that changing the order without a bump fails here rather than in a user's menu. The literal skips to v18 because v15 is taken by omacom#7564 and omacom#8229, v16 by omacom#13888 and v17 by omacom#12557, all open: two branches setting that line to the same value merge with no conflict and leave no bump at all. omacom#13521 bumped v13 to v14 for a records change the same way.
quattro added the platform key-names file to the cache key and moved the marker to v15. The key keeps the key-names file, still leaves out the active keymap line, and the marker is now v16. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The comment said keycodes resolve through the user's configured XKB defaults. xkbcli compile-keymap without --enable-environment-names compiles its built-in defaults and ignores XKB_DEFAULT_* as well as Hyprland's layout, which is the actual reason the keymap line contributes nothing to the records. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
[Low impact] The PR appears safe to merge. SummaryStops the keybindings cache from changing when a menu takes keyboard focus.
No actionable issues found. Tests were reviewed but not run. Reviews (3) · Last reviewed commit: "Require a records cache before checking ..." · Reviewed by Greptile |
|
This branch stopped merging cleanly after quattro changed the same cache key, so I brought it across again and re-verified it on a disposable Omarchy worker. The fix holds. Pushed. quattro (#14431, #14433) added the platform key-names file to the cache key and moved the marker to v15. I merged quattro into the branch (f3e70a3) and resolved the conflict. The key keeps the key-names file and still leaves out the Reproduction. I ran the real script against live Hyprland on the worker, switching between Tests. On the worker: Second opinion. Codex Medium reviewed it in two rounds. In the first it found no defect in the fix or the merge, and it spotted the inaccurate comment, which I confirmed before correcting it. In the second it reviewed the corrected head and had nothing open. Independence is not guaranteed, because the reviewer can read this session's work. It now waits on the maintainer. Nothing is needed from you. |
…criptions quattro now keys the cache on the Omarchy language and its keybindings catalog and bumped the version to v16. Keep both of those inputs, leave the active keymap out as this branch does, and bump to v17 so caches written under quattro's v16 key are not reused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This stopped merging cleanly after quattro started translating keybinding descriptions (#15326), which also changed the cache key. I merged quattro into the branch again (abe7994). The cache key now keeps everything quattro added (the Omarchy language and its keybindings catalog) and still leaves out the active keymap line, as this fix intends. The version moves to v17 so no cache written under quattro's v16 key is reused. The test file keeps both quattro's translation test and the cache test from this PR. Checked on a worker built from the Omarchy ISO, against quattro at 84cfb93:
Second opinion: Codex Medium reviewed the merged head and found no defects. It agreed that nothing in the rendered records reads the active layout, since keycodes resolve through xkbcli's default keymap. It also agreed that the merge keeps quattro's inputs and that the test is not vacuous. It can read this review's reasoning, so its agreement is not independent. This is ready for the maintainer to decide on. Nothing is waiting on the author. |
…yout Quattro now resolves keycode names through the configured leading layout and puts that in the cache key, so the key keeps leading_keyboard and still leaves out Hyprland's active keymap line, which flips while a menu holds keyboard focus. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
This conflicted with Checked on a worker built from the Omarchy ISO, at 2f364f3:
Codex Medium reviewed the merged diff as a second opinion and found nothing; it agreed with the reading above, and its independence is not guaranteed. This now waits on the maintainer. |
|
This conflicts with I didn't bring it across or re-verify it in this run. A change since the last check needs a second model to confirm what kind of change it is, and that model's daily review allowance was already used up. Only Claude Opus 5.5 looked at it this time. Nothing in the fix itself has changed since the last verified head (2f364f3). It will be picked up again once a second review can run. Nothing is needed from you. |
…focus Keep the batched Hyprland query and Lua source invalidation from quattro, removing the device query from both batched and fallback cache keys. Preserve both sets of regression coverage. This also brings in the base fixes for the translation test failure reproduced on the previous head and its merge base. Co-Authored-By: Codex High <[email protected]>
Make the batch stub return device state only when requested, then assert a layout switch reuses the records file and its inode. This catches devices being reintroduced into the default query while retaining the existing fallback regression. Co-Authored-By: Codex High <[email protected]> Co-Authored-By: Opus 5.5 High <[email protected]>
Fail if stat cannot find the initial cache, so two empty command outputs cannot satisfy the cache identity assertion. Co-Authored-By: Codex High <[email protected]> Co-Authored-By: Opus 5.5 High <[email protected]>
|
I merged current Checked on a disposable Omarchy ISO worker with Hyprland 0.57.2: 143 CLI checks and 38 keybindings checks pass, along with the structural translation test and extraction check. The new batch regression fails on Codex High reviewed the change. Opus 5.5 High reviewed the final head and found nothing left after its batch-coverage and cache-existence findings were fixed. muse-wonder via pi, thinking high also reviewed the earlier candidate. Their agreement is not guaranteed independent. #14659 remains open as an alternative for #8140. Greptile scored this head 5/5 with no findings. This waits on the maintainer: Tests and Check translation structure both require workflow approval and have started no jobs, so GitHub CI has not passed. The old failed run’s logs are no longer available; locally, the old head and its merge base share the same locale-generation failure, while current |
Fixes #8140.
The bug
keybindings_cache_key()hashed theactive keymap:line fromhyprctl devicesalongsidehyprctl binds. While an Omarchy menu holds exclusive keyboard focus, Hyprland stops reporting an active keymap altogether, so the same binds produced two different cache names depending on whether a menu was open. Each successful refresh deletes sibling caches (find ... ! -name "" -delete), so every alternating press paid a ~540ms cold rebuild and threw away the cache it had just replaced. On the reporter's machine that meant Super+K was slow on nearly every press.The fix
Hash only what the records are built from:
hyprctl devicesline from the hash. Nothing in the pipeline consumes the session's active keymap: keycode resolution goes throughxkbcli compile-keymap, which reads the user's configured XKB defaults, not Hyprland's transiently reported keymap.The sibling-cache cleanup stays as is: with a stable key there is normally exactly one live cache, and the deletion still clears stale entries after real config changes.
Verification
Added a regression test in
test/shell.d/keybindings-menu-test.sh: it renders once with the stub reportingactive keymap: English (US), flips the stub to report no keymap (the state while a menu has focus), renders again, and asserts both runs land on one records file and render identically.6e9583...vs197c92...).keybindings-menu-test.sh,bin-style-test.sh, and./test/cliall pass.