Skip to content

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

Description

@viktormarinho

Summary

When the user opens the CMS tab from the preview surface before the sandbox pod has finished booting and written its `previewUrl` into the inset entity's `sandboxMap`, the SectionsEditor side panel never mounts. A hard page refresh resolves it because the entity gets re-fetched and the map is populated.

Where it lives

`apps/mesh/src/web/components/sandbox/preview/preview.tsx:808` — the SectionsEditor is gated on:

```tsx
{sectionsOpen && previewUrl && branch && virtualMcpId && (...)}
```

`previewUrl` is derived from `inset?.entity?.metadata?.sandboxMap[userId][branch]`. On the first open of a branch / VM, that slot can be empty for a few seconds while the pod is booting.

Likely fix

When `useSandboxEvents()`'s `lifecycle.phase` transitions to `running` (or specifically when a fresh `sandboxMap` entry is written to the entity), invalidate the React-Query key feeding `useInsetContext` so `previewUrl` re-resolves without a manual page refresh.

Repro

  1. Open a virtual MCP from a cold start (no recently-booted pod).
  2. Immediately switch the preview to the CMS tab.
  3. SectionsEditor panel area shows the loading spinner (or nothing) and stays there.
  4. Hard refresh → editor mounts correctly.

Scope note

Surfaced while testing the sections-editor file picker work (#3469). Filing as a follow-up so that PR can stay focused on the picker.

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