Repository navigation
feat(canvas): keep flagged owners' new canvases in a Terse actor - #433
oliviersm199 wants to merge 5 commits into
Conversation
[High impact] The PR appears safe to merge, with a non-blocking cleanup issue in actor canvases' asset records. Findings
SummaryAdds per-user rollout of actor-held canvas frames while keeping the Doop server and room as the hub.
|
| function saveOnActor(f: Frame) { | ||
| saveActorFrame(f) | ||
| adoptActorFrame(f) |
There was a problem hiding this comment.
Deleted canvases keep asset records
Actor canvases now write asset_refs, but deleteCanvas still finds their frame IDs through the Postgres frames table. Actor-held frames have no rows there, so deleting the canvas leaves stale asset records until a restart. Pending assetRefTimers can also write records after deletion.
Remove the records using the deleted canvas's frame IDs and cancel those timers. This is a non-blocking bookkeeping issue; current asset serving is unaffected.
There was a problem hiding this comment.
Fixed in 431481e. destroyActorCanvas now returns the IDs of the frames its actor held, and deleteCanvas deletes their asset_refs by those IDs and cancels any ref writes still waiting on their debounce. main's Postgres path is unchanged. While in here: frames restored from an actor that missed the boot read now get their refs too, since the boot rebuild of asset_refs never saw them. Covered by drops a deleted canvas’s asset refs, which fails both without the deletion (kept survives) and without the timer cancel (pending is written after the canvas is gone).
…sign#433) * test(browser): bound every UI wait below the test timeout A wait that never comes true now fails on its own line with the condition it waited for, instead of the whole test timing out with only its title. DOOP_TEST_CPU_THROTTLE throttles the page's main thread for chasing a race locally. Plus a temporary flake-hunt workflow. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(browser): say what the page did when a link or focus wait never comes true Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(hunt): temporary trace of FrameView's probe paths Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(canvas): keep a cleared element pick cleared, focus prototype screens once they listen Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * test(hunt): drop the temporary FrameView trace Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * ci: drop the temporary flake-hunt workflow Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit e4f9f6c2c19f99ed92e31223e375fe49f6689016)
An A/B rollout of durable actors behind a per-user `canvas-actors` flag (`feature_flags` table, `bun run flags`). A canvas made or copied by a flagged owner is marked `frame_store = 'actor'` and saves its frames to its Terse CanvasActor where main writes the Postgres frames table. Everything else about it stays main's: the server holds it in memory, and pages, history, activity and the room are unchanged. Every other canvas runs main's code. The flag points are one-line checks in persist.ts, store.ts and api.updateFrame that only act on actor canvases, and with TERSE_ACTOR_URL unset the flags table is never read. - browsers on an actor canvas send plain frame edits straight to the actor; the server follows the actor's socket and folds them in without saving them back - existing canvases never move; `bun run flags move-back` copies an owner's actor canvases back into Postgres - terse-sdk and terse-cli 0.15.0; the app stays on zod 3 - a CI job runs the end-to-end test against a local actor runtime Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
- a confirmed actor delete is finished, instead of being resent forever; shutdown flushes actor and Postgres writes side by side - every access change (link access, canvas members, workspace moves and deletion, workspace member removal) revokes the actor's sockets, retried until the actor confirms; tickets read the access version before rights - browser HTML the server would complete (library fonts, tokens, escaped markup) is saved back completed, as through the app API - the browser bounds connect-and-confirm at 10s and fails only the edits of the socket that closed - boot follows an actor only after reading it, retries a missed snapshot until the store has the canvas, and sends restored frames to the room - a failed canvas or page copy takes its frames off the actor again - actor frames keep their asset_refs like any frame - `bun run flags` exits 1 on errors Co-authored-by: Cursor <cursoragent@cursor.com>
deleteCanvas finds a canvas's asset refs through its frames rows, which a canvas on an actor never has. Its refs now go by the IDs of the frames its actor held, and ref writes still waiting on their debounce are cancelled. Frames restored from an actor that missed the boot read also get their refs, which the boot rebuild of asset_refs could not see. Co-authored-by: Cursor <cursoragent@cursor.com>
server/actorFrames.ts imports generated/actors at load, but the final stage copied only server/ and shared/, so the container crashed on boot with ERR_MODULE_NOT_FOUND for /app/generated/actors/index.js. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
76f0d4c to
a6db473
Compare
…-6841) cheese/main carries its own flake fix (doop-design#433) and the ci-policy R1 push-trigger rule, so the #64 commits are dropped here and the test files take main's version. Smoke routes gain /api/agent-runners and /api/fonts and follow the new /api/model-account view.
An A/B rollout of Terse durable actors for a few people, behind a per-user
canvas-actorsflag. It replaces #187, which moved every canvas's frames off the server. This version keepsmain's architecture and changes only where a flagged canvas's frames are saved.Unflagged canvases run main's code
frame_store = 'actor':server/db/persist.ts: save, save-now, delete, copies, canvas delete, flush and boot loadplaceCanvasinstore.createCanvasandduplicateCanvasadoptedoption onactions.updateFrameapi.updateFrameon the clientrevokeActorAccesswhereverstoreandworkspaceschange who can open a canvasTERSE_ACTOR_URLunset, the default, no canvas is ever marked and the server never readsfeature_flags. If the flags read fails at boot, every flag stays off and the server still starts.bun run devandbun run testare unchanged. The edits tomain's existing files come to about 300 lines across 16 files, counting docs, CI and lint config. Everything else is in new files.zod3;terse-sdkbrings its ownzod4.How a flagged canvas works
canvases.frame_store = 'actor'when someone with the flag creates it, or when they copy any canvas. Existing canvases never move.CanvasActor(src/actor.ts) instead of theframestable. Pages, design history, activity, comments and the room stay wheremainkeeps them.z) straight to the actor over a WebSocket. The ticket comes fromGET /api/canvases/:id/actorand is read-only unless the person can edit. If the direct edit fails, it falls back to the app API. Page moves, sign-off and version-checked saves always go through the API.actions.updateFramewithadopted, which saves nothing back. HTML the server would complete (library fonts, tokens, escaped markup) goes through as an ordinary edit instead, so the completed HTML is saved back to the actor. So the room, history and activity see them as before, and older clients such as installed iOS apps get frames from the room as onmain.Turning it on and off
bun run flags enable canvas-actors <email>...(alsolistanddisable). The server re-reads the table every 30 seconds.disablestops new canvases from going to actors. Canvases already on an actor stay there.bun run flags move-back <email>...turns the flag off, copies those people's actor canvases into the Postgresframestable as the actor holds them, and clears the mark. Restart the server afterwards. Nothing else needs moving, since pages and history never left Postgres.Deploy
feature_flagsand a nullablecanvases.frame_store, with no backfill. It runs at boot.bunx terse-cli init), runbun run deploy:actors, and setTERSE_ACTOR_URLandTERSE_API_KEYon the server. The actor API's WebSocket endpoint has to be reachable from browsers. Then turn the flag on for the testers.bun run dev:actorsstarts Doop with a local actor runtime (Bun 1.4.2+).terse-sdkandterse-cli0.15.0.Validation
bun run test(main's suite, with Terse unset): 2,400 passed.secretBox.test.tsfails only on a checkout whose path contains a space, which is unrelated to this change.tests/canvasActors.test.ts, run against a local actor runtime: 11 passed. It covers:flags move-backtest-actors, runs the generated-client check and that test, and thetestsstatus now requires it..gitattributesmarks the generated actor client and the migration snapshots as generated, so GitHub collapses them. The hand-written diff is about 2.3k lines, including tests.