fix(app): clipboard fallback so copy buttons work in non-secure contexts#17549
Open
Hastyshell wants to merge 8 commits intoanomalyco:devfrom
Open
fix(app): clipboard fallback so copy buttons work in non-secure contexts#17549Hastyshell wants to merge 8 commits intoanomalyco:devfrom
Hastyshell wants to merge 8 commits intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
All copy handlers were calling navigator.clipboard.writeText() directly, which fails silently when the page is not in a secure context (e.g. accessed via HTTP over LAN). Introduce a shared copy() utility that first tries the Clipboard API and falls back to document.execCommand so buttons work in all environments.
File.write and its test belong to a separate PR; remove them from this branch.
d273002 to
5f82ef7
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Open
1 task
6 tasks
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.
Issue for this PR
Closes #14803 #17553
Type of change
What does this PR do?
navigator.clipboard.writeText()requires a secure context (HTTPS orlocalhost). When users runopencode weband access it over LAN via plain HTTP, every copy button in the UI silently fails — the API throws but nothing catches it, so buttons never show the "copied" state.The fix adds a shared
copy(text)utility in both theuiandwebpackages that tries the Clipboard API first and falls back todocument.execCommand("copy")via a hidden textarea. All copy call sites are updated to use this utility.How did you verify your code works?
Tested by accessing
opencode webover HTTP on a LAN IP and clicking the Copy path button, copy code block, copy response, and copy error buttons — all now work correctly.Screenshots / recordings
N/A (functional fix, no visual change)
Checklist