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(agentic-ide): version polling and system-trash deletes for the code editor

rubenluetke10-beepb0f345d3eda8
diff --git a/jarvis/agentic_ide/file_editing.py b/jarvis/agentic_ide/file_editing.py
index 856d97e787..ace953671e 100644
--- a/jarvis/agentic_ide/file_editing.py
+++ b/jarvis/agentic_ide/file_editing.py
@@ -48,6 +48,7 @@ __all__ = [
"TrashUnavailable",
"create_entry",
"delete_entry",
+ "file_version",
"list_files",
"read_text_file",
"rename_entry",
@@ -167,6 +168,20 @@ def read_text_file(root: str | os.PathLike[str], path: str) -> TextFile:
return TextFile(relative, text, version, size, encoding, _detect_eol(text), False, False)
+def file_version(root: str | os.PathLike[str], path: str) -> str | None:
+ """The current version of one file, or None when it no longer exists.
+
+ What the editor polls to notice an agent's edit to an open file; a file
+ too large to edit reports an empty version, as :func:`read_text_file` does.
+ """
+ _, target = _resolve(root, path)
+ if not target.is_file():
+ return None
+ if target.stat().st_size > MAX_EDITABLE_BYTES:
+ return ""
+ return _version_of(target.read_bytes())
+
+
def _atomic_write(target: Path, data: bytes) -> None:
"""Replace ``target`` with ``data`` in one step, keeping its file mode."""
mode: int | None = None
diff --git a/jarvis/ui/web/agentic_ide_routes.py b/jarvis/ui/web/agentic_ide_routes.py
index 11f4c968a6..ccbb55ee90 100644
--- a/jarvis/ui/web/agentic_ide_routes.py
+++ b/jarvis/ui/web/agentic_ide_routes.py
@@ -1994,6 +1994,25 @@ async def get_workspace_text_file(workspace_id: str, path: str) -> dict[str, obj
return _text_file_response(workspace_id, loaded)
+ "/workspaces/{workspace_id}/text-file/version",
+ summary="The current version of one file open in the code editor",
+)
+async def get_workspace_text_file_version(workspace_id: str, path: str) -> dict[str, object]:
+ """What the editor polls to notice that an agent changed an open file.
+
+ ``version`` is null when the file no longer exists.
+ """
+ folder = _workspace_folder(workspace_id)
+ try:
+ version = await asyncio.to_thread(file_editing.file_version, folder, path)
+ except file_editing.EditError as exc:
+ raise HTTPException(status_code=404, detail=str(exc)) from exc
+ except OSError:
+ version = None
+ return {"workspace_id": workspace_id, "path": path.replace("\\", "/"), "version": version}
+
+
@router.put(
"/workspaces/{workspace_id}/text-file",
response_model=WorkspaceTextFileResponse,
diff --git a/pyproject.toml b/pyproject.toml
index 846b658219..15cf8d9771 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -65,6 +65,9 @@ dependencies = [
# malformed vision JSON; without it the repair path silently degrades on
# every fresh install (found 2026-07-18, was never declared).
"json-repair>=0.30",
+ # The code editor's delete moves files to the system trash (Recycle Bin,
+ # macOS Trash, freedesktop trash) instead of erasing them; pure Python.
+ "Send2Trash>=1.8.3",
# cryptography stopped publishing the wheels these two targets need, and
# not at the same release: win_arm64 ends at 46.0.3, and the macosx
# universal2 wheel that covers Intel macOS ends at 48.0.1. Re-verified
diff --git a/requirements.in b/requirements.in
index c10e38d27c..eb279d2a42 100644
--- a/requirements.in
+++ b/requirements.in
@@ -29,6 +29,9 @@ anyio>=4.14.2
# malformed vision JSON; without it the repair path silently degrades on
# every fresh install (found 2026-07-18, was never declared).
json-repair>=0.30
+# The code editor's delete moves files to the system trash (Recycle Bin,
+# macOS Trash, freedesktop trash) instead of erasing them; pure Python.
+Send2Trash>=1.8.3
# Keep transitive auth/JWT crypto wheel-installable where the newest release
# stopped publishing the architecture. KNOWN, ACCEPTED EXPOSURE, re-verified
# against PyPI on 2026-08-26 (latest 50.0.1): 46.0.3 is the last release with a
diff --git a/requirements.txt b/requirements.txt
index 98f57b098d..4b5f652186 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -2164,6 +2164,10 @@ secretstorage==3.5.0 ; sys_platform == 'linux' \
--hash=sha256:0ce65888c0725fcb2c5bc0fdb8e5438eece02c523557ea40ce0703c266248137 \
--hash=sha256:f04b8e4689cbce351744d5537bf6b1329c6fc68f91fa666f60a380edddcd11be
# via keyring
+send2trash==2.1.0 \
+ --hash=sha256:0da2f112e6d6bb22de6aa6daa7e144831a4febf2a87261451c4ad849fe9a873c \
+ --hash=sha256:1c72b39f09457db3c05ce1d19158c2cbef4c32b8bedd02c155e49282b7ea7459
+ # via -r requirements.in
shellingham==1.5.4 \
--hash=sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686 \
--hash=sha256:8dbca0739d487e5bd35ab3ca4b36e11c4078f3a234bfce294b0a0291363404de
diff --git a/tests/unit/agentic_ide/test_file_editing.py b/tests/unit/agentic_ide/test_file_editing.py
index 43baa70591..d3d6095878 100644
--- a/tests/unit/agentic_ide/test_file_editing.py
+++ b/tests/unit/agentic_ide/test_file_editing.py
@@ -213,6 +213,22 @@ async def test_routes_load_save_and_report_conflicts(workspace: Path) -> None:
assert caught.value.detail["current_version"] == saved["version"]
+async def test_version_route_tracks_changes_and_deletion(workspace: Path) -> None:
+ (workspace / "a.txt").write_text("one\n", encoding="utf-8")
+ loaded = await routes.get_workspace_text_file("workspace-1", "a.txt")
+
+ same = await routes.get_workspace_text_file_version("workspace-1", "a.txt")
+ assert same["version"] == loaded["version"]
+
+ (workspace / "a.txt").write_text("two\n", encoding="utf-8")
+ changed = await routes.get_workspace_text_file_version("workspace-1", "a.txt")
+ assert changed["version"] not in (None, loaded["version"])
+
+ (workspace / "a.txt").unlink()
+ gone = await routes.get_workspace_text_file_version("workspace-1", "a.txt")
+ assert gone["version"] is None
+
+
async def test_routes_reject_unknown_workspace_and_escapes(workspace: Path) -> None:
with pytest.raises(HTTPException) as unknown:
await routes.get_workspace_text_file("nope", "main.py")