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.

feat(marketplace): an install from anywhere reaches the open window

Harald1d0668e2d60d
diff --git a/jarvis/core/events.py b/jarvis/core/events.py
index f9f50307bd..bd80c8306c 100644
--- a/jarvis/core/events.py
+++ b/jarvis/core/events.py
@@ -2023,3 +2023,30 @@ class OrbResetRequested(Event):
trigger from the Tk-thread mutation — bus stays sync-friendly.
"""
source: str = "" # "voice" | "tray" | "test"
+
+
+@dataclass(frozen=True, slots=True)
+class MarketplaceItemInstalled(Event):
+ """One marketplace entry just landed on this machine.
+
+ An install can now start anywhere: the desktop's own store card, a
+ terminal running ``jarvis marketplace install``, a spoken sentence going
+ through the router's ``marketplace-install`` tool, or the storefront's
+ button talking to the local app. Only the first of those has a view that
+ knows to refresh itself — the other three used to leave an open window
+ showing a library the file was already missing from, until the user
+ restarted the app or happened to navigate away and back.
+
+ So the install says what it did, once, on the bus. The chat socket's
+ wildcard forward carries every bus event to the frontend, so the open
+ window hears it no matter which surface did the installing and reloads
+ exactly the lane that changed.
+
+ ``ready`` mirrors the install reply's own field: True when the thing is
+ usable right now (a wallpaper, a skill that validated), False when it
+ still needs the user (a plugin waiting to be connected).
+ """
+ kind: str = "" # "skill" | "plugin" | "wallpaper"
+ item_id: str = ""
+ title: str = ""
+ ready: bool = False
diff --git a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
index 6e9d9b262e..86e3d2006f 100644
--- a/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useWebSocket.ts
@@ -542,6 +542,25 @@ export function useWebSocket(): void {
void queryClient.invalidateQueries({ queryKey: ["docs"] });
}
+ if (env.event_name === "MarketplaceItemInstalled") {
+ // The install may have come from anywhere: a terminal running
+ // `jarvis marketplace install`, a spoken sentence, the storefront's
+ // button, or another window of this app. Only the window that
+ // pressed a button knows to refresh itself — every other one used to
+ // keep showing a library the file was already in until it was
+ // restarted. Reload the lane that changed, wherever it came from.
+ const p = env.payload as { kind?: string };
+ void queryClient.invalidateQueries({ queryKey: ["marketplace-community"] });
+ if (p.kind === "wallpaper") {
+ // Prefix match: catalog, uploads and library all hang off this key.
+ void queryClient.invalidateQueries({ queryKey: ["wallpapers"] });
+ } else if (p.kind === "skill") {
+ void queryClient.invalidateQueries({ queryKey: ["skills"] });
+ } else if (p.kind === "plugin") {
+ void queryClient.invalidateQueries({ queryKey: ["marketplace-plugins"] });
+ }
+ }
+
if (env.event_name === "ActionApprovalRequired") {
const p = env.payload as {
mission_id?: unknown;
diff --git a/jarvis/ui/web/marketplace_routes.py b/jarvis/ui/web/marketplace_routes.py
index 75e9679b9a..badd4956d3 100644
--- a/jarvis/ui/web/marketplace_routes.py
+++ b/jarvis/ui/web/marketplace_routes.py
@@ -41,6 +41,7 @@ from fastapi import (
from fastapi.responses import HTMLResponse
from pydantic import BaseModel, Field
+from jarvis.core.events import MarketplaceItemInstalled
from jarvis.core.process_utils import resolve_executable
from jarvis.core.uploads import UploadRejected, stage_upload
from jarvis.marketplace.auth import (
@@ -1136,11 +1137,22 @@ async def _install_community_plugin(plugin_id: str) -> dict[str, Any]:
@router.post("/community/plugins/{plugin_id}/install")
-async def community_install(plugin_id: str) -> dict[str, Any]:
+async def community_install(plugin_id: str, request: Request) -> dict[str, Any]:
"""One-click install: convert the manifest, persist the catalog entry and
usage card, refresh the live registry. The plugin then behaves exactly
like a seed plugin (connect flows, relevance gate, worker bridge)."""
item = await _install_community_plugin(plugin_id)
+ # The window that pressed the button refreshes itself, but it is not
+ # necessarily the only one open.
+ await _announce_install(
+ request,
+ {
+ "kind": "plugin",
+ "id": item.get("id", plugin_id),
+ "title": item.get("display_name") or plugin_id,
+ "ready": False,
+ },
+ )
return {"ok": True, "plugin": item}
@@ -1313,6 +1325,39 @@ async def _install_community_wallpaper(entry: Any) -> dict[str, Any]:
}
+async def _announce_install(request: Request, result: dict[str, Any]) -> None:
+ """Say on the bus that an entry landed, so open windows can catch up.
+
+ An install can start from four places and only one of them — the store
+ card in the desktop app — has a view that refreshes itself afterwards.
+ A terminal, a spoken sentence and the storefront button all left the open
+ window showing a library the file was already in. The bus reaches every
+ surface at once, so the announcement happens here rather than in each
+ caller.
+
+ Never blocks the install: the entry is already on disk by the time this
+ runs, and a window that missed the news is one navigation away from the
+ truth. Same async/sync publish convention as ``mcp_routes``.
+ """
+ bus = getattr(request.app.state, "bus", None)
+ if bus is None:
+ return # headless / early boot: nothing is listening anyway
+ event = MarketplaceItemInstalled(
+ source_layer="ui.web.marketplace",
+ kind=str(result.get("kind") or ""),
+ item_id=str(result.get("id") or ""),
+ title=str(result.get("title") or ""),
+ ready=bool(result.get("ready")),
+ )
+ try:
+ if asyncio.iscoroutinefunction(bus.publish):
+ await bus.publish(event)
+ else:
+ bus.publish(event)
+ except Exception as exc: # noqa: BLE001 - a missed refresh is not a failed install
+ log.debug("MarketplaceItemInstalled publish failed: %s", exc)
+
+
def _install_by_name_404(item_id: str, index: Any) -> HTTPException:
"""404 that names the closest existing entry instead of a dead end."""
import difflib
@@ -1358,29 +1403,34 @@ async def community_install_by_name(item_id: str, request: Request) -> dict[str,
raise _install_by_name_404(item_id, index)
if skill_entry is not None:
- return await _install_community_skill(skill_entry, request)
-
- if wallpaper_entry is not None:
- return await _install_community_wallpaper(wallpaper_entry)
+ result = await _install_community_skill(skill_entry, request)
+ elif wallpaper_entry is not None:
+ result = await _install_community_wallpaper(wallpaper_entry)
+ else:
+ item = await _install_community_plugin(item_id)
+ result = {
+ "ok": True,
+ "kind": "plugin",
+ "id": item.get("id", item_id),
+ "title": item.get("display_name") or item_id,
+ "publisher": item.get("publisher"),
+ "version": item.get("version"),
+ "source_url": item.get("source_url"),
+ "location": "",
+ "state": "not_connected",
+ # A plugin talks to somebody else's service: installed is not the
+ # same as usable, and saying otherwise is the exact confusion this
+ # route exists to kill.
+ "ready": False,
+ "problem": None,
+ "next_action": "connect",
+ "plugin": item,
+ }
- item = await _install_community_plugin(item_id)
- return {
- "ok": True,
- "kind": "plugin",
- "id": item.get("id", item_id),
- "title": item.get("display_name") or item_id,
- "publisher": item.get("publisher"),
- "version": item.get("version"),
- "source_url": item.get("source_url"),
- "location": "",
- "state": "not_connected",
- # A plugin talks to somebody else's service: installed is not the same
- # as usable, and saying otherwise is the exact confusion this route exists to kill.
- "ready": False,
- "problem": None,
- "next_action": "connect",
- "plugin": item,
- }
+ # One announcement for all three kinds, from the one place that knows the
+ # install finished — a per-branch publish would be three chances to forget.
+ await _announce_install(request, result)
+ return result
@router.delete("/community/plugins/{plugin_id}")
@@ -1429,6 +1479,8 @@ async def community_uninstall(plugin_id: str) -> dict[str, Any]:
log.info("plugin %s revocation skipped: %s", plugin_id, exc)
revocation = "failed"
return {"ok": True, "removed": removed, "revocation": revocation}
+
+
# ----------------------------------------------------------------------
# Upload — a plugin manifest dropped onto the UI
# ----------------------------------------------------------------------
diff --git a/tests/unit/marketplace/test_community_install_kinds.py b/tests/unit/marketplace/test_community_install_kinds.py
index e4897169d6..b264ea0993 100644
--- a/tests/unit/marketplace/test_community_install_kinds.py
+++ b/tests/unit/marketplace/test_community_install_kinds.py
@@ -131,7 +131,7 @@ def offline_downloads(monkeypatch: pytest.MonkeyPatch, env: Path) -> None:
monkeypatch.setattr(marketplace_routes, "_download_image", fake_image)
-def _client(env: Path) -> httpx.AsyncClient:
+def _client(env: Path, bus: Any = None) -> httpx.AsyncClient:
from jarvis.skills.registry import SkillRegistry
app = FastAPI()
@@ -142,9 +142,23 @@ def _client(env: Path) -> httpx.AsyncClient:
registry = SkillRegistry(root=skills_root)
registry.reload_sync()
app.state.skill_registry = registry
+ # Absent by default, exactly like a headless boot: the install must work
+ # with nothing listening.
+ if bus is not None:
+ app.state.bus = bus
return httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://test")
+class _RecordingBus:
+ """Captures what the install announced, in order."""
+
+ def __init__(self) -> None:
+ self.events: list[Any] = []
+
+ async def publish(self, event: Any) -> None:
+ self.events.append(event)
+
+
# ----------------------------------------------------------------------
# Wallpapers
# ----------------------------------------------------------------------
@@ -361,3 +375,63 @@ async def test_download_returns_the_bytes_it_was_served() -> None:
"https://raw.example/ok.png", 10_000_000, transport=httpx.MockTransport(handler)
)
assert got == payload
+
+
+# ----------------------------------------------------------------------
+# Telling the open window about it
+# ----------------------------------------------------------------------
+
+
+async def test_a_wallpaper_install_announces_itself(
+ env: Path, offline_downloads: None
+) -> None:
+ """An install from a terminal has to reach the window that is already open.
+
+ Nothing about `jarvis marketplace install` touches the desktop UI, so
+ without this announcement the picker kept showing the library the picture
+ was already in until the app was restarted.
+ """
+ from jarvis.core.events import MarketplaceItemInstalled
+
+ bus = _RecordingBus()
+ async with _client(env, bus) as client:
+ resp = await client.post("/api/marketplace/community/install/moonlit-wave")
+ assert resp.status_code == 200
+
+ announced = [e for e in bus.events if isinstance(e, MarketplaceItemInstalled)]
+ assert len(announced) == 1
+ assert announced[0].kind == "wallpaper"
+ assert announced[0].item_id == "moonlit-wave"
+ # The picture is usable the moment it lands — the frontend uses this to
+ # decide whether it can say "done" or has to point at a next step.
+ assert announced[0].ready is True
+
+
+async def test_a_skill_install_announces_its_own_kind(
+ env: Path, offline_downloads: None
+) -> None:
+ """One event, three kinds: the receiver reloads only the lane that moved."""
+ from jarvis.core.events import MarketplaceItemInstalled
+
+ bus = _RecordingBus()
+ async with _client(env, bus) as client:
+ resp = await client.post("/api/marketplace/community/install/three-point-check")
+ assert resp.status_code == 200
+
+ announced = [e for e in bus.events if isinstance(e, MarketplaceItemInstalled)]
+ assert len(announced) == 1
+ assert announced[0].kind == "skill"
+ assert announced[0].item_id == "three-point-check"
+
+
+async def test_an_install_still_works_with_nobody_listening(
+ env: Path, offline_downloads: None
+) -> None:
+ """Headless, or early boot: no bus, and the install must not care."""
+ async with _client(env) as client:
+ resp = await client.post("/api/marketplace/community/install/moonlit-wave")
+ assert resp.status_code == 200
+ assert resp.json()["ready"] is True