promote FableLoom intent transitions to per-edge sub-resource routes - #4802
Merged
Conversation
…ther (#4786) Adding one intent transition meant PATCHing the node with the whole `transitions` array, so a second writer working from a stale snapshot dropped every row it had never seen — and the editor had to reconcile server-minted ids back into its locally-added rows after each save. Transitions are now sub-resources under their scene, mirroring the node routes: POST mints the `tr-*` id and answers `{ loom, transition }`, PATCH and DELETE address one edge by id and answer with the loom. The whole-array key on the node PATCH keeps working unchanged, so a client or peer from before these routes is unaffected. The scene editor creates a path server-side first, so every row it holds already carries its id; blur-saves, the target select, and remove each touch exactly one edge, and the id re-sync workaround is gone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/fableloom/:id/episodes/:episodeId/nodes/:nodeId/transitions→{ loom, transition }(server mints thetr-*id)PATCH …/transitions/:transitionId→ the loomDELETE …/transitions/:transitionId→ the loomtransitionskey on the node PATCH is unchanged, so a client or federated peer from before these routes keeps working. No on-disk shape change, so no migration and no sync-payload version bump.syncTransitionsFrom, the re-sync that pushed server-minted ids back into locally-added rows after each save, is gone. Blur-saves, the target select, and remove each touch exactly one edge.runSavecollapses the pending-save / error-toast plumbing shared by every write in the panel; a failed delete restores the row from the record instead of leaving a path that only looks gone; a blurred row with no matching record row now saves rather than silently dropping the edit (absent ≠ unchanged).transitionCreateSchema/transitionPatchSchema) derive their caps fromLOOM_LIMITS, andaddNodeTransitionrefuses to exceedTRANSITIONS_MAXwith400 LIMIT_REACHED.Closes #4786
Test plan
server: full Vitest suite green (1563 files). New coverage inserver/services/fableLoom/records.test.js(mint + read back the row, siblings untouched on add/delete, partial patch keeps the id and unlisted fields, 404 on an unknown id, the cap) andserver/routes/fableLoom.test.js(dispatch args for all three routes,idin a POST body is stripped rather than honored, and the whole-array node PATCH still forwards untouched).client: full Vitest suite green (727 files). Newclient/src/components/fableloom/LoomNodeEditor.test.jsxasserts the add path goes throughaddLoomTransitionand neverupdateLoomNode, a blurred edit PATCHes one row by id, an unchanged blur skips the round-trip, and remove DELETEs by id.apiFableLoom.test.jscovers path building and segment encoding.node scripts/run-ci-lint.jsclean.