{"record":{"id":"25a0cd223e087c33","repo":"jackwener/OpenCLI","slug":"pickerresult-reason-failed-to-open-model-pick","errorCode":null,"errorMessage":"pickerResult?.reason || 'Failed to open model picker for model selection'","messagePattern":"pickerResult\\?\\.reason \\|\\| 'Failed to open model picker for model selection'","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/gemini/utils.js","lineNumber":2727,"sourceCode":" * pattern with an explicit page.wait between them.\n */\nexport function selectGeminiModelScript(modelId) {\n    return selectModelInMenuScript(modelId);\n}\n\n/**\n * Select a Gemini model by canonical id (e.g. \"2.5-flash\") in the\n * web UI model picker.  Opens the picker, waits for React, then clicks\n * the matching entry.  Throws CommandExecutionError on failure.\n */\nexport async function selectGeminiModel(page, modelId) {\n    await ensureGeminiPage(page);\n\n    // Open the picker menu.\n    const pickerRaw = await page.evaluate(openModelPickerForThinkingScript());\n    const pickerResult = unwrapGeminiEvaluateResult(pickerRaw, 'Gemini model picker');\n    if (!pickerResult || !pickerResult.ok) {\n        throw new CommandExecutionError(\n            pickerResult?.reason || 'Failed to open model picker for model selection'\n        );\n    }\n\n    // Wait for React to render the menu.\n    await page.wait(0.8);\n\n    // Find and click the matching menu item.\n    const raw = await page.evaluate(selectModelInMenuScript(modelId));\n    const result = unwrapGeminiEvaluateResult(raw, 'Gemini model selection');\n    if (!result || !result.ok) {\n        throw new CommandExecutionError(\n            result?.reason || 'Failed to select Gemini model \"' + modelId + '\"'\n        );\n    }\n\n    await page.wait(0.5);\n    const selectedModelId = await getCurrentGeminiModel(page);","sourceCodeStart":2709,"sourceCodeEnd":2745,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/gemini/utils.js#L2709-L2745","documentation":"CommandExecutionError thrown when the in-page script that opens Gemini's model picker menu reports failure (or returns no result) after unwrapGeminiEvaluateResult. The library cannot proceed to select a thinking model unless the picker menu opens.","triggerScenarios":"Calling the model-selection flow at clis/gemini/utils.js:2727 where openModelPickerForThinkingScript() returns ok:false or a reason, typically because the picker trigger button was not found or not clickable.","commonSituations":"Gemini UI update renaming/changing the picker button; page not logged in or showing an interstitial; slow React hydration; running while another menu is open.","solutions":["Re-run the command (transient UI timing)","Ensure the Gemini page is fully loaded and logged in before running","Update the CLI to match the current Gemini DOM structure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"await page.wait(1.0); // let the app fully hydrate before model operations\nconst ready = await page.evaluate(() => !!document.body && document.body.innerText.length > 0);\nif (!ready) throw new Error('Gemini page not ready for model picker interaction');","typeGuard":null,"tryCatchPattern":"try {\n  await selectGeminiModel(page, modelId);\n} catch (err) {\n  if (err.message.includes('model picker')) {\n    await page.reload();\n    await page.wait(2);\n    await selectGeminiModel(page, modelId); // one retry\n  } else throw err;\n}","preventionTips":["Ensure you are logged in and past any consent/interstitial screens","Reload the page and retry once before failing","Keep the CLI version current with the Gemini UI"],"tags":["browser-automation","dom","gemini"],"backgroundTag":"dom-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}