Skip to content

The repository card shows and manages its document sources - #247

Merged
zlareb1 merged 7 commits into
mainfrom
feat/repository-card-sources
Nov 4, 2026
Merged

zlareb1 merged 7 commits into
mainfrom
feat/repository-card-sources

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Related: #215
Related: #235

Changelog category (leave one):

  • New Feature

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

An opened repository on the dashboard's Repositories page lists its document sources with each one's last sync and counts, and its maintainers add, check, sync, rotate and retire a source there.

Why

The knowledge.source.* ops and the sync worker exist, but the only way to register or watch a source was a raw API call. A repository's documents already show on its card (Docs), so where they come from belongs beside them. The facet reads one knowledge.source.list when a card is opened, as the Docs facet does, so a folded card reads nothing.

Scope and risk

  • New Sources facet on the opened repository card, after Docs, for the same docs namespace (frontend/src/views/RepoSources.tsx). Each row: name, kind, a badge for the last sync (Synced, Incomplete when an ok turn carries an error, Rate limited, Credential refused, Sync failed, Never synced), the last sync and a waiting request as times, and the counts in documents (listed, written, retired, not converted with the reasons in a tooltip, skipped). enabled: false shows "Sync is off on this deployment". A server without the op shows a stated line, never an error banner. The counts are information only; there is no review or confirm step and no pinning.
  • Verbs only for the docs namespace's admin (my_role === "admin", what the server's Role.ADMIN gate checks): Add a source, and a row menu with Check, Sync now, Rotate credential, Retire. Each is a dialog in frontend/src/flows/KnowledgeSourceDialog.tsx, loaded with lazy() on first use (the bundle gate refuses flows/*Dialog.tsx in the boot chunk).
  • Add runs knowledge.source.add with dry_run first and shows the probe (count and sample titles); Add stays off until the form it would send is the one that passed. Folder ids or pasted folder links, the file kinds, and the service account key.
  • The credential is typed into a password field, held in the dialog's state only, sent once in the request body and never rendered, toasted or logged. No output of any op carries it.
  • Retire needs the typed name; documents stay unless "Also retire the documents it wrote" is ticked (delete_documents). Its toast counts the documents and, when sync is off, says they are retired once it is on.
  • Check probes on open and again on Check again; closing the dialog aborts the probe's request.
  • The file kinds keep their option order, so unticking and ticking one again matches the checked form and Add stays on.
  • Pure model frontend/src/lib/knowledgeSources.ts (wire types, badge, counts, form validation mirroring the server's name and folder id rules, body and fingerprint); wrappers frontend/src/api/knowledgeSources.ts.
  • Server: only the regenerated reach manifest (the six ops the dashboard now calls gain plugin_hook). knowledge.source.inspect is not called by the page and keeps its reach.
  • Kinds: the Add dialog registers gdrive sources (a shared folder). A linear source (A project's documents sync from the tracker's document store #245), added through knowledge.source.add, shows on the card as "project documents". Check, Sync now, Rotate credential and Retire work on it, and Rotate labels its field "Read-only API key". A kind the page does not know shows by its wire name, with a generic credential label. A linear form in the Add dialog is left for a follow-up.

Deviations from the original design, each because the boot chunk had 25 bytes of headroom (122855 of 122880 on main):

  • The wrappers are imported from api/knowledgeSources.ts directly, as api/tasks.ts and api/models.ts are, not re-exported from the api.ts barrel (that re-export alone added 26 bytes to the boot chunk).
  • No OP_MIN_ROLE entry for knowledge.source.list: it adds 54 bytes to the boot chunk and no call site would consult it. The read follows the Docs facet beside it: a refusal is a stated line ("Join the repository to see where its documents come from").
  • No flagged_pinned count: the server's sync has no such field.

Known gap, left for a follow-up that fixes both facets with one predicate: the verbs are offered on the docs namespace's my_role === "admin", exactly as the Docs facet offers Add a document, so a deployment with auth off or a token with an admin claim but no admin grant on the namespace sees no verbs even though the server would accept them.

Compatibility, rollout and rollback

  • Wire: none. The page calls the existing ops.
  • Operator steps: none. The facet is visible on any deployment that serves the ops; sync itself still needs LOOM_KNOWLEDGE_SOURCE_SYNC_ENABLED.
  • A dashboard served by a build without the ops shows "Document sources are not available on this deployment yet."
  • Rollback: revert; nothing stored.

Tests

  • npm --prefix frontend run test: 214 files, 1796 tests pass on the final head (one earlier run on this head had one failure under load; the two runs after it were green). New: src/lib/knowledgeSources.test.ts (badge, counts, reasons, folder parsing, form problems, body and fingerprint), src/flows/KnowledgeSourceDialog.test.tsx (check before add, Add off after a change and on again after undoing it or re-ticking a file kind; a refused real add keeps the passed check so Add can be tried again; axe; rotate takes the key in a password field and sends it once; after a successful or refused add and rotate no page text, non-password field or toast contains the key; check on open, Check again, an unreachable summary, and the probe's signal aborted on close; sync now with full and its sync-off toast; retire keeps documents by default and words the sync-off case), RepositoryCard.test.tsx (a reader sees the source, its badge and counts and no verb; the admin gets Add a source and the four menu items; no docs namespace, no facet; a refused read, a failed read, and a failed turn's badge and error line).
  • npm --prefix frontend run build and npm --prefix frontend run budget: OK (boot chunk at main's size).
  • Playwright e2e/repositories.spec.ts: 10 pass, including three new tests (a viewer reads knowledge.source.list once and only when the card opens, sees no button in the facet; a server without the op; the admin's Add dialog with Add off until a check and each verb's dialog opening and closing with no page error). The viewer test's forbidden-request regex now includes knowledge.source.(add|check|rotate|remove|sync_now). e2e/fixtures.ts has a knowledge.source.list handler and a knowledgeSources call counter.
  • Full Playwright run: 499 passed, 6 failed, all timing budgets on routes this change does not touch (Review queue, Health, Guardrails, Policies, Activity paint; Conversations INP) under a load average near 39; on a re-run of route-budget.spec.ts and perf-budget.spec.ts every route passed except two other timing checks (Memories boot LCP, Conversations INP), again routes this change does not render.
  • Against a server from source on its own ClickHouse, auth off, one repository configured: knowledge.source.list answers {sources: [], enabled: false}; a dry-run add with a malformed key answers CREDENTIAL_REFUSED; with a source row and a sync state seeded through server/knowledge/store/sources.py (no vendor credential exists to add one for real), the list, sync_now (requested_at set), check (reachable: false with the refusal in summary) and remove answer the shapes lib/knowledgeSources.ts types, and the built dashboard opened on /repositories shows the facet ("Sync is off…", the source, Synced, "synced 4h ago", "sync requested just now", "12 documents listed · 3 written · 1 not converted") with one knowledge.source.list request and no page error. No loom.audit_log row holds the key.
  • make format-check lint typecheck, the reach census check, test_op_reach_census.py, test_public_copy.py, test_doc_links.py, test_agent_instructions.py: pass.
  • Full Python unit suite (make test-unit) on the round-1 head: 26395 passed, 0 failed. Later commits change only frontend/ and the dashboard docs row.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code. Checked: the op shapes against server/knowledge/api/models_sources.py, the admin gate against ops_sources.py, the form rules against server/knowledge/domain/sources.py, the boot chunk size against main.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • make format-check, make lint, make typecheck and make test-unit pass; the integration suite passes if server behaviour changed.
  • Generated files are regenerated in this PR, not by hand: the SDK op tables, docs/reference/configuration.md and the docs/reference/ tables (python scripts/codegen/docs_reference.py), the reach manifest, schemas/schema.sql (make schema-dump) and the Codex plugin copies (python3 scripts/codegen/agent_plugin_sync.py).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited.
  • A behaviour change to any file a plugin ships (hooks/, lib/, bin/, skills/, .mcp.json, the Codex plugin-defaults.json) bumps both plugin manifests' version, and no other open PR uses that version.
  • The frontend builds (npm --prefix frontend run build) and its tests pass, if frontend/ changed.
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.

🤖 Generated with Claude Code

@zlareb1
zlareb1 force-pushed the feat/repository-card-sources branch 2 times, most recently from fff76d4 to f992677 Compare November 4, 2026 02:21
zlareb1 and others added 5 commits November 4, 2026 02:28
An opened repository card gets a Sources facet after Docs: each source on
the docs namespace with its kind, last sync badge, times and counts, read
once with knowledge.source.list. The namespace's admin gets Add a source
(a dry-run check first), Check, Sync now, Rotate credential and Retire,
each a lazy dialog. The credential is a password field, never shown back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…log tests

The file kinds keep their option order, so unticking and ticking one again
matches the checked form. The retire toast counts its documents and says
they wait while sync is off. Closing the Check dialog aborts its probe.
Tests cover rotate, check and sync now, the facet's refused, error and
failed-row states, and that no page text or toast carries the key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
@zlareb1
zlareb1 force-pushed the feat/repository-card-sources branch from f992677 to d783172 Compare November 4, 2026 02:39
zlareb1 and others added 2 commits November 4, 2026 02:45
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant