mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5641] Chat metadata edits can be transiently reverted by mutations that write the chat cache without the version guard #3122
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#3122
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 (Aug 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5641
Originally assigned to: @kolacheee on GitHub.
What happens
Chat metadata edits are protected against stale server echoes by a per-field version guard, but only when the write goes through
useUpdateChatMetadata. Several other mutations write the chat detail cache with a raw server snapshot, bypassing that guard:useClearAutonomousUnread—packages/client/src/hooks/use-chats.ts:819(qc.setQueryData(chatKeys.detail(chatId), data))use-chats.ts:857(viasyncCachedChat, which does no version merging)packages/client/src/hooks/use-connections.ts:124packages/client/src/hooks/use-background-autonomous.ts:286packages/client/src/hooks/use-game.ts:301/454/485/529If one of these responses was produced by the server before an in-flight metadata PATCH (the server serializes per-chat metadata writes, so a request queued first deterministically returns a pre-PATCH snapshot) but is consumed by the client after it, the cache momentarily regresses recently-changed metadata — including booleans like
narrativeDirectorSecretPlotEnabled,enableAgents, andactiveAgentIdsthat mount/unmount whole sections of the Chat Settings drawer. The section unmounts for a moment and remounts when the guarded PATCH echo restores the value.Why it matters
A remount in that window used to silently destroy an in-progress edit (that symptom is now absorbed by the
DraftNumberInputfix in PR #5640 — the input commits its pending value on unmount). But the underlying flicker is still real: any component state inside the flickered section is reset, and any other unguarded consumer of the regressed metadata briefly acts on stale values.Concrete scenario
An autonomous chat has unread residue, so
AppShellfiresclearAutonomousUnreadfor the active chat (packages/client/src/components/AppShell.tsx:626-640) around the same time the user is editing agent settings in the drawer. The DELETE's response carries a chat snapshot from before the user's just-committed toggle; when it lands, the toggled section blinks. This is a response-ordering race, so it needs unlucky timing (slow machine, slow storage flush) — the same class of window that produced #5636's CI failure.Suggested direction
Route every detail-cache write through the same per-field version merge
useUpdateChatMetadatauses (e.g. givesyncCachedChata merging variant for server snapshots), rather than trusting raw snapshots to be current. The game-surface writers only affect game chats and the Mari writers only the internal Mari chat, so the twouse-chats.tswriters are the highest-value ones.Found while verifying the #5636 fix (adversarial review pass on PR #5640).
@kolacheee commented on GitHub (Aug 29, 2026):
Taking this one (kolacheee + Claude agent) on branch fix/5641-guarded-cache-writers; draft PR to follow with the first commit. #5631 will follow separately after.