{"record":{"id":"8e934432125b058f","repo":"jackwener/OpenCLI","slug":"open-editor-button-not-found","errorCode":null,"errorMessage":"Open Editor button not found","messagePattern":"Open Editor button not found","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qoder/composer.js","lineNumber":42,"sourceCode":"        await page.wait(0.5);\n        return [{ Status: 'enhanced (check composer)' }];\n    },\n});\n\n// -------- open-editor --------\ncli({\n    site: 'qoder',\n    name: 'open-editor',\n    access: 'write',\n    description: 'Click \"Open Editor\" — opens the current draft in a full editor pane.',\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 Editor']));\n        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'Open Editor button not found', '');\n        return [{ Status: 'clicked' }];\n    },\n});\n","sourceCodeStart":24,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/composer.js#L24-L46","documentation":"Thrown by the qoder open-editor command when the DOM text-matching click script cannot find (or click) a button labeled 'Open Editor' in the Qoder UI. The command is a pure UI-automation wrapper: it evaluates clickByTextScript in the Qoder webview and surfaces res?.ok as a CommandExecutionError on failure. It means the expected editor-open control is absent from the current DOM.","triggerScenarios":"Running `qoder open-editor` when: there is no active chat draft (Qoder hides the Open Editor affordance when the composer is empty); the Qoder app was updated and the label or DOM structure changed; the sidebar/panel containing the button is collapsed; or evaluateQoder failed to evaluate in the correct webview frame so the click never executed.","commonSituations":"Scripts that chain open-editor right after launching Qoder before the UI hydrates; users in localized Qoder builds where the button text differs; CI sessions where the Qoder window is backgrounded and the webview throttles rendering.","solutions":["Ensure a draft exists in the Qoder composer (Open Editor only appears with draft content), then rerun the command.","Wait for UI readiness (page.wait) or retry the click a couple of times before declaring failure.","Dump the button labels in the panel area and add the actual label as an additional candidate in clickByTextScript (including localized variants).","Check res?.reason: if it indicates evaluation failure rather than button-not-found, fix the webview attach/evaluate path in evaluateQoder."],"exampleFix":"// before\nconst res = await evaluateQoder(page, clickByTextScript(['Open Editor']));\n// after\nawait page.wait(1);\nconst res = await evaluateQoder(page, clickByTextScript(['Open Editor', 'Open in Editor', '在编辑器中打开']));","handlingStrategy":"retry","validationCode":"// Confirm an 'Open Editor' control exists before invoking the command\nconst hasBtn = await page.evaluate(() =>\n  Array.from(document.querySelectorAll('button, [role=\"button\"]'))\n    .some(b => (b.innerText || '').trim() === 'Open Editor')\n);\nif (!hasBtn) throw new Error('Open Editor control not present — is there a draft in the composer?');","typeGuard":"function hasClickResult(res) {\n  return typeof res === 'object' && res !== null && res.ok === true;\n}","tryCatchPattern":"try {\n  await runCli('qoder open-editor');\n} catch (e) {\n  if (String(e.message).includes('Open Editor button not found')) {\n    await sleep(1500); // allow UI hydration, retry once\n    return runCli('qoder open-editor');\n  }\n  throw e;\n}","preventionTips":["Only call open-editor when the composer holds a draft.","Wait for the Qoder panel to finish mounting before UI automation.","Keep candidate button labels updated per Qoder version/locale.","Prefer checking res?.reason over the generic message when debugging."],"tags":["ui-automation","dom-click","browser","qoder"],"backgroundTag":"ui-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}