{"record":{"id":"f703b248f76ea386","repo":"jackwener/OpenCLI","slug":"copy-button-click-failed","errorCode":null,"errorMessage":"Copy button click failed","messagePattern":"Copy button click failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/antigravity/audit-extras.js","lineNumber":125,"sourceCode":"      // We want the bottom-of-message Copy, not the code-block Copy.\n      const copies = Array.from(document.querySelectorAll('button[aria-label=\"Copy\"]')).filter(isVis);\n      if (!copies.length) return null;\n      const lastCopy = copies[copies.length - 1];\n      let container = lastCopy;\n      let best = '';\n      for (let i = 0; i < 8 && container.parentElement; i++) {\n        container = container.parentElement;\n        const txt = (container.innerText || '').trim();\n        if (txt.length > best.length) best = txt;\n        if (best.length > 200) break;\n      }\n      return { text: best };\n    })()`));\n        if (!data) throw new EmptyResultError('antigravity copy-message', 'No Copy buttons visible — make sure an assistant reply is on screen.');\n        if (kwargs?.['click-button'] === true || kwargs?.['click-button'] === 'true') {\n            const clickResult = unwrapEvaluateResult(await page.evaluate(clickLastScript(['button[aria-label=\"Copy\"]'])));\n            if (!clickResult?.ok) {\n                throw new CommandExecutionError(clickResult?.reason || 'Copy button click failed', '');\n            }\n        }\n        return [\n            { Field: 'Length', Value: String((data.text || '').length) + ' chars' },\n            { Field: 'ClipboardClicked', Value: (kwargs?.['click-button'] === true || kwargs?.['click-button'] === 'true') ? 'yes' : 'no' },\n            { Field: 'Text', Value: data.text || '' },\n        ];\n    },\n});\n\n// -------- copy-code --------\ncli({\n    site: 'antigravity',\n    name: 'copy-code',\n    access: 'read',\n    description: 'Return the text of a code block in the current conversation. Default: last code block; pass --index N (1-based from top) to pick a specific one.',\n    domain: '127.0.0.1',\n    strategy: Strategy.UI,","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/audit-extras.js#L107-L143","documentation":"CommandExecutionError thrown by the optional `--click-button` step of 'antigravity copy-message': after the message text was scraped successfully, the script tried to click a `button[aria-label=\"Copy\"]` and got `ok: false` (or no reason). The fallback message 'Copy button click failed' is used when the page-side script provides no `reason`. This is a partial-success failure — text was captured, but the clipboard click did not happen.","triggerScenarios":"`page.evaluate(clickLastScript(['button[aria-label=\"Copy\"]']))` returns { ok: false }: the Copy button disappeared after the scrape, the wrong button was targeted, or the click was blocked. Only happens when `--click-button` is true/'true'.","commonSituations":"Passing --click-button on a message whose Copy button is rendered lazily or conditionally; UI update changing aria-label from 'Copy'; browser clipboard permissions or focus stealing the click; the command running while the page re-renders.","solutions":["Re-run the command — transient re-renders commonly unmount the button between scrape and click.","Drop the --click-button flag if you only need the text (the command still returns the message content).","Verify the button's current aria-label in devtools and update the 'button[aria-label=\"Copy\"]' selector.","Make sure the Antigravity window/tab has focus so the synthetic click lands."],"exampleFix":"// before\nantigravity copy-message --click-button   // fails when button missing\n\n// after\nantigravity copy-message   // scrape text without clicking; click only if needed","handlingStrategy":"fallback","validationCode":"const wantsClick = String(opts.clickButton) === 'true';\nif (wantsClick) {\n  const hasCopy = await page.evaluate(\"!!document.querySelector('button[aria-label=\\\"Copy\\\"]')\");\n  if (!hasCopy) console.warn('Copy button not found; proceeding without click.');\n}","typeGuard":"function canClickCopy(res) {\n  return res != null && typeof res === 'object' && res.ok === true;\n}","tryCatchPattern":"try {\n  await runCmd('antigravity copy-message --click-button');\n} catch (e) {\n  if (e.code === 'EXEC' && /Copy button click failed/i.test(e.message)) {\n    // fall back: text was still scraped — rerun without the flag\n    await runCmd('antigravity copy-message');\n  } else throw e;\n}","preventionTips":["Only pass --click-button when clipboard capture is essential.","Keep the window focused so synthetic clicks land.","Retry once on click failures — buttons are often re-mounted mid-run.","Verify the Copy aria-label after UI updates."],"tags":["dom-click","clipboard","selector-not-found"],"backgroundTag":"element-click-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}