[PR #8580] [MERGED] feat(sprites): add optional folders and streamline sprite management #8687

Closed
opened 2026-11-07 17:38:56 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8580
Author: @DSBwizzard
Created: 10/30/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara

Base: staging ← Head: codex/sprite-folders


📝 Commits (10+)

  • 6a21797 feat(sprites): organize sprites in folders with shared selection
  • a707352 fix(sprites): adapt folder layout to editor width
  • 15d7c08 refactor(sprites): focus character editor on the sprite library
  • 186f0f6 fix(sprites): tighten mobile controls and loading state
  • 8da4ccc fix(sprites): protect image edits while saving
  • f9ca401 fix(sprites): wrap long folder labels within the library
  • f327d15 fix(sprites): contain folder names across library tools
  • c51f569 fix(sprites): keep selection scoped to the visible library
  • 0b13c77 Keep sprites available across organizational folders
  • ab8fcf4 Keep sprite folders optional and simplify character sheet panel

📊 Changes

51 files changed (+5318 additions, -1293 deletions)

View changed files

📝 docs/characters/personas.md (+4 -0)
📝 docs/characters/sprites.md (+40 -16)
📝 e2e/core-flows.e2e.ts (+30 -3)
➕ e2e/sprite-library.e2e.ts (+1008 -0)
📝 e2e/ui-state-fixture.ts (+2 -0)
📝 packages/client/src/components/characters/CharacterEditor.tsx (+673 -489)
➕ packages/client/src/components/characters/SpriteLibrary.tsx (+696 -0)
📝 packages/client/src/components/chat/SpriteOverlay.tsx (+6 -56)
➕ packages/client/src/components/chat/sprite-display-expression.ts (+67 -0)
📝 packages/client/src/components/personas/PersonaEditor.tsx (+484 -387)
📝 packages/client/src/components/ui/SpriteFrameEditor.tsx (+26 -6)
📝 packages/client/src/components/ui/SpriteGenerationModal.tsx (+16 -8)
📝 packages/client/src/components/ui/SpriteWandCleanupEditor.tsx (+1 -0)
📝 packages/client/src/features/avatars/generation/MeshAvatarSection.tsx (+3 -1)
📝 packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx (+4 -1)
📝 packages/client/src/features/avatars/generation/SpritePicker.tsx (+4 -2)
📝 packages/client/src/features/avatars/renderers/pngtuber/pngtuber-layers.ts (+2 -1)
📝 packages/client/src/features/avatars/stage/avatar-stage-logic.ts (+6 -1)
📝 packages/client/src/features/tracker-panel/lib/sprite-expressions.ts (+6 -5)
📝 packages/client/src/hooks/use-characters.ts (+132 -2)

...and 31 more files

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #8579

Implementation prepared by @DSBwizzard. @SpicyMarinara: this account cannot self-assign in the upstream repository.

Why this change

Large sprite libraries are difficult to manage as a flat grid. This adds optional folders and a clearer editing flow while keeping every sprite available during chats and roleplay.

What changed

  • Add optional inline, collapsible folders above loose sprites, separately for Facial Expressions and Full-body. Support renaming, folder reordering and moving individual or selected sprites. Removing a folder keeps its images.
  • Reuse Marinara's styling and folder interactions, including mobile hold-to-drag, visible source tiles and feedback for collapsed folders and the loose-sprite destination. Keep desktop drag previews on the existing shared preview layer.
  • Streamline the character sprite editor around search, Add sprites, scoped exports, compact Character Sheet management and tools revealed through Select. Retain preview, rename, replacement, framing, cleanup and deletion. Shorten repeated reference guidance while preserving reference selection and avatar fallback.
  • Share folder organization with personas, including a keyboard-accessible Move sprite dialog using the character editor's folder selector. Keep Delete All scoped to the whole current category and distinguish an empty collection from a search with no matches.
  • Store validated folder metadata and editable labels alongside existing images. Preserve file handles on rename, support duplicate labels across folders, and retain organization through sprite, character/persona and native profile transfers.
  • Keep every sprite in the flat API, regardless of folder. Add a catalog endpoint for folder-aware integrations. Update Engine-owned Expression Engine, Game Mode, avatar/PNGTuber, tracker, Mari, /emote and chat asset browsing to resolve edited labels while retaining concrete image references. Contextual sprite card links search all participants for matching file handles before falling back to labels; explicit owner/filename links remain stable. External agent packages are unchanged.
  • Regeneration replaces a unique existing matching label through its stable handle, preserving its folder. Preserve direct-handle replacement for framing, cleanup and explicit image replacement. Keep full-body pose classification and reference preference consistent after label changes.
  • Validate replacement image types/bytes and label lengths before writing. Constrain owner/file path components with Node basename after validation, retain containment checks, and reject linked upload destinations, including dangling links. Handle filename collisions and extension case safely on case-insensitive filesystems. Lock image-only deletion and remove its metadata without risking catalog.json; make Mari deletion label-aware, include SVG and every listed format sharing the handle, reject ambiguous labels and preserve metadata when deletion is a no-op.
  • Keep read-only listing usable when folder information or an owner directory is unreadable, or a file disappears during a scan. Preserve damaged catalogs on failed edits and retain directory-link refusal during export/write operations. Render sprites with unavailable folder information in the loose grid and rate-limit repeated warnings.
  • Report rejected, partial and image-free imports with the appropriate error/warning/success notice and preserve the failure reason. Localize folder/import text and retain steady warning colors during Accent Pulse.
  • Update the English sprite/persona guides, including the catalog API and stored folder order. Add focused transfer, input-validation, replacement, label-compatibility and browser regressions; update the three existing Character Sheet/generation specs for Manage and Add sprites.

Validation

Reviewed source: 05c4a602898d3f2eb9f7d9682f19ccc385ac78bc, based on staging 479575facdecd020ced082f37a6e00683b73d41b. Merge compatibility with current staging 05ad846e7615f72709949043d8d519f1f2e37505 was checked without changing the reviewed source.

Follow-up b619d882e passed pnpm check and all six sprite regression files. Real route/Mari tests cover cross-participant filename/label precedence, label-only fallback, SVG and same-handle multi-format deletion, and byte-identical metadata on a no-op delete. Earlier broader compatibility, browser and container evidence below was captured at 45fc21a4e; client/UI code is unchanged.

Existing human validation checkbox states are preserved. Automated evidence is listed separately.

  • pnpm check passes locally

  • Container (Docker / Podman) built and ran without issue

  • Ran the app, clicked through the changes manually

  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)

  • Above manual verification completed (describe below)

  • Read and followed CONTRIBUTING.md

  • pnpm check passed: formatting, lint, types, localization and production build.

  • Affected regressions passed, including Expression Engine, Game Mode, avatars, /emote, profile export/import, generated saves, deletion, damaged metadata, invalid owners and linked-directory handling. Gallery checks blocked by Windows filesystem privileges passed 7/7 in an isolated Linux container. A real native-profile ZIP round trip preserves a renamed, foldered sprite and its image bytes.

  • Sprite browser cases passed 6/6 across desktop Chromium, mobile Chromium and mobile WebKit. They cover failed/orphan catalog metadata, keyboard moves in both editors, import errors, search/delete scope and existing drag/bulk behavior.

  • The three affected legacy Character Sheet/generation browser cases passed, including regeneration of a renamed, foldered sprite. UI smoke passed 7/7 and production startup/reload passed 3/3.

  • The revised Docker image built and ran. A verified checkpoint and read-only before/after comparison confirmed that the existing preview's saved library and connections were preserved. Actual desktop/mobile loading and expanded-folder checks passed without page errors or horizontal overflow.

  • The latest whole-PR CodeRabbit review found one additional mixed-case Mari replacement defect. It was reproduced, fixed and regression-tested; the follow-up review completed with zero findings. No paid/live-provider calls were made.

  • Earlier incremental CodeRabbit review of the b619d882e follow-up completed with one finding about literal-extension priority. The same basename/extension fallback exists in both the pinned base and current upstream staging; it is unchanged here to preserve upstream lookup behavior. The repair changes filename/handle-versus-label priority only.

  • Security follow-up 05c4a6028: pnpm check and six Windows sprite regression files passed. Isolated Linux regressions verify file/dangling-link upload refusal, outside-image preservation, invalid DELETE owner rejection and existing sprite behavior. The CodeRabbit test-selector finding was fixed; its correction review completed with zero findings. Fresh hosted CodeQL results remain pending; no scanner rules or suppressions were changed.

Manual verification notes

The contributor reviewed the final preview and approved its appearance. The detailed checklist remains for human verification.

Manually verify folder creation, rename, reorder, expansion and deletion; single/multiple moves into expanded/collapsed folders and back to the loose grid; uploads, transfers, selection and editing tools; and representative Expression Engine, Game Mode and avatar choices with renamed sprites. Check touch behavior on a physical device.

Limits: no paid/live-provider calls. Physical Safari long-press remains a manual check. Previously reported intermittent returns to Metadata were not reproduced or established as fixed.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Updated docs/characters/sprites.md and docs/characters/personas.md; translation follow-up: #8605. The former "No docs changes needed" checkbox was cleared because these guides changed. Other human checklist states are unchanged.

GET /api/sprites/:ownerId/catalog exposes folder IDs/category and each sprite's stable expression handle, editable label, folderId and URL. The existing GET /api/sprites/:ownerId still returns every sprite. Folders do not select an active sprite set. This PR does not include a version bump.

UI evidence (if applicable)

Desktop/mobile dark-mode and desktop light-mode captures use bundled Marinara artwork and disposable characters, with loose and grouped examples. Temporary evidence is attached below and is not committed as product assets.

Desktop before / after
Before After
Desktop sprite editor before Desktop sprite editor with optional folders
Mobile before / after
Before After
Mobile sprite editor before Mobile sprite editor with optional folders
Desktop light mode Sprite folders and loose sprites in light mode

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/8580 **Author:** [@DSBwizzard](https://github.com/DSBwizzard) **Created:** 10/30/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `codex/sprite-folders` --- ### 📝 Commits (10+) - [`6a21797`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6a21797124bd552e9ca993c04c6d5f3af1e60746) feat(sprites): organize sprites in folders with shared selection - [`a707352`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a7073521d0a4c7f54a5b912d72354f1065a386eb) fix(sprites): adapt folder layout to editor width - [`15d7c08`](https://github.com/Pasta-Devs/Marinara-Engine/commit/15d7c080824c705d45812f7fddbb37f7f6d5f7fd) refactor(sprites): focus character editor on the sprite library - [`186f0f6`](https://github.com/Pasta-Devs/Marinara-Engine/commit/186f0f646a54b1e8f2c0347ae8d2f491709f3502) fix(sprites): tighten mobile controls and loading state - [`8da4ccc`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8da4ccc4b4322426e7cb55c9aa8a143b11e2fd3c) fix(sprites): protect image edits while saving - [`f9ca401`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f9ca4016b13c5666468321e10fda52f4c4c1f8c0) fix(sprites): wrap long folder labels within the library - [`f327d15`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f327d15ce8a800e033e77f2dede2311c5b7c73fe) fix(sprites): contain folder names across library tools - [`c51f569`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c51f56929493e32c2cc095583f53218c34a842e5) fix(sprites): keep selection scoped to the visible library - [`0b13c77`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b13c77c9f1eda78d3f9a4fb5867760220a16ae6) Keep sprites available across organizational folders - [`ab8fcf4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ab8fcf4f0181b0d17a74a6965a293bdff833848c) Keep sprite folders optional and simplify character sheet panel ### 📊 Changes **51 files changed** (+5318 additions, -1293 deletions) <details> <summary>View changed files</summary> 📝 `docs/characters/personas.md` (+4 -0) 📝 `docs/characters/sprites.md` (+40 -16) 📝 `e2e/core-flows.e2e.ts` (+30 -3) ➕ `e2e/sprite-library.e2e.ts` (+1008 -0) 📝 `e2e/ui-state-fixture.ts` (+2 -0) 📝 `packages/client/src/components/characters/CharacterEditor.tsx` (+673 -489) ➕ `packages/client/src/components/characters/SpriteLibrary.tsx` (+696 -0) 📝 `packages/client/src/components/chat/SpriteOverlay.tsx` (+6 -56) ➕ `packages/client/src/components/chat/sprite-display-expression.ts` (+67 -0) 📝 `packages/client/src/components/personas/PersonaEditor.tsx` (+484 -387) 📝 `packages/client/src/components/ui/SpriteFrameEditor.tsx` (+26 -6) 📝 `packages/client/src/components/ui/SpriteGenerationModal.tsx` (+16 -8) 📝 `packages/client/src/components/ui/SpriteWandCleanupEditor.tsx` (+1 -0) 📝 `packages/client/src/features/avatars/generation/MeshAvatarSection.tsx` (+3 -1) 📝 `packages/client/src/features/avatars/generation/PngtuberVariantsSection.tsx` (+4 -1) 📝 `packages/client/src/features/avatars/generation/SpritePicker.tsx` (+4 -2) 📝 `packages/client/src/features/avatars/renderers/pngtuber/pngtuber-layers.ts` (+2 -1) 📝 `packages/client/src/features/avatars/stage/avatar-stage-logic.ts` (+6 -1) 📝 `packages/client/src/features/tracker-panel/lib/sprite-expressions.ts` (+6 -5) 📝 `packages/client/src/hooks/use-characters.ts` (+132 -2) _...and 31 more files_ </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. ## Linked issue Closes #8579 Implementation prepared by @DSBwizzard. @SpicyMarinara: this account cannot self-assign in the upstream repository. ## Why this change Large sprite libraries are difficult to manage as a flat grid. This adds optional folders and a clearer editing flow while keeping every sprite available during chats and roleplay. ## What changed - Add optional inline, collapsible folders above loose sprites, separately for Facial Expressions and Full-body. Support renaming, folder reordering and moving individual or selected sprites. Removing a folder keeps its images. - Reuse Marinara's styling and folder interactions, including mobile hold-to-drag, visible source tiles and feedback for collapsed folders and the loose-sprite destination. Keep desktop drag previews on the existing shared preview layer. - Streamline the character sprite editor around search, Add sprites, scoped exports, compact Character Sheet management and tools revealed through Select. Retain preview, rename, replacement, framing, cleanup and deletion. Shorten repeated reference guidance while preserving reference selection and avatar fallback. - Share folder organization with personas, including a keyboard-accessible Move sprite dialog using the character editor's folder selector. Keep Delete All scoped to the whole current category and distinguish an empty collection from a search with no matches. - Store validated folder metadata and editable labels alongside existing images. Preserve file handles on rename, support duplicate labels across folders, and retain organization through sprite, character/persona and native profile transfers. - Keep every sprite in the flat API, regardless of folder. Add a catalog endpoint for folder-aware integrations. Update Engine-owned Expression Engine, Game Mode, avatar/PNGTuber, tracker, Mari, /emote and chat asset browsing to resolve edited labels while retaining concrete image references. Contextual sprite card links search all participants for matching file handles before falling back to labels; explicit owner/filename links remain stable. External agent packages are unchanged. - Regeneration replaces a unique existing matching label through its stable handle, preserving its folder. Preserve direct-handle replacement for framing, cleanup and explicit image replacement. Keep full-body pose classification and reference preference consistent after label changes. - Validate replacement image types/bytes and label lengths before writing. Constrain owner/file path components with Node basename after validation, retain containment checks, and reject linked upload destinations, including dangling links. Handle filename collisions and extension case safely on case-insensitive filesystems. Lock image-only deletion and remove its metadata without risking catalog.json; make Mari deletion label-aware, include SVG and every listed format sharing the handle, reject ambiguous labels and preserve metadata when deletion is a no-op. - Keep read-only listing usable when folder information or an owner directory is unreadable, or a file disappears during a scan. Preserve damaged catalogs on failed edits and retain directory-link refusal during export/write operations. Render sprites with unavailable folder information in the loose grid and rate-limit repeated warnings. - Report rejected, partial and image-free imports with the appropriate error/warning/success notice and preserve the failure reason. Localize folder/import text and retain steady warning colors during Accent Pulse. - Update the English sprite/persona guides, including the catalog API and stored folder order. Add focused transfer, input-validation, replacement, label-compatibility and browser regressions; update the three existing Character Sheet/generation specs for Manage and Add sprites. ## Validation Reviewed source: `05c4a602898d3f2eb9f7d9682f19ccc385ac78bc`, based on staging `479575facdecd020ced082f37a6e00683b73d41b`. Merge compatibility with current staging `05ad846e7615f72709949043d8d519f1f2e37505` was checked without changing the reviewed source. Follow-up `b619d882e` passed `pnpm check` and all six sprite regression files. Real route/Mari tests cover cross-participant filename/label precedence, label-only fallback, SVG and same-handle multi-format deletion, and byte-identical metadata on a no-op delete. Earlier broader compatibility, browser and container evidence below was captured at `45fc21a4e`; client/UI code is unchanged. Existing human validation checkbox states are preserved. Automated evidence is listed separately. - [x] `pnpm check` passes locally - [x] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` - `pnpm check` passed: formatting, lint, types, localization and production build. - Affected regressions passed, including Expression Engine, Game Mode, avatars, /emote, profile export/import, generated saves, deletion, damaged metadata, invalid owners and linked-directory handling. Gallery checks blocked by Windows filesystem privileges passed 7/7 in an isolated Linux container. A real native-profile ZIP round trip preserves a renamed, foldered sprite and its image bytes. - Sprite browser cases passed 6/6 across desktop Chromium, mobile Chromium and mobile WebKit. They cover failed/orphan catalog metadata, keyboard moves in both editors, import errors, search/delete scope and existing drag/bulk behavior. - The three affected legacy Character Sheet/generation browser cases passed, including regeneration of a renamed, foldered sprite. UI smoke passed 7/7 and production startup/reload passed 3/3. - The revised Docker image built and ran. A verified checkpoint and read-only before/after comparison confirmed that the existing preview's saved library and connections were preserved. Actual desktop/mobile loading and expanded-folder checks passed without page errors or horizontal overflow. - The latest whole-PR CodeRabbit review found one additional mixed-case Mari replacement defect. It was reproduced, fixed and regression-tested; the follow-up review completed with zero findings. No paid/live-provider calls were made. - Earlier incremental CodeRabbit review of the b619d882e follow-up completed with one finding about literal-extension priority. The same basename/extension fallback exists in both the pinned base and current upstream `staging`; it is unchanged here to preserve upstream lookup behavior. The repair changes filename/handle-versus-label priority only. - Security follow-up `05c4a6028`: `pnpm check` and six Windows sprite regression files passed. Isolated Linux regressions verify file/dangling-link upload refusal, outside-image preservation, invalid DELETE owner rejection and existing sprite behavior. The CodeRabbit test-selector finding was fixed; its correction review completed with zero findings. Fresh hosted CodeQL results remain pending; no scanner rules or suppressions were changed. ### Manual verification notes The contributor reviewed the final preview and approved its appearance. The detailed checklist remains for human verification. Manually verify folder creation, rename, reorder, expansion and deletion; single/multiple moves into expanded/collapsed folders and back to the loose grid; uploads, transfers, selection and editing tools; and representative Expression Engine, Game Mode and avatar choices with renamed sprites. Check touch behavior on a physical device. Limits: no paid/live-provider calls. Physical Safari long-press remains a manual check. Previously reported intermittent returns to Metadata were not reproduced or established as fixed. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Updated `docs/characters/sprites.md` and `docs/characters/personas.md`; translation follow-up: #8605. The former "No docs changes needed" checkbox was cleared because these guides changed. Other human checklist states are unchanged. `GET /api/sprites/:ownerId/catalog` exposes folder IDs/category and each sprite's stable `expression` handle, editable `label`, `folderId` and URL. The existing `GET /api/sprites/:ownerId` still returns every sprite. Folders do not select an active sprite set. This PR does not include a version bump. ## UI evidence (if applicable) Desktop/mobile dark-mode and desktop light-mode captures use bundled Marinara artwork and disposable characters, with loose and grouped examples. Temporary evidence is attached below and is not committed as product assets. <details> <summary>Desktop before / after</summary> | Before | After | | --- | --- | | <img width="330" alt="Desktop sprite editor before" src="https://github.com/user-attachments/assets/e7be7ca4-9a50-48c5-b04e-02dc55989d2b" /> | <img width="330" alt="Desktop sprite editor with optional folders" src="https://github.com/user-attachments/assets/75287061-ef38-43b1-8733-40d97304780d" /> | </details> <details> <summary>Mobile before / after</summary> | Before | After | | --- | --- | | <img width="220" alt="Mobile sprite editor before" src="https://github.com/user-attachments/assets/b6414b5f-63b3-4311-9ae3-304bad0fa568" /> | <img width="220" alt="Mobile sprite editor with optional folders" src="https://github.com/user-attachments/assets/57e9dd81-7d38-4d8b-94e2-05a82b43efc7" /> | </details> <details> <summary>Desktop light mode</summary> <img width="660" alt="Sprite folders and loose sprites in light mode" src="https://github.com/user-attachments/assets/760573df-c23e-4e98-a212-2988662e2c66" /> </details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:38:56 +07:00
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#8687
No description provided.