Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Summary

Implement copy/paste keyboard shortcuts in the terminal (RightSidebar) that match platform conventions:

Platform Copy Paste
macOS Cmd+C Cmd+V
Linux Ctrl+Shift+C Ctrl+Shift+V
Windows Ctrl+C Ctrl+V

Problem

Cmd/Ctrl+V paste didn't work in the terminal. The terminal uses ghostty-web which has paste support via a hidden textarea, but Electron's Edit menu role: "paste" uses execCommand('paste') on the focused element—and ghostty-web focuses the container div, not the textarea.

Solution

Use ghostty-web's attachCustomKeyEventHandler() API to intercept platform-appropriate shortcuts and call the Clipboard API directly.

Key behaviors:

  • Copy only activates when there's a text selection
  • On Linux, Ctrl+C without selection still sends SIGINT (interrupt signal) as expected
  • Uses terminal.paste() which handles bracketed paste mode correctly

Testing

  • Verified typecheck passes
  • Verified static-check passes

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high • Cost: $3.87

Copy link
Collaborator Author

@ammar-agent ammar-agent left a comment

Choose a reason for hiding this comment

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

Addressed: added documentation with VS Code reference link explaining the platform conventions.

@ammar-agent
Copy link
Collaborator Author

@codex review

@ammar-agent
Copy link
Collaborator Author

Addressed: fixed the comment - Windows Ctrl+C does send interrupt signals. The behavior is copy-when-selection-exists (same as VS Code), otherwise SIGINT.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 62a0b3af40

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent
Copy link
Collaborator Author

Addressed: switched from ev.key to ev.code (KeyV/KeyC) for layout-independent detection. This handles Caps Lock and non-US keyboard layouts correctly.

@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13582f6249

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammar-agent
Copy link
Collaborator Author

Addressed: switched to ev.key.toLowerCase() which is layout-aware (Dvorak/Colemak users get shortcuts on their layout's C/V keys) while still handling Caps Lock correctly.

@ammar-agent
Copy link
Collaborator Author

@codex review

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7a3655df37

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Implement copy/paste keyboard shortcuts in the terminal that match
platform conventions:

- macOS: Cmd+C/V (standard Mac shortcuts)
- Linux: Ctrl+Shift+C/V (standard terminal shortcuts, preserves Ctrl+C for SIGINT)
- Windows: Ctrl+C/V (standard Windows shortcuts)

Uses ghostty-web's attachCustomKeyEventHandler() to intercept shortcuts
and call the clipboard API directly, since the Electron Edit menu paste
role doesn't reach ghostty-web's hidden textarea.
@ammar-agent
Copy link
Collaborator Author

Addressed: Linux Ctrl+Shift+C is now always swallowed (no-op if no selection) to prevent it from propagating as SIGINT. Mac/Windows only intercept when there's a selection.

@ammar-agent
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@ammario ammario merged commit d3928b5 into main Jan 10, 2026
21 checks passed
@ammario ammario deleted the terminal-3558 branch January 10, 2026 03:03
ammar-agent added a commit that referenced this pull request Jan 13, 2026
The attachCustomKeyEventHandler in ghostty-web returns:
- true: PREVENT default handling (we handled it)
- false: ALLOW default handling (let ghostty process it)

The clipboard shortcut handler (#1563) had this inverted, returning true
for all non-keydown events and at the end of the handler, which prevented
ghostty from processing any keyboard input.

Fixes terminal input regression introduced in d3928b5.
ammario pushed a commit that referenced this pull request Jan 13, 2026
…1586)

## Summary

Fixes terminal input regression introduced in #1563 (d3928b5).

## Root Cause

The `attachCustomKeyEventHandler` in ghostty-web returns:
- `true`: **PREVENT** default handling (we handled it)
- `false`: **ALLOW** default handling (let ghostty process it)

The clipboard shortcut handler had this inverted:
- Returned `true` for all non-keydown events → blocked keyup/keypress
- Returned `true` at end of handler → blocked all normal key input

This effectively disabled all terminal input except the specific
copy/paste shortcuts.

## Fix

Invert all return values to match ghostty-web's API contract.

---
_Generated with `mux` • Model: `anthropic:claude-opus-4-5` • Thinking:
`high` • Cost: `$2.53`_
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