Skip to content

Add autosaved site lifecycle APIs#3674

Open
adamziel wants to merge 1 commit into
trunkfrom
feature/autosave-site-lifecycle-api
Open

Add autosaved site lifecycle APIs#3674
adamziel wants to merge 1 commit into
trunkfrom
feature/autosave-site-lifecycle-api

Conversation

@adamziel
Copy link
Copy Markdown
Collaborator

What it does

Adds the Redux lifecycle and management APIs for autosaved Playgrounds.

The site model can now distinguish temporary, autosaved, and explicitly saved
sites, track last-use metadata, and expose create/keep/discard behavior through
the site management API.

Rationale

The default autosave UI needs a consistent persistence model underneath it.
Keeping this API layer separate makes the behavior reviewable without mixing in
the browser chrome and overlay changes.

Implementation

Adds lifecycle helpers, slug generation, reducer coverage, client boot handling,
temporary-site persistence updates, and API middleware support for autosaved
sites.

This is stacked on feature/save-url-foundations because autosave restore logic
uses the setup URL fingerprint added there.

Testing instructions

npm exec nx run playground-website:typecheck
npm exec nx test playground-website --testFile=slice-sites.spec.ts

@adamziel adamziel force-pushed the feature/save-url-foundations branch from 0f8ad0e to 5607d06 Compare May 22, 2026 15:18
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch from 6d845e9 to 7175499 Compare May 22, 2026 15:18
@adamziel adamziel force-pushed the feature/save-url-foundations branch from 5607d06 to 2baf0e2 Compare May 22, 2026 15:34
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch from 7175499 to d13a74c Compare May 22, 2026 15:34
@adamziel adamziel force-pushed the feature/save-url-foundations branch from 2baf0e2 to aa15a20 Compare May 22, 2026 15:40
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch from d13a74c to 071c74c Compare May 22, 2026 15:40
@adamziel adamziel force-pushed the feature/save-url-foundations branch from aa15a20 to d906dee Compare May 22, 2026 15:49
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch from 071c74c to f0eaf10 Compare May 22, 2026 15:49
@adamziel adamziel force-pushed the feature/save-url-foundations branch 2 times, most recently from de0d683 to a349ef7 Compare May 22, 2026 16:22
Base automatically changed from feature/save-url-foundations to trunk May 22, 2026 16:41
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch from f0eaf10 to ca2c069 Compare May 22, 2026 16:46
@adamziel adamziel marked this pull request as ready for review May 22, 2026 16:47
@adamziel adamziel requested review from a team, ashfame and Copilot May 22, 2026 16:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

Adds a persistence/lifecycle layer for “autosaved” Playgrounds, enabling Redux and the Sites API to distinguish temporary vs stored sites, track recency, and prune old autosaves.

Changes:

  • Introduces site lifecycle utilities (autosave vs explicit, recency timestamps, autosave pruning).
  • Adds stored-site creation + autosave/keep flows to the Sites API and persistence pipeline.
  • Updates boot/persist logic to record last-used metadata and support background OPFS sync for fresh installs.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/playground/website/src/lib/state/redux/store.ts Adds updateUrl control when activating a site.
packages/playground/website/src/lib/state/redux/slice-sites.ts Adds stored-site creation, preserve/prune helpers, slug normalization, recency sorting, and metadata fields.
packages/playground/website/src/lib/state/redux/slice-sites.spec.ts Adds unit coverage for slug normalization and autosave lifecycle helpers.
packages/playground/website/src/lib/state/redux/slice-clients.ts Annotates OPFS sync state with operation type (save vs autosave).
packages/playground/website/src/lib/state/redux/site-slug.ts Adds slug normalization + collision-free slug generation helpers.
packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts Expands Sites API for autosave/keep/createSavedSite and URL update control.
packages/playground/website/src/lib/state/redux/site-lifecycle.ts New lifecycle helpers: recency, autosave detection, pruning selection.
packages/playground/website/src/lib/state/redux/persist-temporary-site.ts Adds autosave-aware persistence options, URL update control, and client-preserving saves.
packages/playground/website/src/lib/state/redux/boot-site-client.ts Tracks whenLastUsed, supports initial OPFS sync pending, and background sync progress reporting.
packages/playground/website/playwright/e2e/sites-api.spec.ts Adjusts e2e expectations for new storage outcomes and temp-site navigation.
Comments suppressed due to low confidence (1)

packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts:42

  • The API now exposes persistence, but it is typed as string, which weakens the contract for API consumers and makes it easy to return unsupported values. Since you already have SitePersistence ('autosave' | 'explicit'), type persistence as SitePersistence (and consider similarly narrowing storage to the known set including 'temporary').
export interface PlaygroundSitesAPI {

💡 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
Comment thread packages/playground/website/src/lib/state/redux/site-management-api-middleware.ts Outdated
Comment thread packages/playground/website/src/lib/state/redux/slice-sites.ts Outdated
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch 5 times, most recently from 5abb063 to 79dc611 Compare May 23, 2026 23:16
@adamziel adamziel force-pushed the feature/autosave-site-lifecycle-api branch from 79dc611 to 4b67318 Compare May 23, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants