Skip to content

Draft list: a stale tab writes its old metadata.releases back #8569

In review

Description

@thalesvf

What happens

A project's draft list (metadata.releases on the virtual MCP) is written whole by whichever tab acts last, from that tab's cached copy. A tab opened before another change writes its old list back, so:

  • drafts that were discarded come back (pointing at branches that no longer exist), and
  • drafts other people created in the meantime disappear from the list (their branch stays, unlisted).

Seen on a production project: 23 discarded drafts were removed; hours later two editors created drafts from tabs opened before the removal, and the list went back to 25 entries, 18 of them on deleted branches. A draft another editor had created in between was no longer listed.

Why

useReleases().write (apps/web/src/components/thread/repository/use-releases.ts) reads the list from the tab's react-query cache (readCacheReleases), applies the edit and sends the full array. COLLECTION_VIRTUAL_MCP_UPDATE merges metadata shallowly, so releases is replaced as sent. The comment there covers two writers in the same tab (serialized with runSerializedTask); writers in different tabs or by different people are not coordinated, and the last write wins.

Suggested fix

Apply release edits on the server against the stored list instead of sending the array: e.g. RELEASE_CREATE / RELEASE_DELETE / RELEASE_RENAME operations that read and update metadata.releases in one transaction. A smaller step: compare-and-swap on the entity's updated_at and, on conflict, refetch and reapply the reducer.

How to reproduce

  1. Open a project's Site Editor in tab A.
  2. In tab B, discard a draft (or remove entries from metadata.releases).
  3. In tab A, without reloading, create a new draft.
  4. The discarded draft is back in the list.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions