Launch preview webview blocks clipboard write (NotAllowedError) even with focus + user gesture

Status Fixed / completed
Maintainer reply ✓ Yes — amorriscode
Activity 3 comments · opened Jun 13, 2026 · closed Jun 24, 2026
💡 Likely answer: A maintainer (amorriscode, contributor) responded on this thread — see the highlighted reply below.

Summary

Copy-to-clipboard buttons in a web app rendered inside the Launch preview panel always fail. navigator.clipboard.writeText() rejects with NotAllowedError: Write permission denied, and a document.execCommand('copy') fallback also returns false. The exact same button works in an external browser (Chrome).

Environment

  • Claude Code desktop app
  • OS: Windows 11
  • Surface: Launch preview panel (embedded webview); app served on http://localhost:4000

Expected

Clipboard writes from the previewed page should behave like a normal browser tab — clicking a copy button should put text on the clipboard.

Actual

Clicking a copy button performs no clipboard write. An app that fire-and-forgets writeText() (without awaiting the promise) even shows a false "Copied!" toast, so the failure is silent.

Root-cause investigation (run inside the preview document)

1. Baseline

isSecureContext: true                                  // http://localhost — OK
typeof navigator.clipboard.writeText: "function"       // present
featurePolicy.allowsFeature('clipboard-write'): true   // allowed by Permissions Policy
document.hasFocus(): false                             // not focused until a real click

2. Focus behaviour

  • window.focus() and element .focus() do not give the document focus — document.hasFocus() stays false.
  • A trusted click (real pointer event) does set document.hasFocus(): true.

3. Decisive test — fire writeText() from inside a real trusted click handler, so both document focus AND user activation are present:

btn.addEventListener('click', async (ev) => {
  // ev.isTrusted === true, document.hasFocus() === true here
  await navigator.clipboard.writeText('test'); // throws
}, { once: true });

Result:

"FAIL NotAllowedError | trusted=true focus=true"

document.execCommand('copy') (with a focused + selected textarea) also returns false.

So even with trusted user gesture + document focus + clipboard-write allowed by Permissions Policy, the write is denied. The embedded preview webview appears to deny the clipboard-write permission itself.

Impact

Any web app tested in the Launch preview that relies on the clipboard (copy link / copy code / copy token buttons) cannot be exercised there. Apps that don't check the writeText() promise will additionally show misleading "copied" success UI in the preview.

Workaround

Open the app in a real external browser for any clipboard-dependent flow.

Suggestion

Grant the preview webview the clipboard-write permission (and/or run it in a context where document.hasFocus() can become true on interaction) so the Clipboard API and execCommand('copy') behave like a standard browser tab.

View original on GitHub ↗

3 Comments

amorriscode contributor · 3 months ago

Merging a fix for this today, sorry about that.

cloverink · 3 months ago

Confirm this is have been fixed

github-actions[bot] · 1 month ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.