Skip to content

refactor(chat): drop the deprecated new_messages overlay - #757

Merged
bmc08gt merged 1 commit into
feat/nse-store-writesfrom
refactor/chat-drop-new-messages-overlay
Sep 11, 2026
Merged

bmc08gt merged 1 commit into
feat/nse-store-writesfrom
refactor/chat-drop-new-messages-overlay

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

ChatUpdate.new_messages (field 2) is marked [deprecated = true] in flipcash2-protobuf-api, superseded by the sequenced, gap-detectable events batch (messaging.v1.EventBatch, field 6). The decode path kept it as an additive overlay so a message arriving only there was never dropped. The backend now sends events and leaves new_messages empty, so the overlay only costs a second pass over an empty batch and an enum case that every switch over ConversationStreamEvent has to carry.

Nothing is lost

.chatEvents already covers what the .newMessages arm did, in both places that handled it:

  • Store — the .newMessages arm bumped last activity to the newest message by id. applyChatEvents does the same, restricted to .sent mutations, so an edit or delete can't move a feed row on its original low id. That restriction is the correct behaviour, not a regression.
  • Controller — the .newMessages persist arm read the analytics watermark, reconciled pending sends, wrote messages, counted receipts, and scheduled a gap catch-up on a failed write. The .chatEvents arm does all of it, plus the cursor write that makes the messages and the advanced frontier land atomically.

upsertConversationMessages, which only the removed arm called on this path, is still used by the send, load-older, and mutation paths.

Tests

Ported, because they cover ordering, receipt wiring, and backlog handling rather than the deprecated field:

  • ConversationStreamEventDecodeTests — the decode-ordering and messages-plus-typing cases now build events fixtures.
  • ConversationControllerTests and ConversationReceiptWiringTests — mock.emit now goes through a new ConversationStreamEvent.sent(_:in:) test helper that wraps messages as one contiguous run of .sent mutations. The reconnect-replay dedup still holds: the second emit reads a watermark that already includes the message, so it isn't re-credited.

Deleted, because they only existed to cover the overlay:

  • the basic new_messages decode test (chatEventsDecode covers decoding events),
  • chatEventsAndNewMessagesAdditive and emptyEventsKeepsNewMessages, both migration-window gates,
  • ConversationStoreTests.newMessagesBumpsActivity — chatEventsBumpsActivity already asserts the same last-activity behaviour over .chatEvents, so re-expressing it would have duplicated an existing test.

Notes

Stacked on #756, which is itself the top of the NSE preload stack. The commit doesn't depend on that stack — the only thing those PRs change in the files touched here is three import FlipcashStore lines — so it can be re-parented onto main if the stack is going to sit.

A matching removal is queued for Android (EventStreamDelegate.applyUpdate, which uses the field as an exclusive fallback rather than an additive overlay). The two are independent.

`ChatUpdate.new_messages` is marked `[deprecated = true]` in the contract,
superseded by the sequenced, gap-detectable `events` batch. The decode path
kept it as an additive overlay so a message arriving only there was never
dropped; the backend now sends `events` and leaves `new_messages` empty, so
the overlay only costs a second pass over an empty batch and an enum case
every switch has to carry.

`.chatEvents` already covers what the `.newMessages` arm did. The store's
last-activity bump is the same, restricted to `.sent` mutations so an edit or
delete can't move a feed row on its original low id; the controller's persist
arm matches, plus the cursor write that makes messages and the advanced
frontier land atomically.

Ported the ordering and messages-plus-typing decode tests to `events`, and the
receipt-wiring and backlog tests to `.chatEvents` via a new `ConversationStreamEvent.sent`
helper. Deleted the tests that only covered the overlay itself, including the
store's last-activity test — `chatEventsBumpsActivity` already asserts it.
@bmc08gt bmc08gt self-assigned this Sep 11, 2026
@bmc08gt
bmc08gt merged commit b5ba270 into feat/nse-store-writes Sep 11, 2026
bmc08gt added a commit that referenced this pull request Sep 11, 2026
`ChatUpdate.new_messages` is marked `[deprecated = true]` in the contract,
superseded by the sequenced, gap-detectable `events` batch. The decode path
kept it as an additive overlay so a message arriving only there was never
dropped; the backend now sends `events` and leaves `new_messages` empty, so
the overlay only costs a second pass over an empty batch and an enum case
every switch has to carry.

`.chatEvents` already covers what the `.newMessages` arm did. The store's
last-activity bump is the same, restricted to `.sent` mutations so an edit or
delete can't move a feed row on its original low id; the controller's persist
arm matches, plus the cursor write that makes messages and the advanced
frontier land atomically.

Ported the ordering and messages-plus-typing decode tests to `events`, and the
receipt-wiring and backlog tests to `.chatEvents` via a new `ConversationStreamEvent.sent`
helper. Deleted the tests that only covered the overlay itself, including the
store's last-activity test — `chatEventsBumpsActivity` already asserts it.
bmc08gt added a commit that referenced this pull request Sep 11, 2026
…discrete-curve

* origin/main: (27 commits)
  fix(database): share one SQLite writer per owner and take write locks up front (#759)
  feat(chat): declare the payment action on tip DM payments (#752)
  refactor(chat): drop the deprecated new_messages overlay (#757)
  feat(notifications): write prefetched messages into the shared store (#756)
  refactor(store): move the persistence layer into a shared FlipcashStore package (#755)
  feat(database): move the SQLite store into the App Group container (#754)
  feat(database): open the store on demand, close it on background (#753)
  feat(nse): extension crash reporting, a WAL checkpoint, and on-device push hooks (#751)
  feat(home): long-press the You tab to open the account switcher (#749)
  fix(tests): reset Photos access before the previous app instance lingers (#746)
  chore: bump version to 2026.9.2 (#745)
  revert: back out the Coinbase Stable Swapper authority migration (#747) (#750)
  fix(swap): follow the Coinbase Stable Swapper authority migration (#747)
  fix(tests): cancel a cash link through the details screen (#744)
  fix(chat): make the whole Send Cash pill tappable while it stands alone (#743)
  fix(username): drop a leading @ in the validator (#742)
  fix(chat): scope the send-button spring to the button (#741)
  fix(transactions): tighten the details card stack and drop the header badge (#740)
  fix(transactions): draw View in Chat as a card, not the primary action (#739)
  feat(chat): flash the message a reply-quote jump lands on (#738)
  ...

# Conflicts:
#	Code.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
#	FlipcashCore/Package.swift
@bmc08gt
bmc08gt deleted the refactor/chat-drop-new-messages-overlay branch September 15, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant