Repository navigation
fix(agents): offer an agent only .zshrc puts on PATH, as a pane's shell starts it - #3723
Conversation
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
…he probe, report its miss
… a run out, retry them slowly for an install
…ce's recheck at the PC proxy
Merge passMerged head
Two reviewers at this head: Claude (Opus) CLEAR, Codex Terra CLEAR. Four heads were reviewed. The maintainer's own bug: on his Mac the desktop app did not offer Claude Code, because The agent list now also reads the PATH an interactive login shell sets ( What the merge pass ran on real zsh with a throwaway HOME, on this PC and on the test Mac:
The third head added a re-read of the profile every two minutes for an install not yet on PATH. It had no end while any install reached no PATH (20 simulated minutes: the Left for follow-up issue #3731 (and #3727 for an agent reached only through an alias), none HIGH: a PATH line added to Reports: |
Problem
In the desktop app on a Mac, Add agent did not offer Claude Code although typing
claudein a pane works.The app starts its server from Finder/Dock with launchd's bare PATH.
/api/agentsthen looks for each agenton the server's PATH and on the PATH of
zsh -l -c, which reads.zshenvand.zprofilebut not.zshrc.Claude Code's native installer puts
claudein~/.local/binand the PATH line in.zshrc, so theagent read as not installed (
installed: false) and the client hid it. The pane's shell is interactive,reads
.zshrc, and starts it fine.Fix
agentPathProbe(server/shell-agent.ts) gives both locators (catalogLocatorbehind/api/agentsand theagent catalog, and
ShellAgentLocator) the PATH a pane's shell has: the interactive login shell's(
shell -l -i -c) first, then the plain login shell's folders it does not name. Each run keeps theexisting time, output and process-group limits.
an explicit refresh: a new install (
InstalledLookup's first refresh for it, not its 30 s retries) orCheck again in Settings > Agents (
GET /api/agent-catalog?recheck=1). A watching device'srecheckisignored, on this server and when the PC proxy forwards it (
machine-api.tsdrops it, since the PC sees thehub's full token). Later install retries read only the login shell. A reread asked for while a run is out gets a
run that starts after it; rereads within 5 s of the last run (
REREAD_GAP_MS) share one, so a clientrepeating Check again runs
.zshrcat most once per 5 s. The login shell keeps its 60 s TTL.So a
.zshrcthat starts something outliving the shell (eval "$(ssh-agent -s)",tmux new -d) startsit once per server start and once per Check again, not once a minute.
OVIS_PATH_PROBE=1, so a profile can skip such lines:[ -n "$OVIS_PATH_PROBE" ] || eval "$(ssh-agent -s)"..zshrcslower than 2 s, say), the login PATH answers, the reasonis logged once per change (
agents: interactive shell PATH not read (...)), and/api/agent-catalogcarries it as optional
path_problem; Settings > Agents shows it under On this PC with the reason.Later lookups no longer wait on it.
ShellAgentLocatordrops relative entries from the probe's PATH (./node_modules/.binin a.zshrc),as
catalogLocatoralready did.What is offered is what starts: the start types
claudeinto the pane's interactive shell, which resolvesit on the same PATH this reads. With two copies, both locators and zsh's own
command -vagree; a copy onthe service PATH wins as before.
Alternatives considered:
~/.local/binfrom the catalog): a folder no shell PATH names would be offered whiletyping
claudein the pane fails.installed-lookup.tsrefuses folder-only hits for that reason.Not covered:
alias claude=~/.claude/local/claude: the alias ison no PATH. Follow-up: agents: Claude Code reached only through a shell alias is not offered #3727.
.zshrcafter the first read of an install (as Claude's installer advises): found onCheck again or a restart, which the Settings note points to. Follow-up: agents: cases the interactive-shell PATH read of #3723 leaves out #3731.
.zshrcthat returns early without a terminal ([[ -t 0 ]] || returnbefore its PATH line): the probehas no terminal (stdin ignored), so that line never runs and the agent stays missing, silently. A pty for
the probe would cover it. Follow-up: agents: cases the interactive-shell PATH read of #3723 leaves out #3731.
The other findings left for later (an old interactive PATH kept over a changed login profile, Check again
not refreshing the shell-agent locator for up to 60 s, the Settings note's wording for an
exec tmux.zshrcand for bash users) are in #3731.
Validation
shell-agent.test.tstests failed before the change (agentPathProbemissing).reread(locator refresh,catalog refresh, not TTL runs) and the
OVIS_PATH_PROBE=1marker; interactive timeout leaves the loginPATH, is kept, logged once and told by the catalog; relative entries refused by both locators;
InstalledLookupasks the interactive shell for a new install only;/api/agent-catalogpath_problemand
?recheck=1.bun test server/shell-agent.test.ts server/agent-catalog-detect.test.ts server/installed-lookup.test.ts server/agent-catalog-routes.test.ts src/lib/i18n.test.ts src/conventions.test.ts: 119 pass, 1 skip (Windows only).bun run check fast: exit 0./bin/zsh), fresh/tmpclone of main, server started asthe packaged app starts it (staged bun and herdr-core 0.1.17,
OVIS_RUNTIME=herdr-core, bare PATH/usr/bin:/bin:/usr/sbin:/sbin), throwaway HOME, fakeclaudein~/.local/bin:.zshrconly:installed: true(main:false);POST /api/workspace/createwithagent: claudeansweredagent_started: true, and the pane ran~/.local/bin/claude..zshrcwitheval "$(ssh-agent -s)": 1 agent after 3 reads, still 1 after 65 s and 2 more reads,2 after Check again. Guarded by
OVIS_PATH_PROBE: 0. (Test agents killed afterwards.).zshrcwithsleep 3: first read 2866 ms, second 27 ms; claudeinstalled: false; catalogpath_problem: "/bin/zsh -l timed out after 2000 ms"; logged once..zprofile(the workaround):installed: true.?recheck=1GETs ran.zshrctwice.server/machine-proxy.test.ts: a watching device'sagent-catalog?recheck=1reaches the PC withoutrecheck(fails without themachine-api.tsline).Ovis.appitself (not built on eamac; the server it starts was run fromthe same staged files), and the Settings > Agents note in a browser (covered by typecheck, i18n tests only).