mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #450] refactor(storage): per-message serializer + stable swipeId for chats.storage.ts patch queues #197
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#197
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 @coderabbitai[bot] on GitHub (May 6, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/450
Originally assigned to: @SpicyMarinara on GitHub.
Summary
The patch queue introduced in PR #448 (
withPatchQueue) addresses serialization forappendMessageAttachmentandappendSwipeAttachment, but a broader set of race conditions remains inpackages/server/src/services/storage/chats.storage.ts.Problem
The current per-key queue only covers helper-to-helper paths. The following functions still read and overwrite the same JSON fields outside the queue and can therefore race with queued appends:
updateMetadataaddSwipesetActiveSwiperemoveSwipeAdditionally, the swipe queue key is constructed as
messageId:swipeIndex. BecauseremoveSwipe()renumbers swipe indices, an enqueued patch can target the wrong swipe — or no swipe at all — after renumbering occurs.Proposed Solution
perMessagePatchQueuesmap and funnel every function that touches message or swipe extras (updateMetadata,addSwipe,setActiveSwipe,removeSwipe,appendMessageAttachment,appendSwipeAttachment,updateMessageExtra,updateSwipeExtra) throughwithPatchQueuekeyed bymessageId.swipeId(the database row ID, e.g.,messageSwipes.id) instead of the mutableswipeIndexas part of the queue key, so that renumbering inremoveSwipedoes not invalidate or misdirect enqueued operations.removeSwipeeither avoids renumbering indices entirely (e.g., using sparse indices or tombstoning), or properly invalidates/migrates queued operations for affected swipe IDs.Context
packages/server/src/services/storage/chats.storage.ts—withPatchQueue,appendMessageAttachment,appendSwipeAttachment,updateSwipeExtra,addSwipe,setActiveSwipe,removeSwipeRequested by @cha1latte.
@cha1latte commented on GitHub (May 6, 2026):
Triage note: labeling this as
scope-riskbecause the request is tightly aligned with storage correctness, but it changes queue semantics across several message and swipe mutation paths inchats.storage.tsrather than one isolated helper.Least risky next step is to keep this as a scoped storage follow-up and define the per-message serialization and stable
swipeIdbehavior before patching all affected mutation paths.