Improve terminal navigation shortcuts and streamline git action PR flow#42
Conversation
WalkthroughAdds platform-aware terminal navigation shortcut handling via a new Changes
Sequence DiagramsequenceDiagram
actor User
participant Drawer as ThreadTerminalDrawer
participant Keybindings
participant Terminal as TerminalViewport
User->>Drawer: Press arrow key + modifier
Drawer->>Keybindings: terminalNavigationShortcutData(event, platform)
alt Navigation shortcut detected
Keybindings-->>Drawer: Return navigation sequence
Drawer->>Drawer: preventDefault & stopPropagation
Drawer->>Drawer: sendTerminalInput(sequence, "Failed to move cursor")
Drawer->>Terminal: Write navigation data
Terminal-->>User: Cursor moves
else No shortcut match
Keybindings-->>Drawer: Return null
Drawer->>Drawer: Continue to other handlers (clear shortcut, default)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
Add terminal navigation shortcut handling and unify terminal input writing in
|
Greptile SummaryEnhanced terminal with keyboard shortcuts for cursor navigation by adding support for platform-specific word and line movement using modifier keys with arrow keys.
Confidence Score: 5/5
Important Files Changed
Flowchartflowchart TD
A[Keyboard Event] --> B{terminalNavigationShortcutData}
B --> C{Is Shift Key?}
C -->|Yes| D[Return null]
C -->|No| E{Is ArrowLeft/Right?}
E -->|No| D
E -->|Yes| F{Platform?}
F -->|macOS| G{Modifier Key?}
F -->|non-macOS| H{Modifier Key?}
G -->|Option/Alt only| I[Word Movement<br/>ESC+b or ESC+f]
G -->|Cmd/Meta only| J[Line Movement<br/>Ctrl-A or Ctrl-E]
G -->|Other| D
H -->|Ctrl only| I
H -->|Alt only| I
H -->|Other| D
I --> K[sendTerminalInput]
J --> K
K --> L[api.terminal.write]
L --> M[Terminal Updates Cursor]
Last reviewed commit: 9547718 |
- handle platform-specific modifier+arrow combos in terminal input - reuse terminal write path for clear and navigation actions - add shortcut tests for macOS and non-macOS mappings
35f153c to
9547718
Compare
|
@greptileai review |
|
@greptileai review |
- guard terminal clear/navigation shortcut handlers to only process `keydown` - add tests verifying `keyup` events are ignored
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/web/src/keybindings.test.ts (1)
357-366: Consider adding a test for Alt+Arrow on non-macOS platforms.The implementation at
keybindings.tslines 265-267 supports Alt+Arrow for word movement on non-macOS platforms, but this behavior isn't covered by tests. Adding a test would ensure this code path remains functional.🧪 Suggested test addition
it("maps Ctrl+Arrow on non-macOS to word movement", () => { assert.strictEqual( terminalNavigationShortcutData(event({ key: "ArrowLeft", ctrlKey: true }), "Win32"), "\u001bb", ); assert.strictEqual( terminalNavigationShortcutData(event({ key: "ArrowRight", ctrlKey: true }), "Linux"), "\u001bf", ); }); + + it("maps Alt+Arrow on non-macOS to word movement", () => { + assert.strictEqual( + terminalNavigationShortcutData(event({ key: "ArrowLeft", altKey: true }), "Win32"), + "\u001bb", + ); + assert.strictEqual( + terminalNavigationShortcutData(event({ key: "ArrowRight", altKey: true }), "Linux"), + "\u001bf", + ); + });
…icker Port upstream commits 3d35868..f70cb5d: - Add pull-request thread setup for local and worktree modes (pingdotgg#42) - Refine branch picker behavior and gate /checkout-pr by thread type (pingdotgg#43) Includes PR resolution via GitHub CLI, worktree-aware PR checkout, shared branch picker filtering, deferred query, conditional virtualization, and /checkout-pr gating to local draft threads only.
adds basic terminal navigation
Summary by CodeRabbit
New Features
Tests