mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2728] [Issue]: Game-mode HUD widgets — stat_block update misrouting, lost manual saves, inventory_grid drops, off-screen recovery, timer restart #1372
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#1372
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/2728
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The game-mode HUD widget subsystem has multiple state/persistence defects. Model-driven
stat_blockupdates are dropped or misrouted into a non-renderedvaluefield when the block has no stats or the name doesn't match. Manual widget saves race two different persistence paths (a stale chat-metadata sync, and the debounced PUT) and get reverted. A configuredinventory_gridwidget is filtered out of the render path entirely. The inventory-grid contents editor wipes quantity/slot on any edit. A locked widget/map panel restored at a smaller viewport is never re-clamped and becomes unrecoverable. And a finished timer restarts on reload because completion is never persisted.Bug 1 — applyWidgetUpdate drops/misroutes stat_block updates (medium)
How it breaks the pipeline: The stat_block branch is gated on
changes.statName && w.type==='stat_block' && newConfig.stats. (a) Whenstatsis undefined, control falls to the numeric else-branch which writesnewConfig.value— a fieldStatBlockWidgetnever reads — so the stat write is lost and config is polluted. (b) Even with stats, the match is exactstat.name===targetNamewith no trim/case tolerance and no append fallback, so any drift drops the update.Steps to replicate: Have a stat_block with no
statsyet; the GM emits a[widget: id, stat="Str", value=5]tag. The stat never appears; a phantomconfig.valueis set.Code trace:
game-mode.store.ts:337-350(guard:337, else writesvalue:345-346); renderer reads onlyconfig.statsGameWidgetPanel.tsx:1068-1084; parsergame-tag-parser.ts:921-924; sole apply pathGameSurface.tsx:3873-3874. (Note:stats:[]is truthy so it takes the branch and silently drops;stats:undefinedis the misroute case.)Bug 2 — Manual widget save clobbered by stale chat-metadata sync (medium)
How it breaks the pipeline: The widget-persistence reconciliation guard (
getPendingHudWidgetPersistenceSignature) is set only by the agent/debounced path; the manualsaveWidget/useUpdateGameWidgetspath never registers it. IfchatMetarefetches with the oldgameWidgetStatewhile the PUT is in flight,useSyncGameStatesees a signature mismatch with no pending guard and reverts the optimistic edit.Steps to replicate: Edit a widget value during a game turn (when
chatKeys.detailis invalidated by the streaming metadata patch); the value briefly reverts to the previous value.Code trace:
GameWidgetPanel.tsx:250-271(saveWidget);use-game.ts:578-599(useUpdateGameWidgets, no pending set); guarduse-game.ts:727-736; signature set only bydebouncedPersistWidgets/applyWidgetUpdategame-mode.store.ts:87-103,372-374; server PUTgame.routes.ts:6044-6055; invalidationuse-generate.ts:1703.Bug 3 — Debounced widget PUT overwrites a concurrent manual save (low)
How it breaks the pipeline:
applyWidgetUpdate's debounced timer captures a model-applied widget array and fires ~1s later;useUpdateGameWidgets's immediate PUT never cancels that timer. If a manual save lands between, the stale debounced PUT (full replace) overwrites the saved edit on the server, reverting it ~1s later.Steps to replicate: Model emits a widget tag at turn end, user manually edits+saves within ~1s; the manual edit reverts after a beat.
Code trace:
game-mode.store.ts:87-103(debounce, onlyclearTimeoutat:90),:328-379(applyWidgetUpdate->debouncedPersistWidgets :374);GameWidgetPanel.tsx:250-268;use-game.ts:578-600(no timer cancel); server full replacegame.routes.ts:6044-6055.Bug 4 — Configured inventory_grid widget never renders (low)
How it breaks the pipeline:
getVisibleWidgetsfiltersw.type !== 'inventory_grid'before theMAX_WIDGETSslice, so aninventory_gridthe user/model configured (and that counts toward the 4-widget budget, is persisted, and is kept updated by the server) never appears in the HUD rail despite a working renderer existing.Code trace:
GameWidgetPanel.tsx:84-86(filter+slice); renderer exists:473-474,1107-1180; both panels use itGameSurface.tsx:8900-8901,9337-9345; selectable+countedGameWidgetSetupEditor.tsx:19,110-111,195,227; server maintains itscene-analyzer.ts:120-121,156-159.Bug 5 — Inventory-grid contents editor resets quantity/slot on any edit (medium)
How it breaks the pipeline: The Contents textarea serializes only
item.nameand rebuilds the whole array as{name, quantity:1}on change, discarding existingquantityandslot(which drive the category tabs and count badges).Steps to replicate: With a blueprint/imported inventory_grid containing
{name:'Potion', quantity:5, slot:'consumable'}, edit the Contents textarea (add a line); Potion becomes{name:'Potion', quantity:1}and loses its slot.Code trace:
GameWidgetSetupEditor.tsx:534-546(value:535, onChange rebuild:538-545);normalizeConfigkeeps array as-is:158-163; lost fields used atGameWidgetPanel.tsx:1114,1167-1169; typegame.ts:478.Bug 6 — Locked-on-restore dragged panel never re-clamped, unrecoverable off-screen (medium)
How it breaks the pipeline: Panels default to locked; the unlock->drag->re-lock flow persists
{locked:true, x, y}. On reload a locked panel hasdrag={false}, so framer-motion's drag feature (and its resize listener / ResizeObserver that would re-clamp) is never created; the stale wide-viewport offset applied viastyle={{x,y}}is never re-bounded at a smaller viewport, putting the header/lock toggle off-screen with no reset affordance. (Most exposed: the always-draggableGameMapPanel.)Code trace:
DraggablePanel.tsx:26-84(seed from localStorage, no clamp/resize listener; writes only on dragEnd/toggleLocked);GameWidgetPanel.tsx:402-409/GameMap.tsx:546-554(style={{x,y}},drag={!locked}, no dragControls); constraints resizeGameSurface.tsx:8734,9335. (Refined cause: locked-on-restore path, not framer-motion failing to re-bound in general.)Bug 7 — Finished timer restarts on reload (low)
How it breaks the pipeline: The countdown lives only in local
displaySeconds; on reaching 0 it never writesconfig.running=false/config.seconds=0, so persisted config keepsrunning:trueand the old seconds. On reload the timer remounts and restarts.Code trace:
GameWidgetPanel.tsx:1182-1222(local state:1185, reseed effect:1189-1194, completion clears interval but no write-back:1201-1209); rehydrateuse-game.ts:719-733. (Only the reload path reproduces; in-session re-renders do not.)Suggested Fix
statName, operate on(newConfig.stats ?? []), match trimmed/case-insensitively, and append{name, value}when no match — never fall through to the numericvaluebranch. (Bug 1.)pendingWidgetPersistence(chatId+signature) inuseUpdateGameWidgets/saveWidgetbefore mutation and clear on settle so the sync respects in-flight manual edits. (Bug 2.)useUpdateGameWidgetscancel any pending debounce (exportclearPendingWidgetPersist()from the store, call inonMutate), or share one persistence path. (Bug 3.)inventory_gridin the rail (drop the exclusion) or stop making it selectable/counted in the setup editor. (Bug 4.)quantity/slotby matching incoming names against prior contents, or expose quantity/slot in the editor. (Bug 5.)x/yinto the constraints rect on mount and on a window/constraints ResizeObserver (for locked panels too), and add a reset-position affordance. (Bug 6.)running:false/seconds:0throughapplyWidgetUpdate/updateGameWidgets. (Bug 7.)Template checklist
pnpm checkpasses (TypeScript + ESLint)value)Affected files
packages/client/src/stores/game-mode.store.tspackages/client/src/components/game/GameWidgetPanel.tsxpackages/client/src/components/game/GameWidgetSetupEditor.tsxpackages/client/src/components/game/DraggablePanel.tsxpackages/client/src/components/game/GameMap.tsxpackages/client/src/components/game/GameSurface.tsxpackages/client/src/hooks/use-game.tsAudit 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: MEDIUM. Line numbers are against the
stagingworking tree.@SpicyMarinara commented on GitHub (Jun 21, 2026):
Fixed in 6e3ff066.\n\nCovered the HUD-widget failure cluster here:\n- routes stat_block model updates by stat name without falling through into the generic value path\n- keeps manual widget saves from being clobbered by stale metadata or pending debounced PUTs\n- restores inventory_grid widgets to the HUD and preserves item quantity/slot metadata when editing contents\n- clamps persisted map/widget panel positions back into the viewport and adds double-click reset on the lock button\n- persists completed timers as stopped at zero so they do not restart after reload\n\nPer maintainer request, deferred pnpm validation until the issue sweep is complete.