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(ultrawiki): let a folder source name what it should skip

Ruben Lütkebfe71d36d6e0
diff --git a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.test.tsx b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.test.tsx
index b4c143eb03..f9ae3a7a20 100644
--- a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.test.tsx
@@ -472,6 +472,111 @@ describe("SourcesPanel — bridge sources carry a real identity", () => {
});
});
+describe("SourcesPanel — folders to skip", () => {
+ function installFolderPickerMock(created: unknown[]) {
+ return installFetchMock({
+ "/api/ultrawiki/areas": () => ({ areas: [], total: 0 }),
+ "/api/ultrawiki/connectors": () => ({
+ connectors: [
+ {
+ id: "local-folder",
+ kind: "builtin",
+ label: "Local folder",
+ label_key: "ultrawiki.sources.connector_local_folder",
+ brand: "folder",
+ status: "available",
+ description_key: "ultrawiki.connectors.local_folder",
+ connector: "local-folder",
+ integration_id: "",
+ },
+ ],
+ total: 1,
+ builtin: 1,
+ bridge: 0,
+ }),
+ "/api/ultrawiki/bridge/candidates": () => ({
+ candidates: [],
+ total: 0,
+ connected: 0,
+ }),
+ "/api/ultrawiki/sources": (init) => {
+ created.push(JSON.parse(String(init?.body ?? "{}")));
+ return { id: "src-folder" };
+ },
+ });
+ }
+
+ async function pickTheFolderTile() {
+ fireEvent.click(screen.getByTestId("ultrawiki-add-source-toggle"));
+ await waitFor(() => {
+ expect(screen.getByTestId("uw-picker-local-folder")).toBeDefined();
+ });
+ fireEvent.click(screen.getByTestId("uw-picker-local-folder"));
+ }
+
+ it("sends the skip list as its own config key", async () => {
+ const created: unknown[] = [];
+ installFolderPickerMock(created);
+ renderWithClient(<SourcesPanel sources={[]} onChanged={vi.fn()} />);
+
+ await pickTheFolderTile();
+ fireEvent.change(screen.getByTestId("ultrawiki-path-input"), {
+ target: { value: "/home/someone/Desktop" },
+ });
+ fireEvent.change(screen.getByTestId("ultrawiki-exclude-input"), {
+ target: { value: "ship-release-work, backups" },
+ });
+ fireEvent.click(screen.getByTestId("ultrawiki-create-source"));
+
+ await waitFor(() => {
+ expect(created).toHaveLength(1);
+ });
+ expect(created[0]).toMatchObject({
+ connector: "local-folder",
+ config: {
+ root: "/home/someone/Desktop",
+ exclude: ["ship-release-work", "backups"],
+ },
+ });
+ });
+
+ it("stores no skip list when the field is left alone", async () => {
+ const created: unknown[] = [];
+ installFolderPickerMock(created);
+ renderWithClient(<SourcesPanel sources={[]} onChanged={vi.fn()} />);
+
+ await pickTheFolderTile();
+ fireEvent.change(screen.getByTestId("ultrawiki-path-input"), {
+ target: { value: "/home/someone/Desktop" },
+ });
+ fireEvent.click(screen.getByTestId("ultrawiki-create-source"));
+
+ await waitFor(() => {
+ expect(created).toHaveLength(1);
+ });
+ // An empty field must not write an empty key the backend then has to
+ // interpret — absent means "use the built-in noise list only".
+ const body = created[0] as { config: Record<string, unknown> };
+ expect("exclude" in body.config).toBe(false);
+ });
+
+ it("is offered for a folder source but not for a dropped export", async () => {
+ installFolderPickerMock([]);
+ renderWithClient(<SourcesPanel sources={[]} onChanged={vi.fn()} />);
+
+ fireEvent.click(screen.getByTestId("ultrawiki-add-source-toggle"));
+ await waitFor(() => {
+ expect(screen.getByTestId("uw-picker-local-folder")).toBeDefined();
+ });
+ // Nothing before a type is picked: the field belongs to the folder flow.
+ expect(screen.queryByTestId("ultrawiki-exclude-input")).toBeNull();
+
+ fireEvent.click(screen.getByTestId("uw-picker-local-folder"));
+
+ expect(screen.getByTestId("ultrawiki-exclude-input")).toBeDefined();
+ });
+});
+
describe("SourcesPanel — the dropped-export add flow", () => {
function installExportPickerMock(
created: unknown[],
diff --git a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx
index da95735c6d..bc9fd5eb10 100644
--- a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx
@@ -485,6 +485,7 @@ function AddSourceForm({
const [option, setOption] = useState<ConnectorOption | null>(null);
const [label, setLabel] = useState("");
const [rootPath, setRootPath] = useState("");
+ const [excludes, setExcludes] = useState("");
const [exportPath, setExportPath] = useState("");
const [selectedAreas, setSelectedAreas] = useState<string[]>([]);
const [submitting, setSubmitting] = useState(false);
@@ -518,6 +519,16 @@ function AddSourceForm({
setError("");
const config: Record<string, unknown> = {};
if (needsPath && rootPath.trim()) config.root = rootPath.trim();
+ if (needsPath) {
+ // A folder the user actually picks is often mostly clutter (build
+ // output, working copies). Sent only when non-empty so an untouched
+ // field stores nothing at all.
+ const skip = excludes
+ .split(",")
+ .map((name) => name.trim())
+ .filter(Boolean);
+ if (skip.length > 0) config.exclude = skip;
+ }
if (isExport && exportPath.trim()) config.path = exportPath.trim();
if (option.connector === BRIDGE_CONNECTOR && option.integrationId) {
config.integration_id = option.integrationId;
@@ -607,6 +618,25 @@ function AddSourceForm({
</label>
)}
+ {needsPath && (
+ <label className="block">
+ <span className="mb-1.5 flex items-center gap-1 text-[10px] uppercase tracking-wider text-muted-foreground">
+ <FolderOpen className="h-3 w-3" aria-hidden />
+ {t("ultrawiki.sources.exclude_label")}
+ </span>
+ <input
+ type="text"
+ value={excludes}
+ onChange={(e) => setExcludes(e.target.value)}
+ className={inputCls}
+ data-testid="ultrawiki-exclude-input"
+ />
+ <span className="mt-1 block text-[11px] text-muted-foreground">
+ {t("ultrawiki.sources.exclude_hint")}
+ </span>
+ </label>
+ )}
+
{isExport && (
<ExportPreview path={exportPath} onPathChange={setExportPath} />
)}
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index cae2454819..6ce6c2a361 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -2937,6 +2937,8 @@
"label_label": "Name",
"path_label": "Ordnerpfad",
"path_hint": "Der Ordner wird auf diesem Gerät gelesen; vor Freigabe und Synchronisierung wird nichts abgerufen.",
+ "exclude_label": "Ordner überspringen (optional)",
+ "exclude_hint": "Ordnernamen mit Komma getrennt, z. B. Archiv, Backups. Abhängigkeits- und Cache-Ordner werden immer übersprungen.",
"areas_label": "Bereiche",
"no_areas": "Bis du weitere anlegst, wird der Standardbereich verwendet.",
"bridge_label": "Verbundene Integration",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index 495d627ac3..246a651997 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -2923,6 +2923,8 @@
"label_label": "Name",
"path_label": "Folder path",
"path_hint": "The folder is read on this machine; nothing is pulled before you approve and sync.",
+ "exclude_label": "Folders to skip (optional)",
+ "exclude_hint": "Comma-separated folder names, e.g. archive, backups. Dependency and cache folders are always skipped.",
"areas_label": "Areas",
"no_areas": "The default area is used until you create more.",
"bridge_label": "Connected integration",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index c5448702c2..e583c3ef00 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -2922,6 +2922,8 @@
"label_label": "Nombre",
"path_label": "Ruta de la carpeta",
"path_hint": "La carpeta se lee en este equipo; no se extrae nada antes de aprobar y sincronizar.",
+ "exclude_label": "Carpetas que omitir (opcional)",
+ "exclude_hint": "Nombres de carpeta separados por comas, p. ej. archivo, copias. Las carpetas de dependencias y caché siempre se omiten.",
"areas_label": "Áreas",
"no_areas": "Se usa el área por defecto hasta que crees más.",
"bridge_label": "Integración conectada",
diff --git a/jarvis/ultrawiki/connectors/local_folder.py b/jarvis/ultrawiki/connectors/local_folder.py
index 7aa3c631f5..041d3621e7 100644
--- a/jarvis/ultrawiki/connectors/local_folder.py
+++ b/jarvis/ultrawiki/connectors/local_folder.py
@@ -281,7 +281,9 @@ class LocalFolderConnector:
if root is None:
return
extensions = self._extensions(ctx)
- paths = await asyncio.to_thread(self._sorted_files, root, extensions)
+ paths = await asyncio.to_thread(
+ self._sorted_files, root, extensions, self._skip_dirs(ctx)
+ )
pending = [
path
for path in paths
@@ -299,7 +301,9 @@ class LocalFolderConnector:
return
threshold = parse_mtime_cursor(cursor, connector_id=self.id)
extensions = self._extensions(ctx)
- paths = await asyncio.to_thread(self._sorted_files, root, extensions)
+ paths = await asyncio.to_thread(
+ self._sorted_files, root, extensions, self._skip_dirs(ctx)
+ )
for batch in _batched(paths, READ_BATCH):
items = await asyncio.to_thread(
self._items_for_paths, root, batch, min_mtime_ns=threshold
@@ -369,7 +373,27 @@ class LocalFolderConnector:
normalized.append(text if text.startswith(".") else f".{text}")
return tuple(normalized) or self.DEFAULT_EXTENSIONS
- def _sorted_files(self, root: Path, extensions: tuple[str, ...]) -> list[Path]:
+ def _skip_dirs(self, ctx: ConnectorContext) -> frozenset[str]:
+ """Folder names not walked: the built-in noise list PLUS the user's.
+
+ Lower-cased for matching, because a list typed on Windows or macOS
+ (case-insensitive filesystems) has to keep working when the same
+ config is opened on Linux. Additive by design — naming one folder must
+ never switch the sensible defaults off.
+ """
+ names = {name.lower() for name in self.SKIP_DIR_NAMES}
+ for entry in ctx.config.get("exclude") or ():
+ text = str(entry).strip().lower()
+ if text:
+ names.add(text)
+ return frozenset(names)
+
+ def _sorted_files(
+ self,
+ root: Path,
+ extensions: tuple[str, ...],
+ skip_dirs: frozenset[str] | None = None,
+ ) -> list[Path]:
"""All matching files under ``root``, sorted by ``external_id``.
The sort key is deliberately :meth:`_external_id_for`, not the raw
@@ -377,14 +401,20 @@ class LocalFolderConnector:
resuming can only be correct while walk order and checkpoint order are
the same string ordering.
- Hidden directories and files (dot-prefixed) plus :attr:`SKIP_DIR_NAMES`
- are excluded. Symlinked directories are not followed. Blocking — call
- it through ``asyncio.to_thread``.
+ Hidden directories and files (dot-prefixed) plus ``skip_dirs`` (which
+ defaults to :attr:`SKIP_DIR_NAMES`) are excluded. Symlinked
+ directories are not followed. Blocking — call it through
+ ``asyncio.to_thread``.
"""
+ skip = (
+ skip_dirs
+ if skip_dirs is not None
+ else frozenset(name.lower() for name in self.SKIP_DIR_NAMES)
+ )
matches: list[tuple[str, Path]] = []
for dirpath, dirnames, filenames in os.walk(root):
dirnames[:] = sorted(
- d for d in dirnames if not d.startswith(".") and d not in self.SKIP_DIR_NAMES
+ d for d in dirnames if not d.startswith(".") and d.lower() not in skip
)
base = Path(dirpath)
for name in filenames:
diff --git a/jarvis/ultrawiki/connectors/normal_wiki.py b/jarvis/ultrawiki/connectors/normal_wiki.py
index 2ff1a0686b..3fa8706e12 100644
--- a/jarvis/ultrawiki/connectors/normal_wiki.py
+++ b/jarvis/ultrawiki/connectors/normal_wiki.py
@@ -77,7 +77,15 @@ class NormalWikiConnector(LocalFolderConnector):
def _extensions(self, ctx: ConnectorContext) -> tuple[str, ...]:
return self.DEFAULT_EXTENSIONS
- def _sorted_files(self, root: Path, extensions: tuple[str, ...]) -> list[Path]:
+ def _sorted_files(
+ self,
+ root: Path,
+ extensions: tuple[str, ...],
+ skip_dirs: frozenset[str] | None = None,
+ ) -> list[Path]:
+ # skip_dirs is accepted for the base-class contract and deliberately
+ # unused: this walk visits only the four page-kind directories, so
+ # there is no unrelated tree a user could need to exclude.
matches: list[Path] = []
for kind in self.PAGE_KINDS:
sub = root / kind
diff --git a/tests/unit/ultrawiki/test_connectors.py b/tests/unit/ultrawiki/test_connectors.py
index aae2df04e6..258943c867 100644
--- a/tests/unit/ultrawiki/test_connectors.py
+++ b/tests/unit/ultrawiki/test_connectors.py
@@ -325,6 +325,75 @@ class TestLocalFolderNoiseDirectories:
assert {"AppData", "Library"} <= LocalFolderConnector.SKIP_DIR_NAMES
+class TestLocalFolderExcludes:
+ """A built-in noise list cannot know what THIS folder is cluttered with.
+
+ A measured real Desktop was 84% one folder holding ~50 working copies of
+ the same project - importable text by every rule, worthless as knowledge,
+ and 300k files nobody would notice were wrong until the bill arrived.
+ Naming them is the user's call, so the source carries its own list.
+ """
+
+ async def test_an_excluded_folder_is_not_walked(self, tmp_path: Path):
+ (tmp_path / "keep.md").write_text("keep", encoding="utf-8")
+ clutter = tmp_path / "ship-release-work"
+ clutter.mkdir()
+ (clutter / "copy.md").write_text("drop", encoding="utf-8")
+
+ ctx = _ctx({"root": str(tmp_path), "exclude": ["ship-release-work"]})
+ items = await _collect(LocalFolderConnector().backfill(ctx))
+
+ assert [item.external_id for item in items] == ["keep.md"]
+
+ async def test_excludes_apply_at_every_depth(self, tmp_path: Path):
+ nested = tmp_path / "projects" / "alpha" / "build-output"
+ nested.mkdir(parents=True)
+ (nested / "generated.md").write_text("drop", encoding="utf-8")
+ (tmp_path / "projects" / "notes.md").write_text("keep", encoding="utf-8")
+
+ ctx = _ctx({"root": str(tmp_path), "exclude": ["build-output"]})
+ items = await _collect(LocalFolderConnector().backfill(ctx))
+
+ assert [item.external_id for item in items] == ["projects/notes.md"]
+
+ async def test_excludes_add_to_the_built_in_noise_list(self, tmp_path: Path):
+ """Naming one folder must not switch the sensible defaults off."""
+ (tmp_path / "keep.md").write_text("keep", encoding="utf-8")
+ for noisy in ("node_modules", "mine"):
+ folder = tmp_path / noisy
+ folder.mkdir()
+ (folder / "junk.md").write_text("drop", encoding="utf-8")
+
+ ctx = _ctx({"root": str(tmp_path), "exclude": ["mine"]})
+ items = await _collect(LocalFolderConnector().backfill(ctx))
+
+ assert [item.external_id for item in items] == ["keep.md"]
+
+ async def test_a_blank_or_missing_exclude_list_changes_nothing(
+ self, tmp_path: Path
+ ):
+ (tmp_path / "keep.md").write_text("keep", encoding="utf-8")
+ ctx = _ctx({"root": str(tmp_path), "exclude": ["", " "]})
+ items = await _collect(LocalFolderConnector().backfill(ctx))
+ assert [item.external_id for item in items] == ["keep.md"]
+
+ async def test_exclusion_is_case_blind_on_every_platform(self, tmp_path: Path):
+ """Windows and macOS folder names are case-insensitive; Linux is not.
+
+ A list typed on one machine has to keep working on the next, so the
+ match is case-blind everywhere rather than following the host.
+ """
+ clutter = tmp_path / "Ship-Release-Work"
+ clutter.mkdir()
+ (clutter / "copy.md").write_text("drop", encoding="utf-8")
+ (tmp_path / "keep.md").write_text("keep", encoding="utf-8")
+
+ ctx = _ctx({"root": str(tmp_path), "exclude": ["ship-release-work"]})
+ items = await _collect(LocalFolderConnector().backfill(ctx))
+
+ assert [item.external_id for item in items] == ["keep.md"]
+
+
class TestLocalFolderFileTypes:
""""Import my whole Desktop" means documents and code, not just notes.