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: edit UltraWiki folder source settings

Ruben Lütke6912d9d63fdf
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 f9ae3a7a20..35dbbbbfeb 100644
--- a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.test.tsx
@@ -165,6 +165,41 @@ describe("SourcesPanel — consent gate", () => {
expect(onChanged).toHaveBeenCalledTimes(1);
});
});
+
+ it("edits a folder path and exclusions without recreating the source", async () => {
+ const editable = source({
+ id: "src-editable",
+ consent: "approved",
+ config: { root: "C:/Notes", exclude: ["archive"] },
+ });
+ const fetchMock = installFetchMock({
+ "/api/ultrawiki/sources/src-editable": () => editable,
+ });
+ const onChanged = vi.fn();
+ renderWithClient(
+ <SourcesPanel sources={[editable]} onChanged={onChanged} />,
+ );
+
+ fireEvent.click(screen.getByTestId("uw-source-edit-src-editable"));
+ fireEvent.change(screen.getByTestId("uw-source-edit-exclude-src-editable"), {
+ target: { value: "archive, dist" },
+ });
+ const form = screen.getByTestId("uw-source-edit-form-src-editable");
+ fireEvent.submit(form);
+
+ await waitFor(() => {
+ expect(fetchMock).toHaveBeenCalledWith(
+ "/api/ultrawiki/sources/src-editable",
+ expect.objectContaining({
+ method: "PATCH",
+ body: JSON.stringify({
+ config: { root: "C:/Notes", exclude: ["archive", "dist"] },
+ }),
+ }),
+ );
+ });
+ await waitFor(() => expect(onChanged).toHaveBeenCalledTimes(1));
+ });
});
describe("SourcesPanel — approve imports everything", () => {
diff --git a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx
index bc9fd5eb10..a9e8cc06d1 100644
--- a/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx
+++ b/jarvis/ui/web/frontend/src/components/ultrawiki/SourcesPanel.tsx
@@ -30,6 +30,7 @@ import {
FolderOpen,
Info,
Loader2,
+ Pencil,
Plus,
RefreshCw,
ShieldCheck,
@@ -57,6 +58,7 @@ import {
fetchUltraWikiAreas,
revokeUltraWikiSource,
startUltraWikiSync,
+ updateUltraWikiSource,
type UltraWikiSource,
} from "@/lib/ultrawikiApi";
@@ -117,6 +119,7 @@ export function SourcesPanel({
try {
await action();
onChanged();
+ return true;
} catch (e) {
pushToast(
"error",
@@ -125,6 +128,7 @@ export function SourcesPanel({
(e as Error).message,
),
);
+ return false;
} finally {
setBusySource(null);
}
@@ -197,6 +201,11 @@ export function SourcesPanel({
onCancelJob={(jobId) =>
void run(source.id, () => cancelUltraWikiJob(jobId))
}
+ onUpdate={(config) =>
+ run(source.id, () =>
+ updateUltraWikiSource(source.id, { config }),
+ )
+ }
/>
))}
</ul>
@@ -212,6 +221,7 @@ function SourceCard({
onRevoke,
onSync,
onCancelJob,
+ onUpdate,
}: {
source: UltraWikiSource;
busy: boolean;
@@ -219,8 +229,12 @@ function SourceCard({
onRevoke: () => void;
onSync: () => void;
onCancelJob: (jobId: string) => void;
+ onUpdate: (config: Record<string, unknown>) => Promise<boolean>;
}): JSX.Element {
const t = useT();
+ const [editing, setEditing] = useState(false);
+ const [editRoot, setEditRoot] = useState("");
+ const [editExcludes, setEditExcludes] = useState("");
const consent = String(source.consent);
const badge = CONSENT_BADGE[consent] ?? CONSENT_BADGE.pending;
const approved = consent === "approved";
@@ -232,6 +246,23 @@ function SourceCard({
source.last_outcome?.finished_at ?? source.last_sync_at ?? null;
const lastFinishedText = formatRelativeTime(lastFinished, t);
+ function beginEdit() {
+ setEditRoot(source.config?.root ?? "");
+ setEditExcludes((source.config?.exclude ?? []).join(", "));
+ setEditing(true);
+ }
+
+ async function saveEdit(event: React.FormEvent) {
+ event.preventDefault();
+ const exclude = editExcludes
+ .split(",")
+ .map((name) => name.trim())
+ .filter(Boolean);
+ if (await onUpdate({ root: editRoot.trim(), exclude })) {
+ setEditing(false);
+ }
+ }
+
return (
<li
className="card-outline rounded-xl border border-border bg-card/40 p-3"
@@ -420,6 +451,18 @@ function SourceCard({
)}
<div className="mt-2 flex flex-wrap items-center gap-2">
+ {PATH_CONNECTORS.includes(source.connector) && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={beginEdit}
+ disabled={busy || Boolean(activeJob)}
+ data-testid={`uw-source-edit-${source.id}`}
+ >
+ <Pencil className="mr-1 h-3.5 w-3.5" aria-hidden />
+ {t("common.edit")}
+ </Button>
+ )}
{!approved && (
<Button
size="sm"
@@ -465,6 +508,49 @@ function SourceCard({
)}
</div>
+ {editing && (
+ <form
+ onSubmit={(event) => void saveEdit(event)}
+ className="mt-3 space-y-2 rounded-lg border border-border bg-background/40 p-2.5"
+ data-testid={`uw-source-edit-form-${source.id}`}
+ >
+ <label className="block text-[11px] text-muted-foreground">
+ {t("ultrawiki.sources.path_label")}
+ <input
+ type="text"
+ value={editRoot}
+ onChange={(event) => setEditRoot(event.target.value)}
+ required
+ className="mt-1 w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground"
+ data-testid={`uw-source-edit-root-${source.id}`}
+ />
+ </label>
+ <label className="block text-[11px] text-muted-foreground">
+ {t("ultrawiki.sources.exclude_label")}
+ <input
+ type="text"
+ value={editExcludes}
+ onChange={(event) => setEditExcludes(event.target.value)}
+ className="mt-1 w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground"
+ data-testid={`uw-source-edit-exclude-${source.id}`}
+ />
+ </label>
+ <div className="flex justify-end gap-2">
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => setEditing(false)}
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button type="submit" size="sm" disabled={busy || !editRoot.trim()}>
+ {busy ? t("common.saving") : t("common.save")}
+ </Button>
+ </div>
+ </form>
+ )}
+
{!approved && (
<p className="mt-1.5 text-[11px] leading-relaxed text-muted-foreground">
{t("ultrawiki.sources.approve_scope")}
diff --git a/jarvis/ui/web/frontend/src/lib/ultrawikiApi.ts b/jarvis/ui/web/frontend/src/lib/ultrawikiApi.ts
index 851111d8e2..9d28f0cb67 100644
--- a/jarvis/ui/web/frontend/src/lib/ultrawikiApi.ts
+++ b/jarvis/ui/web/frontend/src/lib/ultrawikiApi.ts
@@ -144,6 +144,11 @@ export interface UltraWikiSource {
consent: UltraWikiConsent | string;
enabled: boolean;
areas: string[];
+ /** Safe editable settings are returned only for folder-shaped sources. */
+ config?: {
+ root?: string;
+ exclude?: string[];
+ };
counts: Partial<UltraWikiCounts> | null;
sync_state: Record<string, unknown> | null;
/** The run currently importing from this source, if any. */
@@ -1016,6 +1021,24 @@ export function approveUltraWikiSource(
);
}
+export function updateUltraWikiSource(
+ sourceId: string,
+ body: {
+ label?: string;
+ config?: Record<string, unknown>;
+ areas?: string[];
+ },
+): Promise<UltraWikiSource> {
+ return request<UltraWikiSource>(
+ `/api/ultrawiki/sources/${encodeURIComponent(sourceId)}`,
+ {
+ method: "PATCH",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(body),
+ },
+ );
+}
+
/**
* One page of the stored inventory. The counts say HOW MANY items exist per
* stage; this says WHICH ones — the question "what is even in this database?".
diff --git a/jarvis/ui/web/ultrawiki_routes.py b/jarvis/ui/web/ultrawiki_routes.py
index 195c451325..8f7323dcae 100644
--- a/jarvis/ui/web/ultrawiki_routes.py
+++ b/jarvis/ui/web/ultrawiki_routes.py
@@ -1538,6 +1538,14 @@ class CreateSourceBody(BaseModel):
areas: list[str] = Field(default_factory=list)
+class UpdateSourceBody(BaseModel):
+ """Editable source fields; omitted values keep their current setting."""
+
+ label: str | None = Field(default=None, min_length=1)
+ config: dict[str, Any] | None = None
+ areas: list[str] | None = None
+
+
@router.post("/sources", status_code=201, summary="Register an UltraWiki source")
async def create_source(body: CreateSourceBody, request: Request) -> dict[str, Any]:
"""Register a new source with consent PENDING — approval is a separate explicit step."""
@@ -1554,6 +1562,25 @@ async def create_source(body: CreateSourceBody, request: Request) -> dict[str, A
return source
[email protected]("/sources/{source_id}", summary="Update an UltraWiki source")
+async def update_source(
+ source_id: str, body: UpdateSourceBody, request: Request
+) -> dict[str, Any]:
+ """Change a source path, exclusions, label, or areas without re-approving."""
+ service = _service(request)
+ try:
+ return await service.update_source(
+ source_id,
+ label=body.label,
+ config=body.config,
+ area_ids=body.areas,
+ )
+ except ValueError as exc:
+ message = str(exc)
+ status_code = 404 if message.startswith("unknown source") else 400
+ raise HTTPException(status_code=status_code, detail=message) from exc
+
+
@router.post(
"/sources/{source_id}/approve",
summary="Approve an UltraWiki source and import everything it holds",
diff --git a/jarvis/ultrawiki/service.py b/jarvis/ultrawiki/service.py
index a18ba83e47..9ee735d737 100644
--- a/jarvis/ultrawiki/service.py
+++ b/jarvis/ultrawiki/service.py
@@ -1051,6 +1051,12 @@ class UltraWikiService:
str(config.get("integration_id") or "") if isinstance(config, dict) else ""
)
brand, connector_kind = _connector_identity(connector_id, integration_id)
+ editable_config: dict[str, Any] = {}
+ if connector_id in _FOLDER_CONNECTOR_IDS and isinstance(config, dict):
+ editable_config = {
+ "root": str(config.get("root") or ""),
+ "exclude": [str(value) for value in config.get("exclude") or []],
+ }
return {
"id": row.get("id"),
"connector": connector_id,
@@ -1066,6 +1072,9 @@ class UltraWikiService:
"consent": row.get("consent"),
"enabled": row.get("enabled"),
"areas": row.get("areas", []),
+ # Only folder settings are returned: they contain no credential,
+ # and the Sources view needs them to repair a path or exclusion.
+ "config": editable_config,
"counts": _counts_dict(counts)
if isinstance(counts, PipelineCounts)
else counts,
@@ -1306,6 +1315,43 @@ class UltraWikiService:
assert source is not None
return source
+ async def update_source(
+ self,
+ source_id: str,
+ *,
+ label: str | None = None,
+ config: dict[str, Any] | None = None,
+ area_ids: list[str] | None = None,
+ ) -> dict[str, Any]:
+ """Update one source without resetting consent or stored content."""
+ await self.ensure_started()
+ store = self._require_store()
+ source = await store.get_source(source_id)
+ if source is None:
+ raise ValueError(f"unknown source {source_id!r}")
+ connector_id = str(source.get("connector") or "")
+ connector = self._build_connector(connector_id)
+ resolved_config: dict[str, Any] | None = None
+ if config is not None:
+ resolved_config = dict(source.get("config") or {})
+ resolved_config.update(dict(config))
+ resolved_config = await asyncio.to_thread(
+ self._checked_folder_config, connector, resolved_config
+ )
+ next_label = str(label).strip() if label is not None else str(source["label"])
+ if not next_label:
+ raise ValueError("source label must not be blank")
+ await store.upsert_source(
+ source_id,
+ connector=connector_id,
+ label=next_label,
+ config=resolved_config,
+ areas=list(area_ids) if area_ids is not None else None,
+ )
+ updated = await store.get_source(source_id)
+ assert updated is not None
+ return updated
+
@staticmethod
def _checked_folder_config(
connector: Any, config: dict[str, Any]
diff --git a/tests/unit/web/test_ultrawiki_routes.py b/tests/unit/web/test_ultrawiki_routes.py
index c9fe80dcb1..bc932f65fd 100644
--- a/tests/unit/web/test_ultrawiki_routes.py
+++ b/tests/unit/web/test_ultrawiki_routes.py
@@ -261,6 +261,57 @@ def test_sync_on_pending_source_is_409(env) -> None:
assert "not approved" in response.json()["detail"]
+def test_folder_source_settings_can_be_repaired_without_recreating_it(env) -> None:
+ _activate(env)
+ docs = env.tmp / "editable-docs"
+ docs.mkdir()
+ created = env.client.post(
+ "/api/ultrawiki/sources",
+ json={
+ "connector": "local-folder",
+ "label": "Editable docs",
+ "config": {"root": str(docs), "exclude": ["archive"]},
+ },
+ )
+ assert created.status_code == 201, created.text
+ source_id = created.json()["id"]
+
+ updated = env.client.patch(
+ f"/api/ultrawiki/sources/{source_id}",
+ json={"config": {"root": str(docs), "exclude": ["archive", "dist"]}},
+ )
+
+ assert updated.status_code == 200, updated.text
+ assert updated.json()["consent"] == "pending"
+ assert updated.json()["config"]["exclude"] == ["archive", "dist"]
+ listed = env.client.get("/api/ultrawiki/sources").json()["sources"]
+ row = next(source for source in listed if source["id"] == source_id)
+ assert row["config"] == {"root": str(docs), "exclude": ["archive", "dist"]}
+
+
+def test_folder_source_update_rejects_a_missing_path(env) -> None:
+ _activate(env)
+ docs = env.tmp / "existing-docs"
+ docs.mkdir()
+ created = env.client.post(
+ "/api/ultrawiki/sources",
+ json={
+ "connector": "local-folder",
+ "label": "Docs",
+ "config": {"root": str(docs)},
+ },
+ )
+ source_id = created.json()["id"]
+
+ response = env.client.patch(
+ f"/api/ultrawiki/sources/{source_id}",
+ json={"config": {"root": str(env.tmp / "missing")}},
+ )
+
+ assert response.status_code == 400
+ assert "There is no folder" in response.json()["detail"]
+
+
def test_approve_then_sync_completes_against_local_folder(env) -> None:
_activate(env)
source_id, job_id = _approve_and_sync_folder(env)