Skip to content

The dashboard uploads a file for the server's extractor and follows its ingest job - #283

Merged
zlareb1 merged 15 commits into
mainfrom
feat/dashboard-ingest-files
Nov 6, 2026
Merged

zlareb1 merged 15 commits into
mainfrom
feat/dashboard-ingest-files

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Related: #157

Changelog category (leave one):

  • Improvement

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):

The dashboard's Library and a repository's documents add a file by uploading it for the server's extractor and following its ingest job to the revision it publishes. Each file is badged beforehand with the format this deployment reads it as, or refused when no extractor reads it; the browser no longer parses PDFs or Word files.

Why

The issue's plan has the dashboard upload originals and call knowledge.ingest, with progress, capability badges, and browser extraction as a preview at most. The Library's add dialog and the repository docs dialog still did the extraction themselves:

  • pdf.js for PDFs and mammoth for .docx;
  • the text posted through knowledge.upsert, with the original as base64 in the JSON body.

A file added from the dashboard therefore got the browser's text, not the extractor's sections, tables, locators and coverage. It also capped files at 25 MB and read no other format (no .pptx, .xlsx, SQL or TOML structure). #282 lets the server say which formats a deployment reads (knowledge.formats); this PR uses it.

Design

  • API (frontend/src/api.ts, api/knowledge.ts):

    • postFile sends a File as the raw body (application/octet-stream) on the same request path as every call: the token, the inflight counter and the typed errors.
    • New calls: uploadKnowledgeFile (/v1/knowledge.upload), ingestKnowledge, knowledgeIngestStatus and knowledgeFormats. A server that predates knowledge.formats answers 404, which reads as "not listed" (null).
    • addKnowledge loses its original-bytes options. Pasted text has no original.
  • Helpers (frontend/src/lib/fileIngest.ts):

    • fileVerdict names the format a file is read as, as the server's format_of does: its extension, then its media type, then the default. It refuses a legacy Office name, an empty file, a file over max_upload_bytes, or a format no extractor reads (available: false): each is what the upload or the ingest would refuse. An extractor that could not be asked (available: null) refuses nothing: the badge says so, and an ingest sent waits for it.
    • ingestFile uploads, ingests and polls knowledge.ingest_status until the job ends, reporting each step in words (ingestStep): queued, extracting, embedding, publishing, then ready with its revision and chunks, partial, or failed with its code.
    • Its signal bounds the upload alone, so a large file is not cut off at the client's default 60 s request bound. It also stops the following: the loop checks it before and after each poll. Each poll keeps the default bound. ingestClock.sleep is the one pause between polls (1 s), which tests replace. A failed poll (a replica restarting, a rate limit, a dropped connection) is tried again; after three in a row it throws FollowLost. The job is queued and goes on, so both dialogs then close saying it goes on, with the same message closing gives (one per dialog; for a replaced document it names its new revision), instead of offering to send the file again; neither reloads the list then, since nothing has published yet.
  • Components (frontend/src/flows/FileIngest.tsx):

    • useKnowledgeFormats reads the formats when a dialog opens.
    • PickedFile shows the file's name and size with its format badge: success, danger ("not read here") or neutral ("extractor not answering").
    • AllowPartial is the allow_partial checkbox.
    • IngestProgress is a polite live region.
    • The file picker sets no accept: a name no format claims is read as the default format (.json, .yaml, .xml, a file with no extension), and an extractor that is not answering refuses nothing. fileVerdict says what will happen instead.
  • Library dialog (AddDocumentDialog):

    • Two tabs, "Upload a file" and "Paste text"; replace mode keeps its locked source_uri, so a file becomes the document's next revision.
    • The run has three phases (IngestPhase). While the bytes upload, Cancel cancels the upload: nothing is queued yet, and a stalled upload cannot lock the dialog. The knowledge.ingest call, which may queue the job and keeps the default request bound, holds the dialog (Cancel disabled, Escape and outside clicks refused). Once the job is followed the dialog can close; closing (or leaving the page) stops the following, and the toast says the document is in the Library once it publishes and the list is reloaded. While busy the form is frozen: the address fields, allow-partial, the tabs and the paste text.
    • A partial publish says so in its toast, with what the coverage lost; a failed job keeps the dialog open with its reason and code, said once in the alert.
  • Repository docs dialog (RepoDocAddDialog):

    • The same file path, with its own signal, aborted when the dialog closes. As in the Library dialog, Cancel cancels a pending upload, the ingest call holds the dialog (its Cancel disabled), and once the job is followed the button reads Close and closing toasts that the job goes on. While busy, a dropped file is ignored and the address fields (title, description; in the Library also the source URI and tags) are disabled, so the screen keeps naming the file and address the job has. Its errors go through humanizeError, so a dropped connection reads as the lost-connection sentence (the work may have committed) in file and paste mode alike.
    • The ingest is sent with expected_revision: 0. The address is made free against the documents the card listed (its first 20); one another document holds past those fails revision_conflict, shown in the dialog, instead of publishing over it. That matches the paste path's knowledge.add, which refuses a taken address.
    • A partial publish says so in the card's toast, with what was lost (onAdded(title, lost)). Paste stays a text write.
  • Removed:

    • browser extraction (extractPdfText, extractDocxText, readDocumentFile, base64);
    • the pdfjs-dist and mammoth dependencies and their module declarations;
    • the raised chunk-size warning that existed only for them.

    lib/docFiles.ts keeps slugify.

  • Errors: the upload's own refusals, PAYLOAD_TOO_LARGE (413) and UNSUPPORTED_FILE (415), get sentences ("Too large:", "This file type is not read:") for when the formats could not be read first or a proxy caps the body lower.

  • Copy and docs: the empty Library's line says the server extracts the file; the Library row of docs/features/dashboard.md says how a file is added.

Alternatives considered:

  • Keeping the browser's extraction as a preview of the text before upload. The text shown would not be the text stored: the extractor's blocks, tables and coverage differ. Once the ingest publishes, the Library shows the stored text.
  • Waiting for the job in the background with a toast only. A person adding a file wants to know it was read or why it was not, so the dialog follows the job; it can still be closed.

Scope and risk

  • Dashboard only, plus the reach manifest, which counts the dashboard's new calls.
  • Uploads need an extractor. A deployment with no extractor configured shows every format "not read here" and refuses the file; pasted text still works.
  • The bundle shrinks: pdf.js, its worker and mammoth are gone. The bundle budget passes.

Compatibility, rollout and rollback

  • Older server: against a server that predates knowledge.formats the badge is absent and nothing is refused before sending; the job's own failure is shown.
  • Rolling upgrade: a build N-1 replica answers the upload and ingest ops already (they predate this PR).
  • Rollback: reverting restores browser extraction.

Tests

  • Unit, frontend/src/lib/fileIngest.test.ts:
    • the format by extension, media type and default;
    • the refusals: legacy name, empty file, size, no extractor;
    • an unknown availability refused nothing, and no formats listed means no guess;
    • the words for each job state and stage (one chunk is "1 chunk");
    • upload, ingest and polls in order, each step reported;
    • an abort stops the following, each poll sent with no signal of its own;
    • a failed poll is tried again, misses with a success between them do not add up, and three in a row throw FollowLost naming the job.
  • Unit, frontend/src/api/knowledge.test.ts: the upload sends the File as the body, application/octet-stream, its name and type in the query; expected_revision is sent only when set; a 404 from knowledge.formats reads as nothing listed.
  • Unit, frontend/src/flows/AddDocumentDialog.test.tsx:
    • a PDF is badged, uploaded as its bytes, ingested with its title and followed until it publishes, with no extracted text offered;
    • a .pptx no extractor reads is refused before anything is sent;
    • a failed job keeps the dialog open with its reason;
    • a partial publish says so, with what was lost;
    • closing while following stops the polls, the job left to the server;
    • polls that keep failing close the dialog saying the job goes on, the file sent once and the list not reloaded;
    • a pending upload can be cancelled (nothing ingested after it lands), its fields frozen; the ingest call holds the dialog against Cancel and Escape;
    • replace mode publishes the file under its locked address and title, toasting the revision, and says the new revision shows when it stops following;
    • pasted text is a text write.
  • Unit, frontend/src/views/RepoDocs.test.tsx: a writer's file is uploaded and ingested under the address made from its name, with expected_revision: 0; a file whose address another document holds is refused with revision_conflict's reason; a partial publish's toast names what was lost; closing while following toasts and stops the polls; a dropped connection shows the lost-connection sentence in file and paste mode; a pending upload's title is frozen and a dropped file ignored, and the ingest call holds the dialog; Cancel during the upload closes the dialog and ingests nothing once the bytes land; polls that keep failing close it saying the job goes on, the list not reloaded; a format no extractor reads is refused before anything is sent; the suite resets every mock it uses before each test; the paste test still passes.
  • Unit, frontend/src/lib/format.test.ts: the upload's two refusal codes are worded.
  • npm --prefix frontend run test (1,888), run build, run budget, and the Playwright suite (E2E_PORT=… npm --prefix frontend run e2e, 495 passed) pass.
  • Full unit suite: run on the rebased head before the merge.

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 dialogs against the server's upload, ingest and formats ops in the tests above, the Playwright suite, and a review at every push.

  • 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 and others added 15 commits November 6, 2026 05:44
…ts ingest job

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]>
…osing stops the following; the picker hides nothing the server reads

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…goes on; a failure is said once

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…alog's address and file stay put

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…busy form is frozen

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…mments say the cancellable upload

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…said to go on, not offered again

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…ds nothing; the miss count resets

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
… follow is tested not to reload

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: zlareb1 <[email protected]>
…elds; replace mode and the card's refusal are tested

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]>
@zlareb1
zlareb1 merged commit 3c09eef into main Nov 6, 2026
21 of 24 checks passed
@zlareb1
zlareb1 deleted the feat/dashboard-ingest-files branch November 6, 2026 07:22
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