Skip to content

[Bug]: Codex app-server daemon keeps the pane key of the first session, so every later session's status lands on that one pane #23643

Done

Description

@ethznn

Operating system

macOS

Orca version

v1.4.215

Details

Summary

Codex's app-server daemon is spawned once, detaches (ppid=1), and keeps the ORCA_PANE_KEY of whichever pane first needed it. Every Codex session it serves afterwards reports agent status under that one pane, whatever workspace the session actually belongs to.

One inherited key, three visible faults:

when the inherited pane is what happens observed
alive another workspace's row shows this session's reply a session in sideby answered; the row appeared under snowboarder-app
alive, serving several sessions they overwrite one shared row one stored row with paneKey → snowboarder-app and providerSession → a plico session
gone every Codex session disappears from the lists 8 Codex sessions running, last-status.json holds 0 codex entries

Claude is unaffected in the same store at the same moments — its sessions keep one entry per pane.

Reproduction (desktop only; no mobile needed)

  1. Open a Codex session in workspace A. This is what spawns the app-server daemon, which inherits A's ORCA_PANE_KEY and detaches.
  2. Open a Codex session in workspace B and send it one message.
  3. Look at B's row in the sidebar, in orca worktree ps, or in the mobile workspace list.

B's reply is attributed to A, and B never gets a row. If A's tab has since been closed, nothing is recorded at all.

Two runs of step 2–3 here:

Run 1 — inherited pane still alive. Sent route test 2 to a Codex session in sideby. orca worktree ps reported it under snowboarder-app:

snowboarder-app
  - codex   route test 2 수신했습니다.   paneKey=65f6c734…:153f3a28…

sideby's tab is a1da984f…:25b4a560… and had no agent row. Grepping every live terminal for the string found it in exactly one place — the sideby session. Delivery was correct; only the attribution was wrong.

Run 2 — inherited pane gone. Opened a Codex session in plico (pane 75551d8a…:5fc0bf4d…, tab titled 테스트 123 실행 | plico) and sent one message. The session holds the exchange; the sidebar shows no agent on plico; and the store holds:

source별: {'claude': 3}

No codex entry at all, while every other Codex session kept running (snowboarder-app ×2, hyeonho ×4, plico ×1, sideby ×1).

The daemon

Every Codex TUI carries the pane key of the pane it was launched in:

pid=13940  ppid=13575 (zsh)  cwd=sideby           key=a1da984f…
pid=20584  ppid=20250 (zsh)  cwd=snowboarder-app  key=58aedee0…
pid=56677  ppid=56297 (zsh)  cwd=plico            key=ab4e6efe…

The daemon does not:

pid=73875  ppid=1            cwd=snowboarder-app  key=65f6c734…   codex app-server daemon pid-update-loop
pid=73940  ppid=73875        cwd=snowboarder-app  key=65f6c734…   codex app-server --listen unix:// --managed-daemon
pid=57979  ppid=73940        cwd=snowboarder-app  key=65f6c734…   codex-code-mode-host

65f6c734… is one Codex tab in snowboarder-app — the first session that needed the daemon. ppid=1 is the point: it outlived its spawning shell and now serves every session with that key frozen in its environment.

Watching the single stored codex row over a few hours, its providerSession kept changing while paneKey, tabId and worktreeId stayed frozen:

observed paneKey / worktreeId providerSession → rollout cwd
17:32 snowboarder-app the reply belonged to the sideby session
22:06 snowboarder-app 01a0e6f6… → /Users/hyeonho/Develop/plico
22:35 snowboarder-app 01a0e83a… → /Users/hyeonho/Develop/snowboarder-app
23:25 snowboarder-app 01a0e865… → a session started in a different workspace

The 22:06 row is the clearest: a single stored status whose pane says one workspace and whose provider session, resolved through its own transcriptPath, says another.

Why the existing guard does not catch it

src/shared/agent-status-identity.ts already knows about inherited pane keys — its comment says "child agent CLIs inherit ORCA_PANE_KEY from their parent terminal" — but the check is an agent-type comparison:

if (!args.existing || !existingAgentType || existingAgentType === incomingAgentType) {
  return { agentType: incomingAgentType, inheritedFromActivePane: false }
}

A Codex daemon reporting onto a Codex pane passes straight through, so shouldSuppressInheritedTerminalStatus never sees it. The guard was built for a different agent nesting inside a pane, not for one shared daemon serving many panes of the same agent.

The disappearing case follows from the same key: once the inherited pane is retired, the rows are addressed to something that no longer accepts them — ingestTerminalStatus returns early on getAgentStatusDisposition(paneKey) !== 'accept', and indexAgentStatusRowsByPaneKey drops rows it cannot address.

Where a fix could sit

The payload already carries what is needed to re-bind: providerSession.id and its transcriptPath. The server also has a precedent for re-keying a row by a stronger identity — ingestTerminalStatus follows terminalHandle through getStatusPaneKeyForTerminalHandle and calls transferPaneAuthority when it disagrees with the reported pane (server/server-ingest-terminal.ts, server/server-row-ownership.ts). #11158 applies the same principle in automations: attribute by agent session, not only by paneKey.

So: index providerSession.id → paneKey where Orca still knows both — it stamps exactly that pair when it launches a structured session (orca-runtime-structured-agent-session-launch-tui.ts passes providerSession: { key: 'session_id', id } alongside the terminal's paneKey/tabId/handle) — and prefer that binding over a reported pane key that contradicts it.

One case that does not cover: a session started by typing codex in a terminal, where Orca never learns the session id except from the first status event, which is itself mis-keyed. The rollout file's cwd identifies the workspace and could seed the binding, but that is a design call rather than something the data forces.

Related

I have this reproducing on a live host and am happy to open the PR for the binding described above if that scope looks right.

Activity

  1. added theissue type on Sep 28, 2026
  2. added
    bug
    on Sep 28, 2026
  3. added
    os:macos
    on Sep 28, 2026
  4. maxmilian commented on Sep 28, 2026

    @maxmilian
    Contributor

    This looks like the same mechanism #23411 (OrcaWin, open) addresses — the shared Codex app-server daemon runs Orca's hook script while still carrying the first pane's env, and #23411 makes the hook detect the shared daemon and re-attribute by session cwd / live Codex panes instead. #23517 reports the same symptom on Windows + WSL with Codex 0.157. Linking so they can be verified together.

  5. AmethystLiang commented on Sep 28, 2026

    @AmethystLiang
    Contributor

    looking into it

  6. jrmougan commented on Sep 29, 2026

    @jrmougan

    Also reproducing on Linux with the latest versions — here the daemon carries no Orca env at all, so it's the "gone" row of the table: no Codex session reaches Orca.

    Environment

    • Host: Fedora 44 (Linux 7.2, x86_64), Orca desktop 1.4.216
    • Codex CLI 0.159.0, logged in with ChatGPT, shared managed daemon (codex app-server --listen unix:// --managed-daemon)
    • Client: Orca Mobile — the Codex tab shows up but its transcript is empty (same symptom as Mobile: Codex conversation transcript does not display #13494). Claude tabs on the same pairing render fine.

    Observations

    • ~/.codex/hooks.json points every event at ~/.orca/agent-hooks/codex-hook.sh, and all hooks are trusted in config.toml.
    • The daemon process environment has 0 ORCA_* variables (tr '\0' '\n' < /proc/<daemon-pid>/environ | grep -c ^ORCA_ → 0).
    • ~/.config/orca/agent-hooks/last-status.json holds only claude entries and no codex entries, even though there were 3 Codex sessions that day (3 rollout files under ~/.codex/sessions/).
    • ~/.config/orca/agent-hooks/spool/ doesn't exist, so the hook exits early (no ORCA_PANE_KEY) without even spooling.

    This matches the mechanism described here and in #11941 / #23767. Workaround I'm about to try: launch Codex in Orca panes with codex --no-daemon, so hooks inherit the pane env. I'll report back if it doesn't help. Looking forward to #23411.

  7. maxmilian commented on Sep 30, 2026

    @maxmilian
    Contributor

    A caveat on my earlier link to #23411, since your Linux case is the one it doesn't reach. At #23411's current head (e6fc5ab), the shared-daemon detection in codex-hook-script.ts is gated on the stamp being present — [ -n "${ORCA_PANE_KEY:-}" ] && orca_ancestor_depth=0 || orca_ancestor_depth=4 — and the existing early exit is unchanged: if ORCA_AGENT_HOOK_PORT, ORCA_AGENT_HOOK_TOKEN or ORCA_PANE_KEY is empty, the script spools and exits before posting. The endpoint-file refresh doesn't help either, since it's only read when ORCA_AGENT_HOOK_ENDPOINT is set, and it doesn't carry a pane key. So a daemon with no ORCA_* env at all, like yours, still exits there with the PR applied.

    #23411 fixes the "alive" rows (a daemon carrying the wrong pane's stamp); the "gone" row with an env-less daemon needs a separate way for the hook to find the Orca endpoint. cc @OrcaWin @AmethystLiang in case that's worth covering in the same PR or tracking separately.

  8. nwparker commented on Nov 26, 2026

    @nwparker
    Contributor

    This looks fixed on current main by #23900, #23907, #23933. Hooks were misattributed because the shared Codex app-server daemon kept the first pane's ORCA_PANE_KEY. Orca now launches Codex with --no-daemon, so each pane runs its own server; sharing only happens if the user opts in (#23929) or passes agents/queue/--remote.

    Closing as fixed. If you still see this on the latest release, please reopen with your Orca version and steps, and we'll take another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugos:macos

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions