feat(review): comment and suggest edits on the live article, Google Docs style
Adds an optional review mode to Spaces built from the template, so reviewers can comment on the live article instead of in a separate doc.
For reviewers (open the article with ?review and sign in with Hugging Face):
- comment on selected text or on a figure; reply, react, edit, delete, resolve/reopen, copy a link to a comment;
- suggest deleting text or replacing it, shown inline as strikethrough / inserted text; the Space owner accepts or rejects;
- comments sit as cards in the margin next to their text, on a layer above the page, plus a Comments panel (open / resolved / detached). Narrow screens use the panel only.
Published page is unaffected. The layer only loads with ?review, and the API returns 404 unless the REVIEW_MODE Space variable is on. Only the Space owner and usernames in REVIEWERS can read or write.
Storage. One JSON file per thread on a storage bucket mounted at /data. The server refuses to save if /data isn't a mounted volume, so comments are never silently lost on restart, and it falls back to in-place writes where the mount doesn't support rename. review/pull_comments.py exports every thread to a markdown summary through an owner-only endpoint (authenticated with the owner's HF token).
How it's wired: a small FastAPI app (review/server.py) runs next to nginx on 127.0.0.1:7861, proxied at /api/review/ and /oauth/; sign-in uses huggingface_hub's OAuth helpers. The Astro dev server proxies the same paths, so it works locally too.
Setup (documented in the README and in .ai/skills/review-mode/SKILL.md): hf_oauth: true in the README metadata, a private bucket mounted at /data (Space settings โ Storage Buckets, read & write), and the REVIEW_MODE / REVIEWERS variables.
Tested on the demo article (sign-in, text and figure comments, suggestions, resolve) and in use on a multi-chapter article Space with a bucket mount.
Same change on GitHub: https://github.com/tfrere/research-article-template/pull/2