Yeachan-Heo/oh-my-codex · critical · Error

shutdown_shared_session_worker_target_invalid:${sharedWorker

Error message

shutdown_shared_session_worker_target_invalid:${sharedWorkerPaneIds.filter((paneId) => excludedSharedWorkerPaneIds.has(paneId)).join(',')}

What it means

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.

Source

Thrown at src/team/runtime.ts:5152

    const authorizedDiscoveredWorkerPaneIds = sharedSessionTopology
      ? collectAuthorizedSharedSessionWorkerPaneIds(
        [...new Set([
          ...canonicalExplicitWorkerPaneIds,
          ...sharedSessionTopology.teamWorkerPaneIds,
        ])],
        tmuxPaneOwnerId,
        canonicalExplicitWorkerPaneIds,
        undefined,
        initiallyTaggedWorkerPaneIds,
      )
      : (sessionName ? listPaneIds(sessionName) : []);
    const excludedSharedWorkerPaneIds = new Set(
      [effectiveLeaderPaneId, effectiveHudPaneId]
        .filter((paneId): paneId is string => typeof paneId === 'string' && /^%[0-9]+$/.test(paneId)),
    );
    const sharedWorkerPaneIds = [...new Set(authorizedDiscoveredWorkerPaneIds)];
    if (sharedSessionTopology && sharedWorkerPaneIds.some((paneId) => excludedSharedWorkerPaneIds.has(paneId))) {
      throw new Error(`shutdown_shared_session_worker_target_invalid:${sharedWorkerPaneIds.filter((paneId) => excludedSharedWorkerPaneIds.has(paneId)).join(',')}`);
    }
    // Freeze this union before any shared-session topology effect. HUD teardown
    // and restoration must never cause later worker target rediscovery.
    const shutdownPaneIds = sharedSessionTopology
      ? sharedWorkerPaneIds
      : collectShutdownPaneIds({
        config,
        candidatePaneIds: authorizedDiscoveredWorkerPaneIds,
        leaderPaneId: effectiveLeaderPaneId,
        hudPaneId: effectiveHudPaneId,
      });
    const canonicalWorkerPaneIds = [...shutdownPaneIds];
    const expectedSharedWorkerPanePids = new Map<string, number>();
    const prekillResolvedWorkerPaneIds = new Set<string>();
    type FrozenSharedPaneAuthorization = {
      paneId: string;
      pid: number;
      owner: string | null;

View on GitHub (pinned to 3ad79a8a6f)

Solutions

  1. Compare live tmux panes against team config (leader_pane_id, hud_pane_id, worker panes) and fix the drifted IDs
  2. Restart/recreate the team so discovery and config agree, then retry shutdown
  3. As a workaround, use force shutdown after manually verifying the pane layout

Example fix

# before
omx team shutdown myteam
# error: shutdown_shared_session_worker_target_invalid:%3

# after
tmux list-panes -t myteam -F '#{pane_id} #{pane_title}'
omx team config set myteam leader_pane_id %1   # correct drift
omx team shutdown myteam
Defensive patterns

Strategy: validation

Validate before calling

const excluded = new Set([leaderPaneId, hudPaneId].filter(p => /^%[0-9]+$/.test(p ?? '')));
const overlap = discoveredWorkerPaneIds.filter(p => excluded.has(p));
if (overlap.length) throw new Error(`worker discovery includes leader/HUD panes: ${overlap}`);

Type guard

function workerTargetsValid(discovered: string[], leader?: string, hud?: string): boolean {
  const ex = new Set([leader, hud].filter((p): p is string => !!p && /^%[0-9]+$/.test(p)));
  return !discovered.some(p => ex.has(p));
}

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Yeachan-Heo/oh-my-codex@3ad79a8a6f (2026-08-27). Data as JSON: /api/errors/5c84233c1389af36. Report an issue: GitHub.