Claude panes launched through a sandbox wrapper: chat shows "Conversation unavailable", and Resume would escape the wrapper
Versions: Ovis 0.5.3, herdr 0.9.5, Linux
Setup
I run Claude Code in herdr panes through a sandbox wrapper (@anthropic-ai/sandbox-runtime, i.e. bubblewrap). Each project gets its own CLAUDE_CONFIG_DIR. The process tree in the pane looks like this:
pane shell
└─ wrapper (bash) foreground, CLAUDE_CONFIG_DIR=<project store>, HERDR_AGENT=claude
└─ node srt-cli.js foreground, same environment
└─ bwrap --new-session ... setsid(): everything below is in another session
└─ claude ... NOT among the pane's foreground processes
To keep herdr working I already:
- export
HERDR_AGENT=claudeon the foreground processes. This is the hint herdr provides for wrappers like bubblewrap, and herdr's status detection works with it. - run a
SessionStarthook inside the sandbox plus a relay outside it that callsherdr pane report-agent-session <pane> --source custom:<wrapper> --agent claude --agent-session-id <id> -- <wrapper> --resume <id>. herdr therefore knows the session id and how to resume the session inside the sandbox.
Problem 1: the chat view cannot find the transcript
claudeTranscriptPath() (server/conversation.ts) gets the session id from herdr correctly. It then looks for the store via claudeProcesses(), which keeps only foreground processes that pass isClaudeProcess(). Under a wrapper there are none, so it falls back to defaultClaudeConfigDir() (~/.claude). The transcript is in <project store>/projects/..., so the pane shows "Conversation unavailable — show a terminal output preview".
Proposal
When no foreground process passes isClaudeProcess(), accept a foreground process whose environment has HERDR_AGENT=claude (read from /proc/<pid>/environ, the same way environSource() already reads CLAUDE_CONFIG_DIR). Its CLAUDE_CONFIG_DIR is the store. All the existing rules can stay as they are: exactly one such process, an unreadable or ambiguous store is an error, never a guess.
When several foreground processes carry the hint (the wrapper and its children inherit it), they share one environment. Taking the outermost one, or requiring that they all agree on CLAUDE_CONFIG_DIR, keeps this unambiguous.
Problem 2: Resume and session history bypass the wrapper
POST /api/sessions/resume (server/session-history-routes.ts) opens a new tab and starts claude --resume <id> with the source's CLAUDE_CONFIG_DIR. For a wrapped pane, fixing problem 1 makes this worse: the session listing would show the project store, and Resume would start the session outside the sandbox with the sandbox's config. The store check after launch passes, because the store is the same.
Proposal (either works)
- Use the resume command the agent reported. If herdr has a resume command reported for the session (
report-agent-session ... -- <command>, sourcecustom:*), Resume runs that command instead ofclaude --resume. This is the command herdr itself uses after a restart. - Refuse it. For stores found only through the
HERDR_AGENThint (problem 1), refuse Resume with a clear error, for example409 launch_wrapped, and do not start a bareclaude.
Option 1 is better for users. Option 2 is the minimal safe behaviour.
Workaround I use meanwhile
The wrapper starts its outer foreground process with argv[0]=claude (exec -a claude node srt-cli.js ...), so isClaudeProcess() matches it and its CLAUDE_CONFIG_DIR is read. Problem 1 is gone, but problem 2 remains. It also does not work through npx, because npm exec rewrites process.title.
One more requirement: the relay has to report with --source herdr:claude. herdr 0.9.5 stores the resume command for a custom:* source, but it does not expose the id as agent_session in agent.get. So Ovis has no session id, and the PID-record fallback cannot help either, because Claude's pid inside the sandbox's PID namespace does not match the host pid. With herdr:claude both are kept: agent_session is set and agent_resume keeps the wrapper's argv. It might be worth having Ovis also accept the session from agent_resume when agent_session is missing.
I'm happy to send a PR for problem 1, and for problem 2 once you've picked between the two options.
Similar setup here on macOS with a different wrapper: Claude Code runs in herdr panes through a small Node launcher that execs claude. herdr's job scan finds claude behind it today, so status and the chat work, but the same two problems appear as soon as a wrapper puts claude outside the pane's foreground process group.
Two things I would add to the proposal, from reading main a81ec59:
- When more than one foreground process carries
HERDR_AGENT=claude(a wrapper and its child both export it), accept the hint only if they all agree onCLAUDE_CONFIG_DIR; otherwise answer the same "ambiguous" the history list already gives (server/claude-store.ts), rather than falling back to~/.claude. The fallback is the worst case: it can show another account's conversation. - For Resume, a session found through the hint should never be relaunched as bare
claude --resume(server/session-history-routes.ts, the new-tab path). Refusing with a clear code (for example 409launch_wrapped) and hiding Resume for such sessions in the list is enough for a first step; relaunching through the wrapper's ownresume_argvcan come later. herdr already stores that argv frompane report-agent-session, but its read API does not return it yet, so that half needs herdr.
Happy to test a branch on macOS.
I checked main at 6946dcb01d78275ac041f088c0b8842921e7c06c with the isolated wrapper fixtures (bun test ./server/conversation.test.ts -t "#3931", 4 passed). The conversation reader now finds the reported session in the wrapper-provided store, and refuses ambiguous stores; #4121 added this coverage. These checks cover the Chat reader only, not launching Resume through the wrapper. I am leaving the issue open for the separate Resume behavior.