Repository navigation
Conversation
…t write its old list back `useReleases().write` sent the whole `metadata.releases` array from the tab's cache, and the update tool replaced it as sent. A tab opened before another change wrote its old list back: discarded drafts returned and drafts created meanwhile disappeared. - VIRTUAL_MCP_RELEASE_EDIT applies one edit (add, add pull request, rename, remove, mark sandbox) to the stored list under a row lock and writes only that key, so concurrent edits compose. - A whole-metadata update keeps the stored `releases`; the list changes only through the new tool. - The edit reducers move to `@decocms/shared/release-edits`; the web applies the same edit optimistically and then takes the server's list. Closes #8569 Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
What is this contribution about?
Closes #8569.
A project's draft list (
metadata.releases) was written whole by whichever tab acted last.useReleases().writeread the list from the tab's cache, applied the edit and sent the full array, andCOLLECTION_VIRTUAL_MCP_UPDATEreplacedreleasesas sent. A tab opened before another change wrote its old list back: discarded drafts returned (on deleted branches) and drafts other people created in the meantime disappeared from the list.VIRTUAL_MCP_RELEASE_EDITapplies one edit (add,add-pull-request,rename,remove,mark-sandbox) to the stored list.VirtualMCPStorage.editReleasesreads the rowFOR UPDATE, applies the edit and writes only thereleaseskey, so concurrent edits from other tabs or people compose. It checksRELEASES_MAXagainst the stored list and fails closed on malformed stored metadata instead of overwriting it. Access matchesCOLLECTION_VIRTUAL_MCP_UPDATE: sameagents:managepermission, organization and project-scope checks.releases.VirtualMCPStorage.updatenow keeps the row's current list in the same statement. That also closes the other paths that sent an old copy: settings forms that resend the full metadata,VIRTUAL_MCP_PINNED_VIEWS_UPDATE, and the read at the top of the update tool.@decocms/shared/release-edits. The web applies the same edit to its cache optimistically, then takes the list the server returns.Behavior change:
releasessent throughCOLLECTION_VIRTUAL_MCP_UPDATEis now ignored; the field's description points to the new tool.Not in this PR: pushing the list to other open tabs (they still show their old copy until the next refetch, but can no longer write it back), and cleaning up entries that already point at deleted branches.
How did you verify your code works?
apps/api/src/storage/virtual-patch-metadata.integration.test.tsagainst Postgres 16 (afterbun run --cwd=apps/api migrate): two new tests. ConcurrenteditReleasescalls (remove + add) both land, and a whole-metadataupdatewith a stale list, and withmetadata: null, keeps the stored list. Both fail without the storage change.virtual.integration.test.tsandstudio-pack.integration.test.tsalso pass.release-edits.test.ts(17 tests) now imports the reducers from@decocms/shared/release-edits.tsc --noEmitpasses inapps/api,apps/webandpackages/shared;bun run fmt,lintandknipare clean.tool-io.tswas regenerated withgenerate:tool-contracts.apps/api/src/storage,apps/api/src/tools/virtual,apps/web/src/components/thread/repository,packages/shared/src) pass: 1552 pass, 0 fail, the same asmain. The fullbun run testhung locally onENFILE(the machine ran out of open files), so CI runs the whole suite.Screenshots/Demonstration
No visual change.
How to Test
Migration Notes
None. No schema change.
Review Checklist
releasessent throughCOLLECTION_VIRTUAL_MCP_UPDATEis now ignored)🤖 Generated with Claude Code
Summary by cubic
Fixes draft list edits racing across tabs: a stale tab could write its old
metadata.releasesarray back, resurrecting discarded drafts and hiding drafts other tabs created. Edits are now applied to the stored list on the server, and whole-metadata writes keep the stored list.VIRTUAL_MCP_RELEASE_EDITtool applies one edit (add, add pull request, rename, remove, mark-sandbox) to the stored list under a row lock, so concurrent edits from other tabs or people compose.@decocms/shared/release-edits; the web applies the same edit to its cache optimistically, then takes the list the server returns.releasessent viaCOLLECTION_VIRTUAL_MCP_UPDATEis now ignored; the field's description points to the new tool.Not in this PR: pushing the list to other open tabs (they still show their old copy until the next refetch, but can no longer write it back), and cleaning up entries that already point at deleted branches.
Written for commit 8204c3b. Summary will update on new commits.