Skip to content

🐞 Fix stale isLoopOpen check causing action keys to leak to focused app#1096

Merged
mrkai77 merged 1 commit into
mrkai77:developfrom
bit-saver:fix/consume-stale-isloopopen
May 11, 2026
Merged

🐞 Fix stale isLoopOpen check causing action keys to leak to focused app#1096
mrkai77 merged 1 commit into
mrkai77:developfrom
bit-saver:fix/consume-stale-isloopopen

Conversation

@bit-saver
Copy link
Copy Markdown
Contributor

Summary

In KeybindTrigger.performKeybind, the normal (non-bypassed) keybind branch returns its consume/opening decision based on the isLoopOpen value captured at the top of the function — i.e. before openLoop() ran. When Loop's open-state hasn't propagated by the moment that stale value is read (easy to lose when the trigger key and action key are pressed in rapid succession), the function returns .opening and the caller forwards the action key to the frontmost app.

The symmetric bypassed-action branch 16 lines below already uses checkIfLoopOpen() (fresh check) for the same return decision, and the inline comment immediately above the affected line documents the intent:

Only consume the event if the last command actually opened Loop.

The stale check contradicts that comment; the fresh check honors it. This appears to be an oversight in the non-bypassed branch.

Change

One line in Loop/Core/Observers/KeybindTrigger.swift:

-                    return isLoopOpen ? .consume : .opening
+                    return checkIfLoopOpen() ? .consume : .opening

Symptom this fixes

When holding the trigger key and pressing an action key (e.g. Globe + W bound to Maximize), the action runs but the action key also reaches the focused app, triggering unwanted typing or app shortcuts. Reproducible on macOS 26.3 against the current develop branch.

Verification

With the patch applied, action chords cleanly resize the window without leaking the action key. Bypassed actions continue to work as before (they already used the fresh check). No other behavior change.

I'm running a locally built copy of develop with this single-line fix and have verified the leak is gone in TextEdit and a few other apps.

In KeybindTrigger.performKeybind, the normal (non-bypassed) keybind
branch returned a consume/opening decision based on the isLoopOpen
value captured at the top of the function, *before* the openLoop()
call on the preceding line had a chance to update Loop's state. When
the trigger key and action key are pressed in rapid succession, this
loses the race and returns .opening, which forwards the action key
to the frontmost app.

The bypassed-action branch 16 lines below already uses the fresh
checkIfLoopOpen() for the same return decision. The inline comment
on lines 193-194 documents the intent ("Only consume the event if
the last command actually opened Loop") which the fresh check
honors and the stale check contradicts.
@mrkai77 mrkai77 changed the title Fix stale isLoopOpen check causing action keys to leak to focused app 🐞 Fix stale isLoopOpen check causing action keys to leak to focused app May 11, 2026
Copy link
Copy Markdown
Owner

@mrkai77 mrkai77 left a comment

Choose a reason for hiding this comment

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

Thank you! For future PRs, please use our PR template instead of creating your own. Since this is a relatively small change, though, I’ll go ahead and merge it :)

@mrkai77 mrkai77 merged commit 2ea3561 into mrkai77:develop May 11, 2026
1 check passed
@mrkai77 mrkai77 added the Bug label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants