Skip to content

fix(desktop): forward unregistered ctrl/meta chords to v1 terminal PTY#3390

Merged
Kitenite merged 1 commit into
mainfrom
hotkey-issue-v1-investigation
Apr 12, 2026
Merged

fix(desktop): forward unregistered ctrl/meta chords to v1 terminal PTY#3390
Kitenite merged 1 commit into
mainfrom
hotkey-issue-v1-investigation

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Apr 12, 2026

Summary

  • Fixes [bug] Cannot use keyboard shortcuts from apps running in the terminal #3385. v1 terminal swallowed every ctrl/meta chord, so TUIs (Claude Code, Codex, vim, tmux) and shell readline shortcuts (Ctrl+R, Ctrl+W, Ctrl+U) never reached the PTY.
  • Mirrors the v2 pattern at terminal-runtime.ts:21: use resolveHotkeyFromEvent to only bubble chords actually registered as app hotkeys; everything else reaches the PTY.
  • One-line change in helpers.ts:597.

Before / after

Before: if (event.metaKey || event.ctrlKey) return false; — any modifier chord was blocked from xterm.
After: if (resolveHotkeyFromEvent(event) !== null) return false; — only registered app hotkeys bubble.

Registered app hotkeys (FIND_IN_TERMINAL, SCROLL_TO_BOTTOM, CLEAR_TERMINAL, QUICK_OPEN, …) still work. Reserved chords (Ctrl+C/D/Z/S/Q) still go to xterm as before.

Test plan

  • In a v1 terminal, press Ctrl+R at a bash/zsh prompt → (reverse-i-search) appears
  • Ctrl+W / Ctrl+U / Ctrl+T / Ctrl+K behave normally in the shell
  • Run claude in a v1 terminal → Ctrl+P (model switcher) and Ctrl+O (extended output) work
  • FIND_IN_TERMINAL, SCROLL_TO_BOTTOM, CLEAR_TERMINAL, QUICK_OPEN still fire
  • Ctrl+C / Ctrl+D / Ctrl+Z still reach xterm (SIGINT / EOF / SIGTSTP)
  • Line/word motion unchanged: Cmd+←/→ and Opt+←/→ on mac, Ctrl+←/→ on Windows

Summary by cubic

Forward unregistered Ctrl/Meta chords to the v1 terminal PTY so TUIs and shell shortcuts work again. Only registered app hotkeys bubble to the app; everything else reaches xterm.

  • Bug Fixes
    • Replaced the broad ctrl/meta check with resolveHotkeyFromEvent to match v2 behavior.
    • Restores shell readline and TUI shortcuts (Ctrl+R/W/U/T/K, Claude Code Ctrl+P/Ctrl+O). App hotkeys (FIND_IN_TERMINAL, SCROLL_TO_BOTTOM, CLEAR_TERMINAL, QUICK_OPEN) and reserved chords (Ctrl+C/D/Z/S/Q) stay unchanged.

Written for commit d5f06ce. Summary will update on new commits.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved terminal keyboard input handling to ensure application hotkeys are properly recognized while allowing other keystrokes to flow through to the terminal.

v1's keyboard handler returned false for every ctrl/meta combo, starving
TUIs like Claude Code of Ctrl+P/Ctrl+O and shell readline shortcuts like
Ctrl+R/W/U. Mirror v2's pattern (terminal-runtime.ts:21): use
resolveHotkeyFromEvent to only bubble chords actually registered as app
hotkeys, letting everything else reach the PTY.

Fixes #3385.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 126c4855-4872-4d25-8e04-40ac08807b0d

📥 Commits

Reviewing files that changed from the base of the PR and between ef67d8a and d5f06ce.

📒 Files selected for processing (1)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.ts

📝 Walkthrough

Walkthrough

Updated hotkey handling in Terminal helpers to resolve keyboard shortcuts correctly. Changed the setupKeyboardHandler function to import resolveHotkeyFromEvent and narrow ctrl/meta key event bubbling to only occur when events match registered app hotkeys, rather than blocking all ctrl/meta combinations.

Changes

Cohort / File(s) Summary
Terminal Hotkey Handler
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.ts
Imported resolveHotkeyFromEvent and refined keyboard event bubbling logic. Changed keydown event handling to conditionally bubble only when the event resolves to a registered app hotkey, allowing unregistered ctrl/meta combinations to be routed to the terminal instead of being blocked.

Possibly related issues

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes


🐰 A rabbit hops through the keys,
No more shortcuts lost in the breeze!
Hotkeys resolved, both right and true,
Terminal apps get their shortcuts too! 🎹✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: forwarding unregistered ctrl/meta key chords to the v1 terminal PTY.
Description check ✅ Passed The description covers all required template sections with clear explanations of the problem, solution, test plan, and technical details.
Linked Issues check ✅ Passed The PR directly addresses issue #3385 by restoring keyboard shortcuts (Ctrl+P, Ctrl+O, Ctrl+R, Ctrl+W, Ctrl+U) for in-terminal apps and shell readline.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the keyboard event handling in v1 terminal; no unrelated modifications were introduced.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch hotkey-issue-v1-investigation

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.

@Kitenite Kitenite merged commit 41cd804 into main Apr 12, 2026
6 of 7 checks passed
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 12, 2026

Greptile Summary

This PR fixes a bug in the v1 terminal where all ctrl/meta keyboard chords were swallowed before reaching the xterm PTY. The one-line change in helpers.ts replaces a broad modifier-key guard with a precise check using resolveHotkeyFromEvent, which only bubbles chords that are actually registered as app hotkeys — directly mirroring the existing v2 terminal (terminal-runtime.ts:21) pattern.

  • Root cause fixed: if (event.type === "keydown" && (event.metaKey || event.ctrlKey)) return false blocked every Ctrl/Meta chord (e.g., Ctrl+R for shell history, Ctrl+W to delete word, Ctrl+U to clear line) from reaching the PTY, breaking TUIs like Claude Code, Codex, vim, and tmux.
  • New behavior: resolveHotkeyFromEvent(event) !== null filters only the registered application hotkeys (FIND_IN_TERMINAL, QUICK_OPEN, NEW_GROUP, CLOSE_PANE, etc.), letting everything else pass through to the PTY.
  • Existing safeguards preserved: the isTerminalReservedEvent guard for Ctrl+C/D/Z/S/Q comes before the new check and is unaffected; the explicit CLEAR_TERMINAL intercept (which calls options.onClear()) is also unaffected.
  • keyup parity maintained: resolveHotkeyFromEvent returns null for non-keydown events (line 10 of resolveHotkeyFromEvent.ts), so the implicit event.type guard from the old code is preserved inside the helper.

Confidence Score: 5/5

Safe to merge — minimal, well-reasoned one-line fix that exactly mirrors the proven v2 terminal pattern.

The change is correct and complete. All existing safeguards (reserved events, CLEAR_TERMINAL intercept, cursor-motion overrides) execute before the new check and are unaffected. The event.type guard that was previously explicit is preserved inside resolveHotkeyFromEvent (it returns null for non-keydown events). Duplicate hotkey keys in the registry (e.g. FIND_IN_TERMINAL / FIND_IN_CHAT / FOCUS_TASK_SEARCH all sharing meta+f) are handled correctly — the Map lookup still returns non-null so those chords are blocked as intended. No regressions are introduced on any platform.

No files require special attention.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/helpers.ts Replaces the broad `metaKey

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[KeyboardEvent fires in v1 terminal] --> B{Cursor-motion override?\nCmd+←/→, Opt+←/→, Ctrl+←/→ Win}
    B -- yes --> C[Write escape seq to PTY\nreturn false]
    B -- no --> D{isTerminalReservedEvent?\nCtrl+C/D/Z/S/Q/backslash}
    D -- yes --> E[return true → PTY receives event]
    D -- no --> F{CLEAR_TERMINAL binding match?}
    F -- yes --> G[call onClear\nreturn false]
    F -- no --> H{resolveHotkeyFromEvent ≠ null?\nRegistered app hotkey}
    H -- yes --> I[return false → bubbles to\nreact-hotkeys-hook]
    H -- no --> J[return true → PTY receives event\nCtrl+R, Ctrl+W, Ctrl+U, etc.]
Loading

Reviews (1): Last reviewed commit: "fix(desktop): forward unregistered ctrl/..." | Re-trigger Greptile

@Kitenite Kitenite deleted the hotkey-issue-v1-investigation branch April 12, 2026 23:11
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

AytuncYildizli added a commit to AytuncYildizli/superset that referenced this pull request Apr 13, 2026
…v1 terminal

superset-sh#3390 changed the v1 terminal keyboard handler so any chord not registered
as an app hotkey falls through to the PTY. That regressed standard OS
clipboard shortcuts: Cmd+C / Cmd+V / Cmd+X / Cmd+A on macOS and the
Linux/Windows equivalents (Ctrl+Shift+C/V/X/A, Shift+Insert) are not
registered as app hotkeys, so they now reach xterm and never get a chance
to copy/paste via Electron's edit menu — text selection in the terminal
became impossible to copy.

Add an explicit short-circuit before the "fall through to PTY" branch:
when the chord is exactly an OS clipboard combination, return false so the
event bubbles to the host. xterm.js' selection / Electron's edit role still
get to do the work; SIGINT (Ctrl+C in PTY) and other terminal-reserved
chords are unaffected because they're handled earlier in the same handler.

Reproduced on Superset Desktop v1.5.1 (macOS, Apple Silicon, Turkish
keyboard): Cmd+C in terminal pane silently dropped before this patch,
copies selection after.
MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request Apr 13, 2026
superset-sh#3390)

v1's keyboard handler returned false for every ctrl/meta combo, starving
TUIs like Claude Code of Ctrl+P/Ctrl+O and shell readline shortcuts like
Ctrl+R/W/U. Mirror v2's pattern (terminal-runtime.ts:21): use
resolveHotkeyFromEvent to only bubble chords actually registered as app
hotkeys, letting everything else reach the PTY.

Fixes superset-sh#3385.
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.

[bug] Cannot use keyboard shortcuts from apps running in the terminal

1 participant