Skip to content

fix(agents): offer an agent only .zshrc puts on PATH, as a pane's shell starts it - #3723

Merged
devswha merged 4 commits into
mainfrom
fix/agent-path-interactive-shell
Nov 12, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/agent-path-interactive-shell

Conversation

@devswha

@devswha devswha commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Problem

In the desktop app on a Mac, Add agent did not offer Claude Code although typing claude in a pane works.
The app starts its server from Finder/Dock with launchd's bare PATH. /api/agents then looks for each agent
on the server's PATH and on the PATH of zsh -l -c, which reads .zshenv and .zprofile but not .zshrc.
Claude Code's native installer puts claude in ~/.local/bin and the PATH line in .zshrc, so the
agent 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 (catalogLocator behind /api/agents and the
    agent 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 the
    existing time, output and process-group limits.
  • The interactive shell runs once per server start, shared by both locators, and its answer is kept until
    an explicit refresh: a new install (InstalledLookup's first refresh for it, not its 30 s retries) or
    Check again in Settings > Agents (GET /api/agent-catalog?recheck=1). A watching device's recheck is
    ignored, on this server and when the PC proxy forwards it (machine-api.ts drops it, since the PC sees the
    hub'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 client
    repeating Check again runs .zshrc at most once per 5 s. The login shell keeps its 60 s TTL.
    So a .zshrc that starts something outliving the shell (eval "$(ssh-agent -s)", tmux new -d) starts
    it once per server start and once per Check again, not once a minute.
  • Every probe shell runs with OVIS_PATH_PROBE=1, so a profile can skip such lines:
    [ -n "$OVIS_PATH_PROBE" ] || eval "$(ssh-agent -s)".
  • When only the interactive run fails (a .zshrc slower than 2 s, say), the login PATH answers, the reason
    is logged once per change (agents: interactive shell PATH not read (...)), and /api/agent-catalog
    carries it as optional path_problem; Settings > Agents shows it under On this PC with the reason.
    Later lookups no longer wait on it.
  • ShellAgentLocator drops relative entries from the probe's PATH (./node_modules/.bin in a .zshrc),
    as catalogLocator already did.

What is offered is what starts: the start types claude into the pane's interactive shell, which resolves
it on the same PATH this reads. With two copies, both locators and zsh's own command -v agree; a copy on
the service PATH wins as before.

Alternatives considered:

  • Installer folders (~/.local/bin from the catalog): a folder no shell PATH names would be offered while
    typing claude in the pane fails. installed-lookup.ts refuses folder-only hits for that reason.
  • Showing a not-found agent with a hint: the agent is installed and starts, so a hint would be wrong.

Not covered:

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 .zshrc
and for bash users) are in #3731.

Validation

  • Failing first: the new shell-agent.test.ts tests failed before the change (agentPathProbe missing).
  • New tests: interactive PATH found where the login one misses; once-and-keep with reread (locator refresh,
    catalog refresh, not TTL runs) and the OVIS_PATH_PROBE=1 marker; interactive timeout leaves the login
    PATH, is kept, logged once and told by the catalog; relative entries refused by both locators;
    InstalledLookup asks the interactive shell for a new install only; /api/agent-catalog path_problem
    and ?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.
  • Live on the test Mac (eamac, macOS 27.0.1, real /bin/zsh), fresh /tmp clone of main, server started as
    the 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, fake claude in ~/.local/bin:
    • PATH line in .zshrc only: installed: true (main: false); POST /api/workspace/create with
      agent: claude answered agent_started: true, and the pane ran ~/.local/bin/claude.
    • .zshrc with eval "$(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.)
    • .zshrc with sleep 3: first read 2866 ms, second 27 ms; claude installed: false; catalog
      path_problem: "/bin/zsh -l timed out after 2000 ms"; logged once.
    • Before the fix, PATH line in .zprofile (the workaround): installed: true.
  • Live on eamac (same setup): 10 concurrent ?recheck=1 GETs ran .zshrc twice.
  • server/machine-proxy.test.ts: a watching device's agent-catalog?recheck=1 reaches the PC without
    recheck (fails without the machine-api.ts line).
  • Not checked: the signed, packaged Ovis.app itself (not built on eamac; the server it starts was run from
    the same staged files), and the Settings > Agents note in a browser (covered by typecheck, i18n tests only).

@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • On macOS, the desktop app now detects Claude Code and other agents using the PATH configured by an interactive shell, including paths added in interactive startup files.
    • Agent detection also retains paths available through the login shell when the interactive-shell lookup fails, improving results across different shell configurations.

The non-Windows agent lookup now combines PATH results from interactive and non-interactive login shells. The agent catalog uses this probe, and tests cover interactive-only PATH entries and probe failures.

Changes: Agent PATH probing

Layer / File(s) Summary
Interactive PATH probe and validation
server/shell-agent.ts, server/shell-agent.test.ts
loginShellProbe can run with an interactive shell. agentPathProbe combines interactive and non-interactive PATH entries, deduplicates them, and reports failure reasons when neither probe returns a PATH. Tests cover interactive-only executable paths and fallback behavior.
Default probe adoption
server/shell-agent.ts, server/agent-catalog-detect.ts, changelog.d/agent-path-interactive-shell.md
The non-Windows agent locator and catalog detector use agentPathProbe. The changelog describes the interactive-shell PATH behavior.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Low

Possibly related PRs

  • devswha/ovis#2413: Changes ShellAgentLocator PATH retention and lookup behavior, which now receives the combined PATH.
  • devswha/ovis#3652: Changes the shared login-shell probe options and contract used by this change.
  • devswha/ovis#2326: Introduces defaultLoginProbe(), which this change updates to use agentPathProbe.

Suggested reviewers: photojupi, willowite

Merge Risk: Minimal · up to b6498

Agent discovery now also reads the PATH set by a pane's interactive shell, so agents installed via .zshrc are detected. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: agent discovery now uses the PATH a pane's interactive shell gets, so an agent is offered only when .zshrc puts it on PATH. The changeset adds agentPathProbe, which ru…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description follows the repository template. It has a Change section that explains the problem, the fix, alternatives, and out-of-scope items. It has a Validation section that lists the tests run,…
Full details: Title check

Explanation

The title names the main change: agent discovery now uses the PATH a pane's interactive shell gets, so an agent is offered only when .zshrc puts it on PATH. The changeset adds agentPathProbe, which runs interactive and login probes and merges their PATH. The title is specific and matches the objectives. It is a long, comma-heavy line of 81 characters, which is acceptable.

Full details: Description check

Explanation

The description follows the repository template. It has a Change section that explains the problem, the fix, alternatives, and out-of-scope items. It has a Validation section that lists the tests run, their results, the live Mac checks, and what was not checked. The template asks for an issue link for features; this is a bug fix, so no issue link is needed. The description is long and dense, but its required content is complete.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 14687c5 and b649829.

Files selected for processing: 4

  • changelog.d/agent-path-interactive-shell.md
  • server/agent-catalog-detect.ts
  • server/shell-agent.test.ts
  • server/shell-agent.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

@devswha
devswha merged commit 968d6fa into main Nov 12, 2026
21 of 22 checks passed
@devswha

devswha commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Merge pass

Merged head ec77c6efbd1b as 968d6fabaef8 on GitHub's checks, with no unresolved review threads.

Reviewer Verdict Note
claude CLEAR
codex CLEAR

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 claude is in ~/.local/bin and only .zshrc puts that on PATH.

The agent list now also reads the PATH an interactive login shell sets (-l -i -c), joined before the login shell's. The interactive shell runs once per server start and again only on an install or Check again; its environment carries OVIS_PATH_PROBE=1 so a profile can skip lines that start something lasting; a failed interactive read is logged once and shown in Settings > Agents; relative PATH entries are dropped in both locators; rereads are at least 5 s apart; a watching device's ?recheck=1 is ignored, also when forwarded to another PC.

What the merge pass ran on real zsh with a throwaway HOME, on this PC and on the test Mac:

  • the maintainer's case: offered, .zshrc ran once in three simulated minutes of lookups, later lookups 17 ms;
  • a .zshrc with eval "$(ssh-agent -s)": the first head left one agent per probe run; this one leaves one per server start, none with the documented guard;
  • a .zshrc slower than 2 s: the reason is logged and told, and later lookups do not wait on it;
  • two copies of one agent: both locators and zsh's own command -v pick the same one.

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 .zshrc ran 11 times and left 11 ssh-agent processes), so it was cut: server/installed-lookup.ts is as at the second head.

Left for follow-up issue #3731 (and #3727 for an agent reached only through an alias), none HIGH: a PATH line added to .zshrc after Add agent was first opened needs Check again (both reviewers reproduced it; the cut above is why); Check again leaves the shell-started agents' locator stale for up to 60 s (Codex, reproduced); the reason shown says zsh -l for the interactive run too; the interactive run has the login shell's 2 s budget; after one Check again, switching PC or language sends recheck=1 again; docs/agent-catalog.md and DESIGN.md still describe the login PATH only (all Claude, read).

Reports: ~/.cache/ovis-tmp/reports/pr-3723-*.report.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant