[PR #4230] [MERGED] Rework the background picker into a Background Library modal #6292

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4230
Author: @Gunterlie
Created: 7/28/2026
Status: ✅ Merged
Merged: 7/28/2026
Merged by: @SpicyMarinara

Base: staging ← Head: background-library-modal


📝 Commits (3)

  • fafd5f9 Rework the background picker into a Background Library modal
  • d650533 Address CodeRabbit review on the Background Library modal
  • 133e1d0 Merge branch 'staging' into background-library-modal

📊 Changes

18 files changed (+1257 additions, -758 deletions)

View changed files

📝 e2e/core-flows.e2e.ts (+150 -65)
📝 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 (+873 -573)
📝 packages/client/src/lib/background-library.ts (+1 -3)
📝 packages/client/src/localization/locales/en.json (+35 -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 (+49 -67)
📝 packages/server/src/routes/game-assets.routes.ts (+11 -2)
📝 packages/server/src/routes/generate.routes.ts (+2 -3)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+3 -11)
📝 packages/server/src/services/agents/agent-executor.ts (+2 -3)
📝 packages/server/src/services/background-library-organization.ts (+39 -2)
📝 packages/server/src/services/game/game-asset-generation.ts (+6 -6)
➕ packages/server/src/services/image/image-thumbnail.ts (+75 -0)
📝 packages/server/src/services/mari-db/mari-images.service.ts (+4 -4)

📄 Description

Heads up: I read what you said, Mari, and I kept it in mind while making this.

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.
  • There was no way to mark a background as a favorite independent of the Roleplay default background.
  • Organization state (folder assignments, favorites) kept pointing at backgrounds that had been deleted.
  • Game-asset grids decoded full-size 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.
  • Filename-only display — backgrounds show their on-disk filename rather than a separate editable label, so what you see in the library matches what chats and agents reference.
  • 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 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, 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 favorites: star a background, reload, confirm it persists and shows under the Favorites chip; rename it and confirm the star follows; delete it and confirm the star is dropped.
  • Manually verify folder flow: create a folder (named at creation), import an image into the open folder, rename and delete the folder from the chips.
  • Manually verify both move paths: drag a card onto a folder chip on desktop, and use the non-drag Move action on a touch device.
  • Manually verify on a touch device that card actions no longer cover the tag editor, and that tag editing still works.
  • Manually verify game-asset grids request ?w=320 thumbnails (Network tab) and still render correctly.
  • Manually verify light + dark mode, mobile viewport, empty library state, and a failing upload/error path.

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 card-based browsing, search, source and folder filters, favorites, tagging, drag-and-drop organization, and improved touch and keyboard controls.
    • Added thumbnail loading and caching for faster background previews.
    • Background uploads can now be assigned to the active folder.
  • Improvements
    • Tag filters now display the available tag count.
    • Background selection, renaming, deletion, and folder management provide clearer controls.
    • Improved persistence when stopping generation and editing chat messages.
  • Bug Fixes
    • Removed stale background entries from library organization data.

🔄 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/4230 **Author:** [@Gunterlie](https://github.com/Gunterlie) **Created:** 7/28/2026 **Status:** ✅ Merged **Merged:** 7/28/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `background-library-modal` --- ### 📝 Commits (3) - [`fafd5f9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fafd5f90c9b0d365761312c41e1e1f375ddc37fa) Rework the background picker into a Background Library modal - [`d650533`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d6505337ad27937109c7be042741aefbd437fa1a) Address CodeRabbit review on the Background Library modal - [`133e1d0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/133e1d02ca069496857fe93ca7ddc421e1c3b7d7) Merge branch 'staging' into background-library-modal ### 📊 Changes **18 files changed** (+1257 additions, -758 deletions) <details> <summary>View changed files</summary> 📝 `e2e/core-flows.e2e.ts` (+150 -65) 📝 `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` (+873 -573) 📝 `packages/client/src/lib/background-library.ts` (+1 -3) 📝 `packages/client/src/localization/locales/en.json` (+35 -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` (+49 -67) 📝 `packages/server/src/routes/game-assets.routes.ts` (+11 -2) 📝 `packages/server/src/routes/generate.routes.ts` (+2 -3) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+3 -11) 📝 `packages/server/src/services/agents/agent-executor.ts` (+2 -3) 📝 `packages/server/src/services/background-library-organization.ts` (+39 -2) 📝 `packages/server/src/services/game/game-asset-generation.ts` (+6 -6) ➕ `packages/server/src/services/image/image-thumbnail.ts` (+75 -0) 📝 `packages/server/src/services/mari-db/mari-images.service.ts` (+4 -4) </details> ### 📄 Description > Heads up: I read what you said, Mari, and I kept it in mind while making this. ## 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. - There was no way to mark a background as a favorite independent of the Roleplay default background. - Organization state (folder assignments, favorites) kept pointing at backgrounds that had been deleted. - Game-asset grids decoded full-size 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. - **Filename-only display** — backgrounds show their on-disk filename rather than a separate editable label, so what you see in the library matches what chats and agents reference. - **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 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, 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 favorites: star a background, reload, confirm it persists and shows under the Favorites chip; rename it and confirm the star follows; delete it and confirm the star is dropped. - Manually verify folder flow: create a folder (named at creation), import an image into the open folder, rename and delete the folder from the chips. - Manually verify both move paths: drag a card onto a folder chip on desktop, and use the non-drag **Move** action on a touch device. - Manually verify on a touch device that card actions no longer cover the tag editor, and that tag editing still works. - Manually verify game-asset grids request `?w=320` thumbnails (Network tab) and still render correctly. - Manually verify light + dark mode, mobile viewport, empty library state, and a failing upload/error path. ## 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 card-based browsing, search, source and folder filters, favorites, tagging, drag-and-drop organization, and improved touch and keyboard controls. * Added thumbnail loading and caching for faster background previews. * Background uploads can now be assigned to the active folder. * **Improvements** * Tag filters now display the available tag count. * Background selection, renaming, deletion, and folder management provide clearer controls. * Improved persistence when stopping generation and editing chat messages. * **Bug Fixes** * Removed stale background entries from library organization data. <!-- 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:01 +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#6292
No description provided.