mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2661] [Issue]: Assigning a preset races two endpoints → active preset can revert / next generation uses stale preset #1312
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#1312
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 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2661
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Assigning a preset to a chat fires two endpoints concurrently with no sequencing; under latency the chat-metadata response can overwrite the chat detail cache with the stale
promptPresetId, so the active-preset indicator reverts and the next generation may resolve the old preset.Expected behavior
After selecting a preset for a chat, the chat's
promptPresetIdshould reliably reflect the new preset in cache and for the next generation.Actual behavior
selectPreset()callsupdateMetadata.mutate({ id, presetChoices: {} })andupdateChat.mutate({ id, promptPresetId: newId })back-to-back against two endpoints with no ordering. The metadata mutation'sonSuccesswrites the full chat row (which may still carry the oldpromptPresetId) into the detail cache viasetQueryData. If the metadata response lands after the chat response, it clobbers the newpromptPresetId.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/client/src/components/panels/PresetsPanel.tsx:341–363— the two mutations fire unordered againstPATCH /chats/:id/metadataandPATCH /chats/:id.useUpdateChatMetadata.onSuccess(packages/client/src/hooks/use-chats.ts) doesqc.setQueryData(chatKeys.detail(id), data)with the full chat row returned by the metadata PATCH, whosegetByIdread can still hold the oldpromptPresetId(the metadata write is unordered relative to the chat write).ChatAreasyncsuseChat(activeChatId)into the Zustand store, so the stale value re-emits into the active-preset indicator (read ~PresetsPanel:289), and a generation started before refetch can resolve the stale preset.Steps to reproduce
/metadataresponse lands slightly after/chats/:id, observe the active-preset checkmark snap back to A (or persist as A until a manual chat switch/refetch).Suggested fix
Sequence the two mutations (only clear
presetChoicesafter thepromptPresetIdchange succeeds, or vice-versa), or haveuseUpdateChatMetadata.onSuccessmerge only metadata fields into the cache rather than overwriting the whole chat row withsetQueryData(detail, data).Environment
b826f8f4)Additional context
Identified via systematic source review on staging (refs @
b826f8f4). Directly affects which preset governs the next generation, so it can manifest as "I switched presets but the model still behaves like the old one." Filed alongside related pipeline issues.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 (Jun 20, 2026):
Implemented on branch codex/spicymarinara-assigned-issues: metadata mutations now merge metadata into the cached chat detail instead of overwriting newer non-metadata fields like promptPresetId. Final validation will run after the full assigned sweep per maintainer request.