mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2727] [Issue]: Tracker panel rendering crashes and numeric/string coercion bugs in stat bars (non-array stats crash the whole panel) #1371
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#1371
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?
Originally created by @kolacheee on GitHub (Jun 21, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2727
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The tracker types assert
stats: CharacterStat[],value: number,customFields: Record<string,string>, etc., but nothing coerces or validates the LLM's free-form JSON at the agent-merge boundary, and the renderers trust the declared types. A misbehaving tracker model that emits a non-arraystats, a numeric string, or an off-type value either CRASHES the whole tracker panel (no error boundary anywhere in the subtree) or silently renders empty/garbled bars. Separately, the Fahrenheit-conversion regex matches a bare 'f' anywhere in the temperature string, mis-converting common Celsius+condition strings. These map directly to "tracker panel blanks out" and "stat bar not updating / shows wrong value" reports.Bug 1 — Non-array character.stats crashes the entire tracker panel (high)
How it breaks the pipeline:
getCharacterAmbienceStyleruns unconditionally for every character card and doescharacter.stats?.find(...). Optional chaining guards only null/undefined; a truthy non-array ({}, string) makes.findnot a function -> synchronous TypeError in render. There is NO error boundary in the tracker subtree, so the throw unmounts the React tree and blanks the app.Steps to replicate: Have the character-tracker emit a character with
"stats": {}(or"none"). The whole tracker panel white-screens.Code trace:
tracker-profile-style.ts:330getSolidCssColor(character.stats?.find(s=>s.color)?.color); calledCharacterTrackerCard.tsx:228,FeaturedCharacterTrackerCard.tsx:211(pass rawcharacter, so the local?? []guards don't help). Server persists verbatim (generate.routes.ts:7661,7872), lock-merge only touches statsif(Array.isArray(next.stats))(tracker-field-locks.ts:569), clientnormalizeGameStatecoerces only text fields (game-state.store.ts:30). No error boundary under tracker-panel (repo grep finds onlyEncounterModal.tsx).Bug 2 — Non-array personaStats / customTrackerFields crash the panel (low)
How it breaks the pipeline:
TrackerSectionListguards only null (?? []); a non-array object reachesPersonaTrackerPanel/StatList/CustomFieldListwhere.length/.map/.somethrow.Code trace:
TrackerSectionList.tsx:94,98; crash sitesPersonaTrackerPanel.tsx:225-230,StatList.tsx:330,389,CustomTrackerPanel.tsx:46,73. (Reachable via the unvalidated PATCH endpointchats.routes.ts:1482-1483or a pre-existing bad row; normal agent paths normalize to arrays, so this is an API-boundary robustness gap.)Bug 3 — String-typed stat max collapses the bar to 0% (medium)
How it breaks the pipeline:
getStatPercentguards max withNumber.isFinite(the static, non-coercing form):Number.isFinite('100')===false, so a numeric-string max returns 0% even though the numbers next to the bar read correctly. Bar empty in both edit and read-only mode.Steps to replicate: Tracker emits
{value:75, max:'100'}; the bar is empty, label reads '75 / 100'.Code trace:
tracker-stat-layout.ts:51-54; consumedStatList.tsx:100,289. No numeric coercion on the AI write path (agent-executor.ts:1929-1937raw parse;generate-route-utils.ts:136verbatim;tracker-field-locks.ts:417-421spread; client coerces only text fields).Bug 4 — String-typed stat value shows 0 in edit mode while the bar shows the real percentage (medium)
How it breaks the pipeline:
InlineNumberusesNumber.isFinite(value) ? value : 0, so a string value renders 0 in the editor while the bar computes the real percent via JS arithmetic coercion — a confusing mismatch, and saving overwrites the real value with 0.Steps to replicate: Tracker emits
{value:'50', max:100}; bar shows 50%, editor shows 0, static display shows '50'.Code trace:
InlineControls.tsx:344-348; barStatList.tsx:289viatracker-stat-layout.ts:51-54; staticStatList.tsx:266-270.Bug 5 — Non-numeric stat value -> invalid 'NaN%' width (low)
How it breaks the pipeline:
getStatPercentdoes not guard/coercestat.value;'high'/100*100=NaN propagates through Math.min/max towidth:'NaN%', an invalid CSS length the browser ignores, so the fill never reflects the value.Code trace:
tracker-stat-layout.ts:51-54;StatList.tsx:100,289. (Same applies in the HUDRoleplayHUDPanels.tsx:1730,1792.)Bug 6 — Temperature with any 'f' mis-converted from Fahrenheit (medium)
How it breaks the pipeline:
parseTemperatureValuetests/°?\s*f/iwith both the degree and whitespace optional, so a bare 'f' anywhere (e.g. '5°C, foggy') triggers Fahrenheit conversion, corrupting the gauge label, color, and percent.Steps to replicate: Set/emit temperature '5°C, foggy' (or '12C, frosty', '-3°C, frigid'); the panel shows a far-colder converted value (e.g. -15°C).
Code trace:
world-state-display.ts:231-237(test:235), consumed:256,269,287; rendered viaWorldStatePanel.tsx:81->WorldForecastTile.tsx:32,105,108,117. (Requires both a digit and a stray 'f' in the same string; bare condition words alone return null.)Suggested Fix
TrackerSectionListso one bad field can't blank the panel; coerce defensively ingetCharacterAmbienceStyle(const stats = Array.isArray(character.stats) ? character.stats : []). (Bug 1.)Array.isArray(...) ? ... : []guards for personaStats/customFields/inventory/quests inTrackerSectionList, or normalize all GameState array fields innormalizeGameState. (Bug 2.)getStatPercent, coerce both operands withNumber(...)and guard withNumber.isFinitebefore dividing; ideally coercestat.value/stat.maxto finite numbers when normalizing the snapshot so the bar, editor (InlineNumber), and static display all agree. (Bugs 3-5.)InlineNumber(typeof value==='number' ? value : Number(value)). (Bug 4.) Mirror the value-coercion fix inRoleplayHUDPanelsstat bars. (Bug 5.)/(?:\d|°)\s*°?\s*f(?:ahrenheit)?\b/i) so 'foggy'/'frosty' don't trigger conversion. (Bug 6.)Template checklist
pnpm checkpasses (TypeScript + ESLint)statsdoes not crash the tracker panelAffected files
packages/client/src/features/tracker-panel/lib/tracker-profile-style.tspackages/client/src/features/tracker-panel/components/TrackerSectionList.tsxpackages/client/src/features/tracker-panel/lib/tracker-stat-layout.tspackages/client/src/features/tracker-panel/components/controls/InlineControls.tsxpackages/client/src/features/tracker-panel/components/controls/StatList.tsxpackages/client/src/features/tracker-panel/lib/world-state-display.tspackages/client/src/components/game/RoleplayHUDPanels.tsxAudit provenance
Found by a multi-agent static audit of the trackers/widgets subsystem (Round 1 + round-2 gap sweep + completeness critic, each finding adversarially verified). Severity: HIGH. Line numbers are against the
stagingworking tree.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in
eccb5e20. Tracker character cards and section lists now guard malformed non-array stats/persona/custom arrays, the tracker panel has a local error boundary fallback, stat percentage/edit controls coerce numeric strings and clamp invalid values, the compact roleplay HUD uses the same stat coercion, and Fahrenheit parsing now requires the unit next to the numeric temperature so strings like '5°C, foggy' stay Celsius.