Skip to content

fix(terminal): app shortcuts no longer type into the pane - #215

Merged
devswha merged 3 commits into
mainfrom
fix/app-shortcuts-skip-terminal
Sep 30, 2026
Merged

devswha merged 3 commits into
mainfrom
fix/app-shortcuts-skip-terminal

Conversation

@devswha

@devswha devswha commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Change

Refs #214 (Phase 0). In the terminal lens, Ctrl+Shift+↓ switched to the next pane and also typed ESC[1;6B into it; Ctrl+Shift+↑ typed ESC[1;6A.

useShortcuts claims app shortcuts in a window capture listener that only calls preventDefault(). xterm.js doesn't check defaultPrevented, so it still encoded the key. By then React had already switched the selection, so the sequence went to the pane you switched to. The other app shortcuts (Ctrl+Shift+K/J/B/N/,) aren't encoded by xterm in its legacy keyboard mode today, but they are skipped the same way.

The fix is a new isAppShortcut() in src/lib/shortcuts.ts, built on the same matchShortcut the listener uses. xterm's attachCustomKeyEventHandler returns false for any key it matches.

Not in this PR: on macOS, Cmd+Shift+↑/↓ in the message box still switches panes instead of selecting text. Fixing that conflicts with keyboard pane switching in the chat lens, where the box has focus, so it stays in #214.

Validation

  • scripts/ui-regression.ts now checks the terminal lens: Ctrl+Shift+↓ and Ctrl+Shift+↑ each leave the pane, and no input frame goes to any pane.
    • Without the fix, it fails with Control+Shift+ArrowDown must not reach a pane (text: '\x1B[1;6B').
    • With the fix, all 30 browser groups pass against the isolated test herdr session.
  • bun run typecheck, src/lib/shortcuts.test.ts and bun run build pass.

🤖 Generated with Claude Code

devswha and others added 2 commits October 1, 2026 06:54
The app claims its shortcuts in a window capture listener that only calls
preventDefault(). xterm.js does not check defaultPrevented, so it still
encoded the key: in the terminal lens Ctrl+Shift+Down switched panes and
sent ESC[1;6B to the pane it had just switched to (Up sent ESC[1;6A).
xterm's key handler now skips any app shortcut.

Refs #214.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: devswha/herdr-web-ui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: e83d5168-daf9-47f4-bbe6-9c664eea902f

📥 Commits

Reviewing files that changed from the base of the PR and between 1daba61 and 26a792a.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • src/components/PaneTerminal.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Ctrl+Shift+↑ and Ctrl+Shift+↓ now switch terminal panes without sending the shortcut keys to the pane.
  • Tests
    • Added browser regression checks for pane switching and verified the original selection is restored.

Walkthrough

Terminal app shortcuts are checked before existing Ctrl-key handling. Matching events do not reach xterm. Browser regression checks verify that Ctrl+Shift+ArrowUp and Ctrl+Shift+ArrowDown switch panes without sending input.

Changes

Shortcut input handling

Layer / File(s) Summary
Recognize and filter app shortcuts
src/lib/shortcuts.ts, src/components/PaneTerminal.tsx, scripts/ui-regression.ts, CHANGELOG.md
isAppShortcut matches events against registered shortcuts. PaneTerminal blocks matching events from reaching xterm. Browser checks cover both pane-switch shortcuts and verify that neither sends terminal input. The changelog records the fix.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: yoonwoo-ha

Merge Risk: ⚪ Minimal · up to 26a79

Registered app shortcuts are filtered before reaching terminal input, while ordinary keys retain their existing handling. The regression checks both pane-switch shortcuts for pane input; no actionable merge-blocking risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1… 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 primary change: preventing application shortcuts from typing into the terminal pane.
Description check ✅ Passed The description includes the required Change and Validation sections. It explains the defect, implementation, affected behavior, regression coverage, and test results. It does not include the template…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

@devswha
devswha merged commit ebf6b24 into main Sep 30, 2026
3 checks passed
@devswha
devswha deleted the fix/app-shortcuts-skip-terminal branch September 30, 2026 23:04
devswha added a commit that referenced this pull request Oct 1, 2026
## Change

Installed apps are on v0.3.35. This PR prepares v0.3.36. The app and
plugin versions go up together, and the Unreleased notes move under the
dated release heading.

It also fixes the CHANGELOG: the #187 entries (edge swipe, Hide
keyboard) had been placed in the already released 0.3.34 section. They
now sit under Added in 0.3.36, merged with #217's text-selection fix for
the swipe. Entries that had no PR link now have one.

This release includes:
- **Added:**
  - Left-edge drawer swipe and keyboard dismissal on phones (#187)
- Opt-in color palettes and agent icons, with Amber staying the default
(#188)
  - Claude's suggested next prompt in the composer (#198)
  - Plan meters at the top of the sidebar as an option (#206)
- **Fixed:**
  - A fallback card for blocked screens no reader knows (#205)
  - Ctrl+Shift+↑/↓ typing into the terminal (#215)
  - Attach-held races (#207)
  - Plugin `stop` returning before the server is gone (#210)
  - A table inside a list (#209)
  - Queued messages showing only under the chat lens (#213)
  - Quick replies column on wide screens (#212)
  - A clear message for Windows hosts (#208)
- **Pre-release review:** an adversarial review of everything since
v0.3.35 found these problems, fixed in #216 (server) and #217 (client):
- Fallback menu inference typed digits into a following prompt and cut
off wrapped labels.
  - The held-attach timeout unlocked input after a refusal.
  - The suggestion read could delay prompt polling.
  - `stop` misread zombie processes.
  - The swipe stole text selection.
  - Ordered-list numbering restarted after a table.
  - A stale suggestion survived Send now.
  - The top usage panel hid provider failures.

## Validation

- `bun scripts/release-notes.ts 0.3.36` passes.
- Fast checks and Integration and browser must pass before the squash
merge. After the merge, publish with `gh workflow run release.yml --ref
main -f version=0.3.36`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
devswha added a commit that referenced this pull request Oct 2, 2026
…ession with Mod+Shift+O (#298)

## Change

The bugs reported in #214, checked again on main first:

1. **Pane switching leaking `ESC[1;6B` into the terminal**: already
fixed by #215. Checked in headless Chrome against an isolated herdr:
Ctrl+Shift+↓ in pane A's terminal switched to pane B, and neither pane
(both running `cat -v`) received anything; what was typed next landed in
B.
2. **New session (Mod+Shift+N) never reaching the page in a Chrome
tab**: Chrome reserves Ctrl+Shift+N for a new incognito window.
**Mod+Shift+O** now opens New session too, and is the one the app shows;
Mod+Shift+N still works where the browser passes it (the installed app).
Checked: Ctrl+Shift+O in the terminal opens the New session dialog and
types nothing into the pane.
3. **Cmd+Shift+↑/↓ taken from the message box on a Mac**: reproduced
with a Mac platform in headless Chrome: the shortcut switched panes and
left the message behind. `useShortcuts` now leaves Mod+Shift+arrows to
text fields (textarea, text inputs, contenteditable) and switches panes
from the terminal (xterm's own input element) and everywhere else.
Checked: the same key in the message box no longer switches panes.

The configurable shortcuts that #214 proposes are not part of this; the
issue stays open for them.

## Validation

- Playwright against an isolated herdr session, as above.
- `src/lib/shortcuts.test.ts`: which targets keep the arrows, and both
new-session keys.
- `bun run typecheck`, `bun run test:unit`, `bun run build`.
- Not checked: a real Mac (the platform was set in the page) and a real
Chrome tab's reserved keys (headless Chrome passes every key to the
page).
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.

1 participant