mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5654] [Issue]: Game HUD never compacts when its surface mounts after the widget state hydrates #3129
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#3129
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 @Romuromylus on GitHub (Aug 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5654
Originally assigned to: @Romuromylus on GitHub.
Summary
When a Game chat's custom widget state hydrates while the transcript is still loading,
GameSurfacemeasures its HUD layout before the surface element exists and attaches noResizeObserver, so the layout is never measured again on its own. At widths above the compact-by-width shortcut this leaves the desktop widget rails rendered on top of the dialogue until the window happens to be resized.Expected behavior
A Game chat with HUD widgets opened at a tablet or narrow-desktop width should collapse into the compact choice stage, with the widget rails flanking the choice cards, regardless of whether the transcript or the chat metadata resolved first.
Actual behavior
The desktop widget rails render over the dialogue and the compact stage never appears. Nothing recovers it for the rest of the session except a window resize, because the observer that would have re-measured the layout was never attached.
The mechanism is in
packages/client/src/components/game/GameSurface.tsx. The widget-layout effect is keyed on[combatUiActive, normalizedWidgets.length]. It measureshudSurfaceRef.currentand attaches aResizeObserverto it, butGameSurfacealso has an early return for its messages-loading branch that mounts no surface at all, and the widget state hydrates from chat metadata (useSyncGameState) independently of the messages query. When the widget count lands while that branch is showing,updateWidgetLayoutfinds no element and returns, andconst surface = hudSurfaceRef.currentisnullso no observer is attached either. Neither dependency changes when the real surface mounts a moment later, so nothing re-measures.#5618 changed that effect's reset from a flat
falsetowindow.innerWidth < 768, which makes the stranded value coincidentally correct on a phone. It does not address the measurement or the missing observer, so every case where the compact layout depends on the overlap estimate rather than raw width is still broken.Steps to reproduce
hud_left, twohud_right), whose latest assistant message carries a[choices: ...]block.GET /api/chats/<id>/messagesresponse until the surface has rendered its loading state.Instrumenting the effect shows the two orderings directly:
A Playwright probe at 900px reports
{ choiceStage: 0, desktopRails: 2 }on currentstaging, against{ choiceStage: 1, desktopRails: 0 }once the effect re-measures when the surface mounts.Environment
staging, currently5c6ac775e)Logs, screenshots, or video
No console errors. The surface renders completely and only the layout branch is wrong, which is why it reads as a styling problem rather than a failure.
Additional context
Found while investigating #5626. The two tests named there are now green on
stagingafter #5633 and #5618, but both of those addressed the symptoms; this is the app-side defect underneath, and it survives on any path where the compact decision depends on measurement instead of thewindow.innerWidth < 768shortcut.Workaround for users: resize the window once after opening the chat.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Aug 30, 2026):
Fixed by #5628, squash-merged to
stagingas7f43d455e.The widget-layout effect now depends on the HUD surface node itself, so mounting the surface re-establishes both the measurement and the
ResizeObserver. A hydration that lands while the messages-loading branch is up no longer strands the layout.Covered by a regression case at 900px in
e2e/core-flows.e2e.ts, which is past thewidth < 768shortcut and so can only reach the compact layout by measuring. It holds the first page of messages until the loading branch has committed to pin the ordering, and asserts the branch was actually observed so the hold cannot quietly stop guarding. It fails with the fix reverted (two[data-game-widget-rail]elements and no choice stage) and passes with it.Closing as resolved.