Skip to content

[Bug]: Agents running inside a user's tmux session are not detected/shown as running #7797

Description

@jwlee-muhayu

Summary

Orca does not identify running AI agents (e.g. claude, codex) when they run inside a user's tmux session. The agent never shows up as a live/running agent on the pane, worktree, or project view — the pane just reads as tmux.

Note: this is about live agent detection. The file-based Agent Session History (AI Vault, which scans ~/.claude/projects/**) still surfaces the transcript by cwd; only the live/running indicator is missing.

Root cause

Live foreground detection walks the process tree downward from the pane's shell pid and only inspects that subtree:

  • src/main/providers/agent-foreground-process.ts — collectDescendants(rows, shellPid)
  • src/relay/pty-shell-utils.ts — the relay twin

When a user runs tmux in an Orca pane, the process in the pane is the tmux client. tmux daemonizes a server (double-fork, reparented to pid 1), and every pane process — including claude — is a child of that server, not of the pane's shell. So the descendant walk from the shell pid reaches only the tmux client (not a recognized agent) and never the agent. It falls back to the client name (tmux).

The OSC path (OSC 133 / OSC 9999 status sequences) also misses it, because tmux does not forward those to the outer terminal by default.

Proposed fix

When the shell's subtree contains a tmux client, hop to that client's active pane pid and re-run the same recognition walk from there:

  1. Detect a tmux client among the descendants.
  2. tmux [-L/-S <sock>] list-clients -F '#{client_pid} #{pane_pid}' → map our client pid to its active pane pid (one call; #{pane_pid} resolves in the client's context).
  3. Re-run the existing descendant recognition from that pane pid (and also consider the pane's own top process, for tmux new-session claude).

Best-effort (any tmux failure falls through unchanged), POSIX-only, mirrored in both the local and relay/SSH paths, with a short TTL cache to avoid forking tmux on every foreground poll.

Environment

  • Affects both local and SSH remote (relay) sessions.
  • POSIX (macOS/Linux); Windows unaffected.

Activity

  1. added theissue type on Jul 12, 2026
  2. added
    bug
    on Jul 16, 2026
  3. nwparker commented on Jul 18, 2026

    @nwparker
    Contributor

    Status: REPRODUCED (unit test, macOS)

    Live agent detection walks the process tree downward from the pane's shell pid via collectDescendants in src/main/providers/agent-foreground-process.ts:20 (used by resolveAgentForegroundProcessFromPs at line 108). tmux double-forks its server and reparents it to pid 1, so the agent (claude/codex) is a child of the tmux server, not the pane shell. The descendant walk from the shell pid reaches only the tmux client (unrecognized) and returns the tmux fallback — the agent never shows as running. The relay/SSH twin src/relay/pty-shell-utils.ts:163 has the same downward-only walk, so remote sessions are affected too.

    Repro pins the buggy result with the real product code, plus a control showing the identical ps table yields claude when the walk starts from the tmux server pid:

    pnpm exec vitest run --config config/vitest.config.ts src/main/providers/repro-7797-tmux-agent-detection.test.ts
    

    Fix direction: when a tmux client is found in the subtree, map it to its active pane pid (tmux list-clients -F '#{client_pid} #{pane_pid}') and re-run the recognition walk from there (best-effort, POSIX-only, mirrored in the relay path).

    Key files: src/main/providers/agent-foreground-process.ts, src/relay/pty-shell-utils.ts, src/shared/agent-process-recognition.ts.


    Automated bug-reproduction pass. Repro artifact committed on branch nwparker/bug-repro-pass2; check it out to run the command above. Writeup: docs/bug-reproductions/7797.md.

  4. added
    has_repro
    on Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughas_repro

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions