Skip to content

fix(web): copy text over plain HTTP - #231

Merged
leoisadev1 merged 3 commits into
mainfrom
fix/web-plain-http-clipboard
Sep 11, 2026
Merged

fix(web): copy text over plain HTTP#231
leoisadev1 merged 3 commits into
mainfrom
fix/web-plain-http-clipboard

Conversation

@leoisadev1

Copy link
Copy Markdown
Member

What Changed

writeTextToClipboard now copies with document.execCommand("copy") when the Clipboard API is missing. The fallback runs during the original click, restores prior focus, and still throws ClipboardApiUnavailableError if both paths fail. Empty values stay a no-op.

Message copy, code copy, diagnostics, and other useCopyToClipboard callers 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

  • This PR is small and focused
  • I explained what changed and why
  • I linked the accepted plugin or provider proposal in Why, or this PR does not add one
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Verification

  • vp test run apps/web/src/hooks/useCopyToClipboard.test.ts (8 tests)
  • targeted lint/format and web typecheck
  • isolated bot chat: successful copy and the error toast

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.

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.
@github-actions github-actions Bot added size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Sep 10, 2026
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown

Greptile Summary

This change adds a legacy execCommand("copy") fallback when the modern Clipboard API is unavailable, preserving temporary-element cleanup and focus restoration. The fallback safely handles pages without a document body and retains structured clipboard-unavailable errors.

Confidence Score: 5/5

Safe 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

Comment thread apps/web/src/hooks/useCopyToClipboard.ts
The execCommand path threw a raw TypeError when document existed but
body did not. Return the same ClipboardApiUnavailableError callers
already handle.
@leoisadev1
leoisadev1 merged commit 315c22d into main Sep 11, 2026
11 of 13 checks passed
@leoisadev1
leoisadev1 deleted the fix/web-plain-http-clipboard branch September 11, 2026 01:04
@github-actions github-actions Bot mentioned this pull request Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant