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(ide): keep a damaged workspace snapshot aside instead of overwriting it

rubenluetke10-beep1ccc96e9c409
diff --git a/jarvis/agentic_ide/resume_store.py b/jarvis/agentic_ide/resume_store.py
index f69c12edca..959c82a280 100644
--- a/jarvis/agentic_ide/resume_store.py
+++ b/jarvis/agentic_ide/resume_store.py
@@ -608,12 +608,34 @@ def load() -> Snapshot | None:
data = json.loads(path.read_text(encoding="utf-8"))
except FileNotFoundError:
return None
- except (OSError, ValueError) as exc:
+ except ValueError as exc:
+ # Moved aside rather than ignored: the next save merges with what
+ # ``load`` returns, so a file read as "nothing" would be overwritten
+ # and every remembered workspace in it lost for good (RUB-102).
+ kept = _quarantine(path)
+ logger.warning(
+ "Agentic IDE: resume snapshot is damaged ({}) — kept as {} and starting without it",
+ exc,
+ kept or "nothing (could not be moved)",
+ )
+ return None
+ except OSError as exc:
logger.warning("Agentic IDE: unreadable resume snapshot, ignoring it: {}", exc)
return None
return Snapshot.from_dict(data)
+def _quarantine(path: Path) -> Path | None:
+ """Move a damaged store out of the way, next to it, with a timestamp."""
+ target = path.with_name(f"{path.stem}.damaged-{int(time.time())}{path.suffix}")
+ try:
+ os.replace(path, target)
+ except OSError as exc:
+ logger.warning("Agentic IDE: damaged resume snapshot could not be moved: {}", exc)
+ return None
+ return target
+
+
def _all_closed_path() -> Path:
"""Sibling of the store: when the last open workspace was closed by hand."""
return _store_path().with_name(_store_path().stem + ".all_closed")
diff --git a/tests/unit/agentic_ide/test_reboot_resume.py b/tests/unit/agentic_ide/test_reboot_resume.py
index aa0df7a2db..c272cfa6c3 100644
--- a/tests/unit/agentic_ide/test_reboot_resume.py
+++ b/tests/unit/agentic_ide/test_reboot_resume.py
@@ -188,3 +188,15 @@ def test_snapshot_records_whether_an_agent_was_running() -> None:
# Older snapshots carry no field: every pane counts as running.
parsed = resume_store.SnapshotTerminal.from_dict({"name": "T1", "agent": "claude"})
assert parsed is not None and parsed.running is True
+
+
+def test_a_damaged_snapshot_is_kept_aside_instead_of_overwritten() -> None:
+ path = resume_store._store_path()
+ path.parent.mkdir(parents=True, exist_ok=True)
+ path.write_text('{"workspaces": [', encoding="utf-8")
+
+ assert resume_store.load() is None
+
+ assert not path.exists()
+ kept = list(path.parent.glob(f"{path.stem}.damaged-*{path.suffix}"))
+ assert len(kept) == 1 and kept[0].read_text(encoding="utf-8") == '{"workspaces": ['