Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(terminal): restore copying from Claude Code’s fullscreen TUI #9949

Closedcallmemorgan(GitHub profile, opens in a new tab)wants to merge 16 commits intomain fromrefs/pull/9949/headopened View on GitHub

I had a number of frustrating situations (old terminal sessions in particular) where copying out of the t3code terminal didn't work with the Claude Code fullscreen tui enabled. Claude Code’s copy-on-select sends OSC 52 clipboard writes, which t3code wasn’t handling. Digging into Claude Code's copy-escape mode (hold shift when selecting text) there were also instances where t3code would hand mouse movement back to the Claude Code instance, even if a drag was still ongoing. This should make the default copy-on-select behavior in Claude Code's fullscreen tui work more reliably, and also improve the reliability of the drag-to-copy-with-shift-pressed fallback option Claude Code exposes.

Text below this line written by an LLM:

What Changed

Fixed copying from fullscreen terminal applications:

  • Preserve desktop/web native selection during redraws and keep Shift-drag active through pointer release. Clear completed selections when typing, pasting, or scrolling sends input to the application.
  • Handle OSC 52 clipboard writes on desktop, web, iOS, and Android using a shared parser. Ignore history, background output, and stale pending requests; keep writes ordered without building a backlog.
  • Offer a Copy or Clear action on plain-HTTP web connections where copying requires a user click.

Why

Claude Code’s fullscreen redraws could erase a selection mid-drag. Releasing Shift before the trackpad button could hand the remaining drag back to Claude. Its copy-on-select OSC 52 path was unsupported.

Both Shift-drag/Cmd+C and Claude’s own copy were verified in T3 desktop with Claude Code 2.1.261 on the contributor’s physical MacBook Neo trackpad. A separate Chrome test over LAN HTTP verified Copy and Clear against the macOS clipboard, including leaving it unchanged before the click.

The latest fixes pass 180 focused web/shared tests and the web/mobile/client-runtime typechecks. Clipboard output reaches each client before the display buffer is trimmed; tests cover 600 KiB copies and verify that no extra RPC subscription is created. Browser testing covers an available async clipboard API that rejects the write, followed by a successful user-initiated copy. Captured startup output from all six installed providers (Codex, Claude, Cursor, Grok, OpenCode, and Antigravity) passed selection/copy/input checks through the terminal renderer. These were startup-screen checks, not full model turns.

Native iOS verification passed on one iPhone 17e simulator running iOS 26.5 on the MacBook Neo: exact Unicode clipboard text, empty-payload clearing, ignored background output, fresh copying after foregrounding, and no history replay after leaving and reopening the terminal. This caught and fixed Android-only AppState focus/blur subscriptions being registered on iOS. Android has not been tested in an emulator.

UI Changes

Terminal selection gestures are demonstrated below. Plain-HTTP connections now show a Copy/Clear prompt when the browser requires a click.

fullscreen-terminal-copy.webm

Checklist

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

Implemented with GPT-6 Astra in T3 Code on Morgan’s behalf, with simplification by Fable 5.1.


Note

Medium Risk Large changes to terminal pointer handling, clipboard timing, and input routing in a core user-facing surface; regressions could affect selection, copy/paste, or mouse reporting in fullscreen apps.

Overview Adds OSC 52 clipboard support end-to-end so fullscreen TUIs (e.g. Claude Code copy-on-select) can push text to the system clipboard on web, desktop, iOS, and Android.

A shared @t3tools/client-runtime/terminal-clipboard module parses live PTY output for OSC 52, ignores history/replay and ineligible chunks, and serializes native writes so only the newest pending copy runs. terminalEnvironment.observeAttach taps the same attach stream before buffer retention—no second RPC—feeding writeClipboard / resetClipboard on Ghostty and a mobile useTerminalClipboard session tied to route focus and app state. Web shows a Copy/Clear toast when navigator.clipboard is blocked and falls back to a gesture-based copy.

Ghostty selection and input are reworked: drags bind to their pointer (including Shift fullscreen drags), autoscroll and capture loss are handled cleanly, and committed user input goes through sendUserInput, which clears a finished selection before sending to the PTY while modifier keys, protocol replies, and native copy keep the highlight. Session output sync no longer clears selection on every chunk; keyboard shortcuts in the drawer use the surface input path instead of direct atom writes.

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

Note

Restore terminal clipboard copying from fullscreen TUI via OSC 52 and gesture-based selection

  • Adds a stateful OSC 52 clipboard parser, serialized native write queue, and eligibility-gated session in packages/client-runtime/src/terminalClipboard.ts; only live, focused, visible terminal output triggers a clipboard write, and snapshot/replay history is excluded
  • Refactors GhosttyTerminalSurface in apps/web/src/terminal/ghostty/surface.ts to track selection as an owned pointer drag with centralized teardown, clearing stale selections on input, output eviction, visibility/focus/window-blur changes, and disposal
  • Adds GhosttyTerminalCore.selectionPosition and wraps native point/grid-ref conversions in finally blocks in apps/web/src/terminal/ghostty/core.ts to fix memory leaks on thrown conversions
  • Integrates clipboard forwarding in web TerminalViewport and mobile useTerminalClipboard, with toast/action fallback when browser blocks automatic writes and Expo Clipboard support on mobile
  • Adds observeAttach to the terminal atom factory in packages/client-runtime/src/state/terminal.ts so consumers can tap live attach stream events before retention without a second RPC subscription
  • Risk: GhosttyTerminalSurface constructor now reads the active element to initialize focus; onClipboardWrite and observeClipboard are new surface options that hosts must wire up or clipboard output is silently dropped. pasteFromClipboard, onKeyDown, onPaste, onCompositionEnd, onInput, and onWheel now route through sendUserInput, which clears non-dragging selections before delivery — callers relying on direct onData invocation for these paths are affected
Macroscope summarized 8339d2e.
    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-09-05T19:48:28.735281Z8339d2eNew commits
      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

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

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — The change spans shared terminal infrastructure plus web, desktop, and mobile clipboard, pointer, and input behavior, creating a broad production blast radius beyond a self-contained fix. It also adds a line-level lint suppression in the shared clipboard parser, warranting human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 8fba6168d8

      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    5. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 69ae8f4a91

      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    6. Stale Bugbot comment from a previous run.

    7. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 2bf45b6852

      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    8. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: f34fad32e4

      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    9. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      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 f34fad32e4787ec128d28beb48253e94121c9858. Configure [here](https://www.cursor.com/dashboard/bugbot).
    10. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 09986610de

      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    11. Addressed the current findings from a separate Sonnet review in ec4f980f2:

      • Retire cached selection coordinates when the core's tracked endpoints move during scrollback eviction.
      • Finish native selection when left is released during a chorded mouse gesture, and clear unmoved selections on pointer cancellation.
      • Clear stale application/link ownership after pointer capture is lost.
      • Preserve selection for the remaining modifier key names and skip full-grid selection clearing when no selection exists.

      168 focused web/core tests and the web typecheck pass. The six captured provider startup regressions also pass again; these check selection, redraw, copying, and subsequent input, not full model turns.

      I rechecked the review's HTTP fallback claims against the current helper in Chrome and Playwright WebKit. Both copied exact text and cleared the native macOS clipboard from a button click without a DOM selection. System-message parsing and combined q selectors were already addressed. The existing Ctrl+C policy and explicit-click authorization for fallback toasts remain unchanged.

      Native iOS verification is now building on the Neo with two build jobs and one simulator. No simulator pass is claimed yet.

      Written by GPT-6 Astra in T3 Code on Morgan's behalf.

    12. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: ec4f980f22

      ℹ️ About Codex in GitHub

      Your team has set up Codex to 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 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    13. Pushed 4f20dde84 and 81e261032. Fable 5.1’s simplification consolidates the web/mobile clipboard lifecycle and moves parser/session tests beside the shared implementation. The follow-up fixes isolate failing stream observers, free selection-coordinate allocations on failure, preserve focus acquired during terminal setup, and complete application mouse release on capture loss.

      Native iOS testing found that AppState focus/blur subscriptions are Android-only. Those subscriptions are now conditional. On the Neo’s iPhone 17e simulator running iOS 26.5, the terminal opened without the previous error overlay. Live PTY output through the isolated T3 server copied exact Unicode text and cleared the native iOS clipboard. Background output and history replay after leaving/reopening the terminal did not change it; fresh copying worked after returning.

      All 180 focused tests, web/mobile/shared-runtime typechecks, and six provider startup-capture regressions passed. Targeted lint reported no errors. The provider checks cover selection, redraw, copying, and subsequent input, not full model turns. Android was not run in an emulator. The simulator, stream, Metro, and isolated backend are shut down again.

      Written by GPT-6 Astra in T3 Code on Morgan’s behalf.

    14. Rebased onto upstream main at f8b4c464b; the new head is 8339d2ea1. The rebase was conflict-free, and git range-diff confirms all 16 commit patches are unchanged. All 180 focused terminal/clipboard tests passed again on the rebased head. The previously verified terminal code is unchanged, so the simulator stayed shut down.

      Written by GPT-6 Astra in T3 Code on Morgan’s behalf.

Sign in to join this conversation.