diff --git a/src/renderer/src/components/settings/ManageSessionsSection.tsx b/src/renderer/src/components/settings/ManageSessionsSection.tsx index 0c909fea4f6..39909dffaf0 100644 --- a/src/renderer/src/components/settings/ManageSessionsSection.tsx +++ b/src/renderer/src/components/settings/ManageSessionsSection.tsx @@ -184,7 +184,7 @@ export function ManageSessionsSection(): React.JSX.Element { if (worktreeId) { // Why: match SessionsStatusSegment — route through the shared // activation path before switching tab so the worktree container - // is mounted by the time setActiveTab runs. + // is mounted by the time activateTabAndFocusPane runs. activateAndRevealWorktree(worktreeId) } setActiveView('terminal') diff --git a/src/renderer/src/components/sidebar/WorktreeCardAgents.tsx b/src/renderer/src/components/sidebar/WorktreeCardAgents.tsx index 7a0ae36d9a9..094e568aaa7 100644 --- a/src/renderer/src/components/sidebar/WorktreeCardAgents.tsx +++ b/src/renderer/src/components/sidebar/WorktreeCardAgents.tsx @@ -88,13 +88,15 @@ const WorktreeCardAgentsBody = React.memo(function WorktreeCardAgentsBody({ (tabId: string, paneKey: string) => { acknowledgeAgents([paneKey]) const colon = paneKey.indexOf(':') - const parsed = colon === -1 ? NaN : Number(paneKey.slice(colon + 1)) + const tail = colon > 0 ? paneKey.slice(colon + 1) : '' + const parsed = /^\d+$/.test(tail) ? Number.parseInt(tail, 10) : NaN let paneId: number | null = null - if (Number.isFinite(parsed)) { + if (Number.isFinite(parsed) && parsed > 0) { paneId = parsed } else { - // Why: paneKey for sidebar agent rows is always ${tabId}:${paneId}; - // a non-numeric tail means upstream row construction drifted. + // Why: paneKey for sidebar agent rows is always ${tabId}:${paneId} + // with a positive integer paneId; anything else (empty, zero, + // non-numeric) means upstream row construction drifted. console.warn('[WorktreeCardAgents] malformed paneKey, skipping pane focus', paneKey) } // Why: route through activateAndRevealWorktree so cross-repo clicks also