{"record":{"id":"f27e781797ac3499","repo":"paperclipai/paperclip","slug":"execcommand-copy-failed","errorCode":null,"errorMessage":"execCommand copy failed","messagePattern":"execCommand copy failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/src/lib/clipboard.ts","lineNumber":41,"sourceCode":"  // success — so keep the element simple and just push it off-screen.\n  const textarea = document.createElement(\"textarea\");\n  textarea.value = text;\n  textarea.setAttribute(\"aria-hidden\", \"true\");\n  textarea.tabIndex = -1;\n  textarea.style.position = \"fixed\";\n  textarea.style.top = \"0\";\n  textarea.style.left = \"-9999px\";\n  document.body.appendChild(textarea);\n\n  const previouslyFocused = document.activeElement as (Element & {\n    focus?: (options?: FocusOptions) => void;\n  }) | null;\n  try {\n    textarea.focus({ preventScroll: true });\n    textarea.select();\n    textarea.setSelectionRange(0, text.length);\n    const success = document.execCommand(\"copy\");\n    if (!success) throw new Error(\"execCommand copy failed\");\n  } finally {\n    document.body.removeChild(textarea);\n    if (previouslyFocused !== document.activeElement && typeof previouslyFocused?.focus === \"function\") {\n      previouslyFocused.focus({ preventScroll: true });\n    }\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":49,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/ui/src/lib/clipboard.ts#L23-L49","documentation":"Legacy clipboard fallback failure: document.execCommand('copy') on the off-screen textarea returned false, meaning the browser refused the programmatic copy (permissions, non-user-gesture context, or detached DOM). The error lets the caller surface a manual-copy fallback; the modern navigator.clipboard path is preferred when available.","triggerScenarios":"Thrown at ui/src/lib/clipboard.ts:41 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the async Clipboard API (navigator.clipboard.writeText) instead of execCommand, or retry after a user gesture grants clipboard permission."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}