orca icon indicating copy to clipboard operation
orca copied to clipboard

[Feature]: Support Claude Code Agent View (`claude agents`) as a launch mode

Open minho-pinta-sh opened this issue 4 months ago • 1 comments

Problem or use case

Claude Code's Agent View (claude agents) is the TUI that manages background sessions. It's how I actually drive my work: I open Agent View and run several background sessions, often isolated in their own worktrees.

Orca has a launch mode per TUI agent (src/shared/tui-agent-config.ts): claude launches the claude binary, and claude-agent-teams launches the orca claude-teams wrapper — which is Agent Teams, a different Claude Code feature. There is no launch mode for Agent View.

Agent View is directly scriptable and scopable, which is what makes this worth wiring in properly. From claude agents --help:

  • --cwd <path> — "Show only background sessions started under <path>" (a scope filter, not a working-directory setter)
  • --json — "Print active sessions as a JSON array and exit (for scripting; does not require a TTY)"
  • --all — with --json, include completed sessions
  • plus per-dispatch defaults: --agent, --model, --effort, --permission-mode, --allow-dangerously-skip-permissions, --add-dir, --mcp-config, --settings

So claude agents --cwd <worktree> is exactly "Agent View for this workspace."

Today I can't get that through Orca. It also can't be faked through settings:

  • agentDefaultArgs is documented as "CLI arguments appended after the binary/path and before prompts", and claude uses promptInjectionMode: 'argv' with draftPromptFlag: '--prefill', so the final command is claude <args> --prefill "<prompt>". Putting agents in the args yields claude agents --prefill "…" — the prompt flag lands after a subcommand, and Orca's prompt injection and session tracking both assume the normal interactive chat TUI.
  • agentCmdOverrides (replacing the binary with claude agents) hits the same problem.

Proposed solution

  • [ ] Add an Agent View launch mode that runs claude agents --cwd <worktree path>, so the view opened from a workspace shows exactly that workspace's background sessions.
  • [ ] Don't apply the single-chat prompt-injection path to it — Agent View is a session manager, not a chat.
  • [ ] Pass through the useful per-dispatch defaults (--agent, --model, --permission-mode) from Orca's agent settings.
  • [ ] Wire it into the rest of the agent model: per-session tracking/notifications, and binding each background session to the worktree it owns.

Alternatives or additional context

  • Agent Teams (orca claude-teams) is a different feature: teammates run as separate processes (--teammate-mode, tmux/iTerm2 split panes or in-process), which is why they also escape pane-level tracking (cf. #2432). This request is specifically about Agent View.
  • --json means Orca doesn't need to scrape a TTY to know what's running — see #7911.
  • Related: #7911, #7913, #2432, #5700.
  • Part of #7918 (umbrella: multi-repo work driven by agent-managed worktrees and stacked PRs).

minho-pinta-sh avatar Jul 09 '26 08:07 minho-pinta-sh

Some diagnostics from running Agent View inside Orca, in case it helps scope this (Orca 1.4.217, Claude Code 2.1.288, macOS).

Symptom: sessions dispatched from claude agents never appear in Orca's sidebar agent list, no matter which Orca tab they are viewed or attached from. Regular claude sessions in the same worktree are listed normally.

What I found:

  1. The first claude agents run spawns a detached daemon (claude daemon run --origin transient …, parent launchd). It inherits the full ORCA_* environment of the Orca tab it was started from (ORCA_TAB_ID, ORCA_TERMINAL_HANDLE, ORCA_PANE_KEY, ORCA_AGENT_LAUNCH_TOKEN, …).
  2. Every background session runs as a child of that daemon (claude bg-pty-host → claude bg-spare), so all of them carry that one tab's identity, including sessions dispatched or attached from other tabs.
  3. A tab running claude agents or claude attach <id> only hosts a viewer. The session's hooks fire inside the daemon's child process, not in the viewer's pane.
  4. agent-hooks/last-status.json had no entries for either the daemon's origin tab or the viewer tabs. I did not pin down where the events are dropped (hooks not reaching the server vs. being rejected by the pane/authority checks).

Gotcha when working around it: claude --resume <id> for a session that is still alive in the daemon does not start a local session. Claude Code turns it into claude attach <id> (visible in ps), so the session stays undetected. /exit or ← in the attached view also leaves it running (claude attach --help: "The session keeps running either way").

Workaround that works: stop the background session first (exit it from Agent View, or claude stop <id>), then run claude --resume <full-session-id> in a normal Orca tab. The process is then a plain claude --resume … owned by that tab, and Orca lists it right away.

Repro:

  1. Orca tab A: run claude agents and dispatch a session.
  2. Orca tab B: run claude agents (or claude attach <id>) and open that session.
  3. Neither tab shows the session in the sidebar. ps eww <session pid> shows tab A's ORCA_TAB_ID / ORCA_TERMINAL_HANDLE.

Possibly useful for an implementation: claude agents --json lists both interactive and background sessions with sessionId, cwd, state, and pid for live processes.

JaydonZhao avatar Oct 03 '26 21:10 JaydonZhao