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(artifacts): keep finished artifacts and hide chat media from the Artifacts list
rubenluetke10-beep9e56aff0f2dd
diff --git a/jarvis/missions/cleanup.py b/jarvis/missions/cleanup.pyindex ddaa02060c..69f9df7c6e 100644--- a/jarvis/missions/cleanup.py+++ b/jarvis/missions/cleanup.py@@ -28,6 +28,7 @@ from pathlib import Pathfrom typing import Finalfrom jarvis.core.process_utils import NO_WINDOW_CREATIONFLAGS+from jarvis.missions.standalone_run import MARKER_NAMElogger = logging.getLogger(__name__)@@ -96,6 +97,8 @@ def _sweep_blocking(age_seconds = now - mtimeif age_seconds < cutoff_seconds:continue # too young — keep+ if _holds_deliverables(entry):+ continue # the user's artifacts — never an age-based deletion# Older than cutoff -> remove.if not _remove_entry(entry, repo_root=repo_root):@@ -111,6 +114,38 @@ def _sweep_blocking(return stats+def _holds_deliverables(entry: Path) -> bool:+ """True when ``entry`` is a run whose results the user can still open.++ The sweep exists to reclaim worker scaffolding (worktrees, CLI homes), but+ finished runs live in the same root: every page, picture and report in the+ Artifacts section is a file under ``tasks/<id>/artifacts/files``. Deleting+ those after N days silently emptied the section (2026-09-29). A standalone+ run (its ``.standalone-run.json`` marker) is kept too: chat media is served+ from there and a chat transcript would otherwise lose its pictures.++ A worktree-slug directory never has either, so it is still reclaimed.+ """+ if (entry / MARKER_NAME).is_file():+ return True+ tasks_dir = entry / "tasks"+ try:+ task_dirs = [child for child in tasks_dir.iterdir() if child.is_dir()]+ except OSError:+ return False # no tasks directory — nothing the user could open+ for task_dir in task_dirs:+ files_dir = task_dir / "artifacts" / "files"+ try:+ if any(path.is_file() for path in files_dir.rglob("*")):+ return True+ except OSError as exc:+ # Unreadable deliverables are still deliverables: keeping a+ # directory is recoverable, deleting it is not.+ logger.warning("startup_sweep: cannot read %s: %s", files_dir, exc)+ return True+ return False++def _on_rmtree_error(func, path, exc_info) -> None: # type: ignore[no-untyped-def]"""``shutil.rmtree`` onerror hook: clear the read-only bit and retry.diff --git a/jarvis/missions/standalone_run.py b/jarvis/missions/standalone_run.pyindex 35cfa34c8d..6d9dc2afca 100644--- a/jarvis/missions/standalone_run.py+++ b/jarvis/missions/standalone_run.py@@ -84,6 +84,19 @@ def read_marker(run_dir: Path) -> dict[str, Any] | None:return data if isinstance(data, dict) else None+#: Marker kinds that only park a chat's media so the transcript can serve it.+#: They are storage, not results: a picture pasted into a chat or a clip a tool+#: returned is no artifact, and listing each one as a run flooded the Artifacts+#: section with untitled "Chat media" rows (2026-09-29). Their files stay+#: reachable by URL; the run list leaves them out.+CHAT_ATTACHMENT_KINDS = frozenset({"chat_media", "chat_image"})+++def is_chat_attachment(marker: dict[str, Any]) -> bool:+ """True when the marker belongs to a chat's parked media, not a run."""+ return marker.get("kind") in CHAT_ATTACHMENT_KINDS++def marker_label(marker: dict[str, Any]) -> str | None:"""The tile label for a standalone run: what was asked, else what came out."""for key in ("utterance", "title"):@@ -93,4 +106,11 @@ def marker_label(marker: dict[str, Any]) -> str | None:return None-__all__ = ["MARKER_NAME", "marker_label", "read_marker", "write_marker"]+__all__ = [+ "CHAT_ATTACHMENT_KINDS",+ "MARKER_NAME",+ "is_chat_attachment",+ "marker_label",+ "read_marker",+ "write_marker",+]diff --git a/jarvis/ui/web/outputs_routes.py b/jarvis/ui/web/outputs_routes.pyindex 92db9c3dc9..dc2b83ed4d 100644--- a/jarvis/ui/web/outputs_routes.py+++ b/jarvis/ui/web/outputs_routes.py@@ -32,6 +32,7 @@ from starlette.responses import FileResponse, HTMLResponsefrom jarvis.missions.kontrollierer.deliverable_paths import (is_nondeliverable_scratch,)+from jarvis.missions.standalone_run import is_chat_attachmentfrom jarvis.missions.standalone_run import marker_label as standalone_marker_labelfrom jarvis.missions.standalone_run import read_marker as read_standalone_markerfrom jarvis.missions.state_machine import MissionState, is_terminal@@ -507,6 +508,13 @@ async def list_outputs(request: Request) -> OutputsResponse:exc = read_errors[0]raise HTTPException(status_code=500, detail=f"Outputs root not readable: {exc}") from excentries = sorted(entries_by_name.values(), key=lambda path: path.name, reverse=True)+ # A chat's parked media is served by URL, never listed as a run — see+ # CHAT_ATTACHMENT_KINDS for the "Chat media" flood this prevents.+ entries = [+ entry+ for entry in entries+ if not is_chat_attachment(read_standalone_marker(entry) or {})+ ]# Artifact archives can contain entire generated projects. Walking them is# blocking filesystem work and must never run on the ASGI event-loop thread:diff --git a/tests/missions/test_cleanup.py b/tests/missions/test_cleanup.pyindex ff784363c7..c52c44184b 100644--- a/tests/missions/test_cleanup.py+++ b/tests/missions/test_cleanup.py@@ -16,6 +16,7 @@ from jarvis.missions.cleanup import (daily_cleanup_task,startup_sweep,)+from jarvis.missions.standalone_run import write_marker# --- startup_sweep ---@@ -93,6 +94,54 @@ async def test_sweep_mixed_keeps_fresh_removes_old(tmp_path: Path) -> None:assert not old.exists()+def _age(path: Path, days: int = 30) -> None:+ past = time.time() - (days * 86400)+ os.utime(path, (past, past))+++async def test_sweep_keeps_old_runs_that_hold_deliverables(tmp_path: Path) -> None:+ """A finished run's pages and pictures are the Artifacts section itself.++ The age sweep deleted them after 14 days and the section emptied out+ (2026-09-29). Scaffolding without deliverables is still reclaimed.+ """+ root = tmp_path / "outputs"+ root.mkdir()+ artifact = root / "mission_artifact"+ files = artifact / "tasks" / "task-1" / "artifacts" / "files" / "site"+ files.mkdir(parents=True)+ (files / "index.html").write_text("<title>Dashboard</title>")+ empty_run = root / "mission_failed"+ (empty_run / "tasks" / "task-1" / "artifacts" / "files").mkdir(parents=True)+ worktree = root / "20260727T095351__scaffolding__259d2674"+ (worktree / "tasks" / "task-1" / "workspace").mkdir(parents=True)+ for entry in (artifact, empty_run, worktree):+ _age(entry)++ stats = await startup_sweep(isolation_root=root, cleanup_days=14)++ assert stats["removed"] == 2+ assert artifact.exists()+ assert not empty_run.exists()+ assert not worktree.exists()+++async def test_sweep_keeps_old_standalone_runs(tmp_path: Path) -> None:+ """Chat media lives in a standalone run; deleting it breaks the transcript."""+ root = tmp_path / "outputs"+ root.mkdir()+ media = root / "chat-media-abc"+ write_marker(media, kind="chat_media", title="Chat media")+ _age(media)++ stats = await startup_sweep(isolation_root=root, cleanup_days=14)++ assert stats["removed"] == 0+ assert media.exists()++@pytest.mark.asyncioasync def test_sweep_cleanup_days_zero_removes_anything(tmp_path: Path) -> None:"""With cleanup_days=0, all found dirs should be removed — thediff --git a/tests/unit/ui/web/test_outputs_routes.py b/tests/unit/ui/web/test_outputs_routes.pyindex b7526d4d5e..2ed9ab6610 100644--- a/tests/unit/ui/web/test_outputs_routes.py+++ b/tests/unit/ui/web/test_outputs_routes.py@@ -801,6 +801,35 @@ async def test_list_outputs_still_hides_an_unmarked_neighbour(assert [s["slug"] for s in r.json()["sessions"]] == [marked.name][email protected]("kind", ["chat_media", "chat_image"])+async def test_list_outputs_leaves_out_chat_attachments(+ app: FastAPI, tmp_path: Path, kind: str+) -> None:+ """A chat's parked media is no artifact.++ Every picture or clip shown in a chat is archived as its own directory so+ the transcript can serve it; listing those flooded the Artifacts section+ with untitled "Chat media" rows (2026-09-29). The files stay reachable.+ """+ artifact = _make_worktree_dir(tmp_path, utterance="drawn", short="feedface")+ write_standalone_marker(artifact, kind="visualization", title="Drawn")+ attachment = tmp_path / "chat-media-0123456789abcdef01234567"+ files = attachment / "tasks" / "chat" / "artifacts" / "files"+ files.mkdir(parents=True)+ (files / "media.png").write_bytes(b"\x89PNG")+ write_standalone_marker(attachment, kind=kind, title="Chat media")++ with TestClient(app) as client:+ listed = client.get("/api/outputs")+ served = client.get(+ f"/api/outputs/{attachment.name}/files/tasks/chat/artifacts/files/media.png/download"+ )++ assert [s["slug"] for s in listed.json()["sessions"]] == [artifact.name]+ assert served.status_code == 200++@pytest.mark.asyncioasync def test_list_outputs_tolerates_a_corrupt_marker(app: FastAPI, tmp_path: Path) -> None:"""A half-written marker degrades that ONE entry, never the whole listing."""