Skip to content

Google Messages: an unread chat always shows "1", whatever the real count - #817

Closed
itz4blitz wants to merge 1 commit into
mainfrom
issue/704-unread-count
Closed

itz4blitz wants to merge 1 commit into
mainfrom
issue/704-unread-count

Conversation

@itz4blitz

Copy link
Copy Markdown
Collaborator

What changed and why

A Google Messages chat no longer shows a badge of 1 just because the phone says it is unread. The texts that arrive are the count: three new texts show 3. When the phone later says the chat is read, the badge goes to 0 and the read marker moves to the newest text. A batch applies the messages before the conversation row, so a read flag in that batch does not wipe a count that the same batch just delivered.

A flag on its own, with no texts cached, stays at 0. A direct or group row has no way to show "unread, count unknown" as a dot: any unread number is drawn as that number. Publishing 1 would be the bug this fixes. Mark as unread is not added. The calls this adapter already speaks have no request for it.

Type

  • feature
  • fix
  • perf
  • refactor
  • chore
  • docs

Platforms

  • windows
  • macos
  • linux
  • android
  • ios

Proof

Scenario: e2e/scenarios/messages-unread

Lab run: Not run.

Compatibility

No protocol change. An older shell still draws the unread number it is given. An older chatd ignores TINYCLIENT_PROVE=messages-unread and keeps serving, so the same driver fails there.

Risk and rollback

A chat the phone has marked unread, before any text has arrived here, shows no badge. Revert this commit to restore the old badge of 1.

Release note

A Google Messages chat shows how many texts are unread, and clears when the phone has read them.

Tested

cargo test -p chatd --no-default-features --test messages and the decoder unit test for the unread flag. cargo clippy -p chatd --no-default-features --all-targets.

Not tested with a live Google account. The lab was not run.

Closes #704

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Tiny Code Review

⚠️ Code review unavailable · run

the AI provider rate-limited the request

This is advice, not a gate. Re-run with the agent:review label or a /review comment.

@unRekable unRekable left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

🟡 1 finding (0 blocking).

The change reads the Bugle unread flag as a flag, counts live texts as they arrive, clears on the phone's read with the marker at the newest seen message, and applies an update batch messages-first so a read flag cannot wipe a count the same batch delivered. The design holds: the synthesized marker composes with set_counts' rewind guards, and the prove self-check, unit test, and e2e scenario cover the fix on all sides. The one real gap is that the whole clear path depends on connection-local memory, so after chatd restarts or reconnects it silently does nothing and a persisted count survives the phone's read.

Residual risk

  • At connect (fresh account or right after pairing) a chat the phone says is unread shows no badge at all: the wire's flag carries no count and any invented number would reintroduce #704. The PR body accepts this trade.
  • Counts already persisted wrong by the old build (the flag's 1) are not healed by this diff; they stay until the phone sends a fresh read event or a new text arrives, since flag=true now never writes a count.
  • The field-order fix covers one update batch; if Google splits a batch's messages and its read flag across separate update events, the clear still uses whatever this client had seen, which is the best available marker but not a phone-acknowledged one.

Comment thread crates/chatd/src/adapters/messages.rs Outdated
.unwrap_or_else(|poisoned| poisoned.into_inner())
.get(conversation)
.cloned();
let Some((id, sent)) = newest else {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Major: clear_read only works for chats this connection has already seen a message on: account.newest starts empty, so right after a start or a reconnect a phone read of a chat whose count a previous session persisted does nothing, and the badge stays wrong until a new text arrives and is read again — the exact case this PR says it fixes. Fall back to the store when the in-memory map has no entry; Context::newest already returns the newest stored message id for the conversation, and the row's updated keeps the timestamp.

Suggested change
let Some((id, sent)) = newest else {
let Some((id, sent)) = newest.or_else(|| {
let id = account.ctx.newest(conversation).ok().flatten()?;
let sent = account
.ctx
.known(conversation)
.ok()
.flatten()
.map(|row| row.updated)
.unwrap_or(0);
Some((id, sent))
}) else {
return;
};

…one has read them.

The phone's unread flag is not a count. A chat with no texts stays at zero instead of showing 1, three texts count as three, and a later read flag moves the marker to the newest text and clears the badge. Messages in one batch are applied before the conversation row.

Closes #704
@itz4blitz
itz4blitz force-pushed the issue/704-unread-count branch from bc25c5a to a782b7e Compare November 20, 2026 21:20
itz4blitz added a commit that referenced this pull request Nov 21, 2026
…903)

* A reaction on an encrypted Tiny conversation is asked of the plaintext route the server refuses, and the test expects it sealed with an echo that lands (red)

* Reactions in an encrypted Tiny conversation go out sealed, and fold back onto the message

* The lab records a reaction in an encrypted Tiny conversation landing and echoing back

* The reaction's authenticated data is described on its own

* The audit's findings: a client id inside the server's 64 characters, folds rebuilt in the server's order, owed reactions applied when their message lands, and a reaction that cannot open yet is folded again

* Sealed reactions persist: chips live in the stored rows, the fold's cursor and owed pairs are kept sealed beside the cache, a blob that cannot open yet holds the cursor until it opens or its tries run out, and a restart neither refolds history nor loses a count

* Show the preview Telegram sends inside a photo until its thumbnail lands, and stop failing photos the cache removed.

Telegram puts a tiny copy of every photo (its stripped thumbnail, about
40 px) inside the message. chatd now rebuilds it into a JPEG from
Telegram's fixed header and keeps it on disk as soon as the message is
read, without asking the network. It reaches the shell as the new
optional Attachment.preview. The tile draws it stretched over the
photo's place while the chat-sized thumbnail downloads, and the
thumbnail replaces it in the same place at the same size. Load images
and spoilers hide it exactly as they hide the photo. A photo with no
usable preview shows the image icon as before. Album tiles use the
same code.

What came inside a message is kept at once, on the thread that reads
the message, so a preview never waits behind the downloads it stands
in for. Each write has its own part file, so two writers of the same
file never cut each other short.

The media cache retried a Telegram file it had evicted at Telegram's
internal tg://file/ name, which no host serves, and marked it
"Telegram does not serve files from that address." The photo then said
it could not load, with a Retry that could not work, until Telegram
read the message again. The cache now leaves those files to Telegram
and never marks them failed, so the box shows the preview or the icon,
and chatd clears the old failures once at start. Signal, Messages and
web addresses are unchanged.

The e2e scenario telegram-photo-preview holds the thumbnail on the fake
wire, checks the screen shows the preview, lets the thumbnail go, and
checks it lands in the same place.

* Ignore local proof folders and stray target worktrees

`_proof/` and `target-wt/` are ship-it evidence and local build output. They were showing up as untracked work on every checkout.

* The remaining review findings: the sealed fold log is rewritten instead of appended whole and keeps only what the cursor can still deliver, a blob that cannot open three folds is skipped for this session and the first fold after a restart steps back below it, the reaction list is paged without the device mutex held and a page applies only while the cursor still stands where it was asked for, rows without an id move the cursor so a page of them is never asked for twice, and a taken-back reaction leaves no empty entry behind

* Show a Signal long text as the text it carries, with a continuation note, and tell the composer the 2048 cap

* Start tinyclient at sign-in when the setting asks, with the registration each platform already owns

* Put the unread count on the Linux launcher entry and flash for attention

* Keep the continuation note out of what a Signal quote sends

* Name the launcher entry value's lifetime and keep the badge rows off phones

* Ring when a Signal call arrives and leave a missed-call line when it is not answered

* Keep tinyclient alive in a Windows tray behind an opt-in close-to-tray setting

* Keep the attention rows on desktop and off phones

* Name Signal view-once media instead of a bare Photo, on send and receive paths alike

* Point the view-once test at the AttachmentPointer proto where it actually lives

* Withdraw each Signal ring by its own call and let the newest offer take the ring

* Draw the mouse pointer into Windows screen shares, with a Wayland off-switch

* Offer quick actions on the taskbar, Dock and launcher icon

* Say what a Signal payment or gift badge carries instead of a bare word

* Give Signal local read-receipt and typing switches that the send paths honour

* Fix the tray's windows-rs 0.62 call shapes and rebuild the icon after explorer restarts

* Let the tray search closure match find's double reference again

* Call the cursor's GDI handles behind unsafe with the safety story written down

* Store reminders, wake the notifier for their due time and post them once (stage 1a)

* Show who reacted, with the honest Someone fallback where only counts arrive

* Keep an edit time and the superseded words on edited messages, off the wire when empty

* Mark a whole space read in one go, scoped so other spaces keep their badges

* Let notify reach the hub it drives and fix the prove driver's type errors

* Fix the reactors patch compile: name the closure's user for the peer, and spell the assertion's count and owners to the reaction's own types

* Match the row before by reference and borrow the capped prior in the test

* Open the reminder test store as a Path so it compiles

* Give the edited tooltip to the finished text block so both branches type the same

* Let actions name the reactors: open draw's person and who to the conversation module, take the name resolver as a reborrowed FnMut, and let who read a shared context

* Pin the kept edit ahead of the deleted row in the prior test

* Drop the redundant .into() on the reactor menu item id so ElementId inference is unambiguous

* Clone the reactor's key so the click listener stays Fn.

* Tell Discord the share quality that was picked.

Opcode 12 names the size, frame rate and bitrate of the share, and is sent again when that quality changes. The picture drive asks for that bitrate. A camera stays one layer.

Closes #338

* Block, add and remove a Telegram contact, and read who is blocked.

Closes #487

* Keep Signal bold, italic, strike, monospace and spoiler, and leave a spoiler out of the preview.

Closes #747

* Show a hidden last seen in words, and list the groups in common.

Closes #523

* Send photos, videos and files in a Signal chat. Closes #742

* Keep one copy of each Signal file while it uploads.

The row writes the payloads to disk, then the wire takes that same buffer. A failed send removes the files it wrote.

* Telegram: use inline bots by typing "@bot query" in any chat

A GIF-picker query that starts with @bot asks that bot in the open chat and keeps an article result. A message that came through a bot the account already knows names it. A GIF search is unchanged. No location is sent to a bot.

Closes #482

* Read a Teams thread past the first page of replies.

Scrolling up follows the cursor Teams sends with each page, and opening an old reply loads the page that ends there. Once the start of the chain is stored, the post counts every reply that was stored.

Closes #633

* Answer a Teams team's info and section its roster into owners, members and guests.

Closes #668

* Name a failed action, and give it a ref to quote.

A request that fails for no specific reason says what was tried and a short ref. The same ref is in the log with the real error, and Copy diagnostics lists recent refs. A call that comes back without an error says it could not be placed.

Closes #765

* Look up a Signal username and open a chat with that account.

Closes #730

* Settings can change a shortcut, and the quick switcher lists commands after >.

Closes #789

* Show Slack custom emoji from the workspace list without opening the picker.

Closes #563

* Follow a move to another Discord voice channel.

A voice state that puts us in another channel of the same server retargets the call and rejoins with that channel. A direct call, another server, and leaving the channel stay as they were. The dock says the call moved.

Closes #333

* Show who replied in a Discord thread and keep the reply count current.

A reply updates the starter chip with the count, the newest faces, and unread. A thread update copies Discord's count when it is ahead.

Closes #387

* Show both names, custom fields, and roles on a Slack profile.

A profile reads labelled custom fields once an hour, keeps the full name beside the display name, and turns a manager into that person's link.

Closes #592

* Star a Slack conversation on Slack, and clear it when Slack does.

Closes #603

* Color fenced code blocks from their language, including diff and ansi.

Closes #358

* Show a Slack meeting as a card with a Join link, and say when an old call happened.

A Zoom, Meet, Teams or Webex call block is a card with who is in it, or how long it ran, and a Join link. An old Slack call reads as a call that happened. A call id with nothing filled in stays the placeholder.

Closes #555

* Discord highlighter: an escape followed by non-ASCII text no longer panics the coloring task

take_sgr bailed after one byte of a multi-byte character, so ansi() sliced the
source mid-character. It now leaves a non-ASCII byte for the caller, and a test
covers escapes followed by accented, emoji and CJK text.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* Cover the window after it has been left, and hide what a notification says.

Closes #751

* Count Google Messages unread from the texts, and clear it when the phone has read them.

The phone's unread flag is not a count. A chat with no texts stays at zero instead of showing 1, three texts count as three, and a later read flag moves the marker to the newest text and clears the badge. Messages in one batch are applied before the conversation row.

Closes #704

* Ask the phone to unpair this computer when Google Messages signs out.

Closes #703

* Show a Google Messages video as a video, and a voice note with its waveform.

Closes #705

* Sync a Signal delete for me, and stop sending a late delete to everyone.

A message or chat deleted on the phone now leaves here. Past one day, Delete tells only this account's other devices. An edit or a delete for everyone older than two days is ignored.

Closes #714

* Keep a Signal reaction across a restart so a new emoji replaces the old one.

Closes #739

* Telegram: files over 200 MB, and files served from Telegram's CDN, cannot be downloaded.

Closes #505

* Show a Signal group rename, and the line that says who changed it.

A newer group revision updates the row and writes one system line per change. The snapshot at connect does not invent lines. Leaving the group marks it read-only.

Closes #720

* Remember which chat a Telegram message is in, so a delete after reconnect removes it.

Closes #515

* Telegram: link previews have no picture, no Instant View, and no control when sending.

Closes #506

* Telegram: see someone's live location on a map as it moves

A live share stays a normal message with a card: the coordinates, the heading, how long it was shared, and whether it is still going. When the same message moves, the card updates and it does not count as another unread message. Coming into range is a service line. No map tile is fetched.

Closes #453

* Keep view-once Telegram media locked instead of downloading it.

A photo, video, or voice message with a timer reads as a locked row and queues no file. An ordinary photo is still fetched.

Closes #546

* Notify someone who has no username when they are mentioned in Telegram.

The composer sends the display name. Someone with no username becomes their first name plus a text mention. Someone with a username becomes that username, which already notifies them.

Closes #534

* Offload owe_reactions from socket thread and drop stray __pycache__ .pyc files

* Slack: send formatted text as Slack's rich text, including labelled links (#595)

A formatted send, edit, scheduled message, or file comment goes to Slack as rich_text blocks, with the plain text kept as the fallback. A labelled link is a link element. A plain send stays text only.

Closes #595

* mediad: support TINYCLIENT_MEDIAD_SCREEN=null in headless voice tests

* Show a Telegram checklist's items, and mark the one that is done.

A checklist message lists its title and each item. A completed item is checked. The list is read-only.

Closes #485

* Keep a checklist's open link on the list.

Ticking stays in Telegram. The list ends with the same link the old box opened, so the message can still be reached.

* Telegram: mark a chat as unread

A chat can be marked unread. The badge becomes at least one, Telegram is told with messages.markDialogUnread, and a mark from another device updates the row. Reading the chat clears that mark as well.

Closes #508

* Name a Telegram secret chat and say it only works in the phone apps.

Closes #530

* File Google Messages archive and spam, and send a block.

Closes #674

* Mute a Google Messages chat on this computer.

Closes #690

* Read older Google Messages pages so a search of this computer can find them.

The published relay has no message search. After connecting, each chat is read backward one page at a time until a short page, at the same pace as the inbox. A search then finds a message that was not on the first page, and photos, files and links come from that store once the chat has been read to its start.

Closes #700

* protocol: move code highlighter into shared protocol crate and expand ANSI UTF-8 tests

* Show a poll's options and counts on a card, and apply a poll update.

Closes #520

* Send up to ten files in one Google Messages message.

Closes #689

* Give a Teams chat, channel and message a link that names that place.

The info pane copies Microsoft's documented form for a chat and a channel. A message link uses the same form, and a reply names its post. Each link parses back to the place it came from.

Closes #641

* Stage Signal file send test fixture in outbox for Windows

* Signal: polls cannot be read, voted on, or created

A Signal poll keeps its question and its counts. A vote, a retraction, and an end go out on the wire, and a poll cannot carry a file.

Closes #737

* Fetch the Telegram pictures on screen first, ahead of a channel left and of what is off screen.

Telegram's files come one at a time, 250 ms apart, and every thumbnail a
page named waited in one line: a channel opened after an image-heavy one
waited behind all of the first one's thumbnails, and behind its own that
were not on screen, for 15 to 20 seconds.

The file worker now keeps three lines: the original the viewer waits on,
then the pictures messages show that the shell asked for because they
are on screen (Command::Wanted), the latest asked first, then the rest
in the order pages named them. Telegram keeps the place of each picture
a message shows, as it kept the originals', so an ask moves it ahead. An
ask for a picture no page has named yet is remembered for 30 s and goes
ahead when a page does. A file waiting keeps one place, with the newest
page's reference, so repeated asks are one download. The line still
holds no more than 256: asks are never refused, and the worker lets go
of the last-named background file first. Avatars, custom emoji and a
picker's tiles keep their turn. What is remembered forgets its oldest
half, never all at once.

With #262, a thumbnail the cache removed is fetched again as soon as the
shell asks for it on screen; its test and the docs now say so.

The fake wire gains photo-pages (photo posts in Field Notes and a real
JPEG in Trail crew, read only with their pages) and flood-file. The e2e
scenario telegram-visible-image-priority opens Field Notes, switches to
Trail crew with Ctrl+K while the channel's thumbnails wait, checks from
the wire's log that the group's photo went first and from the screen
that it is drawn.

* Fix bugle::Chat status field in fake.rs after merging #817 and #863

* Fix post-merge Signal integration (capabilities, SendWith poll+files, now_ms, Quote spans, tests)

* Fix Windows build and cross-PR Reaction.who compatibility on Lane 1

* Fix cross-lane integration fields and prove block delimiters across 60 merged PRs

* Perf: add measured-every-pr pipeline and site perf check

* Fix peer-review blockers: restore desktop N10/N11 settings rows and 6 TINYCLIENT_PROVE arms

* Slack: expand built-in emoji table and reaction listing

* Signal: message delivery and read receipts (#729)

* Telegram: typing activity indicators (#543)

* App: message edit history stage 2 (#762)

---------

Co-authored-by: unRekable <unRekable@protonmail.com>
Co-authored-by: Andrii Balakhtar <a.balakhtar@scalr.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
@itz4blitz

Copy link
Copy Markdown
Collaborator Author

Superseded by and merged in #903 (d387971 — Release 2026-11-20 combined PR).

@itz4blitz itz4blitz closed this Nov 21, 2026
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.

Google Messages: an unread chat always shows "1", whatever the real count

2 participants