{"record":{"id":"894c6cae6b7a625e","repo":"jackwener/OpenCLI","slug":"sidebar-toggle-failed-894c6c","errorCode":null,"errorMessage":"sidebar-toggle failed","messagePattern":"sidebar-toggle failed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qoder/ui.js","lineNumber":36,"sourceCode":"    CommandExecutionError,\n    EmptyResultError,\n} from '@jackwener/opencli/errors';\nimport { IS_VISIBLE_JS, clickByTextScript, clickFirstScript, evaluateQoder, parsePositiveInt, requireArrayResult } from './_utils.js';\n\n// -------- sidebar-toggle --------\ncli({\n    site: 'qoder',\n    name: 'sidebar-toggle',\n    access: 'write',\n    description: 'Collapse / Expand the Qoder Quest List sidebar (⌘B).',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [],\n    columns: ['Status'],\n    func: async (page) => {\n        const res = await evaluateQoder(page, clickByTextScript(['Collapse Quest List', 'Expand Quest List']));\n        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'sidebar-toggle failed', '');\n        return [{ Status: `clicked: ${res.matched}` }];\n    },\n});\n\n// -------- open-panel --------\ncli({\n    site: 'qoder',\n    name: 'open-panel',\n    access: 'write',\n    description: 'Open / close the Qoder bottom panel (Output / Terminal / Debug Console). ⌥⌘B equivalent.',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [],\n    columns: ['Status'],\n    func: async (page) => {\n        const res = await evaluateQoder(page, clickByTextScript(['Open Panel', 'Close Panel']));\n        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'open-panel failed', '');","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/ui.js#L18-L54","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nconst res = await evaluateQoder(page, clickByTextScript(['Collapse Quest List', 'Expand Quest List']));\n// after\nlet res = await evaluateQoder(page, clickByTextScript(['Collapse Quest List', 'Expand Quest List']));\nif (!res?.ok) res = await evaluateQoder(page, clickFirstScript(['button[aria-label*=\"Quest\"]', 'button[title*=\"Quest\"]']));","handlingStrategy":"try-catch","validationCode":"const toggleVisible = await page.evaluate(`Array.from(document.querySelectorAll('button')).some(b => /Quest List/.test(b.textContent || ''))`);\nif (!toggleVisible) console.warn('Quest List toggle not found on this page');","typeGuard":"function isClickOk(res) { return Boolean(res && res.ok === true); }","tryCatchPattern":"try {\n  await sidebarToggle(page);\n} catch (e) {\n  if (/sidebar-toggle failed/.test(String(e.message))) console.warn('Toggle missing; sidebar state unchanged');\n  else throw e;\n}","preventionTips":["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."],"tags":["ui-automation","dom-selector","click-failed"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}