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

  1. Inspect the actual toggle button text/aria-label in the running Qoder UI and update the clickByTextScript array.
  2. Add a fallback clickFirstScript with aria-label/title selectors like the settings command does.
  3. Ensure the page is fully loaded (add a wait) before toggling.
  4. 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

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


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