Launch preview webview blocks clipboard write (NotAllowedError) even with focus + user gesture
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()staysfalse.- 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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗