Skip to content

fix(ui): copy to the clipboard outside a secure context - #2866

Open
Charlesthebird wants to merge 2 commits into
release/v0.10.xfrom
charlesthebird/httpSafeIds
Open

Charlesthebird wants to merge 2 commits into
release/v0.10.xfrom
charlesthebird/httpSafeIds

Conversation

@Charlesthebird

Copy link
Copy Markdown
Collaborator

🤖 written by Claude (start)

Changelog

Copy buttons work on deployments served over plain http, and say so when a copy fails.

Testing

  1. cd ui && npm run dev, then open the app on a LAN IP rather than localhost — that origin is not a secure context, so navigator.clipboard is undefined.
  2. Expand a tool result and press copy. The tick appears and the clipboard holds the result; before, nothing happened and nothing was said.
  3. Copy a code block, the LLM-call JSON, and a share link. Each reports its outcome.

Additional Notes

This is the other half of #1868, which fixed crypto.randomUUID for these deployments and left the clipboard alone. That fix is already here and needs no change.

copyText answers the document's own copy event rather than selecting a borrowed textarea. Nothing needs focus, so it also works inside a dialog that traps it — the share dialog's old fallback appended its textarea to document.body and copied nothing there while reporting success.

Success is the event having fired, not what execCommand returns: it returns true for copying nothing.


🤖 written by Claude (end)

`navigator.clipboard` is undefined over plain http from anything but localhost,
so every copy button rejected there: the tool result and the code block reported
nothing, the LLM-call JSON dropped the rejection on the floor, and the share
dialog claimed success it had not checked.

`copyText` answers the document's own `copy` event instead, which needs no
focus and so survives a dialog's focus trap, and returns whether the event
actually fired — `execCommand` returns true for copying nothing. Callers now
report failure rather than implying a copy.

This is the other half of #1868, which fixed `crypto.randomUUID` for the same
deployments and left the clipboard alone.

Signed-off-by: Nicholas Bucher <[email protected]>
@github-actions github-actions Bot added the bug Something isn't working label Sep 17, 2026
@chromatic-com

chromatic-com Bot commented Sep 17, 2026

Copy link
Copy Markdown

Warning

Testing paused

Monthly snapshot limit reached. Update your plan for additional snapshots and to resume testing.

@Charlesthebird
Charlesthebird marked this pull request as ready for review September 18, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants