{"record":{"id":"9ef0131917b48239","repo":"jackwener/OpenCLI","slug":"antigravity-copy-message","errorCode":null,"errorMessage":"antigravity copy-message","messagePattern":"antigravity copy-message","errorType":"exception","errorClass":"EmptyResultError","httpStatus":null,"severity":"error","filePath":"clis/antigravity/audit-extras.js","lineNumber":121,"sourceCode":"    func: async (page, kwargs) => {\n        const data = unwrapEvaluateResult(await page.evaluate(`(() => {\n      const isVis = (el) => { const r = el.getBoundingClientRect(); return r.width > 1 && r.height > 1; };\n      // Antigravity has both \"Copy\" (message) and \"Copy code\" (code block) buttons.\n      // 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',","sourceCodeStart":103,"sourceCodeEnd":139,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/audit-extras.js#L103-L139","documentation":"EmptyResultError (src/errors.ts:145, code 'EMPTY_RESULT') is thrown by 'antigravity copy-message' when the in-page scrape of Copy buttons returns no data — meaning no Copy buttons were found on screen. The first constructor argument is the command name, so the message reads 'antigravity copy-message returned no data'; the hint tells you to make sure an assistant reply is visible. It signals the page state did not match what the command expects.","triggerScenarios":"Running `antigravity copy-message` when no assistant reply (and therefore no Copy buttons) is rendered; the scrape script's loop finds no Copy button containers, returns null/empty after unwrapEvaluateResult, and `if (!data)` fires.","commonSituations":"Invoking the command on a fresh/empty conversation; the assistant is still streaming so buttons have not appeared; the user is not logged in and the chat UI never rendered; a UI redesign renamed or removed the Copy button.","solutions":["Wait until an assistant reply is fully rendered (streaming finished) and run the command again.","Verify you are attached to a conversation with at least one assistant message.","Log in to Antigravity if the chat UI did not load.","If Copy buttons exist but the command still fails, the DOM structure changed — update the scrape selector in audit-extras.js."],"exampleFix":"// before\nantigravity copy-message  # run immediately after sending a prompt\n\n// after\n# wait for the assistant reply to finish rendering, then:\nantigravity copy-message --click-button","handlingStrategy":"validation","validationCode":"// Pre-check that a Copy button is present before invoking copy-message\nconst hasCopy = await page.evaluate(\"!!document.querySelector('button[aria-label=\\\"Copy\\\"]')\");\nif (!hasCopy) throw new Error('No assistant reply with Copy button on screen.');","typeGuard":"function hasScrapedText(data) {\n  return data != null && typeof data === 'object' && typeof data.text === 'string' && data.text.length > 0;\n}","tryCatchPattern":"try {\n  const rows = await runCmd('antigravity copy-message');\n} catch (e) {\n  if (e.code === 'EMPTY_RESULT') {\n    console.error('No assistant reply visible — wait for streaming to finish, then retry.');\n  } else throw e;\n}","preventionTips":["Only run copy-message when an assistant reply is fully rendered.","Check login state — the chat UI must render for the scrape to find buttons.","Treat EMPTY_RESULT as a page-state signal, not a code bug.","Re-check selectors after Antigravity UI updates."],"tags":["empty-result","dom-scrape","browser-automation"],"backgroundTag":"empty-page-scrape-result","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}