Skip to content

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.

fix(macos): import the app bundle into Spotlight, not only LaunchServices

Harald Herze1bb67cfa4eb
diff --git a/docs/BUGS.md b/docs/BUGS.md
index 47179e04d6..331a6f8b41 100644
--- a/docs/BUGS.md
+++ b/docs/BUGS.md
@@ -15221,3 +15221,44 @@ boot critical path — the watchdog's first census is a full interval away), AP-
(the probe's silence is explained by its documented "None means not ready"
contract), BUG-113 (the pane-reconnect storm whose symptom was fixed in 2026-07
while this cause was left standing), `docs/os-parity.md` (the ceilings table).
+
+## BUG-216: the installed macOS app did not show up in Spotlight (MEDIUM, FIXED 2026-09-16)
+
+**Symptom.** `~/Applications/Personal Jarvis.app` was installed, launchable and
+listed by `lsregister -dump`, yet typing "Personal Jarvis" into Spotlight found
+nothing.
+
+**Root cause, two layers.**
+
+1. *Product.* The 2026-08-16 fix (BUG-138 pass) assumed Spotlight answers from
+ the LaunchServices database and stopped at `lsregister`. It does not: the
+ Spotlight search field reads the per-volume metadata store kept by `mds`.
+ The bundle is built in a hidden `.jarvis-native-*` directory and renamed into
+ place, and nothing ever asked Spotlight to import it. The docstring claiming
+ "announce to LaunchServices so Spotlight can find it" was simply wrong.
+2. *Machine.* On the reporting Mac the Data volume's Spotlight store itself was
+ broken: `mdutil -s /System/Volumes/Data` answered "Error: unknown indexing
+ state", and `mdfind` returned no item changed in the preceding four days.
+ Freshly created test apps and plain text files in `~/Applications`,
+ `~/Downloads` and `~/Desktop` stayed unindexed for minutes, with and without
+ `mdimport`. On such a volume nothing new becomes searchable, whichever app
+ wrote it, and only an administrator can re-enable the store.
+
+**Fix.** `jarvis/setup/macos_search_index.py`: every install/repair path already
+calls `register_with_launch_services`, which now also runs `mdimport` on the
+bundle and checks the volume with `df -P` + `mdutil -s <mount point>`. A
+disabled or broken store logs a WARNING carrying the exact repair command
+(`sudo mdutil -i on <vol> && sudo mdutil -E <vol>`). `python -m jarvis --doctor`
+gained `macos-spotlight`: store broken → warn + repair command; bundle not in
+the index → warn + `mdimport`; indexed → ok. `mdutil -s` must be given the mount
+point — handed the bundle path it echoes that path back as the "volume", which
+the live probe caught before it shipped.
+
+**Class rule.** "Registered" is not "searchable": verify against the index the
+user's search box actually reads, and when the OS index itself is broken say so
+with the command that fixes it instead of claiming the app is findable.
+
+**Guards.** `tests/unit/setup/test_macos_search_index.py` (verbatim broken-store
+`mdutil` output, mount-point resolution, import on registration, a Spotlight
+crash never blocks `lsregister`), `tests/unit/diagnostics/test_doctor_diagnostics.py`
+(`check_macos_spotlight`).
diff --git a/docs/os-parity.md b/docs/os-parity.md
index b0b16c390a..1268e0c544 100644
--- a/docs/os-parity.md
+++ b/docs/os-parity.md
@@ -314,6 +314,15 @@ so no platform silently claims an entry the shell cannot see. Announcement is
re-run for an unchanged entry too, which heals an install whose earlier write
succeeded while its announcement did not.
+**Fix pass 2026-09-16 (macOS: registered is not searchable, BUG-216).**
+LaunchServices and Spotlight are separate indexes; `lsregister` alone left the
+bundle out of Spotlight search. macOS now also imports the bundle with
+`mdimport` and checks the volume's Spotlight store (`mdutil -s` on the mount
+point), logging the admin repair command when the store is disabled or broken;
+`--doctor` reports the same as `macos-spotlight`. Windows and Linux are
+unchanged — their index announcements already feed the search the user types
+into.
+
## Audit verdict summary
**No hard breakers found.** No feature crashes on macOS or headless Linux;
diff --git a/jarvis/diagnostics/doctor.py b/jarvis/diagnostics/doctor.py
index f4199b45c3..aa90096f9c 100644
--- a/jarvis/diagnostics/doctor.py
+++ b/jarvis/diagnostics/doctor.py
@@ -297,6 +297,48 @@ def check_computer_use_prereqs(config: Any) -> list[DoctorFinding]:
return findings
+def check_macos_spotlight() -> list[DoctorFinding]:
+ """Whether Spotlight can actually find the installed macOS app.
+
+ LaunchServices registration does not put an app into Spotlight's search
+ (2026-09-16 report): the search field answers from the per-volume metadata
+ store, which can be broken machine-wide. Report the store state and whether
+ the bundle is really indexed, with the command that fixes each.
+ """
+ import sys as _sys
+
+ if _sys.platform != "darwin":
+ return []
+ from jarvis.setup.macos_app_bundle import macos_app_bundle_path
+ from jarvis.setup.macos_search_index import indexed_bundle_paths, spotlight_volume_issue
+
+ bundle = macos_app_bundle_path()
+ if not bundle.exists():
+ return []
+ issue = spotlight_volume_issue(bundle)
+ if issue is not None:
+ return [DoctorFinding(
+ "macos-spotlight", "warn",
+ f"Spotlight cannot index {bundle.name}: {issue.reason} on {issue.volume} "
+ "— no new file on this volume becomes searchable",
+ hint=f"{issue.repair_command} (admin password; reindexing takes a while)",
+ )]
+ indexed = indexed_bundle_paths()
+ if indexed is None:
+ return [DoctorFinding(
+ "macos-spotlight", "info", "Spotlight could not be queried for the app bundle",
+ )]
+ if not indexed:
+ return [DoctorFinding(
+ "macos-spotlight", "warn",
+ f"{bundle.name} is installed but not in the Spotlight index",
+ hint=f'mdimport "{bundle}"',
+ )]
+ return [DoctorFinding(
+ "macos-spotlight", "ok", f"Spotlight finds {bundle.name} ({indexed[0]})",
+ )]
+
+
def run_doctor(config: Any) -> list[DoctorFinding]:
"""Run every completeness check and return a flat, ordered finding list.
@@ -310,6 +352,7 @@ def run_doctor(config: Any) -> list[DoctorFinding]:
("subagent-backend", lambda: check_subagent_backend()),
("brain-provider", lambda: check_brain_provider(config)),
("computer-use", lambda: check_computer_use_prereqs(config)),
+ ("macos-spotlight", lambda: check_macos_spotlight()),
)
for category, fn in checks:
try:
diff --git a/jarvis/setup/macos_search_index.py b/jarvis/setup/macos_search_index.py
new file mode 100644
index 0000000000..ab2cf91346
--- /dev/null
+++ b/jarvis/setup/macos_search_index.py
@@ -0,0 +1,186 @@
+"""Spotlight indexing for the managed macOS app bundle.
+
+LaunchServices and Spotlight are two separate databases. ``lsregister`` makes
+``open -a`` and the Dock resolve the bundle, but the Spotlight search field
+answers from the metadata store that ``mds`` keeps per volume — an app can be
+fully registered with LaunchServices and still be missing from Spotlight.
+The bundle is built in a hidden ``.jarvis-native-*`` directory and renamed
+into ``~/Applications``, and that import is left to the FSEvents stream; this
+module asks for it explicitly with ``mdimport``.
+
+It also names the case no app can repair: a volume whose Spotlight store is
+disabled or broken (``mdutil -s`` answers "unknown indexing state") indexes
+nothing new at all, so the only honest result is the exact admin command that
+re-enables the store. Every probe is bounded, macOS-only and never raises.
+"""
+
+from __future__ import annotations
+
+import logging
+import subprocess
+import sys
+from dataclasses import dataclass
+from pathlib import Path
+
+from jarvis.core.branding import MACOS_BUNDLE_ID
+from jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS
+
+log = logging.getLogger(__name__)
+
+_MDIMPORT = "/usr/bin/mdimport"
+_MDUTIL = "/usr/bin/mdutil"
+_MDFIND = "/usr/bin/mdfind"
+_DF = "/bin/df"
+_TIMEOUT_S = 30
+
+
+@dataclass(frozen=True)
+class SpotlightVolumeIssue:
+ """A volume whose Spotlight store will not index a new app."""
+
+ volume: str
+ reason: str
+
+ @property
+ def repair_command(self) -> str:
+ return f"sudo mdutil -i on {self.volume} && sudo mdutil -E {self.volume}"
+
+
+def _run(argv: list[str]) -> subprocess.CompletedProcess[str] | None:
+ if sys.platform != "darwin" or not Path(argv[0]).is_file():
+ return None
+ try:
+ return subprocess.run( # noqa: S603 - fixed system path, no shell
+ argv,
+ timeout=_TIMEOUT_S,
+ stdin=subprocess.DEVNULL,
+ capture_output=True,
+ text=True,
+ encoding="utf-8",
+ errors="replace",
+ check=False,
+ creationflags=NO_WINDOW_CREATIONFLAGS,
+ )
+ except (OSError, subprocess.SubprocessError) as exc:
+ log.debug("%s did not run: %s", Path(argv[0]).name, exc)
+ return None
+
+
+def request_spotlight_import(bundle: Path) -> bool:
+ """Ask Spotlight to index ``bundle`` now instead of waiting for FSEvents.
+
+ Idempotent; ``True`` only when ``mdimport`` accepted the request.
+ """
+ result = _run([_MDIMPORT, str(bundle)])
+ if result is None:
+ return False
+ if result.returncode != 0:
+ log.debug(
+ "mdimport failed (rc=%s): %s", result.returncode, (result.stderr or "").strip()[:300]
+ )
+ return False
+ return True
+
+
+def parse_mdutil_status(output: str) -> SpotlightVolumeIssue | None:
+ """Read ``mdutil -s <path>`` output; ``None`` means indexing is enabled.
+
+ Output we do not recognise is treated as healthy — a warning must rest on
+ a state macOS actually reported, never on a guess.
+ """
+ volume = ""
+ for raw in output.splitlines():
+ line = raw.strip()
+ if not line:
+ continue
+ if not raw[:1].isspace() and line.endswith(":"):
+ volume = line[:-1]
+ continue
+ lowered = line.lower()
+ if "indexing enabled" in lowered:
+ return None
+ if "indexing disabled" in lowered:
+ return SpotlightVolumeIssue(volume or "/", "Spotlight indexing is turned off")
+ if "unknown indexing state" in lowered:
+ return SpotlightVolumeIssue(
+ volume or "/", "the Spotlight index is not working (unknown indexing state)"
+ )
+ return None
+
+
+def parse_df_mount_point(output: str) -> str | None:
+ """The "Mounted on" column of ``df -P <path>`` output."""
+ lines = [line for line in output.splitlines() if line.strip()]
+ if len(lines) < 2:
+ return None
+ # Filesystem, blocks, used, available, capacity, then the mount point,
+ # which may itself contain spaces.
+ fields = lines[1].split(None, 5)
+ return fields[5].strip() if len(fields) == 6 else None
+
+
+def _mount_point(path: Path) -> str | None:
+ result = _run([_DF, "-P", str(path)])
+ if result is None or result.returncode != 0:
+ return None
+ return parse_df_mount_point(result.stdout or "")
+
+
+def spotlight_volume_issue(path: Path) -> SpotlightVolumeIssue | None:
+ """Whether the volume holding ``path`` can index new items at all.
+
+ ``mdutil -s`` must be given the mount point: handed any other path it
+ echoes that path back, and the repair command would then name a folder.
+ """
+ volume = _mount_point(path)
+ if volume is None:
+ return None
+ result = _run([_MDUTIL, "-s", volume])
+ if result is None:
+ return None
+ return parse_mdutil_status(f"{result.stdout or ''}\n{result.stderr or ''}")
+
+
+def indexed_bundle_paths(bundle_id: str = MACOS_BUNDLE_ID) -> list[Path] | None:
+ """Every app Spotlight has indexed under ``bundle_id``; ``None`` if unknown."""
+ result = _run([_MDFIND, f"kMDItemCFBundleIdentifier == '{bundle_id}'"])
+ if result is None or result.returncode != 0:
+ return None
+ return [
+ Path(line.strip())
+ for line in (result.stdout or "").splitlines()
+ if line.strip().endswith(".app")
+ # Build and rollback directories are hidden; a hit there is not what
+ # the user's search shows.
+ and not any(part.startswith(".") for part in Path(line.strip()).parts)
+ ]
+
+
+def announce_to_spotlight(bundle: Path) -> bool:
+ """Import ``bundle`` into Spotlight and warn when its volume cannot index.
+
+ Returns ``True`` when the import request was accepted.
+ """
+ imported = request_spotlight_import(bundle)
+ issue = spotlight_volume_issue(bundle)
+ if issue is not None:
+ log.warning(
+ "%s is installed but Spotlight cannot find it: %s on %s. "
+ "macOS indexes nothing new there until an administrator runs: %s",
+ bundle.name,
+ issue.reason,
+ issue.volume,
+ issue.repair_command,
+ )
+ return imported
+
+
+__all__ = [
+ "SpotlightVolumeIssue",
+ "announce_to_spotlight",
+ "indexed_bundle_paths",
+ "parse_df_mount_point",
+ "parse_mdutil_status",
+ "request_spotlight_import",
+ "spotlight_volume_issue",
+]
diff --git a/tests/unit/diagnostics/test_doctor_diagnostics.py b/tests/unit/diagnostics/test_doctor_diagnostics.py
index 9e32e35457..588e0ba00d 100644
--- a/tests/unit/diagnostics/test_doctor_diagnostics.py
+++ b/tests/unit/diagnostics/test_doctor_diagnostics.py
@@ -205,3 +205,53 @@ def test_cu_prereqs_wayland_and_headless_are_info_not_failure(monkeypatch) -> No
assert len(findings) == 1
assert findings[0].status == "info"
assert "Wayland" in findings[0].message
+
+
+def _spotlight_env(monkeypatch, tmp_path, *, issue=None, indexed=None):
+ """macOS with an installed bundle and scripted Spotlight probes."""
+ import sys
+
+ from jarvis.setup import macos_app_bundle, macos_search_index
+
+ bundle = tmp_path / "Personal Jarvis.app"
+ bundle.mkdir()
+ monkeypatch.setattr(sys, "platform", "darwin")
+ monkeypatch.setattr(macos_app_bundle, "macos_app_bundle_path", lambda **_kw: bundle)
+ monkeypatch.setattr(macos_search_index, "spotlight_volume_issue", lambda _p: issue)
+ monkeypatch.setattr(macos_search_index, "indexed_bundle_paths", lambda *_a: indexed)
+ return bundle
+
+
+def test_spotlight_check_names_the_broken_store_and_its_repair(monkeypatch, tmp_path) -> None:
+ from jarvis.setup.macos_search_index import SpotlightVolumeIssue
+
+ _spotlight_env(
+ monkeypatch,
+ tmp_path,
+ issue=SpotlightVolumeIssue("/System/Volumes/Data", "the Spotlight index is not working"),
+ )
+ [finding] = doctor.check_macos_spotlight()
+ assert finding.status == "warn"
+ assert "/System/Volumes/Data" in finding.message
+ assert finding.hint is not None and "sudo mdutil -i on /System/Volumes/Data" in finding.hint
+
+
+def test_spotlight_check_flags_an_unindexed_bundle(monkeypatch, tmp_path) -> None:
+ bundle = _spotlight_env(monkeypatch, tmp_path, indexed=[])
+ [finding] = doctor.check_macos_spotlight()
+ assert finding.status == "warn"
+ assert finding.hint == f'mdimport "{bundle}"'
+
+
+def test_spotlight_check_ok_when_indexed(monkeypatch, tmp_path) -> None:
+ bundle = _spotlight_env(monkeypatch, tmp_path, indexed=[tmp_path / "Personal Jarvis.app"])
+ [finding] = doctor.check_macos_spotlight()
+ assert finding.status == "ok"
+ assert bundle.name in finding.message
+
+
+def test_spotlight_check_is_silent_off_macos(monkeypatch) -> None:
+ import sys
+
+ monkeypatch.setattr(sys, "platform", "linux")
+ assert doctor.check_macos_spotlight() == []
diff --git a/tests/unit/setup/test_macos_search_index.py b/tests/unit/setup/test_macos_search_index.py
new file mode 100644
index 0000000000..7e229ec4db
--- /dev/null
+++ b/tests/unit/setup/test_macos_search_index.py
@@ -0,0 +1,237 @@
+"""Installed in LaunchServices is not the same as findable in Spotlight.
+
+The 2026-09-16 report: ``~/Applications/Personal Jarvis.app`` was registered
+with LaunchServices (``lsregister -dump`` listed it) yet Spotlight returned
+nothing. Spotlight answers from its own per-volume metadata store; these tests
+pin that the bundle is imported there and that a volume whose store is broken
+is named with the admin repair command instead of passing silently.
+"""
+
+from __future__ import annotations
+
+import logging
+import subprocess
+import sys
+from pathlib import Path
+
+import pytest
+
+from jarvis.setup import macos_app_bundle, macos_search_index
+from jarvis.setup.macos_search_index import (
+ SpotlightVolumeIssue,
+ announce_to_spotlight,
+ indexed_bundle_paths,
+ parse_df_mount_point,
+ parse_mdutil_status,
+ request_spotlight_import,
+ spotlight_volume_issue,
+)
+
+# Verbatim ``mdutil -s /System/Volumes/Data`` output from the affected Mac.
+_BROKEN_DATA_VOLUME = "/System/Volumes/Data:\n\tError: unknown indexing state.\n"
+_HEALTHY = "/System/Volumes/Data:\n\tIndexing enabled. \n"
+_DISABLED = "/Volumes/External:\n\tIndexing disabled.\n"
+_DF_DATA = (
+ "Filesystem 512-blocks Used Available Capacity Mounted on\n"
+ "/dev/disk3s5 478724992 373871528 31615632 93% /System/Volumes/Data\n"
+)
+
+
+class _Result:
+ def __init__(self, returncode: int = 0, stdout: str = "", stderr: str = "") -> None:
+ self.returncode = returncode
+ self.stdout = stdout
+ self.stderr = stderr
+
+
+def fake_tools(monkeypatch: pytest.MonkeyPatch):
+ """Pretend to be macOS with the metadata tools present; record every argv."""
+ monkeypatch.setattr(sys, "platform", "darwin")
+ monkeypatch.setattr(Path, "is_file", lambda self: True)
+ calls: list[list[str]] = []
+ replies: dict[str, _Result] = {}
+
+ def _run(argv, **_kwargs):
+ calls.append(list(argv))
+ return replies.get(Path(argv[0]).name, _Result())
+
+ monkeypatch.setattr(subprocess, "run", _run)
+ return calls, replies
+
+
+def test_broken_store_is_recognized_with_its_volume() -> None:
+ issue = parse_mdutil_status(_BROKEN_DATA_VOLUME)
+
+ assert issue == SpotlightVolumeIssue(
+ "/System/Volumes/Data", "the Spotlight index is not working (unknown indexing state)"
+ )
+ assert issue.repair_command == (
+ "sudo mdutil -i on /System/Volumes/Data && sudo mdutil -E /System/Volumes/Data"
+ )
+
+
+def test_disabled_indexing_is_recognized() -> None:
+ issue = parse_mdutil_status(_DISABLED)
+
+ assert issue is not None
+ assert issue.volume == "/Volumes/External"
+ assert "turned off" in issue.reason
+
+
[email protected]("output", [_HEALTHY, "", "something macOS may print one day\n"])
+def test_only_a_reported_failure_counts_as_an_issue(output: str) -> None:
+ """A warning must rest on a state macOS reported, never on a guess."""
+ assert parse_mdutil_status(output) is None
+
+
+def test_every_probe_is_inert_off_macos(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(sys, "platform", "linux")
+ monkeypatch.setattr(
+ subprocess, "run", lambda *_a, **_k: pytest.fail("no metadata tool may run off macOS")
+ )
+ bundle = Path("/x/Personal Jarvis.app")
+
+ assert request_spotlight_import(bundle) is False
+ assert spotlight_volume_issue(bundle) is None
+ assert indexed_bundle_paths() is None
+
+
+def test_import_targets_the_bundle(fake_tools) -> None:
+ calls, _replies = fake_tools
+ bundle = Path("/Users/u/Applications/Personal Jarvis.app")
+
+ assert request_spotlight_import(bundle) is True
+ assert calls == [["/usr/bin/mdimport", str(bundle)]]
+
+
+def test_a_failed_import_reports_false(fake_tools) -> None:
+ _calls, replies = fake_tools
+ replies["mdimport"] = _Result(returncode=1, stderr="boom")
+
+ assert request_spotlight_import(Path("/a/Personal Jarvis.app")) is False
+
+
+def test_a_missing_tool_never_raises(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(sys, "platform", "darwin")
+ monkeypatch.setattr(Path, "is_file", lambda self: True)
+
+ def _raise(*_a, **_k):
+ raise OSError("no such file")
+
+ monkeypatch.setattr(subprocess, "run", _raise)
+
+ assert request_spotlight_import(Path("/a/Personal Jarvis.app")) is False
+ assert spotlight_volume_issue(Path("/a")) is None
+
+
+def test_announce_warns_with_the_repair_command_on_a_broken_store(
+ fake_tools, caplog: pytest.LogCaptureFixture
+) -> None:
+ calls, replies = fake_tools
+ replies["df"] = _Result(stdout=_DF_DATA)
+ replies["mdutil"] = _Result(stdout=_BROKEN_DATA_VOLUME)
+ bundle = Path("/Users/u/Applications/Personal Jarvis.app")
+
+ with caplog.at_level(logging.WARNING, logger=macos_search_index.__name__):
+ assert announce_to_spotlight(bundle) is True
+
+ assert [Path(argv[0]).name for argv in calls] == ["mdimport", "df", "mdutil"]
+ assert "sudo mdutil -i on /System/Volumes/Data &&" in caplog.text
+
+
+def test_mdutil_is_asked_about_the_mount_point_not_the_bundle(fake_tools) -> None:
+ """Handed the bundle path, ``mdutil -s`` echoes it back as the "volume"
+ (seen live) and the repair command would name the app folder."""
+ calls, replies = fake_tools
+ replies["df"] = _Result(stdout=_DF_DATA)
+ replies["mdutil"] = _Result(stdout=_BROKEN_DATA_VOLUME)
+
+ issue = spotlight_volume_issue(Path("/Users/u/Applications/Personal Jarvis.app"))
+
+ assert calls[-1] == ["/usr/bin/mdutil", "-s", "/System/Volumes/Data"]
+ assert issue is not None and issue.volume == "/System/Volumes/Data"
+
+
+def test_an_unknown_mount_point_reports_no_issue(fake_tools) -> None:
+ calls, replies = fake_tools
+ replies["df"] = _Result(returncode=1)
+
+ assert spotlight_volume_issue(Path("/nowhere")) is None
+ assert [Path(argv[0]).name for argv in calls] == ["df"]
+
+
+ ("output", "expected"),
+ [
+ (_DF_DATA, "/System/Volumes/Data"),
+ (
+ "Filesystem 512-blocks Used Available Capacity Mounted on\n"
+ "/dev/disk5s1 100 50 50 50% /Volumes/My Disk\n",
+ "/Volumes/My Disk",
+ ),
+ ("", None),
+ ("Filesystem 512-blocks Used Available Capacity Mounted on\n", None),
+ ],
+)
+def test_df_mount_point_parsing(output: str, expected: str | None) -> None:
+ assert parse_df_mount_point(output) == expected
+
+
+def test_announce_is_quiet_on_a_healthy_volume(
+ fake_tools, caplog: pytest.LogCaptureFixture
+) -> None:
+ _calls, replies = fake_tools
+ replies["df"] = _Result(stdout=_DF_DATA)
+ replies["mdutil"] = _Result(stdout=_HEALTHY)
+
+ with caplog.at_level(logging.WARNING, logger=macos_search_index.__name__):
+ announce_to_spotlight(Path("/Users/u/Applications/Personal Jarvis.app"))
+
+ assert caplog.text == ""
+
+
+def test_indexed_paths_skip_hidden_build_directories(fake_tools) -> None:
+ """A stale ``.jarvis-native-*/previous.app`` hit is not what search shows."""
+ calls, replies = fake_tools
+ replies["mdfind"] = _Result(
+ stdout=(
+ "/Users/u/Applications/.jarvis-native-abc/previous.app\n"
+ "/Users/u/Applications/Personal Jarvis.app\n"
+ )
+ )
+
+ assert indexed_bundle_paths("com.example.app") == [
+ Path("/Users/u/Applications/Personal Jarvis.app")
+ ]
+ assert calls[0][1] == "kMDItemCFBundleIdentifier == 'com.example.app'"
+
+
+def test_launch_services_registration_also_imports_into_spotlight(
+ tmp_path: Path, fake_tools
+) -> None:
+ """Every install/repair path goes through this one call; lsregister alone
+ left the app registered but unsearchable."""
+ calls, replies = fake_tools
+ replies["mdutil"] = _Result(stdout=_HEALTHY)
+ bundle = tmp_path / "Personal Jarvis.app"
+
+ assert macos_app_bundle.register_with_launch_services(bundle) is True
+
+ tools = [Path(argv[0]).name for argv in calls]
+ assert "lsregister" in tools
+ assert ["/usr/bin/mdimport", str(bundle)] in calls
+
+
+def test_a_spotlight_crash_never_blocks_launch_services(
+ tmp_path: Path, fake_tools, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ calls, _replies = fake_tools
+
+ def _boom(_bundle: Path) -> bool:
+ raise RuntimeError("mds unavailable")
+
+ monkeypatch.setattr(macos_search_index, "announce_to_spotlight", _boom)
+
+ assert macos_app_bundle.register_with_launch_services(tmp_path / "P.app") is True
+ assert [Path(argv[0]).name for argv in calls] == ["lsregister"]
diff --git a/tests/unit/ui/test_desktop_discoverability.py b/tests/unit/ui/test_desktop_discoverability.py
index 3160284f0c..05a3a811e3 100644
--- a/tests/unit/ui/test_desktop_discoverability.py
+++ b/tests/unit/ui/test_desktop_discoverability.py
@@ -15,7 +15,7 @@ from pathlib import Path
import pytest
-from jarvis.setup import macos_app_bundle
+from jarvis.setup import macos_app_bundle, macos_search_index
from jarvis.ui import icon_utils
@@ -137,6 +137,7 @@ def test_launch_services_registration_forces_the_bundle(
"""``-f`` re-registers a bundle LaunchServices may already have stale."""
monkeypatch.setattr(sys, "platform", "darwin")
monkeypatch.setattr(Path, "is_file", lambda self: True)
+ monkeypatch.setattr(macos_search_index, "announce_to_spotlight", lambda _bundle: True)
calls: list[list[str]] = []
class _Result: