fix: copy to clipboard in non-secure contexts (HTTP on non-localhost)#102
Open
jaffee-circuit wants to merge 1 commit intoboldsoftware:mainfrom
Open
fix: copy to clipboard in non-secure contexts (HTTP on non-localhost)#102jaffee-circuit wants to merge 1 commit intoboldsoftware:mainfrom
jaffee-circuit wants to merge 1 commit intoboldsoftware:mainfrom
Conversation
|
Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Matthew Jaffee.
|
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>
2f0b3d1 to
f36f15f
Compare
|
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. |
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.
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.clipboardisundefinedin non-secure contexts (plain HTTP on a non-localhost hostname). The code callednavigator.clipboard.writeText(text).catch(...), but sincenavigator.clipboardwasundefined, it threw a synchronousTypeErrorbefore any Promise was created — the.catch()never ran. Silent failure, nothing copied.Fix
Added a
copyToClipboard()utility (ui/src/utils/clipboard.ts) that:navigator.clipboard.writeText()when available (secure contexts)textarea+execCommand('copy')otherwiseUpdated all 4 clipboard write call sites: