mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #415] [MERGED] fix(game): tighten bg fuzzy matcher so new scenes don't pin to first library bg #4613
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#4613
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/415
Author: @Romuromylus
Created: 5/4/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @SpicyMarinara
Base:
main← Head:fix/game-bg-fuzzy-matcher📝 Commits (3)
dd125a1fix(game): tighten bg fuzzy matcher so new scenes don't pin to first library bgbbaf11ffix(game): scope stricter fuzzy threshold to backgrounds onlye6756bdfix(game): preserve canonical backgrounds:generated:* tags before fuzzy match📊 Changes
1 file changed (+32 additions, -9 deletions)
View changed files
📝
packages/client/src/lib/asset-fuzzy-match.ts(+32 -9)📄 Description
Linked issue
Closes #414
Why this change
In Game Mode with image generation enabled, starting a new scene renders the wrong background and never triggers a fresh generation. On installs that include the legacy SillyTavern
data/backgrounds/pack (which gets manifest-tagged asbackgrounds:user:<name>), unrelated scenes pin to whichever bg comes first in iteration order — typicallybackgrounds:user:ancient_library.The root cause is a fuzzy-matcher that's too lax:
tagScoreinpackages/client/src/lib/asset-fuzzy-match.tscounts the universal category prefix word (backgrounds) on both the model-emitted tag and every candidate manifest tag, giving every comparison a free +1.bestMatchaccepts anyscore > 0, so that single free point declares a match and returns the first tag walked.Downstream in
applySceneResult:setCurrentBackground(resolved)immediately sets the wrong bg.unresolvedBgfind concludes the bg is already in the manifest, sobackgroundTagis omitted from the/game/generate-assetspayload — no generation request is ever made.Server-side logs
[game/scene-wrap] bg "<chosen>" not in manifest; generation will be deferred, but the deferred call from the client never names the bg, so nothing is generated and the scene stays pinned to the wrongly-matched library image.What changed
packages/client/src/lib/asset-fuzzy-match.ts:tagScorenow takes acategoryargument and excludes the category word from both prose words and tag parts. The category prefix is universal across every candidate, so counting it adds noise without signal.bestMatchnow requires at least 2 specific-word overlaps (initialbestScore = 1, accept ons > bestScore). A brand-new location with only the (already stripped) category prefix in common no longer gets pinned to an arbitrary library bg.resolveAssetTagwas updated to pass the category through.Backwards-compatible behavior preserved:
backgrounds:user:dark_forest.backgrounds:generated:<slug>branch, which is what triggers the/game/generate-assetsrequest the bug was suppressing.No public type changes (
tagScoreandbestMatchare file-local).Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Tested on a Dockerfile build of this branch deployed to a private EasyPanel instance:
enableSpriteGenerationon. Confirmed legacydata/backgrounds/pack present (13 jpgs incl.ancient_library.jpg) anddata/game-assets/backgrounds/{fantasy,modern,scifi}/empty.ancient_library.jpgand stayed there; server logs showedbg "X" not in manifest; generation will be deferredfollowed by no/game/generate-assetsbackground generation entry.backgrounds:generated:<slug>, the/game/generate-assetscall carriedbackgroundTag, and the freshly generated image rendered.Edge cases box left unchecked: this is a non-UI client lib change with no light/dark, mobile, or empty-state visual surface — the matcher is invoked from
applySceneResultonly. Server-rendered visuals were verified against an existing Game Mode chat.Docs and release impact
UI evidence (if applicable)
Not a UI change — affects the client-side asset-tag resolver only. The visible effect is "the right bg renders" (or generation begins) instead of "the wrong stock bg sticks". A demonstration would require generating a scene against a configured image provider, which I can attach as a follow-up if helpful.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.