Repository navigation
Conversation
Live foreground detection walks the process tree downward from the pane's
shell pid, but an agent launched inside tmux is a child of the reparented
tmux server (pid 1), not of the pane shell — so it was never reached and
the pane read as `tmux` instead of e.g. `claude`.
When the shell subtree holds a tmux client, hop to that client's active
pane pid (via `tmux list-clients -F '#{client_pid} #{pane_pid}'`) and
re-run the same recognition walk from there, also considering the pane's
own top process. Best-effort, POSIX-only, mirrored in the local and
relay/SSH paths, with a short TTL cache to avoid forking tmux per poll.
Fixes stablyai#7797
📝 WalkthroughWalkthroughThis PR adds a new shared module, 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/providers/agent-foreground-process.ts (1)
76-105: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider extracting the tmux client-hop pattern to the shared module.
The "find tmux client → resolve active pane → retry recognition → check pane top process" sequence is duplicated between
resolveTmuxHostedAgentProcesshere and the tmux fallback ingetRecognizedForegroundDescendant(src/relay/pty-shell-utils.tslines 254-267). The only difference is the inner recognition function (resolveAgentForegroundProcessFromPsvsrecognizeAgentInSubtree).Extracting a shared helper that accepts the recognition function as a callback would eliminate this duplication. However, this depends on whether
recognizeAgentProcessFromCommandLineandcollectDescendantscan be made available to both bundles — the relay bundle constraint may limit feasibility.Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 4b168d23-8df7-4672-b6a5-00f1e50e4e26
📒 Files selected for processing (5)
src/main/providers/agent-foreground-process.test.tssrc/main/providers/agent-foreground-process.tssrc/relay/pty-shell-utils.tssrc/shared/tmux-active-pane.test.tssrc/shared/tmux-active-pane.ts
What
Detect AI agents (e.g.
claude,codex) that are running inside a user's tmux session so they show up as live/running on the pane, worktree, and project views.Fixes #7797
Why
Live foreground detection walks the process tree downward from the pane's shell pid and only inspects that subtree (
agent-foreground-process.tslocally,pty-shell-utils.tson the relay).When a user runs
tmuxin an Orca pane, the process in the pane is the tmux client. tmux daemonizes a server (reparented to pid 1), and every pane process — includingclaude— is a child of that server, not of the pane's shell. So the descendant walk reaches only the tmux client (not a recognized agent) and the pane reads astmux.How
When the shell's subtree contains a tmux client, hop to that client's active pane pid and re-run the same recognition walk:
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).tmux new-session claude).src/shared/tmux-active-pane.ts(isTmuxClientCommand,parseTmuxSocketArgs,resolveTmuxActivePanePidwith a 500ms TTL cache so we don't forktmuxon every foreground poll).Testing
tmux-active-pane(parsing, socket selector, client→pane mapping, cache TTL, failure fallback).agent-foreground-process.test.ts(client hop + fallback when no active pane).pty-shell-utilstests still pass (recognition logic extracted torecognizeAgentInSubtree, reused).tmux3.6 + realps: agent detected both when it is a child of the pane shell and when it is the pane's top process.oxlintandtsgotypecheck clean.Notes
cwd; this PR only fixes the live/running indicator.ELI5
Agents running inside your own tmux session didn’t show as live in Orca. Process detection now walks into tmux so Claude/Codex still appear as running.