Skip to content

[Website] Share concurrent OPFS autosave operations - #4140

Merged
adamziel merged 12 commits into
trunkfrom
adamziel/serialize-opfs-autosaves
Jul 21, 2026
Merged

[Website] Share concurrent OPFS autosave operations#4140
adamziel merged 12 commits into
trunkfrom
adamziel/serialize-opfs-autosaves

Conversation

@adamziel

Copy link
Copy Markdown
Collaborator

Shares one in-flight autosave operation between concurrent callers for the same Playground.

Before this PR, duplicate autosaveTemporarySite() calls ran the entire persistence pipeline twice: creating the pending OPFS record, copying the filesystem, updating metadata, and pruning old autosaves. PR #4136 serializes the final metadata writes; this follow-up prevents the duplicate pipeline in the first place.

The in-flight entry is removed after success or failure, so a later call can retry normally.

Testing

Start two autosaves for one temporary Playground at the same time. Confirm both callers complete with the same stored Playground and only one persistence operation runs.

Base automatically changed from adamziel/serialize-opfs-metadata-writes to trunk July 21, 2026 11:06
@adamziel
adamziel requested review from a team and zaerl July 21, 2026 11:06
@adamziel
adamziel force-pushed the adamziel/serialize-opfs-autosaves branch from fe6c6a3 to 552163d Compare July 21, 2026 11:06
Copilot AI review requested due to automatic review settings July 21, 2026 11:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Shares a single in-flight OPFS autosave operation across concurrent callers for the same temporary Playground, preventing duplicate persistence pipelines and consolidating routing/pruning behavior.

Changes:

  • Add per-store (per-dispatch) tracking of in-flight autosaves and reuse the same promise for concurrent callers.
  • Consolidate pruning exclusions and defer URL routing so it can run if any concurrent caller requests it.
  • Add Vitest coverage for shared autosave behavior and finalization timing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts Deduplicates concurrent autosave work via an in-flight map and consolidates routing/pruning behavior.
packages/playground/website/src/lib/state/redux/site-management-api-middleware.spec.ts Adds tests verifying autosave promise sharing, finalization waiting, and option aggregation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts Outdated
@adamziel
adamziel force-pushed the adamziel/serialize-opfs-autosaves branch 2 times, most recently from b4f51a6 to 32a3970 Compare July 21, 2026 12:51
@adamziel
adamziel force-pushed the adamziel/serialize-opfs-autosaves branch from 32a3970 to 8d0d5f4 Compare July 21, 2026 12:51
@adamziel
adamziel merged commit 0c1f679 into trunk Jul 21, 2026
102 of 103 checks passed
@adamziel
adamziel deleted the adamziel/serialize-opfs-autosaves branch July 21, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment