Skip to content

feat(desktop): add word-navigation hotkeys#1149

Merged
Kitenite merged 2 commits into
superset-sh:mainfrom
ascrazy:codex/terminal-word-nav-hotkeys
Feb 3, 2026
Merged

feat(desktop): add word-navigation hotkeys#1149
Kitenite merged 2 commits into
superset-sh:mainfrom
ascrazy:codex/terminal-word-nav-hotkeys

Conversation

@ascrazy
Copy link
Copy Markdown
Contributor

@ascrazy ascrazy commented Feb 2, 2026

Description

Adds word‑navigation hotkeys in the desktop terminal:

  • macOS: Option+Left/Right → move by word
  • Windows: Ctrl+Left/Right → move by word

Implemented via xterm keyboard handler to send Meta+B/F sequences, and added unit tests for both platforms.

Related Issues

Type of Change

  • [-] Bug fix
  • New feature
  • [-] Documentation
  • [-] Refactor
  • [-] Other (please describe):

Testing

  • Added some tests to helpers.test.ts

Manual testing

  • Start the desktop app cd apps/desktop && SKIP_ENV_VALIDATION=1 bun run dev
  • Create new workspace
  • Open new terminal tab
  • Type "hello very long long word" into the terminal
  • Use option+left / option+right to navigate across your input

Screenshots (if applicable)

Before After
ScreenRecording2026-02-02at22 11 06-ezgif com-video-to-gif-converter ezgif-4cb6aed55590a808

Additional Notes

-

Summary by CodeRabbit

  • New Features

    • Added platform-specific keyboard shortcuts for word-level cursor navigation in the Terminal:
      • macOS: Option+Left/Right Arrow for backward/forward word movement
      • Windows: Ctrl+Left/Right Arrow for backward/forward word movement
  • Tests

    • Added tests covering keyboard mapping and event handling for macOS and Windows shortcuts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Terminal keyboard handler & tests
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.ts, apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.test.ts
Added setupKeyboardHandler(xterm, { onWrite }) implementing platform detection and mapping Option+Arrow (macOS) / Ctrl+Arrow (Windows) to word-movement escape sequences (Meta+B / Meta+F). Tests mock navigator.platform, capture attachCustomKeyEventHandler, and assert correct onWrite calls and default-prevention behavior.

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)
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Option, Ctrl — I hop and bind,
Arrow turns into words I find,
On Mac and Windows I do play,
Hopping cursors on their way,
A rabbit's cheer for keys aligned 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(desktop): add word-navigation hotkeys' clearly summarizes the main change—adding keyboard shortcuts for word-level navigation in the terminal.
Description check ✅ Passed The description covers all required template sections: clearly explains the feature, includes Type of Change, provides both automated and manual testing instructions with detailed steps, includes before/after screenshots, and addresses all major template fields.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ascrazy ascrazy marked this pull request as ready for review February 2, 2026 21:15
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite left a comment

Choose a reason for hiding this comment

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

Nice this works, thanks @ascrazy !

@Kitenite
Copy link
Copy Markdown
Collaborator

Kitenite commented Feb 3, 2026

Will need to refactor these kind of hotkeys outside of the component for maintainability but can do later

@Kitenite Kitenite merged commit 85e8816 into superset-sh:main Feb 3, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants