[Feature]: Bind an agent-created worktree to the Agent View session that owns it
Problem or use case
When claude agents (Claude Code's Agent View) runs a background session in an isolated worktree, two facts exist but are never connected:
- Claude Code knows which session owns that worktree.
- Orca, once it sees the worktree, knows only that a directory and branch exist.
So the moment Orca opens (or adopts) a worktree that an agent created, it treats it as an ownerless workspace. The live session that is actually working in there is nowhere in Orca — I can't see which agent owns the worktree, can't reach it from the workspace, and can't get notified about it. To touch that session I have to go back to the Agent View TUI and find it by hand.
The binding primitive already exists on the Claude Code side. claude agents --cwd <path> means "show only background sessions started under <path>", and --json prints them without needing a TTY:
[{ "pid": 4968, "cwd": "/path/to/worktree", "kind": "interactive",
"startedAt": 1783566446738, "sessionId": "a0d8dcbf-…",
"name": "orca-16", "status": "busy" }]
cwd locates the worktree and sessionId identifies the owner. Orca just has to ask.
Proposed solution
- [ ] When Orca accesses an agent-created worktree, resolve the owning session — e.g.
claude agents --json --cwd <worktree>— and record the binding (worktree ↔ sessionId). - [ ] Surface the binding on the workspace: which agent, which session, and its current state.
- [ ] Opening that workspace should attach to / resume the bound session, rather than dropping me into an unrelated shell.
- [ ] Persist the binding across restarts, and clear it when the session ends.
- [ ] Route that session's notifications to its bound workspace, so an alert takes me to the right worktree. (Depends on #7911.)
Out of scope here: creating a new session for a workspace that never had one. This issue is specifically about adopting the ownership that already exists.
Alternatives or additional context
- The binding is the missing link that makes the worktree — not the Agent View list — the thing I navigate.
- Because
--cwdfilters by where a session was started, the lookup works for sessions started outside Orca too, which is the common case for me. - Related: #7911, #7916, #7912, #2432 (Agent Teams spawn hidden tmux sessions instead of native Orca panes), #5700.
- Part of #7918 (umbrella: multi-repo work driven by agent-managed worktrees and stacked PRs).