[PR #4226] [CLOSED] Rework the background picker into a Background Library modal #6290

Closed
opened 2026-10-23 04:09:00 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4226
Author: @Gunterlie
Created: 7/28/2026
Status: ❌ Closed

Base: staging ← Head: background-picker-enhance


📝 Commits (10+)

  • 2acc287 feat: enhance background library picker
  • 6f0a774 polish: improve background library browsing
  • 117b92c fix: restore background folder browsing
  • 1595d49 feat: add background folder rail, favorites, and shared thumbnails
  • 94e2cbe polish: replace background folder rail with a native folder select
  • 4a352bf polish: browse background folders with wrapping chips
  • 4fddc83 refactor: one background card, drag onto folder chips, star on the image
  • 2eccd23 polish: float card actions over the thumbnail, label the library entry
  • b758afa polish: name folders on create, import into the open folder, fix modal scroll
  • c22de74 fix: keep card actions off the tags on touch, restore a non-drag move

📊 Changes

18 files changed (+1547 additions, -792 deletions)

View changed files

📝 e2e/core-flows.e2e.ts (+141 -62)
📝 packages/client/src/components/panels/CharactersPanel.tsx (+1 -2)
📝 packages/client/src/components/panels/PersonasPanel.tsx (+1 -2)
📝 packages/client/src/components/panels/SettingsPanel.tsx (+3 -12)
📝 packages/client/src/components/panels/settings/BackgroundPicker.tsx (+924 -571)
📝 packages/client/src/lib/background-library.ts (+3 -1)
📝 packages/client/src/localization/locales/en.json (+39 -1)
📝 packages/client/src/localization/locales/ko.json (+1 -1)
📝 packages/server/src/db/seed-backgrounds.ts (+1 -1)
📝 packages/server/src/routes/backgrounds.routes.ts (+79 -62)
📝 packages/server/src/routes/game-assets.routes.ts (+11 -2)
📝 packages/server/src/routes/generate.routes.ts (+3 -3)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+6 -8)
📝 packages/server/src/services/agents/agent-executor.ts (+22 -8)
📝 packages/server/src/services/background-library-organization.ts (+39 -2)
📝 packages/server/src/services/game/game-asset-generation.ts (+6 -5)
➕ packages/server/src/services/image/image-thumbnail.ts (+75 -0)
📝 packages/server/src/services/mari-db/mari-images.service.ts (+192 -49)

📄 Description

Linked issue

Closes #

Why this change

  • The Settings background picker was a cramped inline list: long tag lists crowded the desktop controls, action buttons overlapped the tags on touch, and the folder rail did not survive small viewports. Browsing more than a handful of backgrounds was painful.
  • Backgrounds had no human-readable name separate from the on-disk filename, so a file like bg_1749.png stayed unreadable even though chats and agents need that filename to stay stable.
  • There was no way to mark a background as a favorite that is independent of the Roleplay default background.
  • Grids decoded full-size game-asset images because the on-disk thumbnailer only existed for chat backgrounds.

What changed

  • Replaced the inline picker with a Background Library modal: one card component, wrapping folder chips (All / Favorites / My uploads / user folders), search, sort, and tag filtering.
  • Labels: new PATCH /api/backgrounds/:filename/label stores a display label in meta.json without touching the filename. Control characters and newlines are normalised out; max 100 chars. The agent's <available_backgrounds> block prefers the label and now XML-escapes label and tag text.
  • Favorites: new PATCH /api/backgrounds/favorite, persisted in organization.json. A rename carries the star to the new id; deletes drop it.
  • Organization pruning: pruneBackgroundLibraryOrganization drops assignments and favorites for backgrounds that no longer exist, called on the write paths so listing stays read-only.
  • Shared thumbnailer: extracted services/image/image-thumbnail.ts out of backgrounds.routes.ts and reused it in game-assets.routes.ts, so game-asset image grids can request ?w=320 instead of the full-size original.
  • Folder UX: name folders at creation time via a prompt dialog, import into the currently open folder, rename/delete from the folder chips, drag a card onto a chip to file it, plus a non-drag Move action (dragging is pointer-only and was unreachable on touch).
  • Card actions float over the thumbnail on hover-capable pointers and stack above the tag chips on touch, so they no longer cover the tag editor.
  • Updated the Playwright background specs in e2e/core-flows.e2e.ts to cover the modal, labels, favorites, the non-drag move, folder rename/delete, and that cards request the cached thumbnail (?w=320) with loading="lazy".
  • English strings added in en.json; ko.json touched for one key.

Validation

  • 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

Manual verification notes

Needs manual verification in a real browser — nothing below has been confirmed by a human yet:

  • Manually verify the Background Library modal opens from Settings → Appearance → Backgrounds → "Browse library", and that it scrolls correctly on a short viewport.
  • Manually verify label editing: rename a background's label, reload, confirm the label persists and the underlying filename is unchanged, and that the chat using that background still renders.
  • Manually verify favorites: star a background, confirm the Favorites chip filters to it, and confirm starring does NOT change the Roleplay default background.
  • Manually verify folder flows: create a folder (named at creation), drag a card onto a folder chip, use the Move action on a touch device, rename and delete a folder, and confirm the folder's backgrounds fall back to unfiled.
  • Manually verify touch layout on a real phone/emulated mobile viewport: card actions sit above the tag chips and do not cover the tag editor; tap targets are reachable.
  • Manually verify game-asset image grids load the downscaled ?w=320 variant and fall back cleanly to the original on a platform without sharp.
  • Manually verify light and dark mode, the empty library state, and the error path when the backgrounds API fails.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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)

UI evidence (if applicable)

Summary by CodeRabbit

  • New Features
    • Redesigned the Background Library with search, sorting, source and folder filters, favorites, tags, and improved card actions.
    • Add custom background labels, edit tags inline, organize backgrounds into folders, and move items using accessible controls.
    • Background thumbnails load more efficiently, improving library performance.
  • Improvements
    • Background names now prioritize custom labels and are searchable.
    • Tag filters display the total number of available tags.
    • Added localized labels and controls for background management features.

🔄 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/4226 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 7/28/2026 **Status:** ❌ Closed **Base:** `staging` ← **Head:** `background-picker-enhance` --- ### 📝 Commits (10+) - [`2acc287`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2acc2872bc386a53fcd9445ddd9133510c738b8e) feat: enhance background library picker - [`6f0a774`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6f0a774435bd7617ac80437b9218aaa0f31c1e58) polish: improve background library browsing - [`117b92c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/117b92c671a7d792cc55cc89615d80b1630b8215) fix: restore background folder browsing - [`1595d49`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1595d49ebc4807fb59469d006814bb4b55934220) feat: add background folder rail, favorites, and shared thumbnails - [`94e2cbe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/94e2cbe44d3de2dc19aab465c755b029dbc4de5d) polish: replace background folder rail with a native folder select - [`4a352bf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4a352bf619c070ed3f57aff13754e408a3b741a6) polish: browse background folders with wrapping chips - [`4fddc83`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4fddc834e661d3d8138a3306b33f3c4429689a34) refactor: one background card, drag onto folder chips, star on the image - [`2eccd23`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2eccd233083c51ae869f6cbb94fc2cc6a93dc9b9) polish: float card actions over the thumbnail, label the library entry - [`b758afa`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b758afa5694b8b5f22ebb7684889982b38d3869d) polish: name folders on create, import into the open folder, fix modal scroll - [`c22de74`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c22de744050773e39d8312027c1f665fcb7fc307) fix: keep card actions off the tags on touch, restore a non-drag move ### 📊 Changes **18 files changed** (+1547 additions, -792 deletions) <details> <summary>View changed files</summary> 📝 `e2e/core-flows.e2e.ts` (+141 -62) 📝 `packages/client/src/components/panels/CharactersPanel.tsx` (+1 -2) 📝 `packages/client/src/components/panels/PersonasPanel.tsx` (+1 -2) 📝 `packages/client/src/components/panels/SettingsPanel.tsx` (+3 -12) 📝 `packages/client/src/components/panels/settings/BackgroundPicker.tsx` (+924 -571) 📝 `packages/client/src/lib/background-library.ts` (+3 -1) 📝 `packages/client/src/localization/locales/en.json` (+39 -1) 📝 `packages/client/src/localization/locales/ko.json` (+1 -1) 📝 `packages/server/src/db/seed-backgrounds.ts` (+1 -1) 📝 `packages/server/src/routes/backgrounds.routes.ts` (+79 -62) 📝 `packages/server/src/routes/game-assets.routes.ts` (+11 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+3 -3) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+6 -8) 📝 `packages/server/src/services/agents/agent-executor.ts` (+22 -8) 📝 `packages/server/src/services/background-library-organization.ts` (+39 -2) 📝 `packages/server/src/services/game/game-asset-generation.ts` (+6 -5) ➕ `packages/server/src/services/image/image-thumbnail.ts` (+75 -0) 📝 `packages/server/src/services/mari-db/mari-images.service.ts` (+192 -49) </details> ### 📄 Description ## Linked issue <!-- No existing issue covers this work. One should be opened before this PR is submitted for review. --> Closes # ## Why this change - The Settings background picker was a cramped inline list: long tag lists crowded the desktop controls, action buttons overlapped the tags on touch, and the folder rail did not survive small viewports. Browsing more than a handful of backgrounds was painful. - Backgrounds had no human-readable name separate from the on-disk filename, so a file like `bg_1749.png` stayed unreadable even though chats and agents need that filename to stay stable. - There was no way to mark a background as a favorite that is independent of the Roleplay default background. - Grids decoded full-size game-asset images because the on-disk thumbnailer only existed for chat backgrounds. ## What changed - Replaced the inline picker with a **Background Library** modal: one card component, wrapping folder chips (All / Favorites / My uploads / user folders), search, sort, and tag filtering. - **Labels**: new `PATCH /api/backgrounds/:filename/label` stores a display label in `meta.json` without touching the filename. Control characters and newlines are normalised out; max 100 chars. The agent's `<available_backgrounds>` block prefers the label and now XML-escapes label and tag text. - **Favorites**: new `PATCH /api/backgrounds/favorite`, persisted in `organization.json`. A rename carries the star to the new id; deletes drop it. - **Organization pruning**: `pruneBackgroundLibraryOrganization` drops assignments and favorites for backgrounds that no longer exist, called on the write paths so listing stays read-only. - **Shared thumbnailer**: extracted `services/image/image-thumbnail.ts` out of `backgrounds.routes.ts` and reused it in `game-assets.routes.ts`, so game-asset image grids can request `?w=320` instead of the full-size original. - Folder UX: name folders at creation time via a prompt dialog, import into the currently open folder, rename/delete from the folder chips, drag a card onto a chip to file it, plus a non-drag **Move** action (dragging is pointer-only and was unreachable on touch). - Card actions float over the thumbnail on hover-capable pointers and stack above the tag chips on touch, so they no longer cover the tag editor. - Updated the Playwright background specs in `e2e/core-flows.e2e.ts` to cover the modal, labels, favorites, the non-drag move, folder rename/delete, and that cards request the cached thumbnail (`?w=320`) with `loading="lazy"`. - English strings added in `en.json`; `ko.json` touched for one key. ## Validation - [ ] `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` ### Manual verification notes Needs manual verification in a real browser — nothing below has been confirmed by a human yet: - Manually verify the Background Library modal opens from Settings → Appearance → Backgrounds → "Browse library", and that it scrolls correctly on a short viewport. - Manually verify label editing: rename a background's label, reload, confirm the label persists and the underlying filename is unchanged, and that the chat using that background still renders. - Manually verify favorites: star a background, confirm the Favorites chip filters to it, and confirm starring does NOT change the Roleplay default background. - Manually verify folder flows: create a folder (named at creation), drag a card onto a folder chip, use the Move action on a touch device, rename and delete a folder, and confirm the folder's backgrounds fall back to unfiled. - Manually verify touch layout on a real phone/emulated mobile viewport: card actions sit above the tag chips and do not cover the tag editor; tap targets are reachable. - Manually verify game-asset image grids load the downscaled `?w=320` variant and fall back cleanly to the original on a platform without `sharp`. - Manually verify light and dark mode, the empty library state, and the error path when the backgrounds API fails. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) 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) ## UI evidence (if applicable) <!-- Before/after screenshots of the old inline picker vs. the new Background Library modal still need to be attached. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Redesigned the Background Library with search, sorting, source and folder filters, favorites, tags, and improved card actions. * Add custom background labels, edit tags inline, organize backgrounds into folders, and move items using accessible controls. * Background thumbnails load more efficiently, improving library performance. * **Improvements** * Background names now prioritize custom labels and are searchable. * Tag filters display the total number of available tags. * Added localized labels and controls for background management features. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:09:00 +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#6290
No description provided.