fix(web): copy text over plain HTTP - #8023
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, self-contained clipboard bug fix that preserves the normal async API and adds a narrowly scoped textarea fallback for unsupported contexts. Cleanup and focus restoration are covered by regression tests, with no schema, deployment, or authentication-logic changes. You can add or adjust custom eligibility rules. Learn more. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4b28706. Configure here.

What Changed
Why
Browsers do not expose
navigator.clipboardon plain-HTTP remote origins. T3 Code is commonly reached over a LAN or Tailscale address, so shared copy actions currently throw instead of copying. The async Clipboard API remains the primary path; the legacy command is used only when that API is unavailable.Fixes #7824.
Verification
vp test run apps/web/src/hooks/useCopyToClipboard.test.tsvp fmt --check apps/web/src/hooks/useCopyToClipboard.ts apps/web/src/hooks/useCopyToClipboard.test.tsvp lint apps/web/src/hooks/useCopyToClipboard.ts apps/web/src/hooks/useCopyToClipboard.test.ts --deny-warningstsgo --noEmitfor@t3tools/webgit diff --checkChecklist
Created with GPT-5.6 Sol via Codex in T3 Code.
Note
Low Risk
Small clipboard fallback in the web copy helper; no auth or data-handling changes. Uses a legacy DOM copy path only when the Clipboard API is unavailable.
Overview
Copy actions now work on remote pages served over plain HTTP (LAN/Tailscale), where
navigator.clipboardis missing.writeTextToClipboardstill prefers the async Clipboard API. When that API is unavailable, it copies via a hidden textarea anddocument.execCommand("copy"), then removes the element and restores focus. It only throwsClipboardApiUnavailableErrorif both paths fail (orwindowis undefined).Adds a regression test covering the fallback path.
Reviewed by Cursor Bugbot for commit 1cc367e. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add
document.execCommand('copy')fallback towriteTextToClipboardWhen
navigator.clipboard.writeTextis unavailable (e.g. plain HTTP),writeTextToClipboardnow falls back to a hidden textarea approach via the newwriteTextWithExecCommandhelper instead of immediately throwingClipboardApiUnavailableError. The helper creates a temporary textarea, selects its contents, callsdocument.execCommand('copy'), then removes the textarea and restores focus.writeTextToClipboardin useCopyToClipboard.ts only throwsClipboardApiUnavailableErrorwhenwindowis undefined or the execCommand fallback fails; callers that relied on the error being thrown whennavigator.clipboardis absent will now seetruereturned instead.Macroscope summarized 1cc367e.