{"record":{"id":"a7f84db41a8cc793","repo":"Yeachan-Heo/oh-my-codex","slug":"detached-hermes-leader-has-no-tmux-pane-identity","errorCode":null,"errorMessage":"detached Hermes leader has no tmux pane identity","messagePattern":"detached Hermes leader has no tmux pane identity","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/index.ts","lineNumber":7029,"sourceCode":"\nfunction traceDetachedLeaderPhase(phase: string): void {\n  if (process.env.OMX_TEST_DETACHED_TRACE !== \"1\") return;\n  const line = `[omx-test-detached] ${phase}\\n`;\n  process.stderr.write(line);\n  const tracePath = process.env.OMX_TEST_DETACHED_TRACE_PATH;\n  if (tracePath) appendFileSync(tracePath, line);\n}\n\nasync function runDetachedSessionLeader(payload: DetachedLeaderPayload): Promise<void> {\n  for (const [key, value] of Object.entries(payload.parentEnv ?? {})) {\n    if (isDetachedLaunchControlPlaneKey(key, process.platform === \"win32\")) continue;\n    process.env[key] = value;\n  }\n  let pane: string;\n  const inheritedPane = process.env.TMUX_PANE?.trim();\n  if (payload.preLaunchOptions.shouldAttach === false) {\n    if (!inheritedPane || !/^%[0-9]+$/.test(inheritedPane)) {\n      throw new Error(\"detached Hermes leader has no tmux pane identity\");\n    }\n    pane = inheritedPane;\n  } else {\n    const paneSnapshot = execTmuxFileSync(\n      [\"list-panes\", \"-t\", payload.sessionName, \"-F\", \"#{pane_id}\\t#{pane_dead}\\t#{pane_pid}\"],\n      { encoding: \"utf-8\", stdio: [\"ignore\", \"pipe\", \"ignore\"] },\n    );\n    pane = parseDetachedLeaderPaneIdByPid(paneSnapshot, process.pid);\n  }\n  process.env.TMUX_PANE = pane;\n  const established = await establishPreLaunchBinding(payload.cwd, payload.sessionId, {\n    tmuxSessionName: payload.sessionName,\n    tmuxPaneId: pane,\n  });\n  const binding = established.binding;\n  let ownedRecord: DetachedActiveRecordOwnership | undefined;\n  let detachedHudProof: DetachedHudAuthority | undefined;\n  const nonce = payload.readyPath?.split(\".\").at(-2) || payload.sessionId;","sourceCodeStart":7011,"sourceCodeEnd":7047,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/cli/index.ts#L7011-L7047","documentation":"For a shouldAttach===false detached leader, the process must already live inside a tmux pane identified by TMUX_PANE matching ^%[0-9]+$, otherwise it has no pane identity to bind to.","triggerScenarios":"Running the detached leader binary directly from a plain shell (no tmux), TMUX_PANE unset/empty, or set to a malformed value (e.g. '0' or '%abc').","commonSituations":"User invokes the internal leader command manually to debug, or a wrapper (nohup, setsid, systemd) strips TMUX_* variables. Also occurs when the pane was destroyed between launch and leader start.","solutions":["Launch through the parent CLI's detached-session flow so the leader inherits TMUX_PANE from the created pane","If running manually, do it inside the target tmux session: tmux new-session -d -s mysession 'leader-cmd'","Validate process.env.TMUX_PANE matches /^%[0-9]+$/ before starting the leader"],"exampleFix":"// before\n$ hermes detached-leader --no-attach   # from a bare shell\n// after\n$ tmux new-session -d -s mysession 'hermes detached-leader --no-attach'","handlingStrategy":"validation","validationCode":"if (options.shouldAttach === false && !/^%[0-9]+$/.test(process.env.TMUX_PANE ?? '')) {\n  throw new Error('must run inside a tmux pane (TMUX_PANE unset)');\n}","typeGuard":"function hasTmuxPaneIdentity(): boolean {\n  return /^%[0-9]+$/.test(process.env.TMUX_PANE?.trim() ?? '');\n}","tryCatchPattern":null,"preventionTips":["Launch detached leaders via the CLI so TMUX_PANE is inherited","Don't wrap the leader in nohup/setsid, which strips tmux env","Verify TMUX_PANE before invoking internal leader commands"],"tags":["tmux","detached-session","environment-variables"],"backgroundTag":"tmux-pane-not-found","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}