feat(desktop): add word-navigation hotkeys#1149
Conversation
📝 WalkthroughWalkthroughAdds a new setupKeyboardHandler function that intercepts terminal key events and maps platform-specific word-navigation shortcuts (macOS: Option+Left/Right, Windows: Ctrl+Left/Right) to Meta+B/Meta+F escape sequences; includes tests validating mapping and onWrite usage. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Browser
participant setupKeyboardHandler
participant XTerm
participant onWrite
User->>Browser: press Option/Ctrl + Arrow
Browser->>setupKeyboardHandler: keydown event
setupKeyboardHandler->>XTerm: attachCustomKeyEventHandler callback invoked
XTerm->>setupKeyboardHandler: passes KeyboardEvent to handler
setupKeyboardHandler->>onWrite: emit escape sequence (e.g., Meta+B / Meta+F)
onWrite->>XTerm: terminal receives input data
setupKeyboardHandler-->>Browser: return false (prevent default)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.test.ts`:
- Around line 33-37: The test file uses "as unknown as XTerm" but never imports
the XTerm type, causing TS errors; add a type-only import for the xterm terminal
type (for example: import type { Terminal as XTerm } from "xterm") at the top of
the test so the casts in helpers.test.ts (the "as unknown as XTerm" uses)
compile correctly.
🧹 Nitpick comments (1)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.test.ts (1)
128-131: Refactor assignment-in-expression to explicit function body.Static analysis flags this pattern as confusing. Extract the assignment to an explicit block for clarity.
Proposed fix
const xterm = { - attachCustomKeyEventHandler: (next: (event: KeyboardEvent) => boolean) => - (handler = next), + attachCustomKeyEventHandler: (next: (event: KeyboardEvent) => boolean) => { + handler = next; + }, };Apply the same change at line 163-164.
|
Will need to refactor these kind of hotkeys outside of the component for maintainability but can do later |
Description
Adds word‑navigation hotkeys in the desktop terminal:
Implemented via xterm keyboard handler to send Meta+B/F sequences, and added unit tests for both platforms.
Related Issues
Type of Change
Testing
Manual testing
cd apps/desktop && SKIP_ENV_VALIDATION=1 bun run devoption+left/option+rightto navigate across your inputScreenshots (if applicable)
Additional Notes
-
Summary by CodeRabbit
New Features
Tests