Skip to content

fix(AppShell): resolve custom Included Library content on reload - #2017

Merged
alexwarren merged 1 commit into
mainfrom
fix/included-library-reload-and-error-formatting
Aug 10, 2026
Merged

fix(AppShell): resolve custom Included Library content on reload#2017
alexwarren merged 1 commit into
mainfrom
fix/included-library-reload-and-error-formatting

Conversation

@alexwarren

Copy link
Copy Markdown
Contributor

Summary

  • Fixes a bug where adding a custom Included Library in the editor, saving, and reopening the game failed with Failed to load game due to the following errors: * Error: Library file not found: lib.aslx — reproducible in both the browser and Electron.
  • Also fixes the same error message rendering as a single squashed line (no visible bullet/line breaks) on the editor's Open/reload screens.

Root cause

An Included Library element only stores its filename on save (<include ref="lib.aslx"/> — see IncludeSaver), not its content. The engine re-fetches the library's content from IGameDataProvider.GetAdjacentFile on every load (WorldModel.GetLibraryStream). WasmEditorBridge always loaded games through ByteArrayGameDataProvider, which had no GetAdjacentFile implementation at all, so any non-built-in library failed to resolve as soon as the game was reloaded — even though the library file was correctly stored as an asset and shown in the tree.

(Published .quest packages aren't affected — GameSaver inlines all library content and drops the <include> reference at publish time, so there's nothing left to resolve at play time. This is specific to the Editor's live-reference save mode.)

Fix

  • ByteArrayGameDataProvider now accepts an optional adjacentFiles map and implements GetAdjacentFile from it.
  • WasmEditorBridge gets a new AddAdjacentFile JSExport (mirrors the existing AddPublishAsset staging pattern); Initialise/SetGameXml consume the staged files when building the provider.
  • editor-store.ts preloads every .aslx asset from the adapter before Initialise/SetGameXml — this is a single choke point so it covers browser, Electron, and server storage.

Separately: the multi-line "Failed to load game due to the following errors:" message was collapsing onto one line in the UI because the <p> tags rendering it had no white-space styling — CodeViewPanel.svelte's equivalent error banner already used whitespace-pre-wrap, so the same class was added to the other three render sites (open/+page.svelte ×2, edit/+page.svelte).

Test plan

  • Added two regression tests to IncludedLibraryTests.cs (reload fails without adjacent bytes, succeeds with them) — reproduces the exact reported error message.
  • dotnet build --configuration Release (full solution) and dotnet test --configuration Release (292+ tests) both pass.
  • npm run check (svelte-check) and npm run lint (eslint) in src/AppShell both pass.
  • Verified live in the AppShell dev server: created a game, added a custom library, saved, reloaded — previously failed, now loads correctly.
  • Verified the error-formatting fix live by importing a game with a broken library reference and confirming the message now renders on separate lines instead of squashed onto one.

🤖 Generated with Claude Code

Adding a custom Included Library, saving, then reopening the game failed
with "Library file not found" — the <include ref="..."/> written on save
only stores the filename (see IncludeSaver), so the engine has to fetch
the library's actual content again from GetAdjacentFile at load time.
WasmEditorBridge fed the WASM engine a ByteArrayGameDataProvider with no
adjacent-file lookup at all, so any non-built-in library failed to
resolve on every reload after the initial (content-free) creation.

ByteArrayGameDataProvider now accepts an optional adjacent-files map and
implements GetAdjacentFile from it. WasmEditorBridge stages files via a
new AddAdjacentFile export (same pattern as AddPublishAsset), and the
AppShell editor-store preloads every .aslx asset from the adapter before
Initialise/SetGameXml — covering browser, Electron, and server storage
through the single openGame()/setGameXml() choke point.

Also fixes the "Failed to load game due to the following errors:"
message rendering as a single squashed line on the editor's start/reload
screens — those <p> tags were missing whitespace-pre-wrap, unlike
CodeViewPanel's equivalent error banner which already had it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@alexwarren
alexwarren merged commit 49fb9ae into main Aug 10, 2026
7 checks passed
@alexwarren
alexwarren deleted the fix/included-library-reload-and-error-formatting branch August 10, 2026 08:14
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