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
- Open a virtual MCP from a cold start (no recently-booted pod).
- Immediately switch the preview to the CMS tab.
- SectionsEditor panel area shows the loading spinner (or nothing) and stays there.
- 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.
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
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.