jackwener/OpenCLI · error · CommandExecutionError
Prompt Enhance button not found
Error message
Prompt Enhance button not found
What it means
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.
Source
Thrown at clis/qoder/composer.js:23
import { cli, Strategy } from '@jackwener/opencli/registry';
import { CommandExecutionError } from '@jackwener/opencli/errors';
import { clickByTextScript, evaluateQoder } from './_utils.js';
// -------- prompt-enhance --------
cli({
site: 'qoder',
name: 'prompt-enhance',
access: 'write',
description: 'Click "Prompt Enhance" — Qoder rewrites the current composer draft for better LLM consumption.',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Status'],
func: async (page) => {
const res = await evaluateQoder(page, clickByTextScript(['Prompt Enhance']));
if (!res?.ok) throw new CommandExecutionError(res?.reason || 'Prompt Enhance button not found', '');
await page.wait(0.5);
return [{ Status: 'enhanced (check composer)' }];
},
});
// -------- open-editor --------
cli({
site: 'qoder',
name: 'open-editor',
access: 'write',
description: 'Click "Open Editor" — opens the current draft in a full editor pane.',
domain: 'localhost',
strategy: Strategy.UI,
browser: true,
args: [],
columns: ['Status'],
func: async (page) => {
const res = await evaluateQoder(page, clickByTextScript(['Open Editor']));View on GitHub (pinned to 49907e53dc)
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.
Example fix
// before const res = await evaluateQoder(page, clickByTextScript(['Prompt Enhance'])); // after await page.wait(1); // let the composer toolbar mount const res = await evaluateQoder(page, clickByTextScript(['Prompt Enhance', 'Enhance', '优化提示词'])); if (!res?.ok) throw new CommandExecutionError(res?.reason || 'Prompt Enhance button not found', '');
Defensive patterns
Strategy: retry
Validate before calling
// Check the composer has draft content and the toolbar is rendered before invoking
const draftLen = await page.evaluate(() => {
const el = document.querySelector('textarea, [contenteditable="true"]');
return el ? (el.value || el.innerText || '').trim().length : -1;
});
if (draftLen <= 0) throw new Error('Composer draft is empty — Prompt Enhance button will not be present'); Type guard
function hasClickResult(res) {
return typeof res === 'object' && res !== null && res.ok === true;
} Try / catch
try {
await runCli('qoder prompt-enhance');
} catch (e) {
if (String(e.message).includes('Prompt Enhance button not found')) {
await sleep(1000);
await runCli('qoder prompt-enhance'); // retry after UI settles
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Open Editor button not found
- New Quest button not found
- Send button not found
- composer type failed
- Qoder send did not create a new visible message row
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/093d91bfd2f768c0.
Report an issue: GitHub.