{"record":{"id":"d9c98917c71b1188","repo":"Yeachan-Heo/oh-my-codex","slug":"failed-to-capture-tmux-source-authority-result","errorCode":null,"errorMessage":"failed to capture tmux source authority: ${result.stderr}","messagePattern":"failed to capture tmux source authority: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/team/tmux-session.ts","lineNumber":293,"sourceCode":"  paneId: string;\n  panePid: number;\n  sessionName: string;\n  sessionId: string;\n  sessionCreated: string;\n  windowId: string;\n  windowIndex: string;\n  /** Present only after the Team owner bootstrap tag has been committed. */\n  teamPaneOwnerId: string | null;\n};\n\nfunction captureSourcePaneAuthority(paneId: string, expectedTeamPaneOwnerId?: string): SourcePaneAuthority {\n  const target = paneId.trim();\n  if (!/^%[0-9]+$/.test(target)) throw new Error(`invalid tmux source pane: ${paneId}`);\n  const result = runTmuxStructured([\n    'display-message', '-p', '-t', target,\n    '#{session_name}\\t#{session_id}\\t#{session_created}\\t#{window_index}\\t#{window_id}\\t#{pane_id}\\t#{pane_pid}',\n  ]);\n  if (!result.ok) throw new Error(`failed to capture tmux source authority: ${result.stderr}`);\n  const fields = result.stdout.split('\\t');\n  if (fields.length !== 7) throw new Error('malformed tmux source authority');\n  const [sessionName, sessionId, sessionCreated, windowIndex, windowId, capturedPaneId, panePid] = fields;\n  if (!sessionName || !/^\\$[0-9]+$/.test(sessionId) || !/^[0-9]+$/.test(sessionCreated)\n    || !/^[0-9]+$/.test(windowIndex) || !/^@[0-9]+$/.test(windowId)\n    || capturedPaneId !== target || !/^[1-9][0-9]*$/.test(panePid)) {\n    throw new Error('malformed tmux source authority');\n  }\n  const parsedPid = Number(panePid);\n  if (!Number.isSafeInteger(parsedPid) || parsedPid <= 0) throw new Error('malformed tmux source authority');\n  const proof = readExactPaneProofSync(target);\n  if (proof.status === 'unavailable') throw new ExactPaneProofUnavailableError(proof);\n  if (proof.status !== 'live' || proof.pid !== parsedPid) throw new Error(`tmux pane identity changed: ${target}`);\n  const ownerResult = runTmuxStructured(['show-option', '-qv', '-p', '-t', target, OMX_TEAM_PANE_OWNER_OPTION]);\n  if (!ownerResult.ok) throw new Error(`failed to capture tmux pane owner: ${ownerResult.stderr}`);\n  const teamPaneOwnerId = ownerResult.stdout.trim() || null;\n  if (teamPaneOwnerId && !/^[A-Za-z0-9._:-]+$/.test(teamPaneOwnerId)) {\n    throw new Error('malformed tmux pane owner');","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/Yeachan-Heo/oh-my-codex/blob/3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2/src/team/tmux-session.ts#L275-L311","documentation":"Thrown when `tmux display-message -p` fails while capturing the 'source pane authority' (session/window/pane identity tuple) for a pane that will authorize later tmux effects. The library refuses to proceed without a verified, fresh identity snapshot so it can never act on a recycled pane ID. The stderr of the underlying tmux command is embedded.","triggerScenarios":"Calling captureSourcePaneAuthority (directly or via leaderSource/paneSource/splitSource/hudSource/createTeamSession) with a pane ID that tmux cannot resolve: pane already closed, session killed, tmux server restarted, malformed %pane id that still passed the /^%[0-9]+$/ shape check, or a broken tmux binary/socket (TMUX_TMPDIR mismatch).","commonSituations":"The source pane was closed by the user or an agent between selection and capture; tmux server was restarted so all pane IDs are stale; SSH session dropped and the tmux socket vanished; TMUX_TMPDIR/TMUX env inherited inconsistently across processes.","solutions":["Verify the pane still exists: `tmux display-message -p -t <paneId> '#{pane_id}'` before retrying","If the tmux server restarted, re-discover pane IDs (all %ids are stale) and rebuild the session","Check the embedded stderr — 'no such pane'/'lost server' each imply a different recovery path","Ensure TMUX and TMUX_TMPDIR are set consistently in the environment your process runs in"],"exampleFix":"// before\nconst source = captureSourcePaneAuthority('%7');\n// after\nif (!runTmuxStructured(['display-message','-p','-t','%7','#{pane_id}']).ok) {\n  throw new Error('source pane %7 is gone; re-select a live pane');\n}\nconst source = captureSourcePaneAuthority('%7');","handlingStrategy":"validation","validationCode":"const ok = runTmuxStructured(['display-message','-p','-t',paneId,'#{pane_id}']);\nif (!ok.ok) throw new Error(`pane ${paneId} no longer addressable: ${ok.stderr}`);","typeGuard":"function isAddressablePane(paneId: string): boolean { return /^%[0-9]+$/.test(paneId); }","tryCatchPattern":"catch (e) { if (/failed to capture tmux source authority/.test(e.message)) { re-discoverPane(); return; } throw e; }","preventionTips":["Re-resolve pane IDs immediately before capture instead of caching them","Keep TMUX and TMUX_TMPDIR consistent across spawned processes","Never reuse pane IDs after a tmux server restart"],"tags":["tmux","pane-lifecycle","race-condition"],"backgroundTag":"tmux-pane-not-found","analyzedSha":"3ad79a8a6fe6e95fdbb8c00e40716fffe4011ce2","analyzedAt":"2026-08-27T22:18:39.783Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}