jackwener/OpenCLI · error · CommandExecutionError

Model click did not verify selected model "${chosenLabel}".

Error message

Model click did not verify selected model "${chosenLabel}".

What it means

After clicking the chosen model option, the command re-reads `.core-model-select-trigger` text and verifies it now contains the requested substring; if the trigger is unreadable or still shows a different model, it throws this CommandExecutionError. It is a post-condition check ensuring the click actually changed the selection rather than silently doing nothing.

Source

Thrown at clis/trae-solo/model.js:123

          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

  1. Re-run the command; if it verifies on retry, the wait was simply too short.
  2. Check the error detail (`current=...`) to see what model is actually active and confirm whether the switch truly failed.
  3. Verify the requested name is a substring of the FULL trigger label after switching (match on a longer/exact substring).
  4. Wait for in-flight AI tasks to complete before switching models.
  5. If persistent across attempts, the Trae build likely changed the menu behavior — update selectors/verification logic.

Example fix

// before
await cli('trae-solo', 'model', 'gpt'); // label 'GPT-4o (preview)' may lag
// after
await new Promise(r => setTimeout(r, 1500)); // let UI settle
const cur = await cli('trae-solo', 'model'); // read-only check
if (!/gpt/i.test(cur[0].Model)) await cli('trae-solo', 'model', 'gpt');
Defensive patterns

Strategy: try-catch

Validate before calling

const cur = await cli('trae-solo', 'model');
if (cur[0]?.Model?.toLowerCase().includes(name)) return; // already active

Type guard

const switchVerified = (result, name) =>
  Array.isArray(result) && typeof result[0]?.Model === 'string' &&
  result[0].Status === 'switched' && result[0].Model.toLowerCase().includes(name.toLowerCase());

Try / catch

try {
  await cli('trae-solo', 'model', name);
} catch (e) {
  if (/did not verify selected model/.test(e.message)) {
    const actual = (e.detail || '').replace('current=', '');
    console.warn(`Switch unverified; trigger shows: ${actual || 'unreadable'}`);
    // re-read and retry before giving up
  } else throw e;
}

Prevention

When it happens

Trigger: The synthetic/CDP click landed but React state did not update; the menu item click was swallowed (e.g. hover-only submenu in a different build); the trigger text failed to re-render within the 0.6s wait; the selected label doesn't contain the requested substring (e.g. matched via a wrapper label); or the trigger became unreadable after the click.

Common situations: Very slow Trae UI where 0.6s is insufficient for the label to update; models whose display name doesn't contain the searched substring; Trae builds where clicking a row opens a nested confirm; automation running while the window is backgrounded so React skips renders.

Related errors


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