jackwener/OpenCLI · error · EmptyResultError
antigravity copy-code
Error message
antigravity copy-code
What it means
EmptyResultError (code 'EMPTY_RESULT') from 'antigravity copy-code': the in-page script found zero Copy buttons associated with code blocks (`btns.length === 0`) or returned nothing, so there is no code text to report. The message names the command ('antigravity copy-code returned no data') with hint 'No code blocks visible.' It reflects page state, not a bug in your arguments.
Source
Thrown at clis/antigravity/audit-extras.js:164
{ name: 'index', type: 'int', required: false, help: '1-based index of code block (default: last)' },
],
columns: ['Field', 'Value'],
func: async (page, kwargs) => {
const idx = Number.isInteger(kwargs?.index) ? kwargs.index : null;
const data = unwrapEvaluateResult(await page.evaluate(`(() => {
const isVis = (el) => { const r = el.getBoundingClientRect(); return r.width > 1 && r.height > 1; };
const btns = Array.from(document.querySelectorAll('button[aria-label="Copy code"]')).filter(isVis);
if (!btns.length) return null;
const idx = ${idx === null ? 'btns.length - 1' : (idx - 1)};
const btn = btns[idx];
if (!btn) return { err: 'index ' + (${idx} ?? 'last') + ' out of range. Have ' + btns.length + ' code blocks.' };
// Find the <code> or <pre> element inside the parent block.
let container = btn;
for (let i = 0; i < 6 && container.parentElement; i++) container = container.parentElement;
const code = container.querySelector('pre, code');
return { text: code ? (code.innerText || '').trim() : (container.innerText || '').trim(), total: btns.length };
})()`));
if (!data) throw new EmptyResultError('antigravity copy-code', 'No code blocks visible.');
if (data.err) throw new CommandExecutionError(data.err, '');
return [
{ Field: 'TotalCodeBlocks', Value: String(data.total) },
{ Field: 'PickedIndex', Value: String(idx === null ? data.total : idx) },
{ Field: 'Length', Value: String((data.text || '').length) + ' chars' },
{ Field: 'Code', Value: data.text || '' },
];
},
});
// -------- settings --------
cli({
site: 'antigravity',
name: 'settings',
access: 'write',
description: 'Click the Antigravity settings button (matched by data-testid="settings-button").',
domain: '127.0.0.1',
strategy: Strategy.UI,View on GitHub (pinned to 49907e53dc)
Solutions
- Scroll to / render an assistant reply that contains a fenced code block, then re-run.
- Run `antigravity copy-message` first to confirm assistant content is visible at all.
- If code blocks exist but have no copy button, the UI changed — update the button-matching selector in audit-extras.js.
- Verify you are attached to the right conversation/tab.
Example fix
// before antigravity copy-code 0 // no code blocks on screen // after # ensure a reply containing code is rendered, then: antigravity copy-code 0
Defensive patterns
Strategy: validation
Validate before calling
// Confirm code blocks exist before invoking copy-code
const codeCount = await page.evaluate("document.querySelectorAll('pre, code').length");
if (!codeCount) throw new Error('No code blocks rendered on screen.'); Type guard
function hasCodeData(data) {
return data != null && typeof data === 'object'
&& typeof data.total === 'number' && data.total > 0
&& typeof data.text === 'string';
} Try / catch
try {
const rows = await runCmd('antigravity copy-code 0');
} catch (e) {
if (e.code === 'EMPTY_RESULT') {
console.error('No code blocks visible — render a reply containing fenced code first.');
} else throw e;
} Prevention
- Ensure the visible reply actually contains fenced code blocks.
- Verify a Copy button exists on code blocks in the current Antigravity version.
- Use copy-message first to confirm assistant content is rendered.
- Keep index within the returned TotalCodeBlocks range.
When it happens
Trigger: Running `antigravity copy-code` (with or without an index) when the visible assistant replies contain no code blocks — the scrape finds no copy-code buttons and `if (!data)` throws.
Common situations: The current reply is prose-only with no fenced code; the conversation is empty; code blocks are rendered without the expected copy button in a newer Antigravity version; you are scrolled to a part of the chat without code.
Related errors
- antigravity copy-message
- No prices returned for train_no=${trainNo} ${fromStation.nam
- No 12306 stations match "${keyword}"
- No trains found from ${fromStation.name} to ${toStation.name
- 1point3acres thread
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0d5b49461586456e.
Report an issue: GitHub.