jackwener/OpenCLI · error · CommandExecutionError

Browser Bridge native click support is required for Creation

Error message

Browser Bridge native click support is required for Creation Actions

What it means

CommandExecutionError thrown when the page object does not implement page.nativeClick, which is required to synthesize trusted mouse events at real coordinates for Creation Action buttons. Ordinary evaluate-based clicks are insufficient here.

Source

Thrown at clis/midjourney/utils.js:1220

    const visible = (element) => {
      const rect = element.getBoundingClientRect();
      const style = getComputedStyle(element);
      return rect.width > 0 && rect.height > 0 && style.visibility !== 'hidden' && style.display !== 'none';
    };
    const close = [...document.querySelectorAll('button[title="Close"]')].filter(visible).at(-1);
    const scope = close?.parentElement?.parentElement;
    if (!scope) return { ok: false, reason: 'job detail scope not found' };
    const matches = [...scope.querySelectorAll('button')]
      .filter(visible)
      .filter((button) => String(button.textContent || '').replace(/\s+/g, ' ').trim() === label);
    const button = matches[wantedIndex];
    if (!button) return { ok: false, reason: `button ${label} occurrence ${wantedIndex} not found`, count: matches.length };
    if (button.disabled) return { ok: false, reason: `button ${label} is disabled`, count: matches.length };
    const rect = button.getBoundingClientRect();
    return { ok: true, x: rect.left + rect.width / 2, y: rect.top + rect.height / 2, count: matches.length };
  }, normalizeButtonText(text), occurrence));
  if (!target?.ok) throw new CommandExecutionError(`Midjourney Creation Action unavailable: ${target?.reason || text}`);
  if (typeof page.nativeClick !== 'function') throw new CommandExecutionError('Browser Bridge native click support is required for Creation Actions');
  await page.nativeClick(target.x, target.y);
  return target;
}

export async function clickVisibleControl(page, label) {
  const target = unwrapEvaluateResult(await page.evaluate((wanted) => {
    const visible = (element) => {
      const rect = element.getBoundingClientRect();
      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';
    };
    const button = [...document.querySelectorAll('button')].find((node) => visible(node) && (
      node.textContent?.trim().replace(/\s+/g, ' ') === wanted
      || node.title === wanted
      || node.getAttribute('aria-label') === wanted
    ));
    if (!button || button.disabled) return null;
    const rect = button.getBoundingClientRect();
    return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Update the Browser Bridge extension/client to a version with nativeClick support.
  2. Pass the Bridge-wrapped page object rather than a raw automation page.
  3. For tests, stub page.nativeClick(x, y).
  4. Fall back to page.click on the button selector if trusted events aren't strictly required.

Example fix

// before
await clickCreationAction(plainPage, 'Upscale', 1);
// after
const page = await bridge.attach(tabId); // has nativeClick
await clickCreationAction(page, 'Upscale', 1);
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof page.nativeClick !== 'function') {
  throw new Error('Browser Bridge with nativeClick is required for Creation Actions');
}

Type guard

function supportsNativeClick(page) { return typeof page?.nativeClick === 'function'; }

Try / catch

try {
  await clickCreationAction(page, 'Upscale', 0);
} catch (err) {
  if (String(err.message).includes('native click')) {
    const bridge = await require('./bridge').attach(tabId);
    await clickCreationAction(bridge, 'Upscale', 0);
  } else throw err;
}

Prevention

When it happens

Trigger: clickCreationAction succeeded in locating the button coordinates, but typeof page.nativeClick !== 'function' (older Bridge or non-Bridge page object).

Common situations: Outdated Browser Bridge; raw puppeteer/playwright page passed in; test mocks without nativeClick stub.

Related errors


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