Improve terminal navigation shortcuts and streamline git action PR flow#42

merged2
main
codething/70a71c65
openedFeb 14, 2026byJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 4d ago

adds basic terminal navigation


Open with Devin

Summary by CodeRabbit

  • New Features

    • Terminal now supports platform-specific navigation shortcuts (Option/Command on macOS, Ctrl/Alt on other platforms) with arrow keys for word- and line-level cursor movement.
    • Terminal keyboard handling unified so navigation and clear shortcuts are processed consistently.
  • Tests

    • Added comprehensive tests covering navigation shortcut behavior across platforms and event types.
Synced from GitHub

Walkthrough

Adds platform-aware terminal navigation shortcut handling via a new terminalNavigationShortcutData export and integrates it into the terminal drawer, which now routes navigation and clear shortcuts through a generalized sendTerminalInput function.

Changes

Cohort / File(s)Summary
Keybindings Module
apps/web/src/keybindings.ts, apps/web/src/keybindings.test.ts
Adds terminalNavigationShortcutData(event, platform) and tests; extends ShortcutEventLike with optional type; enforces keydown-only handling and maps arrow+modifier combos to terminal navigation sequences (word/line moves) with platform-specific rules.
Terminal Drawer Integration
apps/web/src/components/ThreadTerminalDrawer.tsx
Replaces specialized clear handler with a generalized sendTerminalInput(data, fallbackError) and integrates terminalNavigationShortcutData to intercept navigation shortcuts, prevent default, stop propagation, and send navigation sequences to the terminal.

Sequence Diagram

mermaid
1sequenceDiagram
2 actor User
3 participant Drawer as ThreadTerminalDrawer
4 participant Keybindings
5 participant Terminal as TerminalViewport
6
7 User->>Drawer: Press arrow key + modifier
8 Drawer->>Keybindings: terminalNavigationShortcutData(event, platform)
9 alt Navigation shortcut detected
10 Keybindings-->>Drawer: Return navigation sequence
11 Drawer->>Drawer: preventDefault & stopPropagation
12 Drawer->>Drawer: sendTerminalInput(sequence, "Failed to move cursor")
13 Drawer->>Terminal: Write navigation data
14 Terminal-->>User: Cursor moves
15 else No shortcut match
16 Keybindings-->>Drawer: Return null
17 Drawer->>Drawer: Continue to other handlers (clear shortcut, default)
18 end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 2

❌ Failed checks (2 warnings)

Check nameStatusExplanationResolution
Title check⚠️ WarningThe PR title 'Improve terminal navigation shortcuts and streamline git action PR flow' is overly broad and vague. The actual changes focus on adding terminal navigation shortcuts and refactoring terminal input handling, but the 'streamline git action PR flow' portion is not present in the changeset.Consider revising the title to focus on the core change: 'Add terminal navigation shortcuts support' or 'Refactor terminal shortcuts with navigation support', removing the unrelated 'git action PR flow' reference.
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Merge Conflict Detection✅ Passed✅ No merge conflicts detected when merging into main

✏️ 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
  • Commit unit tests in branch codething/70a71c65

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

Synced from GitHub

Add terminal navigation shortcut handling and unify terminal input writing in ThreadTerminalDrawer.TerminalViewport to streamline git action PR flow

Introduce keybindings.terminalNavigationShortcutData for macOS and non-macOS word/line navigation, gate clear shortcuts to keydown events, and route all terminal input through sendTerminalInput in ThreadTerminalDrawer.tsx.

📍Where to Start

Start with terminalNavigationShortcutData and isTerminalClearShortcut in keybindings.ts, then review sendTerminalInput integration and the custom key handler in ThreadTerminalDrawer.tsx.


Macroscope summarized b7bbcb2.

Synced from GitHub

Greptile Summary

Enhanced terminal with keyboard shortcuts for cursor navigation by adding support for platform-specific word and line movement using modifier keys with arrow keys.

  • Added terminalNavigationShortcutData function to map keyboard events to terminal control sequences (ESC+b/f for word movement, Ctrl-A/E for line movement)
  • Refactored terminal input handling to use a generic sendTerminalInput helper function
  • Integrated navigation shortcuts into the terminal's custom key event handler with proper event prevention
  • Provided comprehensive test coverage for all platform-specific shortcuts (macOS Option/Cmd, non-macOS Ctrl/Alt)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation is well-tested with comprehensive test coverage, follows existing patterns in the codebase, and properly handles platform-specific behavior. The refactoring improves code organization without changing existing functionality.
  • No files require special attention

Important Files Changed

FilenameOverview
apps/web/src/keybindings.tsAdded terminalNavigationShortcutData function to map platform-specific arrow key shortcuts (Option/Cmd on macOS, Ctrl/Alt on others) to terminal control sequences for word and line navigation
apps/web/src/components/ThreadTerminalDrawer.tsxRefactored to use generic sendTerminalInput helper and integrated terminal navigation shortcuts into the custom key event handler
apps/web/src/keybindings.test.tsAdded comprehensive test suite for terminalNavigationShortcutData covering macOS (Option/Cmd) and non-macOS (Ctrl/Alt) platforms with proper edge case coverage

Flowchart

mermaid
1flowchart TD
2 A[Keyboard Event] --> B{terminalNavigationShortcutData}
3 B --> C{Is Shift Key?}
4 C -->|Yes| D[Return null]
5 C -->|No| E{Is ArrowLeft/Right?}
6 E -->|No| D
7 E -->|Yes| F{Platform?}
8 F -->|macOS| G{Modifier Key?}
9 F -->|non-macOS| H{Modifier Key?}
10 G -->|Option/Alt only| I[Word Movement<br/>ESC+b or ESC+f]
11 G -->|Cmd/Meta only| J[Line Movement<br/>Ctrl-A or Ctrl-E]
12 G -->|Other| D
13 H -->|Ctrl only| I
14 H -->|Alt only| I
15 H -->|Other| D
16 I --> K[sendTerminalInput]
17 J --> K
18 K --> L[api.terminal.write]
19 L --> M[Terminal Updates Cursor]

Last reviewed commit: 9547718

Added 1 commit

  • Add terminal word and line navigation arrow shortcuts9547718

Added 1 commit

  • Ignore non-keydown terminal shortcutsb7bbcb2
Synced from GitHub
🧹 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.ts lines 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
diff
1 it("maps Ctrl+Arrow on non-macOS to word movement", () => {
2 assert.strictEqual(
3 terminalNavigationShortcutData(event({ key: "ArrowLeft", ctrlKey: true }), "Win32"),
4 "\u001bb",
5 );
6 assert.strictEqual(
7 terminalNavigationShortcutData(event({ key: "ArrowRight", ctrlKey: true }), "Linux"),
8 "\u001bf",
9 );
10 });
11+
12+ it("maps Alt+Arrow on non-macOS to word movement", () => {
13+ assert.strictEqual(
14+ terminalNavigationShortcutData(event({ key: "ArrowLeft", altKey: true }), "Win32"),
15+ "\u001bb",
16+ );
17+ assert.strictEqual(
18+ terminalNavigationShortcutData(event({ key: "ArrowRight", altKey: true }), "Linux"),
19+ "\u001bf",
20+ );
21+ });