[PR #8914] [MERGED] feat(music-dj): a music folder per character and per chat, over the default (#8901) #8880

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8914
Author: @SpicyMarinara
Created: 11/6/2026
Status: ✅ Merged
Merged: 11/6/2026
Merged by: @SpicyMarinara

Base: staging ← Head: feat/music-dj-character-folders


📝 Commits (3)

  • d42ca16 feat(music-dj): a music folder per character and per chat, over the default (#8901)
  • 3089956 fix(music-dj): review fixes for per-character folders (#8901)
  • d8e394d Merge remote-tracking branch 'origin/staging' into feat/music-dj-character-folders

📊 Changes

25 files changed (+1118 additions, -103 deletions)

View changed files

📝 docs/game/game-assets.md (+2 -2)
📝 docs/media/music.md (+27 -5)
📝 packages/client/src/components/agents/AgentEditor.tsx (+3 -4)
📝 packages/client/src/components/chat/AgentAddSetupFields.tsx (+190 -21)
📝 packages/client/src/components/chat/ChatSettingsDrawer.tsx (+109 -38)
📝 packages/client/src/components/chat/ChatSetupWizard.tsx (+10 -1)
📝 packages/client/src/lib/agent-transfer.ts (+3 -0)
📝 packages/client/src/localization/locales/en.json (+9 -0)
📝 packages/server/src/routes/agents.routes.ts (+23 -2)
📝 packages/server/src/routes/backup.routes.ts (+3 -3)
📝 packages/server/src/routes/chats.routes.ts (+11 -0)
📝 packages/server/src/routes/generate.routes.ts (+3 -0)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+4 -0)
📝 packages/server/src/services/generation/agent-resolution.ts (+10 -1)
📝 packages/server/src/services/mari-db/mari-db.service.ts (+10 -6)
📝 packages/shared/src/index.ts (+1 -0)
📝 packages/shared/src/types/chat-preset.ts (+6 -3)
📝 packages/shared/src/types/chat.ts (+5 -0)
➕ packages/shared/src/utils/music-dj-folder.ts (+103 -0)
📝 scripts/regressions/agent-connection-parameters.regression.ts (+50 -0)

...and 5 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 #8901

Why this change

Music DJ's Music folder on this device was a single app-wide setting. Switching from one character's roleplay to another kept playing the first character's soundtrack, and changing the folder for one character changed it for every chat. #8901 asks for a folder per character, an optional per-chat override, and a global default.

The maintainer's decisions (2026-11-06, recorded on the issue):

  • no Character Editor field;
  • a chat or character folder takes over even when the default source is Game Assets;
  • Use default clears only the chat's own folder;
  • saving a typed path needs the same access as the folder picker.

What changed

  • Resolver: packages/shared/src/utils/music-dj-folder.ts. The folder used is this chat's own folder, then the folder linked to the chat's only character, then the default.
    • Only a chat whose whole roster is one character uses the character link. Group chats skip it, and game mode follows the same rule.
    • A chat or character folder puts that chat in folder mode.
  • Server:
    • resolveEffectiveAgentSettings applies the resolver.
    • The chat's full roster is passed from generation, both pipeline calls and both retry resolutions, so the Music DJ prompt lists only the folder in use.
  • Storage:
    • Character links are customMusicCharacterFolders in the Music DJ agent settings.
    • A chat's own folder is the chat metadata key customMusicExternalFolder.
    • There is no storage-format change and no migration: existing setups read as All chats (default).
  • Privileged access: saving a new, non-empty folder path (default, character link or chat folder) calls requirePrivilegedAccess with the folder picker's options, and refuses the same way the picker does. This applies to POST /agents, PATCH /agents/type/:agentType, PATCH /agents/:id and PATCH /chats/:id/metadata.
    • Keeping a saved folder, clearing the default, unlinking and clearing a chat's folder stay open from any device.
    • Professor Mari's database tool refuses to add a folder path through agent_configs or chats.
  • UI: a shared MusicFolderScope appears in the Chat Settings drawer and in the add-agent setup.
    • Apply to offers This chat, the character's name (one-character chats only) and All chats (default).
    • An In use: line shows the folder in use, labelled This chat, From <name> or Default.
    • Use default and Unlink from <name> are new buttons.
    • Add saves every folder edited in the window, each to its own place.
    • The drawer no longer writes the folder in use into the global setting.
    • AgentEditor keeps customMusicCharacterFolders on save, and its field is relabelled Default music folder on this device.
  • Exports:
    • Both keys are in TRANSFER_UNSAFE_AGENT_SETTING_KEYS, so agent exports and duplicates no longer carry device paths.
    • The chat key is in CHAT_METADATA_LOCAL_DESTINATION_KEYS (chat export, the importer, profile export, restore) and CHAT_PRESET_EXCLUDED_METADATA_KEYS.
    • Full-profile backups still keep the default and character folders in the agent settings, as before.
  • Docs:
    • docs/media/music.md: a new section, "Use a different folder for a chat or character", plus updates to remote access and troubleshooting.
    • docs/game/game-assets.md: the relabelled field and the setup form's new behaviour.
    • The [docs-i18n] follow-up is #8913.
  • Regressions:
    • new music-dj-folder-access (the privileged checks; same refusal as the picker);
    • manual-agent-retry-resolution (which folder wins, group chats, forced folder source);
    • music-dj-local-library (only the folder in use reaches the prompt);
    • illustrator-manual-cadence (what Add saves equals what In use showed, for every Apply-to path);
    • agent-connection-parameters (the roster is passed);
    • mari/db-execution-security (Mari can't add a folder path).

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

  • Manually verify #8901's acceptance example. Give soundtrack A to Nazuna and soundtrack B to Keyleth with Apply to set to each character. Open Nazuna's roleplay and check Music DJ uses A, open Keyleth's and check it uses B, then return to Nazuna and check A is still in use with no edits.
  • Manually verify that This chat with folder C changes only that chat, and that Use default brings back the character's folder.
  • Manually verify that a group chat uses the default folder.
  • Manually verify that typing a folder path from a remote device without privileged access is refused with the same message as Choose Folder.
  • Manually verify the drawer and the add-agent modal on a phone, in Roleplay and in Game with Music DJ on.

Agent-run checks:

  • pnpm check: passes (0 errors; the 12 lint warnings are in files this PR doesn't touch).
  • pnpm localization:check: passes.
  • The seven regressions above pass after merging current staging. Each new or changed case fails with its fix removed.
  • About 30 nearby regressions also pass (chat-local-destination-security, capability-gm-verbs, profile import/export, prompt).
  • Reviewed by two reviewers (server/security and client/docs), with each finding verified. All four confirmed findings are fixed in 3089956957:
    • Add dropped edits made under another Apply-to target (found by both reviewers);
    • Mari could set a folder through raw agent_configs;
    • game-assets.md used the old label.

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)

The [docs-i18n] follow-up for docs/media/music.md and docs/game/game-assets.md is #8913.

Separate from this PR (found while mapping it, unchanged here):

  • /game-assets/local-music-file serves any audio file on the device, not only files in a chosen folder.
  • The per-chat Game Assets customMusicFolder is saved but never read.

🤖 Generated with Claude Code


🔄 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/8914 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 11/6/2026 **Status:** ✅ Merged **Merged:** 11/6/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `feat/music-dj-character-folders` --- ### 📝 Commits (3) - [`d42ca16`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d42ca16940edb3cc244e8282ded1f86109c6201b) feat(music-dj): a music folder per character and per chat, over the default (#8901) - [`3089956`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3089956957bfe78614e3bc75737f9fed7ef25019) fix(music-dj): review fixes for per-character folders (#8901) - [`d8e394d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d8e394d152eaa14d6392d15438881481284692c5) Merge remote-tracking branch 'origin/staging' into feat/music-dj-character-folders ### 📊 Changes **25 files changed** (+1118 additions, -103 deletions) <details> <summary>View changed files</summary> 📝 `docs/game/game-assets.md` (+2 -2) 📝 `docs/media/music.md` (+27 -5) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+3 -4) 📝 `packages/client/src/components/chat/AgentAddSetupFields.tsx` (+190 -21) 📝 `packages/client/src/components/chat/ChatSettingsDrawer.tsx` (+109 -38) 📝 `packages/client/src/components/chat/ChatSetupWizard.tsx` (+10 -1) 📝 `packages/client/src/lib/agent-transfer.ts` (+3 -0) 📝 `packages/client/src/localization/locales/en.json` (+9 -0) 📝 `packages/server/src/routes/agents.routes.ts` (+23 -2) 📝 `packages/server/src/routes/backup.routes.ts` (+3 -3) 📝 `packages/server/src/routes/chats.routes.ts` (+11 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+3 -0) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+4 -0) 📝 `packages/server/src/services/generation/agent-resolution.ts` (+10 -1) 📝 `packages/server/src/services/mari-db/mari-db.service.ts` (+10 -6) 📝 `packages/shared/src/index.ts` (+1 -0) 📝 `packages/shared/src/types/chat-preset.ts` (+6 -3) 📝 `packages/shared/src/types/chat.ts` (+5 -0) ➕ `packages/shared/src/utils/music-dj-folder.ts` (+103 -0) 📝 `scripts/regressions/agent-connection-parameters.regression.ts` (+50 -0) _...and 5 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`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #8901 ## Why this change Music DJ's **Music folder on this device** was a single app-wide setting. Switching from one character's roleplay to another kept playing the first character's soundtrack, and changing the folder for one character changed it for every chat. #8901 asks for a folder per character, an optional per-chat override, and a global default. The maintainer's decisions (2026-11-06, recorded on the issue): - no Character Editor field; - a chat or character folder takes over even when the default source is Game Assets; - **Use default** clears only the chat's own folder; - saving a typed path needs the same access as the folder picker. ## What changed - **Resolver:** `packages/shared/src/utils/music-dj-folder.ts`. The folder used is this chat's own folder, then the folder linked to the chat's only character, then the default. - Only a chat whose whole roster is one character uses the character link. Group chats skip it, and game mode follows the same rule. - A chat or character folder puts that chat in folder mode. - **Server:** - `resolveEffectiveAgentSettings` applies the resolver. - The chat's full roster is passed from generation, both pipeline calls and both retry resolutions, so the Music DJ prompt lists only the folder in use. - **Storage:** - Character links are `customMusicCharacterFolders` in the Music DJ agent settings. - A chat's own folder is the chat metadata key `customMusicExternalFolder`. - There is no storage-format change and no migration: existing setups read as **All chats (default)**. - **Privileged access:** saving a new, non-empty folder path (default, character link or chat folder) calls `requirePrivilegedAccess` with the folder picker's options, and refuses the same way the picker does. This applies to `POST /agents`, `PATCH /agents/type/:agentType`, `PATCH /agents/:id` and `PATCH /chats/:id/metadata`. - Keeping a saved folder, clearing the default, unlinking and clearing a chat's folder stay open from any device. - Professor Mari's database tool refuses to add a folder path through `agent_configs` or chats. - **UI:** a shared `MusicFolderScope` appears in the Chat Settings drawer and in the add-agent setup. - **Apply to** offers This chat, the character's name (one-character chats only) and All chats (default). - An **In use:** line shows the folder in use, labelled **This chat**, **From \<name\>** or **Default**. - **Use default** and **Unlink from \<name\>** are new buttons. - Add saves every folder edited in the window, each to its own place. - The drawer no longer writes the folder in use into the global setting. - AgentEditor keeps `customMusicCharacterFolders` on save, and its field is relabelled **Default music folder on this device**. - **Exports:** - Both keys are in `TRANSFER_UNSAFE_AGENT_SETTING_KEYS`, so agent exports and duplicates no longer carry device paths. - The chat key is in `CHAT_METADATA_LOCAL_DESTINATION_KEYS` (chat export, the importer, profile export, restore) and `CHAT_PRESET_EXCLUDED_METADATA_KEYS`. - Full-profile backups still keep the default and character folders in the agent settings, as before. - **Docs:** - `docs/media/music.md`: a new section, "Use a different folder for a chat or character", plus updates to remote access and troubleshooting. - `docs/game/game-assets.md`: the relabelled field and the setup form's new behaviour. - The `[docs-i18n]` follow-up is #8913. - **Regressions:** - new `music-dj-folder-access` (the privileged checks; same refusal as the picker); - `manual-agent-retry-resolution` (which folder wins, group chats, forced folder source); - `music-dj-local-library` (only the folder in use reaches the prompt); - `illustrator-manual-cadence` (what Add saves equals what **In use** showed, for every Apply-to path); - `agent-connection-parameters` (the roster is passed); - `mari/db-execution-security` (Mari can't add a folder path). ## 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 - Manually verify #8901's acceptance example. Give soundtrack A to Nazuna and soundtrack B to Keyleth with **Apply to** set to each character. Open Nazuna's roleplay and check Music DJ uses A, open Keyleth's and check it uses B, then return to Nazuna and check A is still in use with no edits. - Manually verify that **This chat** with folder C changes only that chat, and that **Use default** brings back the character's folder. - Manually verify that a group chat uses the default folder. - Manually verify that typing a folder path from a remote device without privileged access is refused with the same message as **Choose Folder**. - Manually verify the drawer and the add-agent modal on a phone, in Roleplay and in Game with Music DJ on. Agent-run checks: - `pnpm check`: passes (0 errors; the 12 lint warnings are in files this PR doesn't touch). - `pnpm localization:check`: passes. - The seven regressions above pass after merging current staging. Each new or changed case fails with its fix removed. - About 30 nearby regressions also pass (chat-local-destination-security, capability-gm-verbs, profile import/export, prompt). - Reviewed by two reviewers (server/security and client/docs), with each finding verified. All four confirmed findings are fixed in `3089956957`: - Add dropped edits made under another Apply-to target (found by both reviewers); - Mari could set a folder through raw `agent_configs`; - `game-assets.md` used the old label. ## 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) The `[docs-i18n]` follow-up for `docs/media/music.md` and `docs/game/game-assets.md` is #8913. Separate from this PR (found while mapping it, unchanged here): - `/game-assets/local-music-file` serves any audio file on the device, not only files in a chosen folder. - The per-chat Game Assets `customMusicFolder` is saved but never read. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 17:40:25 +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#8880
No description provided.