{"record":{"id":"fd51988842c43b75","repo":"jackwener/OpenCLI","slug":"could-not-find-input-box","errorCode":null,"errorMessage":"Could not find input box","messagePattern":"Could not find input box","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"clis/antigravity/serve.js","lineNumber":240,"sourceCode":"    // Strip \"Copy\" button text at the end\n    reply = reply.replace(/\\s*\\bCopy\\b\\s*$/m, '').trim();\n    // De-duplicate trailing repeated content (e.g., \"OK\\n\\nOK\" → \"OK\")\n    const half = Math.floor(reply.length / 2);\n    const firstHalf = reply.slice(0, half).trim();\n    const secondHalf = reply.slice(half).trim();\n    if (firstHalf && firstHalf === secondHalf) {\n        reply = firstHalf;\n    }\n    return reply;\n}\nasync function sendMessage(page, message, bridge) {\n    if (!bridge) {\n        // Fallback: use JS-based approach\n        await page.evaluate(`\n      (() => {\n        const container = document.getElementById('antigravity.agentSidePanelInputBox');\n        const editor = container?.querySelector('[data-lexical-editor=\"true\"]');\n        if (!editor) throw new Error('Could not find input box');\n        editor.focus();\n        document.execCommand('insertText', false, ${JSON.stringify(message)});\n      })()\n    `);\n        await sleep(500);\n        await page.pressKey('Enter');\n        return;\n    }\n    // Get the bounding box of the Lexical editor for a physical mouse click\n    const rect = await page.evaluate(`\n    (() => {\n      const container = document.getElementById('antigravity.agentSidePanelInputBox');\n      if (!container) throw new Error('Could not find antigravity.agentSidePanelInputBox');\n      const editor = container.querySelector('[data-lexical-editor=\"true\"]');\n      if (!editor) throw new Error('Could not find Antigravity input box');\n      const r = editor.getBoundingClientRect();\n      return JSON.stringify({ x: r.left + r.width / 2, y: r.top + r.height / 2 });\n    })()","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/antigravity/serve.js#L222-L258","documentation":"Fallback path in serve.js sendMessage: when no CDP input bridge is available it injects JS that looks up #antigravity.agentSidePanelInputBox and its Lexical editor; if the editor (or the container itself, via optional chaining) is missing it throws 'Could not find input box'. It guards the same UI dependency as the bridge path but with a generic message.","triggerScenarios":"POST to the messages endpoint with no bridge attached; page.evaluate finds no [data-lexical-editor=\"true\"] inside the input container (container null makes container?.querySelector return undefined).","commonSituations":"Bridge setup failed silently so the JS fallback runs against a page where the Antigravity side panel is closed; editor not yet hydrated after opening a new conversation; Antigravity updated and changed the editor markup.","solutions":["Ensure the Antigravity side panel with the input box is open before sending","Fix CDP bridge setup so the primary (non-fallback) path is used","Wait for the Lexical editor selector before evaluating the fallback script","Re-check the DOM structure after an Antigravity update and adjust the selector"],"exampleFix":"// before\nconst editor = container?.querySelector('[data-lexical-editor=\"true\"]');\nif (!editor) throw new Error('Could not find input box');\n// after\nawait page.waitForSelector('#antigravity.agentSidePanelInputBox [data-lexical-editor=\"true\"]', { timeout: 10000 });\nconst editor = container?.querySelector('[data-lexical-editor=\"true\"]');","handlingStrategy":"validation","validationCode":"const ready = await page.evaluate(() =>\n  !!document.getElementById('antigravity.agentSidePanelInputBox')?.querySelector('[data-lexical-editor=\"true\"]'));\nif (!ready) throw new Error('Antigravity input editor not ready');","typeGuard":"function inputIsReady(container) {\n  return container != null && typeof container.querySelector === 'function'\n    && container.querySelector('[data-lexical-editor=\"true\"]') !== null;\n}","tryCatchPattern":"try {\n  await sendMessage(message);\n} catch (err) {\n  if (err.message === 'Could not find input box') {\n    // open panel / wait for editor, then retry\n  } else throw err;\n}","preventionTips":["Keep the CDP bridge healthy so the fragile JS fallback rarely runs","Ensure the side panel is open before API calls","Poll for the editor selector before typing","Diff the Antigravity DOM after upgrades"],"tags":["dom","selector","automation","antigravity"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}