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(chat): ignore missing media paths

Jaydende40faea4809
diff --git a/dodaios/agent_chat/media.py b/dodaios/agent_chat/media.py
index 6746d250c1..b98d2f6ad0 100644
--- a/dodaios/agent_chat/media.py
+++ b/dodaios/agent_chat/media.py
@@ -280,7 +280,18 @@ class MediaNormalizer:
):
self.reference(ref)
for match in _RAW.finditer(without_links):
- self.reference(match[0])
+ ref = match[0]
+ if ref.startswith(("http://", "https://")):
+ self.reference(ref)
+ continue
+ path_ref = ref
+ if path_ref.startswith("file:"):
+ path_ref = unquote(urlsplit(path_ref).path)
+ if re.match(r"^/[A-Za-z]:/", path_ref):
+ path_ref = path_ref[1:]
+ candidate = (self.cwd / path_ref).resolve()
+ if candidate.is_relative_to(self.cwd) and candidate.is_file():
+ self.reference(ref)
for match in _BARE.finditer(without_links):
candidate = (self.cwd / match[0]).resolve()
if candidate.is_relative_to(self.cwd) and candidate.is_file():
diff --git a/tests/unit/agent_chat/test_media.py b/tests/unit/agent_chat/test_media.py
index 5fd9e0c426..7a01b106d2 100644
--- a/tests/unit/agent_chat/test_media.py
+++ b/tests/unit/agent_chat/test_media.py
@@ -143,6 +143,22 @@ def test_plain_remote_url_is_rendered_in_place_without_duplicate(tmp_path):
assert len(result) == 1
+def test_plain_text_missing_local_media_is_not_a_receipt(tmp_path):
+ missing = tmp_path / "work" / "app" / "windows" / "runner" / "resources" / "app_icon.ico"
+ text = f"Checked {missing} and ./missing.png"
+ result = normalize(tmp_path, text, "assistant_text")
+ assert result == [event(text, "assistant_text")]
+
+
+def test_plain_text_existing_local_media_is_delivered(tmp_path):
+ source = tmp_path / "work" / "app_icon.ico"
+ source.parent.mkdir(parents=True)
+ source.write_bytes(b"icon")
+ result = normalize(tmp_path, f"Created {source}", "assistant_text")
+ assert len(result) == 2
+ assert "![image]" in result[1]["payload"]["text"]
+
+
def test_mixed_assistant_content_keeps_text_and_each_visual_in_order(tmp_path):
blocks = [
{"type": "text", "text": "First image:"},