jackwener/OpenCLI · error · CommandExecutionError

Trae CN approval click failed: ${failed?.Action || 'unknown

Error message

Trae CN approval click failed: ${failed?.Action || 'unknown error'}

What it means

The trae-cn approve command automates clicking approval prompts in the Trae CN IDE. After running approveTraePrompts, if any row's Action starts with 'click-failed' (and dry-run was not set), it throws this CommandExecutionError embedding the first failing row's Action string, so the automation failure is surfaced instead of silently leaving prompts unapproved.

Source

Thrown at clis/trae-cn/approve.js:38

  domain: 'localhost',
  strategy: Strategy.UI,
  browser: true,
  args: [
    { name: 'approve-kinds', type: 'string', required: false, help: 'Comma-separated approval categories: terminal,delete,keep,all (default: terminal,delete; keep is not default)', default: 'terminal,delete' },
    { name: 'limit', type: 'int', required: false, help: 'Max visible prompts to approve in this pass (default: 1)', default: 1 },
    { name: 'max-chars', type: 'int', required: false, help: 'Max chars to return from prompt text; 0 returns full text (default: 600)', default: 600 },
    { name: 'dry-run', type: 'boolean', required: false, help: 'Detect matching prompts without clicking them (default: false)', default: false },
  ],
  columns: ['Status', 'Kind', 'Button', 'Prompt', 'Selector', 'Action'],
  func: async (page, kwargs) => {
    const kinds = normalizeApprovalKinds(kwargs['approve-kinds']);
    const limit = normalizeApprovalLimit(kwargs.limit, 1);
    const maxChars = normalizeMaxChars(kwargs['max-chars'], 600);
    const dryRun = normalizeDryRun(kwargs['dry-run']);
    const rows = await approveTraePrompts(page, kinds, { click: !dryRun, limit, maxChars });
    if (!dryRun && rows.some(row => row.Action && String(row.Action).startsWith('click-failed'))) {
      const failed = rows.find(row => row.Action && String(row.Action).startsWith('click-failed'));
      throw new CommandExecutionError(`Trae CN approval click failed: ${failed?.Action || 'unknown error'}`);
    }
    if (rows.length === 0) {
      return [{
        Status: 'NoPrompt',
        Kind: kinds.join(','),
        Button: '',
        Prompt: 'No matching visible Trae CN approval prompt found',
        Selector: '',
        Action: dryRun ? 'dry-run' : 'none',
      }];
    }
    return rows;
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read the Action string in the error — it carries the underlying click failure detail (e.g. 'click-failed: timeout').
  2. Run with --dry-run first to inspect detected prompts and confirm selectors still match the current UI.
  3. Update/refresh Trae CN and the CLI's selectors if the IDE version changed the approval dialog.
  4. Retry the command; if a prompt is flaky (race on dialog render), increase waits or rerun until rows report success.
  5. Increase --max-chars/--limit options only after clicks succeed; they do not affect click reliability.

Example fix

// before
await run(['trae-cn', 'approve', '--kind', 'all']);
// after
await run(['trae-cn', 'approve', '--kind', 'all', '--dry-run']); // inspect first
await run(['trae-cn', 'approve', '--kind', 'all']); // then click
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check with dry-run and fail fast if the IDE/dialog is not in the expected state:
const probe = await approveTraePrompts(page, kinds, { click: false, limit: 1, maxChars: 200 });
if (probe.length === 0 || probe.some(r => String(r.Status).startsWith('Error')))
  throw new Error('Trae CN approval dialog not detected; check IDE state/version before clicking.');

Type guard

const clickSucceeded = (row) => typeof row?.Action !== 'string' || !row.Action.startsWith('click-failed');

Try / catch

for (let attempt = 1; attempt <= 3; attempt++) {
  try {
    const rows = await approveTraePrompts(page, kinds, { click: true, limit, maxChars });
    if (!rows.some(r => String(r.Action || '').startsWith('click-failed'))) break;
    throw new CommandExecutionError(`Trae CN approval click failed: ${rows.find(r => String(r.Action).startsWith('click-failed'))?.Action}`);
  } catch (e) {
    if (attempt === 3 || !(e instanceof CommandExecutionError)) throw e;
    await page.waitForTimeout(1000 * attempt); // backoff, dialog may still be rendering
  }
}

Prevention

When it happens

Trigger: Running `trae-cn approve` (without --dry-run) when the page's approve button could not be clicked: the selector changed, the prompt closed before the click, the button is covered/disabled, or the DOM action reported a click failure string in its Action field.

Common situations: Trae CN IDE updated and approval-dialog markup/selectors changed; a modal overlay intercepting pointer events; slow rendering so the automation clicks a stale element; approvals already dismissed by another session.

Related errors


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