Skip to content

fix(sandbox): refetch the entity when the dev server comes up - #5317

Merged
pedrofrxncx merged 1 commit into
mainfrom
fix/sandbox-preview-url-refresh-race-w2
Jul 27, 2026
Merged

fix(sandbox): refetch the entity when the dev server comes up#5317
pedrofrxncx merged 1 commit into
mainfrom
fix/sandbox-preview-url-refresh-race-w2

Conversation

@pedrofrxncx

@pedrofrxncx pedrofrxncx commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Fixes #3482.

Payoff: the Sections-Editor/Content panel gets permanently stuck on a spinner on a cold-start open of a virtual MCP, requiring a hard page refresh — a first-run experience bug users hit constantly.

Root cause: previewUrl (which gates the CMS/Content panels — see sandbox-lifecycle-context.tsx's vmEntry?.previewUrl) is derived from the virtual MCP entity's sandboxMap, fetched via a useSuspenseQuery with a 60s staleTime and no live-push subscription. SANDBOX_START can resolve, and the SSE lifecycle can reach "running", before the pod has finished writing its previewUrl into that entity's sandboxMap — so on first open, nothing ever re-fetches the entity and previewUrl stays null until the user does a hard refresh (which re-fetches everything from scratch).

Fix: sandbox-events-context.tsx already invalidates the decofile/live-meta queries at the lifecycle.phase === "running" transition (the exact moment the dev server confirms up). This adds one more invalidation at that same point — the virtual-MCP collection-item query (via the existing invalidateVirtualMcpQueries helper) — so the entity refetches and previewUrl picks up the freshly-written sandboxMap entry without a manual reload.

Verify: bun run fmt and cd apps/web && bunx tsc --noEmit both pass. This is a live-SSE reactivity path (EventSource + entity cache) that isn't cheaply unit-testable without mocks the repo's testing rules disallow for the unit tier — full CI/e2e validates the rest; a reviewer can confirm by opening a virtual MCP from a cold start and immediately switching to the Content/CMS tab (repro steps in #3482) and observing it now self-heals instead of requiring a refresh.

Diff: +8/-1, one file, one concern.


Summary by cubic

Fixes a cold-start race that left the Sections-Editor/Content panel stuck on a spinner. When the dev server reports “running,” we now refetch the virtual MCP entity so previewUrl updates without a hard refresh.

  • Bug Fixes
    • On lifecycle.phase === "running", call invalidateVirtualMcpQueries to re-fetch the virtual MCP collection-item query and pick up the sandboxMap previewUrl.

Written for commit 23955cd. Summary will update on new commits.

Review in cubic

previewUrl (used to gate the CMS/Content panels) is derived from the
virtual MCP entity's sandboxMap, which is cached for 60s and only
refetched on explicit invalidation. SANDBOX_START can resolve, and the
SSE lifecycle can reach "running", before the pod has finished writing
previewUrl into sandboxMap — so on a cold-start open the entity query
never refetches and the panel is stuck until a hard page refresh.

Invalidate the virtual MCP collection-item query at the same point we
already invalidate the decofile/live-meta queries on the running
transition, so previewUrl picks up the freshly-written sandboxMap entry
without a manual reload.
@pedrofrxncx
pedrofrxncx enabled auto-merge (squash) July 27, 2026 23:27
@pedrofrxncx
pedrofrxncx merged commit 93d9e97 into main Jul 27, 2026
14 checks passed
@pedrofrxncx
pedrofrxncx deleted the fix/sandbox-preview-url-refresh-race-w2 branch July 27, 2026 23:38
decocms Bot pushed a commit that referenced this pull request Jul 27, 2026
PR: #5317 fix(sandbox): refetch the entity when the dev server comes up
Bump type: patch

- decocms (apps/api/package.json): 4.138.7 -> 4.138.8

Deploy-Scope: web
pedrofrxncx added a commit that referenced this pull request Jul 28, 2026
previewUrl (used to gate the CMS/Content panels) is derived from the
virtual MCP entity's sandboxMap, which is cached for 60s and only
refetched on explicit invalidation. SANDBOX_START can resolve, and the
SSE lifecycle can reach "running", before the pod has finished writing
previewUrl into sandboxMap — so on a cold-start open the entity query
never refetches and the panel is stuck until a hard page refresh.

Invalidate the virtual MCP collection-item query at the same point we
already invalidate the decofile/live-meta queries on the running
transition, so previewUrl picks up the freshly-written sandboxMap entry
without a manual reload.
pedrofrxncx pushed a commit that referenced this pull request Jul 28, 2026
PR: #5317 fix(sandbox): refetch the entity when the dev server comes up
Bump type: patch

- decocms (apps/api/package.json): 4.138.7 -> 4.138.8

Deploy-Scope: web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sections-editor tab requires page refresh on first open (sandboxMap race)

1 participant