{"record":{"id":"093d91bfd2f768c0","repo":"jackwener/OpenCLI","slug":"prompt-enhance-button-not-found","errorCode":null,"errorMessage":"Prompt Enhance button not found","messagePattern":"Prompt Enhance button not found","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qoder/composer.js","lineNumber":23,"sourceCode":"\nimport { cli, Strategy } from '@jackwener/opencli/registry';\nimport { CommandExecutionError } from '@jackwener/opencli/errors';\nimport { clickByTextScript, evaluateQoder } from './_utils.js';\n\n// -------- prompt-enhance --------\ncli({\n    site: 'qoder',\n    name: 'prompt-enhance',\n    access: 'write',\n    description: 'Click \"Prompt Enhance\" — Qoder rewrites the current composer draft for better LLM consumption.',\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(['Prompt Enhance']));\n        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'Prompt Enhance button not found', '');\n        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']));","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/composer.js#L5-L41","documentation":"Thrown by the qoder prompt-enhance command when the clickByTextScript evaluation in the Qoder webview fails to find or click a button whose visible text is 'Prompt Enhance'. The command drives the Qoder UI via DOM automation, so if the composer toolbar does not currently render that button, the command reports failure with res?.reason or the fallback message. This is a UI-state mismatch, not a network or auth failure.","triggerScenarios":"Running `qoder prompt-enhance` when: the composer has no draft text so Qoder hides the Prompt Enhance action; the button label changed after a Qoder app update (localization or redesign); the page is still loading and the toolbar has not mounted; or evaluateQoder could not attach to the Qoder webview at all so the script returned ok:false with a reason.","commonSituations":"Developers calling prompt-enhance on an empty composer, in a Qoder version where the button is labeled differently (e.g. Chinese locale showing a translated label), or while the sidebar/editor pane is collapsed. Also common when the Qoder window is minimized or the webview context was lost and re-attached to the wrong frame.","solutions":["Type some draft text into the Qoder composer first (e.g. `qoder send` or manually) so the Prompt Enhance button appears, then rerun.","Take a screenshot or dump the composer DOM to check the current button label; update the clickByTextScript(['Prompt Enhance']) candidate strings if Qoder renamed it.","Ensure the Qoder window is open, focused, and fully loaded before running; add a wait/retry before evaluating the click script.","Inspect res?.reason in the thrown error to distinguish 'button not found' from 'evaluateQoder attach failed' and fix the underlying attach issue if that is reported."],"exampleFix":"// before\nconst res = await evaluateQoder(page, clickByTextScript(['Prompt Enhance']));\n// after\nawait page.wait(1); // let the composer toolbar mount\nconst res = await evaluateQoder(page, clickByTextScript(['Prompt Enhance', 'Enhance', '优化提示词']));\nif (!res?.ok) throw new CommandExecutionError(res?.reason || 'Prompt Enhance button not found', '');","handlingStrategy":"retry","validationCode":"// Check the composer has draft content and the toolbar is rendered before invoking\nconst draftLen = await page.evaluate(() => {\n  const el = document.querySelector('textarea, [contenteditable=\"true\"]');\n  return el ? (el.value || el.innerText || '').trim().length : -1;\n});\nif (draftLen <= 0) throw new Error('Composer draft is empty — Prompt Enhance button will not be present');","typeGuard":"function hasClickResult(res) {\n  return typeof res === 'object' && res !== null && res.ok === true;\n}","tryCatchPattern":"try {\n  await runCli('qoder prompt-enhance');\n} catch (e) {\n  if (String(e.message).includes('Prompt Enhance button not found')) {\n    await sleep(1000);\n    await runCli('qoder prompt-enhance'); // retry after UI settles\n  } else throw e;\n}","preventionTips":["Always seed a non-empty composer draft before calling prompt-enhance.","Pin/verify the Qoder app version; UI labels change between updates.","Add a short readiness wait before any DOM-click automation against Qoder.","Log res?.reason on failure to distinguish missing button from failed evaluation."],"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"}