Tasks and notebook store the ProseMirror document body in document tables, not in the cached list/detail metadata. The editor runtime lives in @agata/rich-text; the HTTP contract is engine-neutral.
Why separate endpoints#
| Surface | Metadata (list/detail) | Body |
|---|---|---|
| Task | cacheable | GET/PUT …/document uncached |
| Note | cacheable | GET/PUT …/notes/:id/document uncached |
This way the editor always sees fresh content and does not remount because of detail invalidations.
Editor flow#
The server validates contentJson against schema version 1, increments version atomically when expectedVersion matches, and derives search text, excerpt, and counts. Clients must not send searchText or searchHtml.
Task document#
A stale expectedVersion returns HTTP 409 with code CONFLICT. A successful save returns schemaVersion and the incremented version.
Note document#
Create of a missing document starts at version 1. Updates require expectedVersion and increment exactly once.
Monorepo code#
apps/app/services/tasks/actions/get-task-document.tsapps/app/services/tasks/actions/update-task-document.tsapps/app/services/tasks/queries/get-task-document.tsapps/app/services/notebook/actions/get-note-document.tsapps/app/services/notebook/actions/update-note-document.tsapps/app/services/notebook/queries/fetch-note-document.ts
Anti-abuse limits#
| Limit | Task | Note |
|---|---|---|
| Characters (plain text) | 50,000 | 100,000 |
JSON payload (contentJson) | 400 KB | 800 KB |
Images per entity (task_images / note_images) | 20 | 20 |
Size per image (purpose image / attachment) | 5 MB | 5 MB |
Enforcement:
- API:
UpdateDocument/UpdateNoteDocumentvalidate schema, chars, and JSON size;AttachBlobcounts active rows and validates editor image size/type. - Client: character-count limit in
@agata/rich-text; the editor and the task gallery block uploads at the cap.
Constants: apps/api/internal/shared/limits/rich_text.go and #/shared/constants/rich-text-limits.
Code blocks#
@agata/rich-text highlights a subset of languages (js/ts/tsx, json, css, html, bash, markdown, python, sql, go). The node's language attribute still works when pasting or typing a fenced block with a language; highlighting is presentation-only in the editor.
Images#
Flow: private upload (Vercel Blob) → POST /api/blob/.../attachments → image node with:
src: dynamic relative URL/api/blob?pathname=…(Cache-Control: private, max-age=60;Vary: Cookie; no cache-busting)imageId: UUID of the row (task_images/note_images) returned asattachmentId— not the blob pathname
After attach (task/note):
- Yes:
updateTagof the entity detail (invalidateCache.taskDetail/ notebook equivalent) withrefresh: falsefor the next navigation - No:
refresh()— remounts the RSC and the editor flickers - Gallery: local
setImages(also when the image is inserted from the editor)
Anti-patterns#
- Seed the editor from cached
getTaskDetail updateTagof detail on every save keystrokerefresh()in document autosave (remounts the RSC and the editor flickers)refresh()when attaching or deleting a task/note image (useupdateTag+ local state)- Store
imageId= blob pathname (DELETE expects a UUID) - Omit
expectedVersionon concurrent writes - Send client-derived
searchTextorsearchHtml - Pass raw editor JSON to a Server Action — ProseMirror
attrsare null-prototype and are lost on serialize (images become{ "type": "image" }with nosrc). UseJSON.parse(JSON.stringify(content))(or the session-hook helper) before the action.