Marginalia
A collaborative writing surface where the AI co-editor docks beside the draft — rewrite, grammar, and brief stay in the margin so the article never disappears under a modal.

Click to expandClick to collapse
Marginalia pipeline: Shared Yjs doc → Long-poll sync → TipTap surface → Grammar + rewrite → Docked AI panel → Model tier
What it is
Most AI writing UIs treat the assistant as a takeover: a sheet, a blur, a full-screen chat that asks you to dismiss the draft to finish a thought. Marginalia starts from the opposite question — if you opened help to work on a sentence, why would you want that sentence covered? The assistant lives in the margin; the document stays first-class.
What I built
A TipTap + Yjs editor with long-poll sync, locked/editing modes, passive grammar underlines, selection rewrites, thesaurus and block reorder, plus a docked writing assistant with Assist / History / Brief views and Fast / Mid / Advanced model tiers through the AI Gateway.
Why it was hard
The hard part was not calling a model — it was keeping assistive chrome useful without stealing the page. Large tools had to push the editor aside; micro-tasks (word rewrite, grammar) could float small near the selection, but never as a second full assistant with a blur scrim.
Metrics
Prototype on manglekuo.com/marginalia: in-memory CRDT sync, docked AI panel that keeps the draft readable, model-tier routing for complete / suggest / stitch / task.
▸Implementation notes
- Named the product after the design rule: assistive UI is marginalia — present, useful, and never covering the text it comments on.
- Seeded a deliberately imperfect client email so grammar, rewrite, and the writing brief have something real to press against on first load.
- Split AI work into parallel tasks with serialized document applies, so tone / shorten / review passes can run without stomping each other mid-edit.
- Used Yjs over long-poll rather than WebSockets so the prototype stays deployable as ordinary serverless routes; offline edits merge on reconnect without a conflict UI.
- Exposed Fast / Mid / Advanced tiers that map each task (complete, suggest, stitch, ai-task) to different Gateway models — latency when drafting, stronger models when revising.
