{"record":{"id":"d4a5bde726f55e2e","repo":"jackwener/OpenCLI","slug":"clicked-trae-cn-new-task-via-clicked-method-fr","errorCode":null,"errorMessage":"Clicked Trae CN new task via ${clicked.method}; fresh empty composer was not confirmed","messagePattern":"Clicked Trae CN new task via (.+?); fresh empty composer was not confirmed","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-cn/new.js","lineNumber":35,"sourceCode":"  ],\n  columns: ['Status', 'Action', 'Workspace', 'Model', 'Agent', 'FreshTaskConfirmed', 'TurnsBeforeSubmit', 'Turns', 'ComposerReady', 'SubmitMode'],\n  func: async (page, kwargs) => {\n    const timeout = normalizeTimeout(kwargs.timeout, 10);\n    const clicked = await page.evaluate(clickNewTaskScript());\n    if (!clicked?.ok) {\n      throw selectorError('Trae CN new task button');\n    }\n\n    const started = Date.now();\n    let state = null;\n    while (Date.now() - started < timeout * 1000) {\n      await page.wait(0.5);\n      state = await page.evaluate(currentTaskStateScript());\n      if (state?.composerReady && state.turns === 0) break;\n    }\n\n    if (!state?.composerReady || state.turns !== 0) {\n      throw new CommandExecutionError(\n        `Clicked Trae CN new task via ${clicked.method}; fresh empty composer was not confirmed`,\n        `Observed composerReady=${state?.composerReady ? 'yes' : 'no'}, turns=${state?.turns ?? 'unavailable'}. Verify the current window is a Trae CN chat workspace and retry.`,\n      );\n    }\n\n    const turnsBeforeSubmit = state.turns;\n    let submitMode = '';\n    if (kwargs.prompt !== undefined && kwargs.prompt !== null && String(kwargs.prompt).trim()) {\n      const result = await sendTraePrompt(page, ensurePrompt(kwargs.prompt));\n      submitMode = result.mode;\n      await page.wait(0.5);\n      state = await page.evaluate(currentTaskStateScript());\n    }\n\n    return [{\n      Status: 'Success',\n      Action: kwargs.prompt ? `New task created via ${clicked.method}; prompt submitted` : `New task created via ${clicked.method}`,\n      Workspace: state?.workspace || '',","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-cn/new.js#L17-L53","documentation":"new.js throws a CommandExecutionError when, after clicking the new-task control, repeated probes of the page state never confirm a fresh empty composer (composerReady and turns===0). The error reports which click method was used and the observed composerReady/turns values so you can diagnose whether the click landed at all.","triggerScenarios":"Running `opencli trae-cn new` when the click method (selector/keyboard) did not create a new task: wrong window focused, page not a chat workspace, UI selectors changed after a Trae CN update, or the new task took longer than the probe loop allowed.","commonSituations":"Trae CN app updated and DOM selectors for the new-task button changed; user is looking at a settings or non-chat panel; slow machine where 0.5s-interval probes exhaust retries before the composer resets.","solutions":["Confirm the active window/tab is a Trae CN chat workspace, then retry `opencli trae-cn new`.","Check whether a recent Trae CN update changed the UI and update the click selectors/currentTaskStateScript.","Increase probe attempts/wait interval in new.js if the app is slow to reset.","Manually start a new task in Trae CN and verify the composer state script returns composerReady=true, turns=0."],"exampleFix":"// before (new.js)\nif (!state?.composerReady || state.turns !== 0) {\n  throw new CommandExecutionError(`Clicked Trae CN new task via ${clicked.method}; fresh empty composer was not confirmed`, ...);\n}\n// after: increase probe patience\nfor (let i = 0; i < 20; i++) {\n  await page.wait(1); // was 0.5\n  state = await page.evaluate(currentTaskStateScript());\n  if (state?.composerReady && state.turns === 0) break;\n}","handlingStrategy":"validation","validationCode":"// Verify the current target is a chat workspace before new\nconst state = await page.evaluate(currentTaskStateScript());\nif (!state || typeof state.composerReady === 'undefined') {\n  throw new Error('Current page is not a Trae CN chat workspace; switch targets first.');\n}","typeGuard":"function isFreshComposerState(state) {\n  return Boolean(state && typeof state === 'object' &&\n    state.composerReady === true && Number.isInteger(state.turns) && state.turns === 0);\n}","tryCatchPattern":"try {\n  await createNewTask();\n} catch (e) {\n  if (e instanceof CommandExecutionError && /fresh empty composer was not confirmed/.test(e.message)) {\n    console.error(e.message, e.detail); // inspect composerReady/turns\n    // retry once after re-focusing the correct CDP target\n    await focusChatTarget();\n    return createNewTask();\n  }\n  throw e;\n}","preventionTips":["Ensure the Trae CN window shows a chat workspace, not settings or another panel.","After Trae CN updates, re-verify UI selectors used by the new-task click.","Pick a stable CDP target via `opencli trae-cn targets -f json` before automating.","Allow extra settle time on slow machines."],"tags":["ui-automation","cdp","selector-stale","trae-cn"],"backgroundTag":"ui-automation-click-unverified","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}