Repository navigation
fix(desktop): read and plan the keymap before the text grab - #257
Merged
Merged
Conversation
Parse the keymap and plan bindings before the server grab. Under the grab, reread the live map and reuse the plan only when every reply is byte-identical apart from its sequence number; otherwise plan again under the grab. Changes, verification and every liveness check stay under the grab, and X11_GRAB_MS stays at 250 ms. Refs #222
A fractional performance.now() start made now + 3000 - now round to 2999.999... for some start values, so floor() returned 2999 and the budget assertions failed at random. The new module mock shifted the start time into that range more often.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
desktop_typenow reads and plans the keymap before it grabs the X server, so CPU contention no longer spends the 250 ms grab bound on parsing.Under the grab it rereads the live keymap. It reuses the pre-grab plan only when the modifier, core and XKB replies are byte-identical apart from the sequence number and the keycode range matches. Any other read is planned again under the grab. Changes, the verification read, ungrab and sync all stay under the grab. Every liveness check, the 250 ms bound, the 3-attempt retry from #248, the fail-closed error and the rule that bindings are never restored are unchanged. A test clock fixture now uses whole milliseconds, because a fractional start made the budget assertions fail at random.
Closes #222
222/grab-phase-table.txt222/mutations.log222/final-alone-*.logdesktop-input-captures-live.test.ts222/captures-paired.log,captures-summary.log222/rt-*.json222/coverage-3.logEvidence lives in
~/Artifacts/pickforge-kickoff-2026-10-06/on the dev host. Under the heaviest load, the first grab can still expire. Further cuts would need pipelined keymap requests or reuse of the first free read across retries. Those options are filed as #266.