mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2963] [Issue]: Swipe counter briefly shows wrong values (e.g. 3/2, or number leads the text) after regenerate or switch #1541
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#1541
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 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2963
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The swipe counter can briefly show wrong values right after a regenerate or a swipe switch. Two transient, self-correcting glitches with the same flavor (the counter updates before the rest catches up):
3/2(the active index advanced, the total hasn't yet) before the background refetch fixes it to3/3.Neither loses data, but both look broken, and during the
3/2window the right-arrow can kick off another generation.How to reproduce (try it yourself)
Wrong total after regen:
2/2).You'll see: it briefly shows
3/2, then self-corrects to3/3.Number leads body on switch:
You'll see: the counter jumps to
2/3instantly, but the body/reactions/thinking stay on swipe 1 for a moment before snapping over.Expected (both): the counter and the content/total change together.
Where it is
packages/server/src/services/storage/chats.storage.tsgetMessage()(~705-708) returns noswipeCount(onlygetMessages/listMessagesPaginateddecorate it); the regenerate snapshot is built viagetMessage(generate.routes.ts:6958-6959), and the client merges{...existing, ...incoming}inmergeCachedGeneratedMessage(use-generate.ts~419), soincoming(noswipeCount) leaves the stale total untilrefreshMessagesInBackgroundreconciles.SwipeJumpControl.tsxrendersactiveSwipeIndex + 1against that stale total.packages/client/src/hooks/use-chats.tsuseSetActiveSwipe.onMutate(~1187-1189) spreads only{ ...msg, activeSwipeIndex: index }; the swapped content/extra only arrive inonSuccess(~1199-1201). The body readsmessage.content/extra, so number and body desync until the PUT returns.What's happening
Both are optimistic-update gaps: the index is advanced locally without the matching total (regen) or without the matching content/extra (switch), and the truth only lands on the server round-trip / background refetch.
Suggested fix
message_savedsnapshot with the current swipe count (e.g.swipeCount = (await getSwipes(id)).length) on the regen/swipe paths, or havegetMessage()computeswipeCountlikegetMessages()does, so the merge updates the total.useSetActiveSwipe.onMutate, swapcontent+extraoptimistically from theuseSwipescache, or defer the counter advance untilonSuccess, so the number and body move together.AI-investigated against v2.0.6; both optimistic paths read. Transient/no-data-loss; please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in staging: optimistic swipe switches now move cached content/extra with the active index, and regenerated SSE merges preserve a sane swipe count. Validated with pnpm check and pnpm regression:prompt.