fix(client): read() chat target, dead unsend() guard, i64 fetch cursor - #222
Open
nezumi0627 wants to merge 1 commit into
Open
fix(client): read() chat target, dead unsend() guard, i64 fetch cursor#222nezumi0627 wants to merge 1 commit into
nezumi0627 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three client-facing bugs, each verified with a failing call before the fix:
1.
TalkMessage.read()marked the wrong chat as read for received group messagesFor a group/room message received from someone else,
from.idis the sender's USER mid, butsendChatChecked'schatMidmust be the chat id — so.read()targeted a (usually non-existent) 1:1 chat instead of the group. The neighboringreply()/send()already branch ontoType, which makes this look like an oversight.Now: GROUP/ROOM → always
to.id; USER chats keep the previous behavior (counterpart mid).2.
SquareMessage.unsend()/SquareThreadMessage.unsend()ownership guard was dead codeisMyMessageis an async method on square messages, but bothunsend()implementations tested it as a property:this.isMyMessageis a function object — always truthy — so the guard never fired andunsend()proceeded for anyone's message. Now awaited properly. (TalkMessage.unsend()is unaffected; itsisMyMessageis a getter.)3. Message-fetcher pagination cursor lost i64 precision + crashed on empty pages
createMessageFetcher().fetch()did:parseInt(lastMessage.id)— LINE message ids are ~19-digit values beyondNumber.MAX_SAFE_INTEGER, so the next page's cursor was silently rounded, skipping/duplicating messages. NowBigInt(lastMessage.id)(the struct writer already supports bigint I64).messages.at(-1)!— threwTypeErrorwhen a fetch returned an empty array (end of history). Empty pages now return[]with the cursor left unchanged.Testing
New tests:
talk.test.ts(group read targets chat mid; 1:1 unchanged),square.test.ts(unsend of another member's message throws TypeError without callingunsendMessage),fetcher.test.ts(2^53+1 cursor round-trips losslessly; empty page returns[]without throwing).Full suite:
deno test --allow-all— 218 passed, 0 failed.