Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(terminal): spawn macOS panes as login shells and de-collide shell ids
rubenluetke10-beep9db361a55bc0
diff --git a/jarvis/terminal/shells.py b/jarvis/terminal/shells.pyindex 88724701a1..f4cbb2c217 100644--- a/jarvis/terminal/shells.py+++ b/jarvis/terminal/shells.py@@ -83,12 +83,20 @@ def _unix_shells() -> list[ShellInfo]:Shells are deduplicated by their resolved (``os.path.realpath``) path so asymlinked ``/bin/sh -> bash`` or a ``$SHELL`` that is also in ``/etc/shells``- is listed once. ``argv`` is ``(path, "-i")`` (interactive) — never an- unconditional ``-l`` (a login shell on every spawn re-sources profiles and- is slow).+ is listed once. ``argv`` is ``(path, "-i")`` (interactive) on Linux — never+ an unconditional ``-l`` (a login shell on every spawn re-sources profiles+ and is slow, and Linux PATH edits live in ``~/.bashrc``, which an+ interactive shell reads anyway). macOS is the exception and gets ``-l``:+ every Mac terminal (Terminal.app, iTerm2, VS Code) starts LOGIN shells by+ convention, so user PATH lives in ``~/.zprofile``/``~/.bash_profile`` —+ Homebrew's install instructions put it exactly there, and a non-login zsh+ has no brew and none of the coding CLIs on its PATH. (tcsh ignores ``-l``+ beside other flags rather than erroring.)"""results: list[ShellInfo] = []seen: set[str] = set()+ used_ids: set[str] = set()+ interactive_args = ("-i", "-l") if detect_platform() == "darwin" else ("-i",)def _add(path: str) -> None:if not path or not os.path.isfile(path):@@ -97,8 +105,19 @@ def _unix_shells() -> list[ShellInfo]:if resolved in seen:returnseen.add(resolved)- label = os.path.basename(path)- results.append(ShellInfo(id=label, label=label, argv=(path, "-i")))+ base = os.path.basename(path)+ shell_id = base+ label = base+ suffix = 2+ while shell_id in used_ids:+ # Two installs sharing a basename (system bash + Homebrew bash)+ # must not share an id: the UI dropdown keys on it, and+ # ``get_shell()`` could only ever return the first.+ shell_id = f"{base}-{suffix}"+ label = f"{base} ({path})"+ suffix += 1+ used_ids.add(shell_id)+ results.append(ShellInfo(id=shell_id, label=label, argv=(path, *interactive_args)))# 1. $SHELL (the user's configured login shell)._add(os.environ.get("SHELL", ""))diff --git a/tests/unit/terminal/test_unix_shells.py b/tests/unit/terminal/test_unix_shells.pyindex eeee688c75..224cad6e4d 100644--- a/tests/unit/terminal/test_unix_shells.py+++ b/tests/unit/terminal/test_unix_shells.py@@ -195,3 +195,40 @@ def test_macos_uses_unix_branch(monkeypatch):)ids = [s.id for s in discover_shells()]assert ids == ["zsh"]+++def test_darwin_argv_is_a_login_shell(monkeypatch):+ """On macOS every terminal starts LOGIN shells — user PATH lives in+ ``~/.zprofile`` (Homebrew's install instructions put it there), so a+ non-login pane has no brew and no coding CLIs on its PATH.+ """+ monkeypatch.setattr(shells_mod, "detect_platform", lambda: "darwin")+ _patch_filesystem(+ monkeypatch,+ on_disk={"/bin/zsh"},+ etc_shells=["/bin/zsh"],+ shell_env="/bin/zsh",+ )+ shells = discover_shells()+ assert shells[0].argv == ("/bin/zsh", "-i", "-l")+++def test_same_basename_in_two_places_gets_unique_ids(monkeypatch):+ """System bash + Homebrew bash must not collide on id ``bash``.++ The UI dropdown keys on the id and ``get_shell()`` returns the first+ match, so a shared id made the second install unselectable.+ """+ monkeypatch.setattr(shells_mod, "detect_platform", lambda: "darwin")+ _patch_filesystem(+ monkeypatch,+ on_disk={"/bin/bash", "/opt/homebrew/bin/bash"},+ etc_shells=["/bin/bash", "/opt/homebrew/bin/bash"],+ shell_env=None,+ )+ shells = discover_shells()+ assert [s.id for s in shells] == ["bash", "bash-2"]+ assert shells[1].label == "bash (/opt/homebrew/bin/bash)"+ found = get_shell("bash-2")+ assert found is not None+ assert found.argv[0] == "/opt/homebrew/bin/bash"