stablyai/orca · error · Error

Browser rich-text editing command failed

Error message

Browser rich-text editing command failed

What it means

Thrown by the injected rich-text edit expression when document.execCommand('insertText'|'delete', ...) returns false or throws. execCommand is the bridge's chosen edit path because it produces a real input transaction that rich editors reconcile; when it fails, the value was not committed to the editor's model, so the bridge refuses to report success.

Source

Thrown at src/main/browser/agent-browser-bridge.ts:146

    ' const target = document.activeElement;',
    ' const value = ',
    valueExpression,
    ';',
    ` const selectAll = ${selectAll};`,
    " const isEditable = target?.isContentEditable === true || /^(|true|plaintext-only)$/i.test(target?.getAttribute?.('contenteditable') ?? 'false');",
    " if (!target || target === document.body || !isEditable) { throw new Error('Focused rich-text target is unavailable'); }",
    ' if (selectAll) {',
    "   if (typeof window.getSelection !== 'function') { throw new Error('Rich-text selection is unavailable'); }",
    '   const selection = window.getSelection();',
    "   if (!selection) { throw new Error('Rich-text selection is unavailable'); }",
    '   selection.selectAllChildren(target);',
    ' }',
    " const editCommand = selectAll && value.length === 0 ? 'delete' : 'insertText';",
    ' let edited = false;',
    ' try {',
    '   edited = document.execCommand(editCommand, false, value) === true;',
    ' } catch { edited = false; }',
    " if (!edited) { throw new Error('Browser rich-text editing command failed'); }",
    ' })()'
  ].join('')
}

function isExplicitContentEditableResult(result: unknown): boolean {
  const value =
    result && typeof result === 'object' ? (result as { value?: unknown }).value : undefined
  return typeof value === 'string' && /^(|true|plaintext-only)$/i.test(value)
}

type AgentBrowserExecOptions = {
  envOverrides?: NodeJS.ProcessEnv
  timeoutMs?: number
  timeoutError?: BrowserError
  stdinText?: string
}

type EnqueueTargetedCommandOptions = {

View on GitHub (pinned to 1136503c6a)

Solutions

  1. Confirm the editor is editable and focused before filling.
  2. For editors known to block execCommand, dispatch input events directly (BeforeInputEvent) via CDP instead.
  3. Retry focus then fill, since focus loss is a common cause of execCommand returning false.
  4. If the editor exposes a programmatic setValue API, use that instead of simulated typing.

Example fix

// before
await bridge.fill(editorSelector, text)

// after
await bridge.focus(editorSelector)
try {
  await bridge.fill(editorSelector, text)
} catch (err) {
  if (/rich-text editing command failed/i.test(err.message)) {
    // editor blocks execCommand — use CDP input-event dispatch
    await dispatchInputEventViaCdp(editorSelector, text)
  } else throw err
}
Defensive patterns

Strategy: fallback

Validate before calling

// confirm the editor accepts execCommand before relying on fill:\nconst editable = await isFocusedEditable(bridge)\nif (!editable) {\n  await bridge.focus(selector)\n}

Type guard

async function editorAcceptsExecCommand(bridge: BrowserBridge): Promise<boolean> {\n  return (await bridge.eval('(() => { try { return document.execCommand(\"insertText\", false, \"\") === true; } catch { return false; } })()')) === true\n}

Try / catch

try {\n  await bridge.fill(selector, text)\n} catch (err) {\n  if (/Browser rich-text editing command failed/.test((err as Error).message)) {\n    await dispatchInputEventViaCdp(selector, text) // editor blocks execCommand\n    return\n  }\n  throw err\n}

Prevention

When it happens

Trigger: The contentEditable element does not support execCommand text insertion (some custom editors intercept/preventDefault on beforeinput), the editor is read-only/disabled, execCommand is deprecated and unimplemented for a given editor type, or the editable region lost focus mid-edit.

Common situations: Filling a rich editor that overrides default input handling (Lexical, Slate, custom ContentEditable), an editor in a disabled/readonly state, or a browser build where execCommand is a no-op for the focused node.

Related errors


AI-assisted analysis of stablyai/orca@1136503c6a (2026-08-12). Data as JSON: /api/errors/530565a8e4f2948f. Report an issue: GitHub.