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(macos): install the app into /Applications so it shows among the user's apps
Harald Herz89ee1957f99a
diff --git a/docs/BUGS.md b/docs/BUGS.mdindex f9ad49456a..b59cd09872 100644--- a/docs/BUGS.md+++ b/docs/BUGS.md@@ -15362,3 +15362,16 @@ single restart, onboarding leaves the restart to itself).**Related.** BUG-083, BUG-159, BUG-161 (all "still open" on this point untilnow), `docs/product/privacy-safety-and-support/permissions.md`,`docs/os-parity.md`.++**Follow-up 2026-09-16 (the app was not among the user's apps).** Even with a+healthy index the bundle sat in `~/Applications`, which Finder's+"Applications" item and Launchpad do not show — the user reported it missing+from their apps although it was installed. `macos_app_bundle.py` now installs+into `/Applications` whenever the account can write there without elevation+(every admin account) and keeps `~/Applications` only for standard accounts.+An existing per-user install is moved over once with a plain rename, so its+bytes, code signature and therefore every TCC grant survive (TCC never pins a+path, BUG-161); a running app is followed to its new path instead of being+rebuilt. Uninstall clears both folders, and the Keychain ownership check in+`jarvis/core/control_key.py` and `jarvis permissions` accept both locations.+Guard: `tests/unit/setup/test_macos_app_location.py`.diff --git a/docs/os-parity.md b/docs/os-parity.mdindex 9260127a20..b5595410ff 100644--- a/docs/os-parity.md+++ b/docs/os-parity.md@@ -320,7 +320,11 @@ bundle out of Spotlight search. macOS now also imports the bundle with`mdimport` and checks the indexing switch of the volume that controls it (`/`for the APFS data volume), logging the admin repair command when indexing isoff; `--doctor` (`macos-spotlight`) additionally detects a stalled index by an-import that never appears. Windows and Linux are+import that never appears. The bundle is also installed into `/Applications`+(Finder's Applications folder, Launchpad) whenever the account may write there,+falling back to `~/Applications` for standard accounts; an existing per-user+install is moved over by rename, keeping its signature and TCC grants. Windows+and Linux areunchanged — their index announcements already feed the search the user typesinto.diff --git a/jarvis/cli_ctl/commands/permissions.py b/jarvis/cli_ctl/commands/permissions.pyindex 59196201e8..47d796e301 100644--- a/jarvis/cli_ctl/commands/permissions.py+++ b/jarvis/cli_ctl/commands/permissions.py@@ -13,7 +13,7 @@ import typerfrom jarvis.cli_ctl import invoke, options, renderfrom jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGSfrom jarvis.platform import detect_platform-from jarvis.platform.permissions import APP_NAME, EXPECTED_BUNDLE_ID, PermissionId+from jarvis.platform.permissions import EXPECTED_BUNDLE_ID, PermissionIdapp = typer.Typer(no_args_is_help=True,@@ -22,7 +22,9 @@ app = typer.Typer(def _installed_macos_app() -> Path:- return Path.home() / "Applications" / f"{APP_NAME}.app"+ from jarvis.setup.macos_app_bundle import macos_app_bundle_path++ return macos_app_bundle_path()def _activation_error(message: str) -> NoReturn:diff --git a/jarvis/core/control_key.py b/jarvis/core/control_key.pyindex 08c6fba3c6..2ec5983f00 100644--- a/jarvis/core/control_key.py+++ b/jarvis/core/control_key.py@@ -185,11 +185,16 @@ def _macos_app_identity_token() -> str | None:bundle_id = str(bundle.bundleIdentifier() or "")bundle_path = Path(str(bundle.bundlePath() or "")).resolve()executable = Path(str(bundle.executablePath() or "")).resolve()- expected = (Path.home() / "Applications" / f"{_MACOS_APP_NAME}.app").resolve()+ # Both install locations are canonical: the installer prefers+ # /Applications and falls back to ~/Applications (BUG-161, BUG-216).+ expected = {+ (root / f"{_MACOS_APP_NAME}.app").resolve()+ for root in (Path("/Applications"), Path.home() / "Applications")+ }executable_root = bundle_path / "Contents" / "MacOS"if (bundle_id != _MACOS_BUNDLE_ID- or bundle_path != expected+ or bundle_path not in expectedor not executable.is_file()or not executable.is_relative_to(executable_root)):diff --git a/jarvis/setup/macos_app_bundle.py b/jarvis/setup/macos_app_bundle.pyindex 96995ca54d..9b67f04e8c 100644--- a/jarvis/setup/macos_app_bundle.py+++ b/jarvis/setup/macos_app_bundle.py@@ -134,12 +134,71 @@ def _venv_python(install_dir: Path) -> Path:return Path(sys.executable)+SYSTEM_APPLICATIONS_DIR = Path("/Applications")+++def user_applications_dir() -> Path:+ return Path.home() / "Applications"+++def macos_applications_dir(+ *, system_dir: Path | None = None, user_dir: Path | None = None+) -> Path:+ """The folder the app lives in — or, when it lives nowhere yet, belongs in.++ ``/Applications`` is the folder Finder's "Applications" sidebar item and+ Launchpad show; a bundle kept only in ``~/Applications`` is installed but+ invisible to a user who looks where Mac apps are (BUG-216). It is writable+ without a password for every admin account, so it is the default whenever+ this user can write there; a standard account keeps ``~/Applications``.+ """+ system = system_dir or SYSTEM_APPLICATIONS_DIR+ user = user_dir or user_applications_dir()+ for root in (system, user):+ candidate = root / APP_DIR_NAME+ if candidate.exists() or candidate.is_symlink():+ return root+ return system if os.access(system, os.W_OK) else user++def macos_app_bundle_path(*, applications_dir: Path | None = None) -> Path:- """Return the one canonical per-user application-bundle path."""- root = applications_dir or (Path.home() / "Applications")+ """Return the application-bundle path (see ``macos_applications_dir``)."""+ root = applications_dir or macos_applications_dir()return root / APP_DIR_NAME+def _promote_to_system_applications(+ *, system_dir: Path | None = None, user_dir: Path | None = None+) -> Path | None:+ """Move a ``~/Applications`` install into ``/Applications`` once.++ A rename keeps every byte and therefore the code signature: TCC pins grants+ to the bundle id and signature, never to a path (BUG-161), so the user's+ permissions survive the move. Only runs when ``/Applications`` has no copy+ of its own and is writable without elevation; a failure leaves the app where+ it was, which still works.+ """+ system = system_dir or SYSTEM_APPLICATIONS_DIR+ user = user_dir or user_applications_dir()+ source = user / APP_DIR_NAME+ target = system / APP_DIR_NAME+ if (+ not source.is_dir()+ or source.is_symlink()+ or target.exists()+ or target.is_symlink()+ or not os.access(system, os.W_OK)+ ):+ return None+ try:+ source.rename(target)+ except OSError as exc:+ log.warning("Could not move %s to %s; keeping it in place: %s", source, system, exc)+ return None+ log.info("Moved the macOS app into %s so Finder and Launchpad show it.", system)+ return target++def _is_macho_executable(path: Path) -> bool:try:mode = path.stat().st_mode@@ -1017,7 +1076,10 @@ def ensure_macos_app_bundle(applications_dir: Path | None = None,create_signing_identity: bool = False,) -> Path | None:- """Ensure ``~/Applications/Personal Jarvis.app`` has a stable identity.+ """Ensure ``/Applications/Personal Jarvis.app`` has a stable identity.++ ``~/Applications`` is used instead when this account cannot write+ ``/Applications``; an existing install there is moved over once.A valid existing bundle is preserved byte-for-byte so normal sourceupdates cannot churn its local TCC identity. ``create_signing_identity``@@ -1032,7 +1094,8 @@ def ensure_macos_app_bundle(if sys.platform != "darwin":log.info("App bundle skipped: only macOS uses .app bundles.")return None- applications_dir = Path.home() / "Applications"+ _promote_to_system_applications()+ applications_dir = macos_applications_dir()try:install_root = (install_dir or _default_install_dir()).resolve()bundle = macos_app_bundle_path(applications_dir=applications_dir)@@ -1049,6 +1112,10 @@ def ensure_macos_app_bundle(# certificate identity: the reset that follows would hit this very# process, so that migration waits for the installer.running = _running_managed_bundle(install_root=install_root, diagnostics=diagnostics)+ if running is not None and not running.exists() and bundle.exists():+ # This process still carries the path it launched from, but the+ # bundle was just moved (``_promote_to_system_applications``).+ running = bundleif running is not None:register_with_launch_services(running)if identity is not None and not _signed_with_certificate(running):@@ -1120,21 +1187,29 @@ def ensure_macos_app_bundle(def remove_macos_app_bundle(*, applications_dir: Path | None = None) -> bool:- """Delete the bundle on uninstall and report whether it is gone."""+ """Delete the bundle on uninstall and report whether it is gone.++ Without an explicit directory both install locations are cleared, so an+ app the installer moved or the user dragged elsewhere is not left behind.+ """if applications_dir is None:if sys.platform != "darwin":return True- applications_dir = Path.home() / "Applications"- bundle = macos_app_bundle_path(applications_dir=applications_dir)- if not bundle.exists() and not bundle.is_symlink():- return True- try:- _remove_path(bundle)- log.info("macOS app bundle removed: %s", bundle)- return True- except OSError as exc:- log.warning("Could not remove %s: %s", bundle, exc)- return False+ roots = [SYSTEM_APPLICATIONS_DIR, user_applications_dir()]+ else:+ roots = [applications_dir]+ removed = True+ for root in roots:+ bundle = root / APP_DIR_NAME+ if not bundle.exists() and not bundle.is_symlink():+ continue+ try:+ _remove_path(bundle)+ log.info("macOS app bundle removed: %s", bundle)+ except OSError as exc:+ log.warning("Could not remove %s: %s", bundle, exc)+ removed = False+ return removed__all__ = [@@ -1144,7 +1219,10 @@ __all__ = ["ensure_macos_app_bundle","last_error","macos_app_bundle_is_launchable",+ "SYSTEM_APPLICATIONS_DIR","macos_app_bundle_path",+ "macos_applications_dir",+ "user_applications_dir","macos_launch_services_command","register_with_launch_services","remove_macos_app_bundle",diff --git a/tests/unit/core/test_control_key.py b/tests/unit/core/test_control_key.pyindex 3fa80fa07c..7a45acb327 100644--- a/tests/unit/core/test_control_key.py+++ b/tests/unit/core/test_control_key.py@@ -242,6 +242,33 @@ def test_macos_identity_uses_verified_canonical_designated_requirement(]+def test_macos_identity_rejects_a_bundle_outside_both_install_folders(+ monkeypatch, tmp_path+) -> None:+ """/Applications joined ~/Applications as canonical (BUG-216); any other+ copy of the app still never owns the Keychain item."""+ bundle_path = tmp_path / "Downloads" / "Personal Jarvis.app"+ executable = bundle_path / "Contents" / "MacOS" / "PersonalJarvis"+ executable.parent.mkdir(parents=True)+ executable.write_bytes(b"Mach-O test fixture")+ bundle = SimpleNamespace(+ bundleIdentifier=lambda: "com.personal-jarvis.desktop",+ bundlePath=lambda: str(bundle_path),+ executablePath=lambda: str(executable),+ )+ foundation = SimpleNamespace(NSBundle=SimpleNamespace(mainBundle=lambda: bundle))+ monkeypatch.setattr(ck.sys, "platform", "darwin")+ monkeypatch.setattr(ck.Path, "home", classmethod(lambda _cls: tmp_path))+ monkeypatch.setitem(sys.modules, "Foundation", foundation)+ monkeypatch.setattr(+ ck.subprocess,+ "run",+ lambda *args, **kwargs: pytest.fail("codesign must not run for a stray copy"),+ )++ assert _REAL_MACOS_APP_IDENTITY_TOKEN() is None++def test_macos_identity_rejects_direct_python_before_codesign(monkeypatch, tmp_path) -> None:bundle = SimpleNamespace(bundleIdentifier=lambda: "org.python.python",diff --git a/tests/unit/setup/test_macos_app_location.py b/tests/unit/setup/test_macos_app_location.pynew file mode 100644index 0000000000..cb1933ca6f--- /dev/null+++ b/tests/unit/setup/test_macos_app_location.py@@ -0,0 +1,169 @@+"""The macOS app lives where Mac users look for apps (BUG-216).++A bundle kept only in ``~/Applications`` was installed and launchable, yet the+user could not see it among their apps: Finder's "Applications" item and+Launchpad show ``/Applications``. These tests pin that the installer prefers+``/Applications`` when the account may write there, moves an existing+per-user install over without touching its bytes (the signature, and with it+every TCC grant, survives a rename), and never loses the app on the way.+"""++from __future__ import annotations++import os+import sys+from pathlib import Path++import pytest++import jarvis.setup.macos_app_bundle as mab+from jarvis.setup.macos_app_bundle import (+ APP_DIR_NAME,+ ensure_macos_app_bundle,+ macos_applications_dir,+ remove_macos_app_bundle,+)++pytestmark = pytest.mark.skipif(sys.platform == "win32", reason="POSIX permission bits")+++def _bundle(root: Path, marker: str = "signed-bytes") -> Path:+ bundle = root / APP_DIR_NAME+ (bundle / "Contents" / "MacOS").mkdir(parents=True)+ (bundle / "Contents" / "MacOS" / "PersonalJarvis").write_text(marker, encoding="utf-8")+ return bundle+++def roots(tmp_path: Path) -> tuple[Path, Path]:+ system = tmp_path / "Applications"+ user = tmp_path / "home" / "Applications"+ system.mkdir()+ user.mkdir(parents=True)+ return system, user+++def read_only(roots: tuple[Path, Path]):+ system, _user = roots+ if os.geteuid() == 0:+ pytest.skip("root ignores directory permission bits")+ system.chmod(0o555)+ yield system+ system.chmod(0o755)+++def test_a_fresh_install_goes_to_the_system_applications_folder(roots) -> None:+ system, user = roots+ assert macos_applications_dir(system_dir=system, user_dir=user) == system+++def test_a_standard_account_falls_back_to_its_own_applications_folder(roots, read_only) -> None:+ _system, user = roots+ assert macos_applications_dir(system_dir=read_only, user_dir=user) == user+++def test_an_existing_install_is_found_where_it_is(roots, read_only) -> None:+ system, user = roots+ _bundle(user)+ assert macos_applications_dir(system_dir=system, user_dir=user) == user+++def test_a_copy_in_the_system_folder_wins(roots) -> None:+ system, user = roots+ _bundle(user)+ _bundle(system)+ assert macos_applications_dir(system_dir=system, user_dir=user) == system+++def test_a_per_user_install_is_moved_byte_for_byte(roots) -> None:+ system, user = roots+ _bundle(user, marker="exact-signature")++ moved = mab._promote_to_system_applications(system_dir=system, user_dir=user)++ assert moved == system / APP_DIR_NAME+ assert not (user / APP_DIR_NAME).exists()+ executable = moved / "Contents" / "MacOS" / "PersonalJarvis"+ assert executable.read_text(encoding="utf-8") == "exact-signature"+++def test_an_existing_system_copy_is_never_overwritten(roots) -> None:+ system, user = roots+ _bundle(user, marker="user")+ _bundle(system, marker="system")++ assert mab._promote_to_system_applications(system_dir=system, user_dir=user) is None+ assert (user / APP_DIR_NAME).is_dir()+ assert (system / APP_DIR_NAME / "Contents" / "MacOS" / "PersonalJarvis").read_text(+ encoding="utf-8"+ ) == "system"+++def test_no_move_without_write_access(roots, read_only) -> None:+ _system, user = roots+ _bundle(user)++ assert mab._promote_to_system_applications(system_dir=read_only, user_dir=user) is None+ assert (user / APP_DIR_NAME).is_dir()+++def test_a_failed_move_keeps_the_working_app(roots, monkeypatch: pytest.MonkeyPatch) -> None:+ system, user = roots+ _bundle(user)++ def _refuse(self, target):+ raise OSError("Cross-device link")++ monkeypatch.setattr(Path, "rename", _refuse)++ assert mab._promote_to_system_applications(system_dir=system, user_dir=user) is None+ assert (user / APP_DIR_NAME).is_dir()+++def test_nothing_to_move_is_a_no_op(roots) -> None:+ system, user = roots+ assert mab._promote_to_system_applications(system_dir=system, user_dir=user) is None+++def test_uninstall_clears_both_locations(roots, monkeypatch: pytest.MonkeyPatch) -> None:+ system, user = roots+ _bundle(system)+ _bundle(user)+ monkeypatch.setattr(mab.sys, "platform", "darwin")+ monkeypatch.setattr(mab, "SYSTEM_APPLICATIONS_DIR", system)+ monkeypatch.setattr(mab, "user_applications_dir", lambda: user)++ assert remove_macos_app_bundle() is True+ assert not (system / APP_DIR_NAME).exists()+ assert not (user / APP_DIR_NAME).exists()+++def test_the_running_app_is_followed_to_its_new_location(+ roots, monkeypatch: pytest.MonkeyPatch, tmp_path: Path+) -> None:+ """The process keeps the path it launched from after the move; the repair+ must hand back — and register — where the app is now."""+ system, user = roots+ _bundle(user)+ launched_from = user / APP_DIR_NAME+ monkeypatch.setattr(mab.sys, "platform", "darwin")+ monkeypatch.setattr(mab, "SYSTEM_APPLICATIONS_DIR", system)+ monkeypatch.setattr(mab, "user_applications_dir", lambda: user)+ monkeypatch.setattr(mab, "ensure_local_signing_identity", lambda **_kw: None)+ monkeypatch.setattr(+ mab, "_running_managed_bundle", lambda *, install_root, **_kw: launched_from+ )+ monkeypatch.setattr(+ mab,+ "_install_native_bundle",+ lambda *_a, **_kw: pytest.fail("a moved running app must never be rebuilt"),+ )+ registered: list[Path] = []+ monkeypatch.setattr(mab, "register_with_launch_services", registered.append)++ result = ensure_macos_app_bundle(install_dir=tmp_path / "install")++ assert result == system / APP_DIR_NAME+ assert registered == [system / APP_DIR_NAME]+ assert not launched_from.exists()