jackwener/OpenCLI · error · CommandExecutionError
Category click failed.
Error message
Category click failed.
What it means
This CommandExecutionError is thrown when an in-page browser script that dispatches synthetic mouse events (mouseup/click) to a marketplace category tag fails to report ok:true. The wrapper executed via page.evaluate did not complete successfully or returned a failure reason, so the CLI cannot proceed to scrape '.marketplace-card-v2' cards. It means the simulated category click did not land on a usable element (selector drift, hidden element, or navigation away).
Source
Thrown at clis/trae-solo/skill.js:203
const tag = Array.from(document.querySelectorAll('.marketplace-tag'))
.find((t) => t.offsetParent && (t.textContent || '').trim().toLowerCase().includes(${nameJson}));
if (!tag) return { ok: false, reason: 'Category not found.' };
const r = tag.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),
};
tag.dispatchEvent(new PointerEvent('pointerdown', { ...init, pointerType: 'mouse' }));
tag.dispatchEvent(new MouseEvent('mousedown', init));
tag.dispatchEvent(new PointerEvent('pointerup', { ...init, pointerType: 'mouse' }));
tag.dispatchEvent(new MouseEvent('mouseup', init));
tag.dispatchEvent(new MouseEvent('click', init));
await wait(700);
return { ok: true, chosen: (tag.textContent || '').trim() };
})()`);
if (!switchRes?.ok) {
throw new CommandExecutionError(switchRes?.reason || 'Category click failed.', SESSION_HINT);
}
const items = await page.evaluate(`(function() {
const cards = Array.from(document.querySelectorAll('.marketplace-card-v2')).filter((c) => c.offsetParent);
return cards.map((c, i) => {
const logo = c.querySelector('.skill-logo-svg');
const name = (logo && logo.getAttribute('aria-label')) || '';
const full = (c.innerText || '').replace(/\\s+/g, ' ').trim();
let desc = full;
if (name && desc.startsWith(name)) desc = desc.slice(name.length).trim();
return { index: i + 1, name: name || full.split(' ')[0], description: desc.slice(0, 200) };
});
})()`);
const limit = Number.isInteger(kwargs.limit) && kwargs.limit > 0 ? kwargs.limit : 100;
return ((items || []).slice(0, limit)).map((r) => ({ Index: r.index, Name: r.name, Description: r.description }));
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run with a fresh page; transient render timing often resolves it.
- Verify the category tag selector still exists in the current marketplace DOM and update the page.evaluate snippet in skill.js if renamed.
- Increase the post-click wait (700ms) or poll for '.marketplace-card-v2' visibility instead of fixed sleep.
- Check switchRes.reason in the thrown message for the specific failure and handle that case (e.g. re-navigate to the marketplace page first).
Example fix
// before
await wait(700);
return { ok: true, chosen: (tag.textContent || '').trim() };
// after
for (let i = 0; i < 10; i++) {
await wait(200);
if (document.querySelector('.marketplace-card-v2')) break;
}
return { ok: !!document.querySelector('.marketplace-card-v2'), chosen: (tag.textContent || '').trim() }; Defensive patterns
Strategy: retry
Validate before calling
const ready = await page.evaluate(`!!document.querySelector('.marketplace-card-v2, .marketplace-category-tag')`);
if (!ready) throw new Error('Marketplace UI not ready'); Type guard
function isSwitchOk(res) { return !!res && typeof res === 'object' && res.ok === true && typeof res.chosen === 'string'; } Try / catch
try {
const res = await runCategorySwitch(page);
if (!isSwitchOk(res)) throw new CommandExecutionError(res?.reason || 'Category click failed.');
} catch (e) {
// retry once with fresh page / longer poll before surfacing
} Prevention
- Poll for '.marketplace-card-v2' visibility instead of a fixed 700ms wait
- Assert tag visibility (offsetParent) before dispatching click events
- Snapshot the marketplace DOM in CI to detect selector drift early
- Re-navigate to the marketplace page before retrying a failed click
When it happens
Trigger: Running the marketplace category/listing command when: the category tag selector changed in the Trae marketplace UI, the tag is not visible/clickable (offsetParent falsy), the evaluate block throws or returns {ok:false,reason:...}, or the 700ms wait is not enough and a follow-up check fails.
Common situations: Marketplace UI updated and renamed CSS classes; clicking an already-selected category re-renders and invalidates the node; slow network leaves the tag inside a loading skeleton; automation runs headless where the tag is display:none.
Related errors
- Waiting for 12306 tk auth cookie
- ChatGPT composer is not available on the current page.
- Could not find the ChatGPT model selector in the composer.
- Could not click the ChatGPT ${target.label} model option.
- Could not find the ChatGPT tools menu button in the composer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/cc433c8f4f24afb8.
Report an issue: GitHub.