Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): copy terminal selection with Ctrl+Insert #8541

Mergediamshadmantaqi(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/8541/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHub

What Changed

isTerminalCopyShortcut now treats Ctrl+Insert as copy on non-mac platforms, matching the existing Shift+Insert paste branch. The keydown handler copies with execCommand("copy") the same way it does for Ctrl+Shift+C, so the chord does not go to the PTY and is not treated as SIGINT.

Why

Tiling WMs such as Omarchy map universal copy on a terminal window to Ctrl+Insert. Paste already worked because #5982 added Shift+Insert. Copy still required key === "c", so the selection never reached the clipboard.

Ctrl+Insert is also the usual GTK/VTE copy chord.

Closes #8525

Blast Radius

Web and desktop share GhosttyTerminalSurface. Mobile does not use this helper.

Ctrl+C and Ctrl+Shift+C are unchanged. macOS still ignores Insert for this shortcut.

Verification

Failing-then-passing regression in apps/web/src/terminal/ghostty/surface.test.ts.

  • Before the fix, vp test run apps/web/src/terminal/ghostty/surface.test.ts failed with expected false to be true on Ctrl+Insert.
  • After the fix, that file is 44/44 passing.
  • vp lint on the two changed files: 0 errors.
  • vp run --filter @t3tools/web typecheck: clean.

No UI chrome changed, so no screenshots.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI change (screenshots not applicable)
  • No motion change (video not applicable)

Note

Low Risk Scoped keyboard shortcut and clipboard copy path in the Ghostty terminal surface; existing Ctrl+C and macOS behavior stay unchanged.

Overview Non-mac Ghostty terminal copy now treats Ctrl+Insert like other copy chords when text is selected, alongside existing Ctrl+C / Cmd+C behavior.

isTerminalCopyShortcut adds an Insert branch (Ctrl, no Shift/Meta) on non-mac platforms, mirroring how Shift+Insert is handled for paste. The surface keydown path runs execCommand("copy") for Insert as well as Ctrl+Shift+C, because the browser does not fire a native copy event for those chords—so the selection is primed and copied without sending the key to the PTY or triggering SIGINT semantics tied to plain Ctrl+C.

Regression tests cover Linux acceptance and macOS rejection of Ctrl+Insert.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit c9b54bb6c899677d47075ce376b60ecb71356d19. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Add Ctrl+Insert copy shortcut to terminal on non-mac platforms

  • Extends isTerminalCopyShortcut in surface.ts to return true for the Insert key on non-mac platforms when Ctrl is pressed and neither Shift nor Meta are held.
  • Updates the keydown handler so Ctrl+Insert triggers the synthesized copy path (document.execCommand('copy')) and calls preventDefault, matching the existing Ctrl+Shift+C behavior.
  • Risk: macOS ignores Ctrl+Insert, and Shift+Insert / Meta+Insert are not treated as copy on any platform.
Macroscope summarized 3f0b9ca.

Summary by CodeRabbit

  • New Features

    • Added support for the conventional Ctrl+Insert shortcut to copy terminal content on non-macOS platforms.
    • The shortcut works alongside existing copy shortcuts, providing an alternative way to copy selected terminal text.
  • Bug Fixes

    • Ensured Ctrl+Insert triggers clipboard copying correctly while preserving platform-specific shortcut behavior, including the expected behavior on macOS and for related Insert key combinations.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review Change StackReview Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Path: .coderabbit.yaml

      Review profile: CHILL

      Plan: Advanced

      Run ID: 97812a7e-06c3-41eb-9a79-3e592cfcc819

      📥 Commits

      Reviewing files that changed from the base of the PR and between d6dbe8dd67facf4a43030993bebb58cc7e7ac141 and b0b9776db3e3ef8c523b77898f18267f21237ba3.

      📒 Files selected for processing (2)
      • apps/web/src/terminal/ghostty/surface.test.ts
      • apps/web/src/terminal/ghostty/surface.ts
      🚧 Files skipped from review as they are similar to previous changes (2)
      • apps/web/src/terminal/ghostty/surface.test.ts
      • apps/web/src/terminal/ghostty/surface.ts

      Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


      📝 Walkthrough

      Walkthrough

      The terminal recognizes Ctrl+Insert as a copy shortcut on non-macOS platforms. The keydown handler synthesizes the copy command, and tests cover supported and rejected key combinations.

      Changes

      Terminal copy shortcut

      Layer / File(s)Summary
      Shortcut detection and coverage
      apps/web/src/terminal/ghostty/surface.ts, apps/web/src/terminal/ghostty/surface.test.ts
      isTerminalCopyShortcut accepts Ctrl+Insert on non-macOS platforms. Tests cover valid and invalid modifier and platform combinations.
      Copy event handling
      apps/web/src/terminal/ghostty/surface.ts
      onKeyDown invokes execCommand("copy") for Ctrl+Insert because the shortcut does not produce a native copy event.

      Priority: ➖ Normal — Impact reflects medium issue severity.

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

      Severity of issue fixed: Medium

      Merge Risk: ⚪ Minimal · up to b0b97

      Terminal users on non-macOS platforms can copy selected text with Ctrl+Insert without sending the chord to the PTY, while existing macOS behavior remains unchanged. No current merge-readiness risk remains.

      Suggested reviewers: sunkenintime

      🚥 Pre-merge checks | ✅ 4 | ❌ 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely identifies the main change: adding Ctrl+Insert terminal copy support for web.
      Description check✅ PassedThe description includes the required change summary, rationale, UI impact, checklist, and verification details. It is complete and focused.
      Linked Issues check✅ PassedThe changes satisfy issue [#8525] by recognizing Ctrl+Insert on non-macOS platforms, copying with execCommand("copy"), preventing PTY delivery, preserving macOS behavior, and adding regression coverag…
      Out of Scope Changes check✅ PassedThe changes are limited to the terminal shortcut implementation and its regression test. No unrelated code changes are identified.
      • Fix all pre-merge checks with AI
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: Approved at c9b54bb

      Macroscope's review found this PR approvable — This is a narrowly scoped terminal shortcut fix: non-macOS Ctrl+Insert now copies an existing selection through the established copy path, while existing shortcuts and macOS behavior remain unchanged. Regression tests cover the new and excluded cases, with no schema, infrastructure, or sensitive-area changes.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    5. Bugbot is paused — on-demand spend limit reached

      Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.

      A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.

    6. Windows review of a6b41c0177fbb25e793dd8284def7d31dee090f4, compared with 6df0add6e65b7c0040b5774635f794e4ff802ddd.

      No blocking defect found in the Ctrl+Insert change. All 49 focused surface tests pass, as do format/lint for the two changed files and the web typecheck. Bun is absent on this machine; I used the checkout's pinned Vite+ 0.3.0 tooling and scoped checks.

      In the real T3 app on Windows build 26200 / Chrome 152, a synthetic Ctrl+Insert keydown ran the terminal handler, emitted a trusted copy event through execCommand, and copied the selected text to the Windows OS clipboard. Repeated copy retained the selection. Without a selection, the clipboard stayed unchanged. Ctrl+Shift+C also copied; the Ctrl+C and Shift+Insert clipboard fallback checks behaved as expected within the browser bridge.

      This is a comment rather than approval because physical-key and Electron testing remain incomplete. The browser shortcut tool substitutes a copy event for Ctrl+Insert, so its initial apparent success was discarded as keydown evidence. Please do a physical-key smoke test in Windows Chrome and Electron before treating this as a complete Windows sign-off.

      1. P2, baseline only: closing the test terminal removed it from the UI but left its shell running. Manager.ts:1620 sends SIGTERM through NodePtyAdapter.ts:90; node-pty rejects signals on Windows. I reproduced the dependency behavior separately and verified those files and the lockfile are unchanged from the base. This belongs in separate work and is not a blocker for this PR. Owned test processes were cleaned up.

      Windows review report · Evidence and reproduction bundle

      Reviewed by GPT-6 through Codex.

    7. Note

      GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

Sign in to join this conversation.