Skip to content

editor: a failed scene load shows an error with retry, never an empty scene - #759

Merged
wass08 merged 1 commit into
mainfrom
fix/load-failure-autosave
Sep 2, 2026
Merged

editor: a failed scene load shows an error with retry, never an empty scene#759
wass08 merged 1 commit into
mainfrom
fix/load-failure-autosave

Conversation

@wass08

@wass08 wass08 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

A host onLoad that rejects (failed fetch, timeout) used to fall through to applySceneGraphToEditor(null), i.e. the default site/building/level scaffold. The autosave loop re-baselined its wipe guard on that cleared store, the next store touch (host-panel installedPlugins sync, a plugin tick) armed a save, and the scaffold was written over the real project.

Prod audit on the hosted editor, 2026-09-02: 10–100 such wipes per day; 11–13 % of forks and template starts opened over two weeks lost their copied scene on the first save (scene fetch p95 is ~20 s against a 3 × 8 s host timeout).

Now a failed load keeps the store unloaded and the autosave loop in its loading state, so nothing can be written, and renders a new SceneLoadFailed overlay whose "Try again" re-runs the load effect. A load that resolves null (a genuinely empty project) is unchanged.

Companion host-side PR in private-editor adds a server-side wipe guard and makes the host onLoad throw on a failed fetch.

How to test

  1. In a host (or the standalone app), make onLoad reject or hang past its timeout — e.g. stall the scene fetch in devtools.
  2. Expected: the loader is replaced by "This project couldn't be loaded" with a "Try again" button; no autosave fires (check the network tab / [autosave] console lines); the persisted scene is untouched.
  3. Restore the network and click "Try again": the scene loads normally.
  4. bun test packages/editor/src/hooks/use-auto-save.test.ts still passes; bun x tsgo --noEmit -p packages/editor/tsconfig.json is clean (needs a fresh core/viewer dist).

Verified end to end with a headless Playwright probe against the hosted editor on a local stack: stalled fetch → overlay, 0 autosave writes, DB row untouched → retry loads the scene.

Screenshots / screen recording

Overlay: centred "This project couldn't be loaded — Nothing was changed. Check your connection and try again." with a rounded "Try again" button over the editor shell. (Probe screenshot available on request; the dev build's component-outline overlay makes it noisy.)

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've updated relevant documentation (if applicable)
  • This PR targets the main branch

🤖 Generated with Claude Code

https://claude.ai/code/session_01DLB54VYmGTzvyHNFb3wWxE


Note

High Risk
Touches initial scene load and autosave gating—core persistence path where the prior behavior caused production scene wipes; the change reduces that risk but must behave correctly on every failure mode.

Overview
Failed host onLoad no longer falls back to the default scaffold, which could be autosaved over the real project. On rejection, the scene store stays unloaded, isLoadingSceneRef stays true so autosave does not run, and hasLoadedInitialScene is not set until a load succeeds.

The full-screen loader is replaced by a new SceneLoadFailed overlay (“This project couldn't be loaded” + Try again). Retry bumps sceneLoadAttempt to re-run the load effect. A resolved null (intentionally empty project) is unchanged.

Both v1 and v2 layouts use the same error-vs-loader branch.

Reviewed by Cursor Bugbot for commit be59897. Bugbot is set up for automated code reviews on this repo. Configure here.

…mpty scene

A host `onLoad` that rejects (failed fetch, timeout) used to fall through to
`applySceneGraphToEditor(null)`, i.e. the default site/building/level
scaffold. The autosave loop re-baselined on that cleared store, the next
store touch armed a save, and the scaffold was written over the real
project. Prod audit 2026-09-02: 10–100 such wipes per day; 11–13 % of forks
and template starts opened over two weeks lost their copied scene on the
first save.

Now a failed load keeps the store unloaded and the autosave loop in its
loading state (nothing can be written), and renders `SceneLoadFailed` with
a retry that re-runs the load effect.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DLB54VYmGTzvyHNFb3wWxE
@pascal

pascal Bot commented Sep 2, 2026

Copy link
Copy Markdown

I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…).

Please try again, rephrase, or reach out if it keeps failing.

Error id: bbbadd8f-56e3-4711-be2c-965dd68ce644

@wass08
wass08 merged commit 19327a9 into main Sep 2, 2026
3 checks passed
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.

1 participant