{"record":{"id":"5c84233c1389af36","repo":"Yeachan-Heo/oh-my-codex","slug":"shutdown-shared-session-worker-target-invalid-sh","errorCode":null,"errorMessage":"shutdown_shared_session_worker_target_invalid:${sharedWorkerPaneIds.filter((paneId) => excludedSharedWorkerPaneIds.has(paneId)).join(',')}","messagePattern":"shutdown_shared_session_worker_target_invalid:(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/team/runtime.ts","lineNumber":5152,"sourceCode":"    const authorizedDiscoveredWorkerPaneIds = sharedSessionTopology\n      ? collectAuthorizedSharedSessionWorkerPaneIds(\n        [...new Set([\n          ...canonicalExplicitWorkerPaneIds,\n          ...sharedSessionTopology.teamWorkerPaneIds,\n        ])],\n        tmuxPaneOwnerId,\n        canonicalExplicitWorkerPaneIds,\n        undefined,\n        initiallyTaggedWorkerPaneIds,\n      )\n      : (sessionName ? listPaneIds(sessionName) : []);\n    const excludedSharedWorkerPaneIds = new Set(\n      [effectiveLeaderPaneId, effectiveHudPaneId]\n        .filter((paneId): paneId is string => typeof paneId === 'string' && /^%[0-9]+$/.test(paneId)),\n    );\n    const sharedWorkerPaneIds = [...new Set(authorizedDiscoveredWorkerPaneIds)];\n    if (sharedSessionTopology && sharedWorkerPaneIds.some((paneId) => excludedSharedWorkerPaneIds.has(paneId))) {\n      throw new Error(`shutdown_shared_session_worker_target_invalid:${sharedWorkerPaneIds.filter((paneId) => excludedSharedWorkerPaneIds.has(paneId)).join(',')}`);\n    }\n    // Freeze this union before any shared-session topology effect. HUD teardown\n    // and restoration must never cause later worker target rediscovery.\n    const shutdownPaneIds = sharedSessionTopology\n      ? sharedWorkerPaneIds\n      : collectShutdownPaneIds({\n        config,\n        candidatePaneIds: authorizedDiscoveredWorkerPaneIds,\n        leaderPaneId: effectiveLeaderPaneId,\n        hudPaneId: effectiveHudPaneId,\n      });\n    const canonicalWorkerPaneIds = [...shutdownPaneIds];\n    const expectedSharedWorkerPanePids = new Map<string, number>();\n    const prekillResolvedWorkerPaneIds = new Set<string>();\n    type FrozenSharedPaneAuthorization = {\n      paneId: string;\n      pid: number;\n      owner: string | null;","sourceCodeStart":5134,"sourceCodeEnd":5170,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/runtime.ts#L5134-L5170","documentation":"Consistency guard in shared-session shutdown: the discovered set of worker pane IDs overlaps with panes that must be excluded (the effective leader and HUD pane IDs). Shutdown refuses rather than kill the leader or HUD pane as if it were a worker.","triggerScenarios":"Shutting down a shared-session team where the authorized discovered worker panes include the leader pane and/or HUD pane (per effectiveLeaderPaneId/effectiveHudPaneId), indicating a discovery/config inconsistency.","commonSituations":"Worker pane discovery mis-attributed the leader or HUD pane as a worker (stale pane indices after restarts); config pane IDs drifted from the live tmux layout; manual pane restructuring inside the shared session.","solutions":["Compare live tmux panes against team config (leader_pane_id, hud_pane_id, worker panes) and fix the drifted IDs","Restart/recreate the team so discovery and config agree, then retry shutdown","As a workaround, use force shutdown after manually verifying the pane layout"],"exampleFix":"# before\nomx team shutdown myteam\n# error: shutdown_shared_session_worker_target_invalid:%3\n\n# after\ntmux list-panes -t myteam -F '#{pane_id} #{pane_title}'\nomx team config set myteam leader_pane_id %1   # correct drift\nomx team shutdown myteam","handlingStrategy":"validation","validationCode":"const excluded = new Set([leaderPaneId, hudPaneId].filter(p => /^%[0-9]+$/.test(p ?? '')));\nconst overlap = discoveredWorkerPaneIds.filter(p => excluded.has(p));\nif (overlap.length) throw new Error(`worker discovery includes leader/HUD panes: ${overlap}`);","typeGuard":"function workerTargetsValid(discovered: string[], leader?: string, hud?: string): boolean {\n  const ex = new Set([leader, hud].filter((p): p is string => !!p && /^%[0-9]+$/.test(p)));\n  return !discovered.some(p => ex.has(p));\n}","tryCatchPattern":"try { await shutdownTeam(t, cwd, {}); } catch (e) { if (/^shutdown_shared_session_worker_target_invalid:/.test((e as Error).message)) { await repairPaneIds(t); await shutdownTeam(t, cwd, {}); } else throw e; }","preventionTips":["Keep config pane IDs synchronized with the live tmux layout","Recreate teams after major pane restructuring","Never mix leader/HUD panes into worker pane ranges"],"tags":["shutdown","tmux","pane-targeting"],"backgroundTag":"tmux-session-unavailable","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}