Skip to content

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

Merged
shivamhwp merged 2 commits into
pingdotgg:mainfrom
iamshadmantaqi:fix/terminal-ctrl-insert-copy
Sep 8, 2026
Merged

fix(web): copy terminal selection with Ctrl+Insert#8541
shivamhwp merged 2 commits into
pingdotgg:mainfrom
iamshadmantaqi:fix/terminal-ctrl-insert-copy

Conversation

@iamshadmantaqi

@iamshadmantaqi iamshadmantaqi commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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 for commit c9b54bb. Bugbot is set up for automated code reviews on this repo. Configure here.

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.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown

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 d6dbe8d and b0b9776.

📒 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 name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring 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 name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding Ctrl+Insert terminal copy support for web.
Description check ✅ Passed The description includes the required change summary, rationale, UI impact, checklist, and verification details. It is complete and focused.
Linked Issues check ✅ Passed The 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 ✅ Passed The 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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Aug 28, 2026
@macroscopeapp

macroscopeapp Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

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.

@shivamhwp
shivamhwp force-pushed the fix/terminal-ctrl-insert-copy branch from c9b54bb to 3f0b9ca Compare September 6, 2026 06:15
@cursor

cursor Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

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.

@shivamhwp
shivamhwp enabled auto-merge (squash) September 8, 2026 03:52
@shivamhwp
shivamhwp disabled auto-merge September 8, 2026 03:53
@cursor

cursor Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

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.

@SunkenInTime SunkenInTime left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Shift+Insert already pastes. Ctrl+Insert currently falls through because
isTerminalCopyShortcut only matches the C key.
Mirror the Shift+Insert paste branch. Ctrl+Insert is the GTK/VTE copy
chord and the one tiling WMs send for universal clipboard on a terminal
window. Copy only, do not treat it as SIGINT.

Closes pingdotgg#8525
@shivamhwp
shivamhwp force-pushed the fix/terminal-ctrl-insert-copy branch from a6b41c0 to b0b9776 Compare September 8, 2026 09:44
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

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.

@shivamhwp
shivamhwp merged commit 83b865f into pingdotgg:main Sep 8, 2026
22 checks passed
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Sep 8, 2026
## What's Changed
* feat(chat): attach files to question answers by @shivamhwp in pingdotgg/t3code#9871
* feat(desktop): refresh macOS installer with aurora artwork by @saphid in pingdotgg/t3code#10632
* fix(server): give completed turns a full session idle window by @StiensWout in pingdotgg/t3code#10689
* feat(web): add pull request merge defaults by @Bil0000 in pingdotgg/t3code#8088
* fix(usage): keep account columns aligned across limit rows by @juliusmarminge in pingdotgg/t3code#10690
* fix(web): chat text no longer shows through a 1px gap under composer banners by @vitalyiegorov in pingdotgg/t3code#10635
* refactor(server): classify runtime exports by @juliusmarminge in pingdotgg/t3code#10274
* refactor(server): classify orchestration exports by @juliusmarminge in pingdotgg/t3code#10275
* refactor(server): classify service exports by @juliusmarminge in pingdotgg/t3code#10276
* refactor(server): classify telemetry exports by @juliusmarminge in pingdotgg/t3code#10277
* refactor(server): classify provider exports by @juliusmarminge in pingdotgg/t3code#10278
* refactor(server): classify source control exports by @juliusmarminge in pingdotgg/t3code#10279
* refactor(server): classify source control registry API by @juliusmarminge in pingdotgg/t3code#10280
* refactor(server): classify preview toolkit exports by @juliusmarminge in pingdotgg/t3code#10281
* ci(knip): enforce server exports by @juliusmarminge in pingdotgg/t3code#10282
* feat(web): add previous/next turn navigation in minimap by @UtkarshUsername in pingdotgg/t3code#8531
* fix(web): stop the settings sidebar shifting when switching pages by @t3dotgg in pingdotgg/t3code#10705
* fix(web): copy terminal selection with Ctrl+Insert by @iamshadmantaqi in pingdotgg/t3code#8541
* fix(web): show the same project icon in the command palette as everywhere else by @t3dotgg in pingdotgg/t3code#10712
* fix(web): stop sidebar rows flashing and shifting on click by @t3dotgg in pingdotgg/t3code#10713
* refactor(web): pass the project record to ProjectFavicon so icons cannot drift by @t3dotgg in pingdotgg/t3code#10714

## New Contributors
* @iamshadmantaqi made their first contribution in pingdotgg/t3code#8541

**Full Changelog**: pingdotgg/t3code@v0.0.41-nightly.20260908.1387...v0.0.41-nightly.20260908.1400

Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.41-nightly.20260908.1400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrated terminal ignores Ctrl+Insert copy, breaking tiling-WM universal-clipboard shortcuts

3 participants