jackwener/OpenCLI · error · CommandExecutionError
sidebar-toggle failed
Error message
sidebar-toggle failed
What it means
Thrown by the qoder sidebar-toggle UI command when clickByTextScript(['Collapse Quest List','Expand Quest List']) fails. The error message shows res.reason when available, otherwise the generic 'sidebar-toggle failed'. It means no visible element with those exact texts was found or clickable.
Source
Thrown at clis/qoder/ui.js:36
CommandExecutionError,
EmptyResultError,
} from '@jackwener/opencli/errors';
import { IS_VISIBLE_JS, clickByTextScript, clickFirstScript, evaluateQoder, parsePositiveInt, requireArrayResult } from './_utils.js';
// -------- sidebar-toggle --------
cli({
site: 'qoder',
name: 'sidebar-toggle',
access: 'write',
description: 'Collapse / Expand the Qoder Quest List sidebar (⌘B).',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Status'],
func: async (page) => {
const res = await evaluateQoder(page, clickByTextScript(['Collapse Quest List', 'Expand Quest List']));
if (!res?.ok) throw new CommandExecutionError(res?.reason || 'sidebar-toggle failed', '');
return [{ Status: `clicked: ${res.matched}` }];
},
});
// -------- open-panel --------
cli({
site: 'qoder',
name: 'open-panel',
access: 'write',
description: 'Open / close the Qoder bottom panel (Output / Terminal / Debug Console). ⌥⌘B equivalent.',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Status'],
func: async (page) => {
const res = await evaluateQoder(page, clickByTextScript(['Open Panel', 'Close Panel']));
if (!res?.ok) throw new CommandExecutionError(res?.reason || 'open-panel failed', '');View on GitHub (pinned to 49907e53dc)
Solutions
- Inspect the actual toggle button text/aria-label in the running Qoder UI and update the clickByTextScript array.
- Add a fallback clickFirstScript with aria-label/title selectors like the settings command does.
- Ensure the page is fully loaded (add a wait) before toggling.
- Increase viewport size in headless mode so the toggle isn't collapsed/hidden.
Example fix
// before const res = await evaluateQoder(page, clickByTextScript(['Collapse Quest List', 'Expand Quest List'])); // after let res = await evaluateQoder(page, clickByTextScript(['Collapse Quest List', 'Expand Quest List'])); if (!res?.ok) res = await evaluateQoder(page, clickFirstScript(['button[aria-label*="Quest"]', 'button[title*="Quest"]']));
Defensive patterns
Strategy: try-catch
Validate before calling
const toggleVisible = await page.evaluate(`Array.from(document.querySelectorAll('button')).some(b => /Quest List/.test(b.textContent || ''))`);
if (!toggleVisible) console.warn('Quest List toggle not found on this page'); Type guard
function isClickOk(res) { return Boolean(res && res.ok === true); } Try / catch
try {
await sidebarToggle(page);
} catch (e) {
if (/sidebar-toggle failed/.test(String(e.message))) console.warn('Toggle missing; sidebar state unchanged');
else throw e;
} Prevention
- Check the toggle text in the current Qoder version before scripting.
- Run with a viewport large enough that the sidebar controls are rendered.
- Don't assume toggle presence on pages without the quest sidebar.
- Prefer aria-label selectors over changing text labels.
When it happens
Trigger: The sidebar toggle button's label text changed in a Qoder update; the sidebar is already in the target state and the toggle is hidden; the toggle is an icon-only button without accessible text; the page hasn't finished loading the quest list UI.
Common situations: Qoder version bump renamed 'Quest List' to something else; user runs the command on a page where the quest sidebar feature doesn't exist; headless viewport too small so the toggle is hidden behind a responsive breakpoint.
Related errors
- open-panel failed
- search open failed
- Settings button not found
- 找不到消息输入框
- Could not find an add-to-cart button on the product page.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/894c6cae6b7a625e.
Report an issue: GitHub.