jackwener/OpenCLI · error · CommandExecutionError
Copy button click failed
Error message
Copy button click failed
What it means
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.
Source
Thrown at clis/antigravity/audit-extras.js:125
// We want the bottom-of-message Copy, not the code-block Copy.
const copies = Array.from(document.querySelectorAll('button[aria-label="Copy"]')).filter(isVis);
if (!copies.length) return null;
const lastCopy = copies[copies.length - 1];
let container = lastCopy;
let best = '';
for (let i = 0; i < 8 && container.parentElement; i++) {
container = container.parentElement;
const txt = (container.innerText || '').trim();
if (txt.length > best.length) best = txt;
if (best.length > 200) break;
}
return { text: best };
})()`));
if (!data) throw new EmptyResultError('antigravity copy-message', 'No Copy buttons visible — make sure an assistant reply is on screen.');
if (kwargs?.['click-button'] === true || kwargs?.['click-button'] === 'true') {
const clickResult = unwrapEvaluateResult(await page.evaluate(clickLastScript(['button[aria-label="Copy"]'])));
if (!clickResult?.ok) {
throw new CommandExecutionError(clickResult?.reason || 'Copy button click failed', '');
}
}
return [
{ Field: 'Length', Value: String((data.text || '').length) + ' chars' },
{ Field: 'ClipboardClicked', Value: (kwargs?.['click-button'] === true || kwargs?.['click-button'] === 'true') ? 'yes' : 'no' },
{ Field: 'Text', Value: data.text || '' },
];
},
});
// -------- copy-code --------
cli({
site: 'antigravity',
name: 'copy-code',
access: 'read',
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.',
domain: '127.0.0.1',
strategy: Strategy.UI,View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before antigravity copy-message --click-button // fails when button missing // after antigravity copy-message // scrape text without clicking; click only if needed
Defensive patterns
Strategy: fallback
Validate before calling
const wantsClick = String(opts.clickButton) === 'true';
if (wantsClick) {
const hasCopy = await page.evaluate("!!document.querySelector('button[aria-label=\"Copy\"]')");
if (!hasCopy) console.warn('Copy button not found; proceeding without click.');
} Type guard
function canClickCopy(res) {
return res != null && typeof res === 'object' && res.ok === true;
} Try / catch
try {
await runCmd('antigravity copy-message --click-button');
} catch (e) {
if (e.code === 'EXEC' && /Copy button click failed/i.test(e.message)) {
// fall back: text was still scraped — rerun without the flag
await runCmd('antigravity copy-message');
} else throw e;
} Prevention
- 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.
When it happens
Trigger: `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'.
Common situations: 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.
Related errors
- ${label} click failed
- settings click failed
- sidebar-toggle failed
- 无法在聊天列表中找到该用户,请确认聊天列表中有此人
- Could not find the like control on ${post.code}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/f703b248f76ea386.
Report an issue: GitHub.