[GH-ISSUE #2761] [Issue]: Game-assets browser UI robustness — broken thumbnails, no virtualization, retained state, keystroke normalization #1400

Closed
opened 2026-10-21 05:33:09 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2761

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Lower-impact UI/UX robustness issues in the asset browser and sprite modal.

Sub-bug 1: No thumbnail onError fallback (#36)

  • How it breaks: Grid/list <img src={gameAssetFileUrl(node.path) ?? ''}> (171-176, 257-262) has no onError; a missing/corrupt file 404s and shows the browser's broken-image glyph instead of a FileImage fallback (which is imported but only used for non-image nodes).

Sub-bug 2: No virtualization (#37)

  • How it breaks: nodes.map(...) renders one card/row per node (98, 201) with no windowing; a folder with hundreds/thousands of sprites produces O(n) DOM nodes -> laggy scroll/selection. loading="lazy" defers bytes but not DOM/layout cost.

Sub-bug 3: Filename input normalizes per keystroke (#65)

  • How it breaks: handleCellRename runs trim().toLowerCase().replace(/[^a-z0-9_-]/g,'_') on every onChange and writes it back as the controlled value, so capitals are instantly lowercased and trailing spaces are swallowed — a human-readable multi-word label can't be typed. (No data corruption; handleSave re-normalizes anyway.)

Sub-bug 4: Frame-preview re-decode per tick (#67)

  • How it breaks: The frame-editor effect (723-741) calls cropSpriteDataUrl on every frameAdjustments change — full base64 decode + canvas draw + PNG re-encode — with no debounce/rAF; the cancel flag only gates setState, not the in-flight work. Visible jank on large sprites during slider drags.

Sub-bug 5: Retained state after close (#38) [disputed]

  • How it breaks: On close-without-save, cells/generatedSheets base64 linger until an entity/avatar change. The 'stale applying spinner' half is refuted (finally blocks clear the flags regardless of close). Minor retained-state nit.

Sub-bug 6: user_bg resolveAssetUrl (#61) [latent]

  • How it breaks: Store resolveAssetUrl does gameAssetFileUrl(entry.path) for a __user_bg__/... sentinel path, producing /api/game-assets/file/__user_bg__/... which 404s; GameSurface special-cases the prefix, the store doesn't. Currently no callers (latent landmine on public store API).

Suggested Fix

  • Add onError to swap the failed thumbnail for the FileImage fallback (per-node error state); avoid <img src=''>.
  • Virtualize the grid/list (react-window/react-virtual) or paginate.
  • Keep the filename input as raw local draft text; normalize on blur/save only.
  • Debounce/rAF-coalesce the frame preview recompute (or scale into a reused offscreen canvas).
  • Reset transient generation state on close.
  • Mirror GameSurface's user_bg handling in the store (centralize sentinel-to-URL mapping in game-asset-urls.ts).

Verification checklist (all manual)

  • Verify a missing/corrupt asset shows a file icon, not a broken-image glyph
  • Verify a large asset folder scrolls smoothly
  • Verify the sprite filename field accepts normal multi-word/mixed-case typing
  • Verify dragging frame sliders on a large sprite is not janky
  • Run pnpm check

Affected files

  • packages/client/src/components/game-assets/AssetGrid.tsx
  • packages/client/src/components/ui/SpriteGenerationModal.tsx
  • packages/client/src/stores/game-asset.store.ts

Audit provenance

Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged staging tree. Severity: LOW.

AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.

Originally created by @kolacheee on GitHub (Jun 21, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2761 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Lower-impact UI/UX robustness issues in the asset browser and sprite modal. ## Sub-bug 1: No thumbnail onError fallback (#36) - **How it breaks:** Grid/list `<img src={gameAssetFileUrl(node.path) ?? ''}>` (171-176, 257-262) has no onError; a missing/corrupt file 404s and shows the browser's broken-image glyph instead of a FileImage fallback (which is imported but only used for non-image nodes). ## Sub-bug 2: No virtualization (#37) - **How it breaks:** `nodes.map(...)` renders one card/row per node (98, 201) with no windowing; a folder with hundreds/thousands of sprites produces O(n) DOM nodes -> laggy scroll/selection. `loading="lazy"` defers bytes but not DOM/layout cost. ## Sub-bug 3: Filename input normalizes per keystroke (#65) - **How it breaks:** `handleCellRename` runs `trim().toLowerCase().replace(/[^a-z0-9_-]/g,'_')` on every onChange and writes it back as the controlled value, so capitals are instantly lowercased and trailing spaces are swallowed — a human-readable multi-word label can't be typed. (No data corruption; handleSave re-normalizes anyway.) ## Sub-bug 4: Frame-preview re-decode per tick (#67) - **How it breaks:** The frame-editor effect (723-741) calls `cropSpriteDataUrl` on every `frameAdjustments` change — full base64 decode + canvas draw + PNG re-encode — with no debounce/rAF; the cancel flag only gates setState, not the in-flight work. Visible jank on large sprites during slider drags. ## Sub-bug 5: Retained state after close (#38) [disputed] - **How it breaks:** On close-without-save, cells/generatedSheets base64 linger until an entity/avatar change. The 'stale applying spinner' half is refuted (finally blocks clear the flags regardless of close). Minor retained-state nit. ## Sub-bug 6: __user_bg__ resolveAssetUrl (#61) [latent] - **How it breaks:** Store `resolveAssetUrl` does `gameAssetFileUrl(entry.path)` for a `__user_bg__/...` sentinel path, producing `/api/game-assets/file/__user_bg__/...` which 404s; GameSurface special-cases the prefix, the store doesn't. Currently no callers (latent landmine on public store API). ## Suggested Fix - Add onError to swap the failed thumbnail for the FileImage fallback (per-node error state); avoid `<img src=''>`. - Virtualize the grid/list (react-window/react-virtual) or paginate. - Keep the filename input as raw local draft text; normalize on blur/save only. - Debounce/rAF-coalesce the frame preview recompute (or scale into a reused offscreen canvas). - Reset transient generation state on close. - Mirror GameSurface's __user_bg__ handling in the store (centralize sentinel-to-URL mapping in game-asset-urls.ts). ## Verification checklist (all manual) - [ ] Verify a missing/corrupt asset shows a file icon, not a broken-image glyph - [ ] Verify a large asset folder scrolls smoothly - [ ] Verify the sprite filename field accepts normal multi-word/mixed-case typing - [ ] Verify dragging frame sliders on a large sprite is not janky - [ ] Run `pnpm check` --- ### Affected files - `packages/client/src/components/game-assets/AssetGrid.tsx` - `packages/client/src/components/ui/SpriteGenerationModal.tsx` - `packages/client/src/stores/game-asset.store.ts` ### Audit provenance Found by a multi-agent static audit of the TTS/voice + image-generation subsystems (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified) against the merged `staging` tree. Severity: **LOW**. > AI-drafted from a static read; validation/test-plan boxes intentionally left UNCHECKED for a human to verify before close.
Author
Owner

@SpicyMarinara commented on GitHub (Jun 21, 2026):

Fixed in PR #2747.\n\nWhat changed:\n- asset grid/list thumbnails now track failed image loads and fall back to a file-image icon instead of the browser broken-image glyph\n- large folders render in paged chunks with a Load more control to avoid mounting every asset at once\n- sprite filename edits keep the user's raw draft while typing and normalize on blur/save\n- sprite frame previews are debounce/rAF-coalesced before canvas recrops\n- sprite modal transient generation state is reset on close\n- user_bg paths are handled centrally in game-asset URL resolution so store callers do not build dead game-assets URLs\n\nDeferred repo-wide validation until the end of the issue sweep per maintainer request.

<!-- gh-comment-id:4763374115 --> @SpicyMarinara commented on GitHub (Jun 21, 2026): Fixed in PR #2747.\n\nWhat changed:\n- asset grid/list thumbnails now track failed image loads and fall back to a file-image icon instead of the browser broken-image glyph\n- large folders render in paged chunks with a Load more control to avoid mounting every asset at once\n- sprite filename edits keep the user's raw draft while typing and normalize on blur/save\n- sprite frame previews are debounce/rAF-coalesced before canvas recrops\n- sprite modal transient generation state is reset on close\n- __user_bg__ paths are handled centrally in game-asset URL resolution so store callers do not build dead game-assets URLs\n\nDeferred repo-wide validation until the end of the issue sweep per maintainer request.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1400
No description provided.