{"record":{"id":"35f45c1ffa8fb255","repo":"jackwener/OpenCLI","slug":"pickerresult-reason-failed-to-open-gemini-m","errorCode":null,"errorMessage":"${pickerResult?.reason || 'Failed to open Gemini model picker for model discovery'}","messagePattern":"\\$\\{pickerResult\\?\\.reason \\|\\| 'Failed to open Gemini model picker for model discovery'\\}","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gemini/ask.js","lineNumber":149,"sourceCode":"        // ── Model and thinking discovery (shared by both model and\n        //    thinking selection) ──────────────────────────────────────\n        let discoveredModels = null;\n        if (hasModel || hasThinking) {\n            await ensureGeminiPage(page);\n\n            // Open the picker menu (click the model-picker button).\n            const pickerRaw = await page.evaluate(`\n              (() => {\n                ${pickModelPickerScript()}\n                const picker = findModelPicker();\n                if (!picker) return { ok: false, reason: 'Gemini model picker button was not found' };\n                try { picker.click(); } catch (_) { return { ok: false, reason: 'Failed to click Gemini model picker button' }; }\n                return { ok: true };\n              })()\n            `);\n            const pickerResult = unwrapBrowserBridgeEnvelope(pickerRaw);\n            if (!pickerResult || typeof pickerResult !== 'object' || !pickerResult.ok) {\n                throw new CommandExecutionError(\n                    pickerResult?.reason || 'Failed to open Gemini model picker for model discovery'\n                );\n            }\n\n            // Wait for React to render the menu.\n            await page.wait(1.0);\n\n            // Read model entries from the open menu.\n            const raw = await page.evaluate(readMenuModelsScript());\n            discoveredModels = requireDiscoveredModels(raw);\n\n            // Close the menu. Thinking support is intentionally not copied from\n            // the currently-visible UI into every model row: Gemini exposes\n            // thinking controls for the current selection, not a reliable\n            // per-model capability matrix.\n            await page.evaluate(`(() => { try { document.body.click(); } catch (_) {} })()`);\n        }\n","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/ask.js#L131-L167","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nawait page.wait(1.0);\n// after\nawait page.wait(3.0); // let React render the picker button before clicking","handlingStrategy":"retry","validationCode":"const pickerRaw = await evalBridge(script);\nconst pickerResult = unwrapBrowserBridgeEnvelope(pickerRaw);\nif (!pickerResult?.ok) { await page.wait(2.0); /* retry once before proceeding */ }","typeGuard":"function isPickerResultOk(r) { return !!r && typeof r === 'object' && r.ok === true; }","tryCatchPattern":"try {\n  await runAskCommand();\n} catch (e) {\n  if (/model picker/i.test(e.message)) { await page.reload(); await page.wait(3); /* retry */ }\n  else throw e;\n}","preventionTips":["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"],"tags":["browser-automation","gemini","ui-selector"],"backgroundTag":"dom-selector-stale","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}