fix(web): reset shortcut modifiers after dictation paste - #11
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a1f704c6b5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| window.addEventListener("keydown", onKeyboardEvent, true); | ||
| window.addEventListener("keyup", onKeyboardEvent, true); | ||
| window.addEventListener("blur", onWindowBlur); | ||
| window.addEventListener("paste", onResetEvent, true); |
There was a problem hiding this comment.
Preserve held modifiers across ordinary paste
When a user performs a normal Ctrl/Cmd+V paste and continues holding Ctrl/Cmd, the capture-phase paste handler resets the state even though the modifier remains physically held. The following V keyup or number keydown cannot restore it because non-modifier events now only clear flags, so sidebar jump hints stay hidden until the user releases and presses the modifier again.
Useful? React with 👍 / 👎.
| ctrlKey: currentState.ctrlKey && event.ctrlKey, | ||
| altKey: currentState.altKey && event.altKey, |
There was a problem hiding this comment.
Preserve AltGraph's reported Alt state
On Windows/Linux layouts where AltGraph is emitted as a Control keydown followed by an AltGraph event carrying both ctrlKey and altKey, AltGraph is not normalized as a modifier here. This conjunction therefore retains Ctrl but refuses to set Alt, making the state look like an exact Ctrl-only chord; downstream shouldShowThreadJumpHintsForModifiers can consequently display the default mod+1..9 jump hints while the user is typing AltGr characters.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6cb39cdf6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const eventWithModifierFlags = event as ClipboardEvent & Partial<ShortcutModifierFlags>; | ||
| return { | ||
| metaKey: eventWithModifierFlags.metaKey === true, | ||
| ctrlKey: eventWithModifierFlags.ctrlKey === true, | ||
| altKey: eventWithModifierFlags.altKey === true, | ||
| shiftKey: eventWithModifierFlags.shiftKey === true, |
There was a problem hiding this comment.
Avoid reading modifier flags from ClipboardEvent
For native Ctrl/Cmd+V, ClipboardEvent does not expose metaKey, ctrlKey, altKey, or shiftKey; this cast only suppresses the type error and does not populate those properties. Consequently, getPasteModifierFlags returns all false and shortcutModifierStateAfterPaste clears the physically held modifier, while the following V keyup cannot restore it because non-modifier events only clear state. The fresh evidence beyond the earlier comment is this follow-up's new cast-based extraction, which still leaves the normal paste path indistinguishable from an unmodified synthetic paste.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 315649ad6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (event.type === "keydown") { | ||
| keyboardPastePendingRef.current = | ||
| event.key.toLowerCase() === "v" && (event.metaKey || event.ctrlKey); |
There was a problem hiding this comment.
Reset modifiers after injected keyboard pastes
In the web/desktop shortcut-state hook, a dictation tool that injects Control/Meta keydown, V keydown, and paste but omits the matching keyup is classified as keyboard-initiated here. The paste handler then preserves the held modifier, leaving the thread-jump hints stuck—the failure this change is intended to fix. The paste reset must distinguish ordinary keyboard input from an injected sequence without relying only on the preceding V keydown.
AGENTS.md reference: AGENTS.md:L142-L142
Useful? React with 👍 / 👎.
| ctrlKey: event.type === "keydown", | ||
| altKey: event.type === "keydown", |
There was a problem hiding this comment.
Preserve independently held modifiers on AltGraph release
When a user keeps a separate Control or Alt key held while releasing AltGraph, these assignments unconditionally clear both flags. Because the new non-modifier path can only clear state, a subsequent number keydown cannot restore the still-held modifier, so jump hints remain hidden until that modifier is released and pressed again. Preserve modifier flags that remain active independently of AltGraph.
AGENTS.md reference: AGENTS.md:L142-L142
Useful? React with 👍 / 👎.
Summary
Reset shortcut modifier state after paste and prevent poisoned browser modifier flags from marking modifiers as held.
Validation
Upstream reference: pingdotgg/t3code#8189