jackwener/OpenCLI · error · CommandExecutionError
${pickerResult?.reason || 'Failed to open Gemini model picke
Error message
${pickerResult?.reason || 'Failed to open Gemini model picker for model discovery'} What it means
This CommandExecutionError is thrown when the browser-bridge script that clicks Gemini's model picker button fails or reports not-ok. The library clicks the picker button inside gemini.google.com to enumerate selectable models; if the click throws, the bridge returns ok:false with a reason, or the envelope can't be unwrapped, this fallback message is used.
Source
Thrown at clis/gemini/ask.js:149
// ── Model and thinking discovery (shared by both model and
// thinking selection) ──────────────────────────────────────
let discoveredModels = null;
if (hasModel || hasThinking) {
await ensureGeminiPage(page);
// Open the picker menu (click the model-picker button).
const pickerRaw = await page.evaluate(`
(() => {
${pickModelPickerScript()}
const picker = findModelPicker();
if (!picker) return { ok: false, reason: 'Gemini model picker button was not found' };
try { picker.click(); } catch (_) { return { ok: false, reason: 'Failed to click Gemini model picker button' }; }
return { ok: true };
})()
`);
const pickerResult = unwrapBrowserBridgeEnvelope(pickerRaw);
if (!pickerResult || typeof pickerResult !== 'object' || !pickerResult.ok) {
throw new CommandExecutionError(
pickerResult?.reason || 'Failed to open Gemini model picker for model discovery'
);
}
// Wait for React to render the menu.
await page.wait(1.0);
// Read model entries from the open menu.
const raw = await page.evaluate(readMenuModelsScript());
discoveredModels = requireDiscoveredModels(raw);
// Close the menu. Thinking support is intentionally not copied from
// the currently-visible UI into every model row: Gemini exposes
// thinking controls for the current selection, not a reliable
// per-model capability matrix.
await page.evaluate(`(() => { try { document.body.click(); } catch (_) {} })()`);
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the command after a page.reload() / fresh login so the model picker button is rendered before clicking
- Increase the wait before clicking the picker (e.g. page.wait(2.0)) to let React mount the button
- Update the picker-button selector in clis/gemini/ask.js to match the current Gemini Web DOM
- Check `opencli gemini login` status to ensure an authenticated, non-redirected session
Example fix
// before await page.wait(1.0); // after await page.wait(3.0); // let React render the picker button before clicking
Defensive patterns
Strategy: retry
Validate before calling
const pickerRaw = await evalBridge(script);
const pickerResult = unwrapBrowserBridgeEnvelope(pickerRaw);
if (!pickerResult?.ok) { await page.wait(2.0); /* retry once before proceeding */ } Type guard
function isPickerResultOk(r) { return !!r && typeof r === 'object' && r.ok === true; } Try / catch
try {
await runAskCommand();
} catch (e) {
if (/model picker/i.test(e.message)) { await page.reload(); await page.wait(3); /* retry */ }
else throw e;
} Prevention
- Wait for the picker button to exist ( waitForSelector ) before clicking
- Keep selectors in sync with the current Gemini Web DOM
- Use a persistent logged-in browser profile
- Reload the page before automation if the session was idle
When it happens
Trigger: The injected picker.click() throws (element detached/not clickable), the bridge returns {ok:false, reason:'Failed to click Gemini model picker button'}, or pickerRaw fails unwrapBrowserBridgeEnvelope (null/non-object).
Common situations: Gemini Web UI changed so the picker button selector no longer matches; page not fully rendered before the click; slow network causing React not to mount the button; browser bridge/CDP hiccup or page navigation mid-automation.
Related errors
- Could not select thinking level '${thinkingValue}' in the Ge
- Could not switch to ${wantModel} model
- Claude composer is not available on the current page.
- Codex sidebar extraction returned an invalid payload.
- Could not resolve a stable Codex conversation identity.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/35f45c1ffa8fb255.
Report an issue: GitHub.