Commit History
18 days ago
-
fix(backend): require edit access for uploads
POST /api/upload had no auth check: anyone could push files to the HF dataset with the Space owner's token, and any cookie value was cached as the storage token. It now goes through requireEditor (after the per-IP rate limit, before the body is buffered), accepts PNG, JPEG, GIF, WebP and AVIF only (detected from the bytes, SVG refused) and answers 413 past 10 MB. requireEditor now tells apart 401 (no or invalid session) from 403 (signed in without write access). The citation routes, which fetch DOIs and URLs on the server, use it too. Co-authored-by: Cursor <cursoragent@cursor.com>7d7ba1b
20 days ago
-
feat(mcp): chart and publish tools, structured errors, JSON 404s
- Chart tools for external agents: create_embed (contract validation, data files, version 1, rendering check), insert_embed (after a block with expected_rev, caption, also in apply_edits), update_embed (html, patch or config values, expected_version, Studio draft guard), restore_embed_version, get_embed, list_embeds, check_embed. Every write is a version attributed to the agent; session undo and "Undo its changes" also revert charts. - publish and get_publish_status run the Publish button's flow (now a shared publish service): idempotent while a publish runs, absolute URLs, agent-attributed version. get_article_info states that a Space hosts a single article. - Errors carry a stable code and details in structuredContent (rev_conflict, version_conflict, draft_in_progress, invalid_embed...). - Unknown /.well-known, /mcp and /api paths answer a JSON 404 instead of the editor page, so MCP OAuth discovery falls back to the bearer token. - One headless Chromium job at a…2525af6 -
feat(embed-studio): tweak panel, inspect, automatic check, launcher, inline edit
- Tweak panel: embeds declare 2 to 6 settings in a data-embed-config JSON block (contract + agent prompt updated, runtime 1.2.0 exposes them as ctx.config and applies embedConfig messages live). Sliders, colors, selects, toggles and text update the preview instantly with no model call and are saved back as "manual tweak" versions. - Inspect: a point-and-click inspector in the studio preview; the picked element becomes an @this pointer for the next message, and a label held by a text setting can be edited without the AI. - Automatic check after each iteration: POST /api/embed-check renders the chart in headless Chromium (light/dark, 360/680 px, CDN-only network, one at a time) with the embed checker, now in src/embed-check, and the studio shows "N checks passed, 1 warning [Fix]". - Launcher for new figures (description, CSV drop, 4 gallery starters from GET /api/embed-starters, existing charts) from the top bar and the slash menu, instead of opening a random chart.…4953bfd -
feat(embed-studio): drafts with Apply to article, compare, data drawer
- The studio edits a shared draft (Y.Map("embed-drafts")); the article keeps the applied chart until "Apply to article". New charts from the slash menu or the top bar get their node only on Apply, at the cursor position kept as a Yjs relative position: no more empty nodes. - Closing with unapplied changes offers apply, keep draft or discard; the node shows "X is editing this chart" (awareness) or "Unapplied draft by X". Charts already in the article are not renamed. - Before/after compare reuses the two preview iframes side by side, with a line diff in the Code tab. - Docked data drawer with typed columns and a "used by this chart" flag; files dropped on the chat and tables pasted into it become data files attached to the next message. - "Writing chart... N lines" while the tool input streams. - The conversation of each chart is shared in Y.Map("embed-chats") (readable text only) instead of localStorage. Co-authored-by: Cursor <cursoragent@cursor.com>f7733a1 -
feat(embed-studio): error loop, versions, chips and preview controls
- Preview errors reach the agent: a studio-only reporter in the srcdoc relays uncaught errors, rejections, failed loads and embed:error to the parent; the studio shows "The chart threw ... [Fix it]" and sends one automatic fix per user message. - Versions per agent turn in Y.Map("embed-versions") (shared, capped at 20): vN / Restore / Compare under each reply, Undo last change; restore appends a copy so history stays linear. - Starter and follow-up prompt chips, preview width presets (Article, Wide, 360) and a local light/dark toggle pushed with setTheme. - The agent's title and source land on the node; Shiki code view with Copy and Download. - Provider errors keep their HTTP status; 401/402/429 become actionable messages with Retry; model name in the header; Done replaces Save & Close; no more fake "Generating chart..." banner. - Minimal mobile layout: files drawer and Chat / Preview tabs under 900px. Co-authored-by: Cursor <cursoragent@cursor.com>461e15a -
test(load): add a load test with simulated users, MCP agents and chaos
npm run test:load runs a real server on the fake Hub (production push timings) with users in child processes typing keystroke by keystroke, churn (wifi drops, sleeping laptops, reloads), MCP agents, a 15k-word article and optional HF outage + deploy on a wiped disk. It reports propagation latency, server CPU/RSS, HTTP and agent latency, Hub pushes, then checks that nothing was lost or diverged on any tab, in the cloud copy and on a fresh container. The scenario harness gains realTimings, wrap, env, nodeArgs, pid, errorLines and a bounded log buffer; Tab.open accepts any { port }. Documented in TESTS.md section 2.6 with results on an M1 Pro. Co-authored-by: Cursor <cursoragent@cursor.com>20d64bc -
fix(persistence): save during non-stop editing and before a document unloads
- The Database store hook now flushes the pending debounced save. Hocuspocus runs it at most every 10 s while editing goes on and right before unloading a document, so saves no longer wait for a 2 s pause and a reconnect right after the last writer left no longer reloads a stale disk copy. - debouncedSave writes the previous Y.Doc's pending state at once when a reloaded document (new instance) comes in. - HF pushes wait at most 3x their debounce, so continuous saves cannot postpone the upload forever. - Drop the per-change "[persist] onChange" log line. - Regression scenarios 2.5.20 / 2.5.21; unit tests for flushSave and the reload case, and 2.1.3 now edits one document as in production. Co-authored-by: Cursor <cursoragent@cursor.com>fb274d8 -
fix(storage): merge with the stored copy on push, retry failed loads; add HF storage scenarios
- Pushes merge the CRDT state with the bucket/dataset copy first, so two servers on the same storage no longer erase each other's edits. - A failed document load closes the socket (1013) so every client, including stale tabs on old bundles, reconnects and retries instead of staying stuck on permission-denied. - Create the dataset before writing live-store.json on a new Space. - HF_PUSH_DEBOUNCE_MS / HF_PUSH_RETRY_MS overrides for scenarios. - Scenario harness gains a fault-injecting fake Hub (Node loader hook over @huggingface/hub) and wiped-disk rebuilds; 8 cloud scenarios. Co-authored-by: Cursor <cursoragent@cursor.com>9261492 -
feat(safety): rescue text removed by someone else's change, with real-life scenario tests
Deleting a paragraph in Yjs deletes everything inside it, so an agent revert, a version restore, a stale tab's delete or offline edits into a paragraph removed meanwhile silently dropped other people's words. - The server copies text deleted by someone other than its author into the doc's "rescued" map (authorship learned per Yjs client from the authenticated connection and kept in the doc). - Each tab copies its own text when a remote change removes it, the only place text typed into an already-deleted paragraph still exists. - History panel lists removed text with Put back / Copy / Dismiss; the author gets a banner pointing there. - tests/scenarios: real server process, browser-equivalent tabs and a chaos proxy (freeze, offline, server death) covering stale tabs, deploys, crashes, offline work and bulk removals. Co-authored-by: Cursor <cursoragent@cursor.com>9175180
-
feat(storage): first-class data - no silent failures in the persistence pipeline
The "Saved" label in the top bar used to be a comforting lie: several failure modes (createRepo 403 on a missing manage-repos scope, writeFileSync on a readonly FS, uploadFile mid-debounce network blip) all collapsed into a console.error that the editor never surfaced. A user could type for an hour, see "Saved" the whole time, lose their tab, and discover only after the container rebuilt that nothing had ever made it to the dataset. Make every link in the chain observable, and make the worst signal always win in the UI. Backend ------- - In-memory `StorageStatus` tracker in hf-storage.ts: - `datasetReady` (createRepo succeeded or returned 409) - `lastLocalSaveAt` / `lastCloudPushAt` epoch ms - `pendingPush` (a debounce timer is armed) - `lastError {stage, message, statusCode, at, docName}` where `stage` is one of `dataset-create | local-save | cloud-push` Every write path records success; every error path records the failure. Success on one stage clears the error for …7a42df5 -
feat(storage): private dataset by default + /d/* reverse proxy
The dataset that backs persistence was being created `private: false` on every first write. For org-owned Spaces with strict data policies (notably `HuggingFaceBio/carbon-tokenization`) this could either silently fail (org blocks public dataset creation) or be flat-out wrong (working drafts of an internal research paper shouldn't be sitting on a public dataset). Flip the default to `private: true`. The complication this creates is that published articles' `<img>` tags, og:image and PDF download all pointed at `huggingface.co/datasets/.../resolve/...` URLs that would now 401 for anonymous viewers. Solve that with a small reverse-proxy route on the editor itself. - New `GET /d/:path*` handler streams from `huggingface.co/datasets/${id}/resolve/main/${path}` to the caller, attaching the right HF token along the way: 1. cookie token from the current request (most viewers are signed in on private Spaces anyway) 2. last-known cached user token (any signed-in request warm…c362999
-
feat(backend): rate-limit /api/upload to prevent anonymous abuse
Upload stays intentionally unauthenticated (covered by spec 4.1.3), so guard it with a simple per-IP sliding-window limiter (30 uploads / 60s). The limiter returns 429 with a Retry-After header and uses the X-Forwarded-For head when behind a proxy. Spec updated with the new 4.1.4 test line. Made-with: Cursor5576f9a
-
test: add vitest test suite for publisher, auth, security, utils
- Setup vitest with test helpers for Y.Doc fixtures - 34 tests across 6 files covering: - Publisher pipeline (extraction, HTML gen, post-processing, idempotency) - XSS prevention (licence, title, description, authors, DOI) - Auth (token extraction, OAuth config) - Utils (sanitizeName, docPath, path traversal) - CSS @custom-media resolution - HF Storage configuration Made-with: Cursor755a930