{"record":{"id":"e240b40f86b0a19c","repo":"jackwener/OpenCLI","slug":"result-reason-could-not-switch-to-panelna","errorCode":null,"errorMessage":"${result?.reason || `Could not switch to ${panelName} panel.`}","messagePattern":"(.+?) panel\\.`\\}","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/trae-solo/_actions.js","lineNumber":36,"sourceCode":"    if (!entry) {\n      return { ok: false, reason: 'Panel entry not found.', detail: 'wanted=' + target };\n    }\n    const r = entry.getBoundingClientRect();\n    const init = {\n      bubbles: true, cancelable: true, button: 0, buttons: 1,\n      clientX: Math.round(r.left + Math.min(30, r.width / 2)),\n      clientY: Math.round(r.top + Math.min(10, r.height / 2)),\n    };\n    entry.dispatchEvent(new PointerEvent('pointerdown', { ...init, pointerType: 'mouse' }));\n    entry.dispatchEvent(new MouseEvent('mousedown', init));\n    entry.dispatchEvent(new PointerEvent('pointerup', { ...init, pointerType: 'mouse' }));\n    entry.dispatchEvent(new MouseEvent('mouseup', init));\n    entry.dispatchEvent(new MouseEvent('click', init));\n    await wait(900);\n    return { ok: true };\n  })()`);\n    if (!result?.ok) {\n        throw new CommandExecutionError(result?.reason || `Could not switch to ${panelName} panel.`, result?.detail || '');\n    }\n    return result;\n}\n\n// Click a target element using the full pointer-event chain. Useful for\n// React + radix components that ignore plain .click().\nexport async function pointerClickByEval(page, selectorJsExpr) {\n    return await page.evaluate(`(async () => {\n    const target = ${selectorJsExpr};\n    if (!target) return { ok: false, reason: 'target not found' };\n    const r = target.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),\n    };\n    target.dispatchEvent(new PointerEvent('pointerdown', { ...init, pointerType: 'mouse' }));\n    target.dispatchEvent(new MouseEvent('mousedown', init));","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/trae-solo/_actions.js#L18-L54","documentation":"switchToPanel dispatches a full mouse-event chain on the target panel entry inside the page and expects the injected script to return { ok: true }. When the script reports failure, the library throws CommandExecutionError using the in-page reason if provided, otherwise a generic 'Could not switch to <panel> panel.' message, plus any detail.","triggerScenarios":"The panel entry element was not found or not clickable (selector drift after a Trae update), an overlay intercepted the synthetic mouse events, or the in-page script threw before returning ok.","commonSituations":"Trae UI updates renaming panel entries, running before the app window fully renders, or popup dialogs blocking interaction.","solutions":["Retry after waiting for the Trae window/panels to fully render","Check for open dialogs or overlays in Trae and dismiss them","Verify the Trae version still matches the selectors used by this library","Run the switch manually once to confirm the panel exists in your build"],"exampleFix":"// before\nawait switchToPanel(page, 'chat');\n// after\nawait page.wait(2); // let UI settle\nawait switchToPanel(page, 'chat');","handlingStrategy":"retry","validationCode":"const info = await page.evaluate(inspectTraeShellScript());\nif (!info?.windowReady || info?.dialogOpen) throw new SkipError('Trae UI not ready; wait before switching panels');","typeGuard":"const isPanelSwitchOk = (r) => r && r.ok === true;","tryCatchPattern":"try { return await switchToPanel(page, panelName); } catch (e) { if (e instanceof CommandExecutionError && /Could not switch/.test(e.message)) { await page.wait(2); return switchToPanel(page, panelName); } throw e; }","preventionTips":["Wait for the app window/panels to finish rendering before switching","Dismiss any dialogs blocking the pointer-event chain","Re-verify panel names/selectors after Trae updates"],"tags":["automation","ui-automation","panel-switch"],"backgroundTag":"automation-verification-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}