jackwener/OpenCLI · error · CommandExecutionError
Click on model option failed.
Error message
Click on model option failed.
What it means
Thrown when both click strategies for the chosen model option fail: the real CDP-backed `page.click` on the nth-of-type selector threw, AND the JavaScript fallback (dispatching synthetic pointer/mouse events on the nth visible option) returned false because no visible option existed at that index. It indicates the model menu closed, re-rendered, or the DOM changed between enumeration and clicking.
Source
Thrown at clis/trae-solo/model.js:117
// to JS dispatch on the nth visible option.
const fallbackClicked = await page.evaluate(`(function(i) {
const opts = Array.from(document.querySelectorAll('.core-model-select-model-item[role="option"]'))
.filter((el) => el.offsetParent);
const target = opts[i];
if (!target) return false;
const r = target.getBoundingClientRect();
const init = { bubbles: true, cancelable: true, button: 0, buttons: 1,
clientX: Math.round(r.left + r.width / 2),
clientY: Math.round(r.top + r.height / 2) };
target.dispatchEvent(new PointerEvent('pointerdown', { ...init, pointerType: 'mouse' }));
target.dispatchEvent(new MouseEvent('mousedown', init));
target.dispatchEvent(new PointerEvent('pointerup', { ...init, pointerType: 'mouse' }));
target.dispatchEvent(new MouseEvent('mouseup', init));
target.dispatchEvent(new MouseEvent('click', init));
return true;
})(${idx})`);
if (!fallbackClicked) {
throw new CommandExecutionError('Click on model option failed.', `model=${chosenLabel}`);
}
}
await page.wait(0.6);
const after = await readCurrentModel(page);
if (!after || !after.toLowerCase().includes(name)) {
throw new CommandExecutionError(
`Model click did not verify selected model "${chosenLabel}".`,
after ? `current=${after}` : 'model trigger was unreadable after click',
);
}
return [{ Status: 'switched', Model: after }];
}
// Just read the current.
return [{ Status: 'Active', Model: current }];
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Retry the command — transient menu closing is the most common cause.
- Ensure no background task/re-render is in flight in Trae before switching models (wait for the current operation to finish).
- Use `--list` first to confirm the menu opens reliably, then switch immediately after.
- If persistent, verify the `.core-model-select-model-item[role="option"]` selector still matches in the current Trae build and update selectors.
- Increase page.wait tolerance or re-open the trigger and retry the click.
Example fix
// before
await cli('trae-solo', 'model', 'gpt-4o'); // flaky menu
// after
for (let i = 0; i < 3; i++) {
try { await cli('trae-solo', 'model', 'gpt-4o'); break; }
catch (e) { if (!/Click on model option failed/.test(e.message) || i === 2) throw e;
await new Promise(r => setTimeout(r, 1000)); }
} Defensive patterns
Strategy: retry
Validate before calling
const opts = await cli('trae-solo', 'model', { list: true });
if (!opts.length) throw new Error('Model menu not opening — abort before switch'); Try / catch
try {
await cli('trae-solo', 'model', name);
} catch (e) {
if (/Click on model option failed/.test(e.message)) {
await sleep(1000); // let any re-render settle, then retry once
await cli('trae-solo', 'model', name);
} else throw e;
} Prevention
- Avoid switching models while an AI task is streaming (causes re-renders).
- Retry once with a short delay — menu flakiness is usually transient.
- Keep the Trae window focused/visible during UI automation.
- Pin a known-good Trae version in automation environments.
When it happens
Trigger: The dropdown closes between stage 1 enumeration and stage 2 click (e.g. a re-render or focus change); the option list shrank so `opts[idx]` is undefined in the fallback; the page navigated; or a Trae UI update changed the option element structure so page.click times out on the selector.
Common situations: Slow/heavily loaded Trae windows where menus animate in and out; clicking while an AI task is running causes re-renders; flaky remote/desktop sessions delaying input events; Trae version upgrades altering the `.core-model-select-model-item` DOM.
Related errors
- No model matched: '${name}'
- Model click did not verify selected model "${chosenLabel}".
- settings click failed
- sidebar-toggle failed
- 无法在聊天列表中找到该用户,候选人可能不在当前列表中
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/7bb2c0882fcbae0f.
Report an issue: GitHub.