{"record":{"id":"df1056359f5c89ba","repo":"jackwener/OpenCLI","slug":"selector-df1056","errorCode":"SELECTOR","errorMessage":"Could not find element: TRAE SOLO mode capsule (.index-module__capsule__ ...).","messagePattern":"Could not find element: TRAE SOLO mode capsule \\(\\.index-module__capsule__ \\.\\.\\.\\)\\.","errorType":"error_code","errorClass":"CliError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/mode.js","lineNumber":37,"sourceCode":"    ],\n    columns: ['Status', 'Mode'],\n    func: async (page, kwargs) => {\n        const want = String(kwargs.target || '').trim().toLowerCase();\n        if (want && !['code', 'work'].includes(want)) {\n            throw new ArgumentError('target must be \"code\" or \"work\"');\n        }\n\n        const current = await page.evaluate(`(function() {\n      const cap = document.querySelector('[class*=\"capsule\"]');\n      if (!cap) return '';\n      const aria = cap.getAttribute('aria-label') || '';\n      // aria says \"Switch to <Other> mode\" — current is the OTHER one.\n      const m = aria.match(/Switch to (Code|Work) mode/i);\n      if (m) return m[1].toLowerCase() === 'work' ? 'code' : 'work';\n      return '';\n    })()`);\n        if (!current) {\n            throw selectorError('TRAE SOLO mode capsule (.index-module__capsule__ ...).');\n        }\n\n        if (!want) {\n            return [{ Status: 'Active', Mode: current }];\n        }\n        if (current === want) {\n            return [{ Status: 'no-op (already in target mode)', Mode: current }];\n        }\n\n        await page.evaluate(`(async () => {\n      const wait = (ms) => new Promise((r) => setTimeout(r, ms));\n      const cap = document.querySelector('[class*=\"capsule\"]');\n      if (!cap) return;\n      const r = cap.getBoundingClientRect();\n      const init = {\n        bubbles: true, cancelable: true, button: 0, buttons: 1,\n        clientX: Math.round(r.left + r.width / 2),\n        clientY: Math.round(r.top + r.height / 2),","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/mode.js#L19-L55","documentation":"A SELECTOR CliError thrown by `trae-solo mode` (clis/trae-solo/mode.js:37) when the in-page evaluation cannot find the TRAE SOLO mode capsule element (matched via its .index-module__capsule__ class or the 'Switch to Code/Work mode' aria-label). Without the capsule, the CLI can neither read the current mode nor switch it, so it fails with 'Could not find element'.","triggerScenarios":"`trae-solo mode` (with or without a target mode) runs the capsule-locating page.evaluate; the script returns an empty current value because the capsule element is absent — TRAE SOLO not in the expected view, hashed class names changed, or aria-label wording changed in a new version.","commonSituations":"TRAE SOLO version update changed the CSS-module hash (.index-module__capsule__XXXX) or the aria text 'Switch to <Mode> mode'; the IDE is not in the layout that renders the capsule; window too narrow so the capsule is hidden; English-only assumption broken by localized builds.","solutions":["Update the capsule selector/aria regex in mode.js to match the current TRAE SOLO DOM (new hash and localized aria text)","Make sure the IDE is in the main editor view where the mode capsule renders before running `trae-solo mode`","Version-match: pin TRAE SOLO to a build whose capsule markup matches the selectors, or regenerate hash-based class names per build","Report the mismatch upstream with the TRAE SOLO version and the capsule's current markup"],"exampleFix":"// before\nconst current = await page.evaluate(`...aria.match(/Switch to (Code|Work) mode/i)...`);\nif (!current) throw selectorError('TRAE SOLO mode capsule (.index-module__capsule__ ...).');\n// after\nlet current = await page.evaluate(capsuleScript());\nif (!current) {\n  await page.wait(1); // allow IDE UI to finish mounting\n  current = await page.evaluate(capsuleScript());\n}\nif (!current) throw selectorError('TRAE SOLO mode capsule', 'Check .index-module__capsule__ hash and aria-label wording for your TRAE SOLO version');","handlingStrategy":"retry","validationCode":"const capsule = await page.evaluate(() => {\n  const el = document.querySelector('[class*=capsule]') ||\n    [...document.querySelectorAll('[aria-label]')].find(n => /switch to (code|work) mode/i.test(n.getAttribute('aria-label')));\n  return !!el && el.getBoundingClientRect().width > 0;\n});\nif (!capsule) throw new Error('TRAE SOLO mode capsule not visible — check IDE view and version');","typeGuard":"function hasCapsuleResult(r) { return typeof r === 'string' && r.length > 0; }","tryCatchPattern":"let current = await page.evaluate(capsuleProbeScript());\nif (!hasCapsuleResult(current)) {\n  await page.wait(1.5); // let IDE UI mount\n  current = await page.evaluate(capsuleProbeScript());\n}\nif (!hasCapsuleResult(current)) throw selectorError('TRAE SOLO mode capsule');","preventionTips":["Match selector/aria regexes to your TRAE SOLO version — hashed classes (.index-module__capsule__XX) change per build","Include localized aria-label variants ('Switch to ... mode' in other languages) in the regex","Maximize/normalize the IDE window so the capsule is rendered and visible","Re-verify the capsule probe after every TRAE SOLO upgrade"],"tags":["selector","ui-changed","trae-solo","css-modules"],"backgroundTag":"selector-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}