jackwener/OpenCLI · error

insertText returned no inserted flag — command may not be su

Error message

insertText returned no inserted flag — command may not be supported by the extension

What it means

insertText sends the 'insert-text' command through the extension and expects an { inserted: true } result. A missing/falsy inserted flag means the command returned nothing usable, interpreted as the extension not supporting insert-text.

Source

Thrown at src/browser/page.ts:326

   */
  async setFileInput(files: string[], selector?: string): Promise<void> {
    const result = await sendCommand('set-file-input', {
      files,
      selector,
      ...this._cmdOpts(),
    }) as { count?: number };
    if (!result?.count) {
      throw new Error('setFileInput returned no count — command may not be supported by the extension');
    }
  }

  async insertText(text: string): Promise<void> {
    const result = await sendCommand('insert-text', {
      text,
      ...this._cmdOpts(),
    }) as { inserted?: boolean };
    if (!result?.inserted) {
      throw new Error('insertText returned no inserted flag — command may not be supported by the extension');
    }
  }

  async frames(): Promise<Array<{ index: number; frameId: string; url: string; name: string }>> {
    const result = await sendCommand('frames', { ...this._cmdOpts() });
    return Array.isArray(result) ? result : [];
  }

  async evaluateInFrame(js: string, frameIndex: number): Promise<unknown> {
    const code = buildEvaluateExpression(js);
    return sendCommand('exec', { code, frameIndex, ...this._cmdOpts() });
  }

  async cdp(method: string, params: Record<string, unknown> = {}): Promise<unknown> {
    return sendCommand('cdp', {
      cdpMethod: method,
      cdpParams: params,
      ...this._cmdOpts(),

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Update/reload the OpenCLI Chrome extension to the newest version
  2. Ensure focus is on an editable element before calling insertText
  3. Fall back to keyboard-based typing APIs if insert-text is unsupported

Example fix

// before
await page.insertText('hello');
// after
await page.click(selector); // focus the editable element first
await page.insertText('hello');
Defensive patterns

Strategy: fallback

Validate before calling

const editable = await page.evaluate("!!document.activeElement && (document.activeElement as HTMLElement).isContentEditable || /INPUT|TEXTAREA/.test(document.activeElement?.tagName || '')");
if (!editable) await page.click(targetSelector);

Type guard

function confirmsInsert(r: { inserted?: boolean } | null): r is { inserted: true } { return r?.inserted === true; }

Try / catch

try { await page.insertText(text); }
catch (e) {
  if (String(e.message).includes('no inserted flag')) {
    await page.keyboard.type(text); // fallback
  } else throw e;
}

Prevention

When it happens

Trigger: Calling page.insertText(text) when the extension's response has no truthy inserted property — typically an outdated extension lacking the insert-text handler, or the target element not being editable.

Common situations: Running with an older extension after upgrading the CLI; inserting into a non-focused or non-editable element so the handler reports failure without a proper error.

Related errors


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