chore(focus-pane-helper): tighten paneKey parsing and update stale comment

- WorktreeCardAgents: only accept positive-integer paneId tails (rejects
  empty / non-numeric / zero), via /^\d+$/ pre-test
- ManageSessionsSection: rename stale `setActiveTab` reference in a comment

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
brennanb2025
2026-05-05 13:25:51 -07:00
co-authored by Orca
parent 0a7965d604
commit b2826bbb59
2 changed files with 7 additions and 5 deletions
@@ -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')
@@ -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