fix(web): copy text over plain HTTP - #231
Merged
Merged
Conversation
Remote web pages served over HTTP have no Clipboard API. Copy now falls back to a synchronous execCommand path during the user gesture, restores focus, and still reports a structured error when both paths fail. Adapted from pingdotgg#8023.
Greptile SummaryThis change adds a legacy Confidence Score: 5/5Safe to merge; no blocking issues remain. No outstanding findings remain. The prior missing-document-body issue was resolved by greptile-apps[bot] without explanation, and the current guard returns the structured unavailable-clipboard failure before attempting to append the temporary textarea. Files Needing Attention: None. Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/web-plain-h..." | Re-trigger Greptile |
The execCommand path threw a raw TypeError when document existed but body did not. Return the same ClipboardApiUnavailableError callers already handle.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
writeTextToClipboardnow copies withdocument.execCommand("copy")when the Clipboard API is missing. The fallback runs during the original click, restores prior focus, and still throwsClipboardApiUnavailableErrorif both paths fail. Empty values stay a no-op.Message copy, code copy, diagnostics, and other
useCopyToClipboardcallers all go through this helper.Why
Akeru’s web client is remote-ready. A page opened over plain HTTP has no
navigator.clipboard.writeText, so Copy silently failed. Terminals and older browsers have the same hole.Adapted from pingdotgg/t3code#8023.
UI Changes
No layout change. Isolated browser: copying a Scout reply writes the message text. Breaking both copy paths shows Failed to copy message.
Checklist
Verification
vp test run apps/web/src/hooks/useCopyToClipboard.test.ts(8 tests)Limitations
The execCommand path was unit-tested. A real HTTP (non-HTTPS) remote origin was not served here. Group chat uses the same helper.
Implemented and verified by Grok 4.6 High in Grok Build via Orca.