{"record":{"id":"f2a74479a7b01c11","repo":"jackwener/OpenCLI","slug":"trae-cn-approval-click-failed-failed-action","errorCode":null,"errorMessage":"Trae CN approval click failed: ${failed?.Action || 'unknown error'}","messagePattern":"Trae CN approval click failed: (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-cn/approve.js","lineNumber":38,"sourceCode":"  domain: 'localhost',\n  strategy: Strategy.UI,\n  browser: true,\n  args: [\n    { 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' },\n    { name: 'limit', type: 'int', required: false, help: 'Max visible prompts to approve in this pass (default: 1)', default: 1 },\n    { name: 'max-chars', type: 'int', required: false, help: 'Max chars to return from prompt text; 0 returns full text (default: 600)', default: 600 },\n    { name: 'dry-run', type: 'boolean', required: false, help: 'Detect matching prompts without clicking them (default: false)', default: false },\n  ],\n  columns: ['Status', 'Kind', 'Button', 'Prompt', 'Selector', 'Action'],\n  func: async (page, kwargs) => {\n    const kinds = normalizeApprovalKinds(kwargs['approve-kinds']);\n    const limit = normalizeApprovalLimit(kwargs.limit, 1);\n    const maxChars = normalizeMaxChars(kwargs['max-chars'], 600);\n    const dryRun = normalizeDryRun(kwargs['dry-run']);\n    const rows = await approveTraePrompts(page, kinds, { click: !dryRun, limit, maxChars });\n    if (!dryRun && rows.some(row => row.Action && String(row.Action).startsWith('click-failed'))) {\n      const failed = rows.find(row => row.Action && String(row.Action).startsWith('click-failed'));\n      throw new CommandExecutionError(`Trae CN approval click failed: ${failed?.Action || 'unknown error'}`);\n    }\n    if (rows.length === 0) {\n      return [{\n        Status: 'NoPrompt',\n        Kind: kinds.join(','),\n        Button: '',\n        Prompt: 'No matching visible Trae CN approval prompt found',\n        Selector: '',\n        Action: dryRun ? 'dry-run' : 'none',\n      }];\n    }\n    return rows;\n  },\n});\n","sourceCodeStart":20,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-cn/approve.js#L20-L53","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the Action string in the error — it carries the underlying click failure detail (e.g. 'click-failed: timeout').","Run with --dry-run first to inspect detected prompts and confirm selectors still match the current UI.","Update/refresh Trae CN and the CLI's selectors if the IDE version changed the approval dialog.","Retry the command; if a prompt is flaky (race on dialog render), increase waits or rerun until rows report success.","Increase --max-chars/--limit options only after clicks succeed; they do not affect click reliability."],"exampleFix":"// before\nawait run(['trae-cn', 'approve', '--kind', 'all']);\n// after\nawait run(['trae-cn', 'approve', '--kind', 'all', '--dry-run']); // inspect first\nawait run(['trae-cn', 'approve', '--kind', 'all']); // then click","handlingStrategy":"retry","validationCode":"// Pre-check with dry-run and fail fast if the IDE/dialog is not in the expected state:\nconst probe = await approveTraePrompts(page, kinds, { click: false, limit: 1, maxChars: 200 });\nif (probe.length === 0 || probe.some(r => String(r.Status).startsWith('Error')))\n  throw new Error('Trae CN approval dialog not detected; check IDE state/version before clicking.');","typeGuard":"const clickSucceeded = (row) => typeof row?.Action !== 'string' || !row.Action.startsWith('click-failed');","tryCatchPattern":"for (let attempt = 1; attempt <= 3; attempt++) {\n  try {\n    const rows = await approveTraePrompts(page, kinds, { click: true, limit, maxChars });\n    if (!rows.some(r => String(r.Action || '').startsWith('click-failed'))) break;\n    throw new CommandExecutionError(`Trae CN approval click failed: ${rows.find(r => String(r.Action).startsWith('click-failed'))?.Action}`);\n  } catch (e) {\n    if (attempt === 3 || !(e instanceof CommandExecutionError)) throw e;\n    await page.waitForTimeout(1000 * attempt); // backoff, dialog may still be rendering\n  }\n}","preventionTips":["Always --dry-run first to verify prompts are detected before clicking.","Pin/verify the Trae CN version; UI updates change selectors and break clicks.","Retry with backoff — dialogs that render slowly cause transient click failures.","Keep the IDE window focused/foregrounded so overlays do not intercept clicks.","Log each row's Action field to capture the underlying failure reason."],"tags":["automation","ui-click","trae-cn","approval-flow"],"backgroundTag":"ui-automation-click-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}