Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): add copying terminal selection with ctrl+c in the web app #5638

MergedUtkarshUsername(GitHub profile, opens in a new tab)merged 9 commits intomain fromrefs/pull/5638/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHub

What Changed

When text is selected in a terminal in the web app on Windows, Ctrl+C now copies the selected text instead of sending a ctrl+c into the shell. Ctrl+Shift+C still copies as before.

Copy no longer routes through navigator.clipboard.writeText; instead the surface writes the selection into the native copy event's clipboardData (mirroring the existing paste path), with execCommand synthesizing the event for Ctrl+Shift+C since that key fires no native one. Drops the dead onCopy option and its drawer handler.

Why

Pressing Ctrl+C on a selection used to pass through to the terminal as input even when text was selected, so the shortcut never copied. It now copies on Windows.

Video Demo

https://github.com/user-attachments/assets/bd3150f8-f7b4-4848-91aa-8ee8ff27efd8

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included a video for animation/interaction changes

Note

Medium Risk Changes terminal keyboard semantics (Ctrl+C with selection) and clipboard handling across browsers; scope is localized to the web terminal and DOM context-menu fallback.

Overview Web terminal copy now treats plain Ctrl+C (and Ctrl+Shift+C) as copy when text is selected on non-macOS platforms, instead of requiring Ctrl+Shift+C only. macOS still uses Cmd+C for copy and leaves Ctrl+C for SIGINT when nothing is selected.

Copy moves into GhosttyTerminalSurface: it handles the native copy event via clipboardData, races navigator.clipboard.writeText as a fallback (like paste), uses execCommand('copy') for Ctrl+Shift+C, and on Linux/Windows clears the selection after a plain Ctrl+C copy so the next Ctrl+C can interrupt the shell. The onCopy option and drawer clipboard handler are removed.

Browser context menus gain dismissContextMenu, single-menu tracking (new menus dismiss the prior one), LocalApi.contextMenu.close(), and the terminal drawer calls close when a copy-driven selection clear dismisses the selection action menu.

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

Note

[!NOTE]

Add Ctrl+C copy support in the web terminal surface

  • On non-mac platforms, Ctrl+C now copies the current terminal selection (previously required Ctrl+Shift+C); after copying, the selection is cleared so subsequent Ctrl+C reaches the shell.
  • Copy handling moves into GhosttyTerminalSurface internally: it intercepts the native copy event to set clipboard data, with a navigator.clipboard.writeText fallback when no native event fires. The onCopy callback option is removed from GhosttyTerminalSurfaceOptions.
  • Adds dismissContextMenu to contextMenuFallback.ts and exposes LocalApi.contextMenu.close() in the browser fallback so that copying (which clears a selection) also closes any open selection context menu.
  • Behavioral Change: Ctrl+C in the web terminal no longer sends the interrupt signal when text is selected; it copies instead and clears the selection.
Macroscope summarized 7a0d12c.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: b264d219-b3c7-4556-b449-c663bd65b0c7

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    3. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Needs human review

      This PR changes terminal copy behavior by enabling Ctrl+C (previously required Ctrl+Shift+C on non-Mac) and introduces complex async clipboard handling with race condition management and selection clearing logic. The behavioral changes and non-trivial async coordination warrant human review.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dd31bf85b19bb0602592d53bb230ad92d7a76a35. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.