mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3506] [Issue]: Persona portrait focus/zoom pending save is lost on tab close (no pagehide flush) #1894
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#1894
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 (Jul 11, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3506
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Persona portrait focus/zoom adjustments made in the tracker panel are saved through a 180ms debounce, and the only flush of a pending save happens in a React effect cleanup (component unmount). Nothing flushes the pending save when the document unloads, so closing the tab or hard-refreshing right after adjusting the portrait silently loses the adjustment.
Expected behavior
A pending portrait focus/zoom save survives tab close and hard refresh, the same way game-state patches and chat drafts already do (
use-game-state-patcher.tsflushes onbeforeunloadwith{ keepalive: true };ChatInput.tsxflushes drafts onpagehide).Actual behavior
The flush lives only in an unmount effect cleanup (
PersonaInventoryPanel.tsx~302-309, renamed fromPersonaTrackerPanel.tsxin PR #3503 with identical content). Effect cleanups do not run on document unload, so the debounced save (created at ~211-219, sent viauseUpdatePersonaat ~197) is dropped. During a continuous drag each movement resets the debounce, so the at-risk window is longer than 180ms in practice.Steps to reproduce
Environment
Logs, screenshots, or video
Not applicable — this is a code-review finding. Relevant code:
packages/client/src/features/tracker-panel/components/sections/PersonaInventoryPanel.tsx— debounce ~211-219, flush call ~197, unmount-only cleanup flush ~302-309packages/client/src/hooks/use-characters.tsuseUpdatePersona(~1033) — does not currently accept any request optionspackages/client/src/lib/api-client.ts—api.patchalready acceptsinit?: RequestInit(~262); no lifecycle-tiedAbortControllerexists, which is why the unmount-path flush works fine today withoutkeepaliveAdditional context
Origin: CodeRabbit review on PR #3503 suggested adding
keepaliveto the unmount flush; on verification the suggestion was withdrawn as misdirected because SPA unmount does not abort fetches — the actual gap is that no flush runs on document unload at all. Discussion: https://github.com/Pasta-Devs/Marinara-Engine/pull/3503#issuecomment-4949033335Why it matters: the lost data is cosmetic (portrait focus X/Y/zoom inside
trackerCardColors), so severity is low, but the fix is small and the codebase already has the pattern in three places.Correct fix shape (the two halves are only useful together):
keepalive?: booleanoption throughuseUpdatePersona, destructured OUT of the PATCH body beforeapi.patch(..., data, keepalive ? { keepalive: true } : undefined)— following theuse-achievements.tsprecedent of a narrow boolean rather than rawRequestInit, so nothing can leak into the JSON body or override fetch options.keepalive: truefrom the portrait flush, and add apagehidelistener in the panel that performs the same flush (mirroruse-game-state-patcher.ts:411/ChatInput.tsx's draft flush). The existing pending-save ref nulling already guards against double flushes on bfcachepagehide.Should land after PR #3503 (which renames the file) to avoid conflicts.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jul 11, 2026):
Claimed for implementation by @SpicyMarinara in draft PR #3507.
@SpicyMarinara commented on GitHub (Jul 11, 2026):
Addressed in PR #3507, which is ready for review and has CodeRabbit requested.