Skip to content

fix: copy to clipboard in non-secure contexts (HTTP on non-localhost)#102

Open
jaffee-circuit wants to merge 1 commit intoboldsoftware:mainfrom
jaffee-circuit:fix-clipboard-non-secure-context
Open

fix: copy to clipboard in non-secure contexts (HTTP on non-localhost)#102
jaffee-circuit wants to merge 1 commit intoboldsoftware:mainfrom
jaffee-circuit:fix-clipboard-non-secure-context

Conversation

@jaffee-circuit
Copy link

@jaffee-circuit jaffee-circuit commented Feb 13, 2026

Human Comment

Hi, thanks for Shelley, I've been loving it. I am running it on a personal machine and accessing via tailscale, so I ran into this clipboard issue since the browser thinks it's not a secure connection.

Problem

navigator.clipboard is undefined in non-secure contexts (plain HTTP on a non-localhost hostname). The code called navigator.clipboard.writeText(text).catch(...), but since navigator.clipboard was undefined, it threw a synchronous TypeError before any Promise was created — the .catch() never ran. Silent failure, nothing copied.

Fix

Added a copyToClipboard() utility (ui/src/utils/clipboard.ts) that:

  1. Uses navigator.clipboard.writeText() when available (secure contexts)
  2. Falls back to textarea + execCommand('copy') otherwise

Updated all 4 clipboard write call sites:

  • Message copy action
  • Commit hash copy
  • Terminal panel copy screen/copy all buttons

@cla-bot
Copy link

cla-bot bot commented Feb 13, 2026

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Matthew Jaffee.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

navigator.clipboard is undefined in non-secure contexts (HTTP served
on a non-localhost hostname like zebra.exe.xyz). Calling writeText on
undefined throws a synchronous TypeError that the .catch() didn't handle.

Extract a copyToClipboard utility that uses navigator.clipboard when
available and falls back to textarea+execCommand otherwise. Use it in
all clipboard write sites: Message copy action, commit hash copy, and
terminal panel copy buttons.

Co-authored-by: Shelley <shelley@exe.dev>
@jaffee-circuit jaffee-circuit force-pushed the fix-clipboard-non-secure-context branch from 2f0b3d1 to f36f15f Compare February 13, 2026 03:44
@cla-bot
Copy link

cla-bot bot commented Feb 13, 2026

We require contributors to sign our Contributor License Agreement, and we don't have you on file. In order for us to review and merge your code, please contact @crawshaw at david@bold.dev to get yourself added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant