Skip to content

Personal AI, On Personal Devices

Python

fix(cli): report Rust extension ready when importable without installer marker (#1015)

K Karthikc71a600ad692
diff --git a/src/openjarvis/cli/_bg_state.py b/src/openjarvis/cli/_bg_state.py
index 13392776..a7dfdc49 100644
--- a/src/openjarvis/cli/_bg_state.py
+++ b/src/openjarvis/cli/_bg_state.py
@@ -49,7 +49,14 @@ def get_status(home: Optional[Path] = None) -> BgStatus:
status = BgStatus()
# Rust extension: ready supersedes failed; failed supersedes pending.
- if (state_dir / "extension-built").exists():
+ # The ``extension-built`` marker is only written by the installer scripts,
+ # so editable/dev installs (``uv sync`` + ``maturin develop``) never get
+ # one. Fall back to the runtime import check so those installs don't show
+ # "building" forever (and a stale ``extension-failed`` doesn't lie once the
+ # extension has actually been built).
+ from openjarvis import _rust_bridge
+
+ if (state_dir / "extension-built").exists() or _rust_bridge.RUST_AVAILABLE:
status.rust_extension = "ready"
elif (state_dir / "extension-failed").exists():
contents = _safe_read(state_dir / "extension-failed")
diff --git a/tests/install/conftest.py b/tests/install/conftest.py
index 82994c56..d213d9f0 100644
--- a/tests/install/conftest.py
+++ b/tests/install/conftest.py
@@ -27,4 +27,8 @@ def tmp_openjarvis_home(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path
# Patch doctor_cmd's module-level bindings.
monkeypatch.setattr("openjarvis.cli.doctor_cmd.DEFAULT_CONFIG_PATH", config_path)
monkeypatch.setenv("HOME", str(tmp_path))
+ # These tests drive state purely via marker files; pin the runtime Rust
+ # import check off so a built extension in the dev venv can't flip
+ # "pending"/"failed" to "ready" behind their backs.
+ monkeypatch.setattr("openjarvis._rust_bridge.RUST_AVAILABLE", False)
return home
diff --git a/tests/install/test_bg_state.py b/tests/install/test_bg_state.py
index 8b808c1b..fb1b7ac4 100644
--- a/tests/install/test_bg_state.py
+++ b/tests/install/test_bg_state.py
@@ -4,9 +4,32 @@ from __future__ import annotations
from pathlib import Path
+import pytest
+
+from openjarvis import _rust_bridge
from openjarvis.cli import _bg_state
+def test_get_status_rust_importable_without_marker(
+ tmp_openjarvis_home: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """Editable installs have no installer marker but the ext imports fine."""
+ monkeypatch.setattr(_rust_bridge, "RUST_AVAILABLE", True)
+ s = _bg_state.get_status()
+ assert s.rust_extension == "ready"
+
+
+def test_get_status_rust_importable_supersedes_failed_marker(
+ tmp_openjarvis_home: Path, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ """A stale extension-failed marker must not mask a working extension."""
+ monkeypatch.setattr(_rust_bridge, "RUST_AVAILABLE", True)
+ (tmp_openjarvis_home / ".state" / "extension-failed").write_text("old error")
+ s = _bg_state.get_status()
+ assert s.rust_extension == "ready"
+ assert s.rust_error == ""
+
+
def test_get_status_empty(tmp_openjarvis_home: Path) -> None:
"""No state files = everything 'pending'."""
s = _bg_state.get_status()