#1953·SurfSense

The sources panel cannot write a note or rename a document

Author: MODSetterCreated Sep 28, 2026Updated Oct 1, 2026
Labelsenhancementhelp wantedUIfrontenddesktop

The gap

docs/architecture/documents.md lists this under Known gaps:

The frontend has no way to write or edit a note, or to rename a document; the API routes exist.

Why it matters

Notes are one of the three kinds of source a workspace holds — the doc's first sentence says so — and there is no way to make one. The only way to get text into a workspace is to write it in another application, save it as a file and upload that. A note written in the app would be chunked, embedded and cited exactly like a PDF, which is the whole point of having the type.

Renaming is smaller but more visible: a document's title is whatever the uploaded filename was, it is what appears in the sources list, the Studio source picker and every citation, and it cannot be changed. report_final_v3 (2).pdf follows the user around forever.

Where

The API is done and needs no change: POST /workspaces/{id}/documents takes {title, content} and returns the note with its body, and PATCH /workspaces/{id}/documents/{doc} takes either field, with unset fields left alone.

What done looks like

  • A user can write a note, reopen it and edit it, and rename any document.
  • The hook's existing poll does the freshness work. Editing a note's content puts it back to pending server-side and re-enqueues ingest, so if the edited row lands in state the poll on hasActiveIngestion picks it up and runs it to ready on its own. Do not add a second refresh path.
  • Renaming sends only title. PATCH answers 409 for content on anything that is not a NOTE, because a file's text was extracted from bytes and an edit would vanish at the next ingest — so a rename control shared between files and notes must not send content along for the ride.
  • A title is 1 to 500 characters after trimming, and a name of spaces is refused rather than saved blank. Mirror that in the form so the user finds out before the request, but keep the server authoritative.
  • Everything new is reachable and labelled for a keyboard and a screen reader, including whatever opens the note editor.
  • Delete the Known gaps line from docs/architecture/documents.md in the same PR, and update the What is editable and Notes sections if what you build changes what they describe.

What not to change

The sources list asks for document_type=FILE&document_type=NOTE, which is what keeps Studio output from looking like something the user uploaded. An artifact's body is deliberately read-only — that is the server-side guard ADR 0003 asks for — while renaming and deleting an artifact stay allowed. If your rename control ends up anywhere near the artifact list, keep that split.

How to verify

surfsense_local/frontend/src/features/sources/source-upload.test.tsx shows how this panel is driven in a test, with the API mocked. Write the failing test first: write a note, assert it is created and appears in the list; rename a file, assert the title changes and no content is sent.

bash
cd surfsense_local/frontend
pnpm test
cd ../.. && python scripts/check_docs.py

Before you start

Read CONTRIBUTING.md and the documents doc. This adds interface strings, so follow the translate skill described in AGENTS.md and keep the key shape (en.json is generated from the code). React, colour and polish work follows frontend-workflow, and components in a tree with a components.json follow shadcn after it, not instead of it. This is frontend-only and changes no contract. Open your PR against dev, not main. Comment here to claim this.