jackwener/OpenCLI · error · CommandExecutionError

ChatGPT model selection requires native browser click suppor

Error message

ChatGPT model selection requires native browser click support.

What it means

selectChatGPTModel performs real UI clicks on the ChatGPT page, which requires the page adapter to expose a nativeClick function (CDP-level mouse input). If page.nativeClick is not a function, the browser driver lacks that capability and the library throws CommandExecutionError before touching the page.

Source

Thrown at clis/chatgpt/utils.js:565

    await page.evaluate(`(() => {
        const value = encodeURIComponent(JSON.stringify({ model: ${JSON.stringify(modelSlug)}, effort: ${JSON.stringify(effort)} }));
        for (const domain of ['; domain=.chatgpt.com', '; domain=chatgpt.com', '']) {
            document.cookie = 'oai-last-model-config=; path=/' + domain + '; max-age=0; SameSite=Lax';
        }
        document.cookie = 'oai-last-model-config=' + value + '; path=/; domain=.chatgpt.com; max-age=31536000; SameSite=Lax';
        document.cookie = 'oai-last-model-config=' + value + '; path=/; max-age=31536000; SameSite=Lax';
        if (window.location.pathname === '/new') window.location.reload();
        else window.location.assign('/new');
        return true;
    })()`).catch(() => true);
    return { ok: true, status: response.status, modelSlug, effort };
}

export async function selectChatGPTModel(page, model) {
    const target = requireKnownChatGPTModel(model);
    debugChatGPTModel(`target=${target.key}`);
    if (typeof page.nativeClick !== 'function') {
        throw new CommandExecutionError('ChatGPT model selection requires native browser click support.');
    }
    await ensureOnChatGPT(page);
    debugChatGPTModel('ensured chatgpt');
    const currentUrl = await currentChatGPTUrl(page).catch(() => '');
    debugChatGPTModel(`url=${currentUrl}`);
    if (!currentUrl.startsWith(`${CHATGPT_URL}/new`)) {
        await page.goto(`${CHATGPT_URL}/new`, { waitUntil: 'none' });
        await page.wait(2);
    }
    await ensureChatGPTComposer(page, 'ChatGPT model selection requires a logged-in ChatGPT session with a visible composer.');
    debugChatGPTModel('composer ok');

    const before = await getCurrentChatGPTModel(page);
    debugChatGPTModel(`before=${before.model || 'none'}`);
    if (before.model === target.key) {
        return { Status: 'Already selected', Model: target.label };
    }
    const apiResult = await setChatGPTModelConfig(page, target);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the OpenCLI CDP browser automation page object, which implements nativeClick.
  2. Upgrade/repair the browser driver so CDP Input domain (mouse events) is available.
  3. In tests, add a nativeClick(x, y) no-op or simulated implementation to the page stub.
  4. If native clicks can't be supported, set the model via the ChatGPT UI manually or use setChatGPTModelConfig directly where the session permits.

Example fix

// before
const page = await someLib.open('https://chatgpt.com'); // no nativeClick
await selectChatGPTModel(page, 'advanced');
// after
if (typeof page.nativeClick !== 'function') {
  page = await opencli.browser.open('https://chatgpt.com'); // CDP page with nativeClick
}
await selectChatGPTModel(page, 'advanced');
Defensive patterns

Strategy: type-guard

Validate before calling

if (typeof page.nativeClick !== 'function') {
  throw new Error('This browser driver does not support native clicks; use the OpenCLI CDP page.');
}

Type guard

function supportsNativeClick(page) {
  return page != null && typeof page.nativeClick === 'function'
    && typeof page.evaluate === 'function';
}

Try / catch

try {
  await selectChatGPTModel(page, model);
} catch (err) {
  if (err instanceof CommandExecutionError && /native browser click support/.test(err.message)) {
    page = await opencli.browser.open(page.url()); // reopen with CDP driver
    return selectChatGPTModel(page, model);
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling selectChatGPTModel with a page object from a driver/environment that does not implement nativeClick — e.g. a stubbed/mock page in tests, a headless driver missing input-injection support, or a page object from a different automation library that only supports evaluate().

Common situations: Swapping the underlying browser driver or upgrading it to a version without the nativeClick extension; unit tests injecting a minimal page fake; running in an environment where CDP input domains are disabled (some restricted/remote browser setups).

Related errors


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