fix: repeat copy-mode navigation keys - #2372
Conversation
📝 WalkthroughWalkthroughCopy-mode navigation now supports explicit terminal key-repeat events for arrows, Page Up/Down, Home, and End. Dedicated input leases route these events through copy-mode handling while preserving existing repeat behavior for other keys. ChangesCopy-navigation repeat handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Terminal
participant AppState
participant InputLeaseTable
participant CopyModeHandler
Terminal->>AppState: Send key press
AppState->>InputLeaseTable: Record RepeatCopyNavigation
Terminal->>AppState: Send KeyEventKind::Repeat
AppState->>InputLeaseTable: Check copy-navigation lease
AppState->>CopyModeHandler: Replay navigation repeat_count times
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/app/input/copy_mode.rs (1)
1187-1199: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for both repeat routers.
This test exercises
App::route_client_input, which covers the headless routing path. The PR also changessrc/app/runtime.rs, and the allowlist includes PageUp, PageDown, Home, and End. Add one runtime-path test and cases for the remaining allowlisted keys.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e08b7c75-531f-4917-9e1a-26f5e9b923ae
📒 Files selected for processing (5)
docs/next/CHANGELOG.mdsrc/app/input/copy_mode.rssrc/app/input/lease.rssrc/app/mod.rssrc/app/runtime.rs
|
@coderabbitai review |
|
|
Though I'm interested in this fix , when i |
3638cce to
7cce478
Compare
|
@joonhwan Thanks for catching this you were right. The original allowlist covered only non-character navigation. 7cce478 now includes |
Greptile SummaryThe PR makes explicit repeat events replay copy-mode navigation while preserving single-shot modal actions and input-source ownership.
Confidence Score: 5/5The PR appears safe to merge with no actionable correctness or security issues identified. The local and headless paths consistently establish, replay, and release copy-navigation leases, while the allowlist and mode guards keep non-navigation actions single-shot.
|
| Filename | Overview |
|---|---|
| src/app/input/copy_mode.rs | Adds a tightly scoped repeatability predicate and tests covering navigation, modal-action exclusions, search prompts, prefixes, and platform-specific repeat events. |
| src/app/input/lease.rs | Adds a dedicated consumed-lease disposition used to retain copy-navigation ownership across explicit repeat events. |
| src/app/mod.rs | Extends headless/client event routing to establish copy-navigation leases on presses and replay matching repeat events. |
| src/app/runtime.rs | Mirrors the copy-navigation lease and replay behavior in the asynchronous local-input runtime path. |
| docs/next/CHANGELOG.md | Documents repeat support for copy-mode navigation and continued single-shot handling for other actions. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Raw key event] --> B[Normalize against input lease]
B --> C{Press or Repeat?}
C -->|Press| D{Copy-mode navigation?}
D -->|Yes| E[Execute navigation once]
E --> F[Store RepeatCopyNavigation lease]
D -->|No| G[Use normal input routing]
C -->|Repeat| H{Matching copy-navigation lease and Copy mode active?}
H -->|Yes| I[Replay navigation repeat_count times]
H -->|No| J[Use normal repeat plan]
K[Key release] --> L[Remove lease]
Reviews (1): Last reviewed commit: "fix: repeat copy-mode navigation keys" | Re-trigger Greptile
This feature now works in windows 11 / wt.exe ! The test results follow.
[1] : no input from repeating keys after exiting cursor mode, which is qood BTW, since I've been using herdr, i've not have any chance to use "n/N" keys successfully(like. |
|
Thank you for working on the copy-mode key repeat! This behavior has bothered me too, so I'm glad to see a fix in progress. One suggestion: could the repeat decision be based on what the key press actually did, instead of a list of keys? As analyzed in #2371, what this suppression needs to prevent is: a key triggers an action that leaves the mode, the key is still held, and the remaining repeats leak into the next mode as input. If so, whether a held key is safe to repeat is decided by the action it triggered, not by which key it is bound to. Currently One more reason: if copy-mode keybindings become configurable in the future (I proposed this in #587), a hardcoded key list stops working — for example, binding cursor-up to ctrl+p would leave it non-repeating. Deciding from the result of the press keeps working no matter how keys are rebound. |
Summary
Ctrl-B/F/U/DReproduction
macOS Ghostty reports held keys as Kitty
Repeatevents; Windows can report repeated native presses. Before this change, those paths moved once in copy mode. The patched build repeats navigation continuously without allowing action-key repeats to escape the mode.Tests
just checkRefs #2371