jackwener/OpenCLI · error · Error

Could not find input box

Error message

Could not find input box

What it means

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.

Source

Thrown at clis/antigravity/serve.js:240

    // Strip "Copy" button text at the end
    reply = reply.replace(/\s*\bCopy\b\s*$/m, '').trim();
    // De-duplicate trailing repeated content (e.g., "OK\n\nOK" → "OK")
    const half = Math.floor(reply.length / 2);
    const firstHalf = reply.slice(0, half).trim();
    const secondHalf = reply.slice(half).trim();
    if (firstHalf && firstHalf === secondHalf) {
        reply = firstHalf;
    }
    return reply;
}
async function sendMessage(page, message, bridge) {
    if (!bridge) {
        // Fallback: use JS-based approach
        await page.evaluate(`
      (() => {
        const container = document.getElementById('antigravity.agentSidePanelInputBox');
        const editor = container?.querySelector('[data-lexical-editor="true"]');
        if (!editor) throw new Error('Could not find input box');
        editor.focus();
        document.execCommand('insertText', false, ${JSON.stringify(message)});
      })()
    `);
        await sleep(500);
        await page.pressKey('Enter');
        return;
    }
    // Get the bounding box of the Lexical editor for a physical mouse click
    const rect = await page.evaluate(`
    (() => {
      const container = document.getElementById('antigravity.agentSidePanelInputBox');
      if (!container) throw new Error('Could not find antigravity.agentSidePanelInputBox');
      const editor = container.querySelector('[data-lexical-editor="true"]');
      if (!editor) throw new Error('Could not find Antigravity input box');
      const r = editor.getBoundingClientRect();
      return JSON.stringify({ x: r.left + r.width / 2, y: r.top + r.height / 2 });
    })()

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Ensure the Antigravity side panel with the input box is open before sending
  2. Fix CDP bridge setup so the primary (non-fallback) path is used
  3. Wait for the Lexical editor selector before evaluating the fallback script
  4. Re-check the DOM structure after an Antigravity update and adjust the selector

Example fix

// before
const editor = container?.querySelector('[data-lexical-editor="true"]');
if (!editor) throw new Error('Could not find input box');
// after
await page.waitForSelector('#antigravity.agentSidePanelInputBox [data-lexical-editor="true"]', { timeout: 10000 });
const editor = container?.querySelector('[data-lexical-editor="true"]');
Defensive patterns

Strategy: validation

Validate before calling

const ready = await page.evaluate(() =>
  !!document.getElementById('antigravity.agentSidePanelInputBox')?.querySelector('[data-lexical-editor="true"]'));
if (!ready) throw new Error('Antigravity input editor not ready');

Type guard

function inputIsReady(container) {
  return container != null && typeof container.querySelector === 'function'
    && container.querySelector('[data-lexical-editor="true"]') !== null;
}

Try / catch

try {
  await sendMessage(message);
} catch (err) {
  if (err.message === 'Could not find input box') {
    // open panel / wait for editor, then retry
  } else throw err;
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/fd51988842c43b75. Report an issue: GitHub.