mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6653
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5162
Author: @kolacheee
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @kolacheee
Base:
staging← Head:feat/5161-context-music📝 Commits (6)
23fa0c8feat(music): context-track foundations — scoreable area/tier tags, encounter tiers, keyed generation (#5161)2cf4259feat(music): client wiring, analyzer retirement, scoring context + Spotify search pagination4f21da6fix(music): complete the free-text retirement in postprocess; update pinned regressions2468392fix(music): linear-scan slug trimming — CodeQL polynomial-regex alert07105d5fix(music): review round — path-independent area fill, audible tier tracks, stable legacy pool7e5deb5fix(music): CodeRabbit round — scoped tier continuation, context-required music, Spotify partials📊 Changes
15 files changed (+713 additions, -80 deletions)
View changed files
📝
CHANGELOG.md(+3 -0)📝
packages/client/src/components/game/GameSurface.tsx(+251 -15)📝
packages/server/src/routes/encounter.routes.ts(+2 -1)📝
packages/server/src/routes/game.routes.ts(+7 -1)📝
packages/server/src/routes/sidecar.routes.ts(+7 -1)📝
packages/server/src/routes/tts.routes.ts(+90 -10)📝
packages/server/src/services/sidecar/scene-analyzer.ts(+8 -21)📝
packages/server/src/services/sidecar/scene-postprocess.ts(+10 -5)📝
packages/server/src/services/spotify/game-spotify-music.service.ts(+41 -14)📝
packages/shared/src/schemas/scene-analysis.schema.ts(+2 -0)📝
packages/shared/src/types/combat-encounter.ts(+7 -0)📝
packages/shared/src/types/game.ts(+3 -0)📝
packages/shared/src/utils/music-score.ts(+142 -6)➕
scripts/regressions/context-music-score.regression.ts(+127 -0)📝
scripts/regressions/open-issues.regression.ts(+13 -6)📄 Description
Linked issue
Closes #5161
Why this change
With Game music enabled, every scene transition writes a fresh free-text mood prompt and generates a brand-new 30-second clip — music lurches every turn or two, 30-second loops repeat, and each rephrased mood sentence is a billed generation. #5161's model instead: persistent, context-bound tracks — one per map area and per encounter tier plus the bundled library as the floor — generated once into the game-assets music library and selected during play, so music changes when context changes, never per turn.
What changed
Shipped so far (server + shared foundations):
music-score.ts: a second, scoreable tag grammar for context tracks —music:area:<slug>:<name>andmusic:tier:<tier>:<name>— parsed separately from the state library.scoreMusictakeslocationSlug/enemyTiercontext with precedence: tier track during combat → area track elsewhere → the existing state/genre/intensity scoring. Context selection deliberately keeps the current track while it still fits (the legacy pool's rotation contract is unchanged). NewMUSIC_ENEMY_TIERStaxonomy (common | miniboss | boss | special) with alias normalization.combat-encounter.ts+ encounter init prompt:visuals.encounterTierclassifies the whole encounter;isBossFightremains the fallback signal./api/tts/game-audio: optionalcontext {axis, key, lengthMs}(music only, tier keys validated). Context compositions land in the scoreable library atmusic/<axis>/<key>/and generate once per key — any existing audio file under the key (including a user-dropped replacement) counts as covered — at a default 120 s length (clamped 10–300 s) with provider-timeout headroom. Generation locks collapse per key, so two turns racing into the same area produce one composition. Users can audition/rename/replace these tracks in the existing Game Assets panel with zero UI changes, since tags mirror folders.Client wiring (complete):
combatMusicTierfrom the/encounter/initblueprint (encounterTier, falling back fromisBossFight), cleared with combat state; all three scene-analysis contexts carryenemyTier; the client inline scoring passeslocationSlug+enemyTier;ensureContextMusicTracklazily fills the library (area on scene processing, tier at combat init) as a pure library fill — playback stays with the scoring pass, so music never lurches mid-narration.materializeGeneratedGameAudiois SFX-only now.locationSlugderived fromcurrentLocationand the request'senemyTier.context-music-score(area/tier precedence, keep-current stability, legacy-pool isolation, malformed-tag rejection, variant rotation, tier aliases, slug canonicalization).Also folded in (Game-mode half of #5163): Game Mode's Spotify Music DJ artist and generic-search sources 400'd deterministically since Spotify's February 2026
GET /searchcap of 10 — the candidate pool's default of 50 was passed straight through.searchSpotifyTracksnow paginates in pages of 10 withoffsetup to the requested pool size. The Roleplayspotify_searchtool half stays on #5163.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Agent-run so far (treat as a to-do list to reconfirm):
pnpm buildgreen (shared/server/client),pnpm lintgreen, and the newcontext-music-scoreregression passes vianode ./scripts/run-regressions.mjs --filter context-music-score. No real ElevenLabs generations have been run (mock-only policy).Still needs a human pass with a real ElevenLabs audio connection:
music/area/<slug>/in Game Assets, and the NEXT scene transition switches to it and keeps it while you stay in the area.music/tier/common/andmusic/tier/boss/tracks — combat music applies at encounter init (legacy pool first), and the tier composition crossfades in the moment its generation completes, including mid-fight.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG entries added under Unreleased (feature + the #5163 Game-mode fix).
Summary by CodeRabbit
New Features
Bug Fixes
Tests
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.