Conversation
`navigator.clipboard` is only available in a secure context (HTTPS, or
http://localhost / 127.0.0.1). When the Web UI is served over plain HTTP
to a non-localhost host (a LAN IP, or a Tailscale 100.x address), it is
undefined, so every copy button fails — useFunctionPanelData surfaces
"Failed to copy to clipboard", useCopyFeedback silently no-ops, and the
direct navigator.clipboard.writeText call sites throw.
Add utils/clipboard.ts `copyText()` that falls back to the legacy
execCommand('copy') via an off-screen textarea when navigator.clipboard
is unavailable, and route the copy hooks (useCopyFeedback,
useFunctionPanelData) and all direct writeText call sites through it.
This promotes the correct fallback that already existed locally in
components/rule-card/utils.ts into a single shared helper.
Fixes tingly-dev#1746
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012AKfM1AfoSMcxhZE4Pe6F2
FFengIll
reviewed
Sep 19, 2026
| @@ -0,0 +1,34 @@ | |||
| /** | |||
Contributor
There was a problem hiding this comment.
hwo about to update navigator.clipboard directly ? if we can not, we may create anothe rnew clipboard.
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.
Summary
Copy buttons in the Web UI fail when the page is served over plain HTTP to a non-localhost host (a LAN IP, or a Tailscale
100.xaddress).navigator.clipboardis only defined in a secure context (HTTPS, orhttp://localhost/127.0.0.1), so every copy path throws:hooks/useFunctionPanelData.tscatches it and shows "Failed to copy to clipboard"hooks/useCopyFeedback.tshad no.catchand silently no-opsnavigator.clipboard.writeTextcall sites throwFix
frontend/src/utils/clipboard.tscopyText(): usesnavigator.clipboard.writeTextin a secure context, otherwise falls back to the legacydocument.execCommand('copy')via an off-screen<textarea>; rejects if neither path can copy.useCopyFeedback,useFunctionPanelData) and all directnavigator.clipboard.writeTextcall sites through it.components/rule-card/utils.tsinto the shared helper (removes the duplicate).Test plan
pnpm typecheck: no new errors (40 before this change, 40 after — the repo's pre-existing legacy errors are unchanged).pnpm lint: no new findings (only the repo's pre-existing React-pattern warnings remain).navigator.clipboard.execCommand('copy'). That branch cannot be exercised from a headless localhost/HTTPS context (wherenavigator.clipboardis present), so it is verified by review here rather than an automated run.Fixes #1746
🤖 Generated with Claude Code