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: exclude linked worktrees from UltraWiki folder imports

Ruben Lütke74c20ab36735
diff --git a/jarvis/ultrawiki/connectors/local_folder.py b/jarvis/ultrawiki/connectors/local_folder.py
index 8406267c96..7252520a4a 100644
--- a/jarvis/ultrawiki/connectors/local_folder.py
+++ b/jarvis/ultrawiki/connectors/local_folder.py
@@ -193,6 +193,22 @@ def _is_own_data_dir(path: Path, own_data: tuple[Path, ...]) -> bool:
return any(resolved == own for own in own_data)
+def _is_linked_git_worktree(path: Path) -> bool:
+ """Whether *path* is a linked Git worktree nested below the chosen root.
+
+ Git marks linked worktrees with a ``.git`` file that points back to the
+ primary checkout. They are machine-created copies of content already
+ present elsewhere and can multiply a Desktop import by every active task.
+ A primary checkout has a ``.git`` directory and is intentionally retained.
+ Selecting a worktree itself as the source remains an explicit opt-in,
+ because the walker filters children and never rejects its root.
+ """
+ try:
+ return (path / ".git").is_file()
+ except OSError:
+ return False
+
+
#: Text-shaped suffixes read as UTF-8. Deliberately an ALLOWLIST: a folder
#: full of photos, videos and installers must import as nothing rather than
#: as megabytes of replacement characters. Grouped for review, flattened
@@ -494,6 +510,7 @@ class LocalFolderConnector:
if not d.startswith(".")
and d.lower() not in skip
and not _is_own_data_dir(base / d, own_data)
+ and not _is_linked_git_worktree(base / d)
)
for name in filenames:
if name.startswith("."):
diff --git a/tests/unit/ultrawiki/test_connectors.py b/tests/unit/ultrawiki/test_connectors.py
index 0c23fbe854..d42659756a 100644
--- a/tests/unit/ultrawiki/test_connectors.py
+++ b/tests/unit/ultrawiki/test_connectors.py
@@ -326,6 +326,35 @@ class TestLocalFolderNoiseDirectories:
assert {"AppData", "Library"} <= LocalFolderConnector.SKIP_DIR_NAMES
+ async def test_nested_linked_git_worktrees_are_skipped(self, tmp_path: Path):
+ """A Desktop source must not clone every task worktree into memory."""
+ primary = tmp_path / "primary"
+ primary.mkdir()
+ (primary / ".git").mkdir()
+ (primary / "keep.md").write_text("canonical", encoding="utf-8")
+ linked = tmp_path / "task-worktree"
+ linked.mkdir()
+ (linked / ".git").write_text("gitdir: ../primary/.git/worktrees/task\n")
+ (linked / "duplicate.md").write_text("duplicate", encoding="utf-8")
+
+ items = await _collect(
+ LocalFolderConnector().backfill(_ctx({"root": str(tmp_path)}))
+ )
+
+ assert [item.external_id for item in items] == ["primary/keep.md"]
+
+ async def test_a_worktree_selected_as_the_root_is_imported(self, tmp_path: Path):
+ """The nested filter must preserve an explicit source selection."""
+ (tmp_path / ".git").write_text("gitdir: ../primary/.git/worktrees/task\n")
+ (tmp_path / "note.md").write_text("unique work", encoding="utf-8")
+
+ items = await _collect(
+ LocalFolderConnector().backfill(_ctx({"root": str(tmp_path)}))
+ )
+
+ assert [item.external_id for item in items] == ["note.md"]
+
+
class TestLocalFolderExcludes:
"""A built-in noise list cannot know what THIS folder is cluttered with.