Skip to content

feat(mobile): opening a channel quiets its list row - #9271

Open
baxen wants to merge 3 commits into
mainfrom
mbot/mobile-channel-seen
Open

baxen wants to merge 3 commits into
mainfrom
mbot/mobile-channel-seen

Conversation

@baxen

@baxen baxen commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Mobile half of block/buzz-app#2998. Opening a team channel quiets its bold name, attention dot, and contribution to the app badge. The visit leaves message and thread read state intact. An ordinary message newer than the saved cutoff or an unseen mention or reply can light the row again.

  • seen:<channel> is the cutoff for ordinary activity. When a pass finds unseen ordinary backlog, it uses the newest unseen verified event in that pass, including attention. Mobile saves the cutoff locally and sends it with an existing read-state publish or lifecycle flush.
  • seen:msg:<id> is a device-local receipt for a mention, broadcast, or reply. A late unread attention message still lights the row even when its timestamp is at or below the cutoff. Expired receipts are pruned from live state and disk. Receipts stay out of read-state slots.
  • The page collects hints when it is in front and the app is in use. Returning to an already-quiet row writes nothing. Manual unread takes precedence over the hints.
  • Mobile Solo keeps raw unread in the channel list, Me, and the app badge. Opening Solo uses its existing open-read behavior, as do DMs and forums.

Why this improves mobile

A quick visit clears the row and badge locally while leaving the thread unread. Visit-only hints use the existing sync path, so they incur no dedicated read-state snapshot. The Solo badge follows what Home and Me show.

Related issue

N/A. Mirrors block/buzz-app#2998.

Testing

  • The channel-list widget test opens the channel, goes back, and checks that the name and dot quiet while only row hints are written. Before-and-after screenshots
  • Widget, read-state, and badge tests cover late attention, foreground and background arrivals, device-local receipts, the next flush after a row-only visit, and raw unread for labelled and legacy Solo chats.
  • The full mobile suite, static analysis, and file-size check passed locally.
  • Phone check pending. Open a team channel with an unread thread reply, go back, and check that its row and badge contribution clear. The thread should still show unread. A new mention should light the row again.

Mirrors buzz-app #2998. While a channel page is in front and the app is
in use, it saves row hints for what the row shows: `seen:<channel>` for
ordinary messages (synced) and a local `seen:msg:<id>` receipt for each
mention, broadcast or reply. The channel list's bold and dot and the app
badge leave out what the row has seen. Nothing is read: threads, the
Solo list and every other unread reader keep the unread. A manual
unread on the channel or a message shows the whole row again.

Co-authored-by: mbot <3754f8729004d95654c46dbab3129e4ab9ef05cc2534e2a3fbfc155983bd637b@buzz.block.builderlab.xyz>
Signed-off-by: Bradley Axen <baxen@squareup.com>
@baxen
baxen requested a review from a team as a code owner November 9, 2026 03:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T03:38:24.163670Z e803da9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

🔐 Codex Security Review

Note: This is an automated, security-focused review generated by Codex.
Use it as a supplement to human review; false positives are possible.

Scope

  • Exact PR diff: 4a440b5932eb20a0b38d1674edea33bfa4ad3683...18a1cf2d9febba24d5cd74060092fb80a19eafa8
  • Model: gpt-6.1-sol

💡 Click "edited" above to see earlier reviews for this PR.


Review Summary

Overall Risk: NONE

No concrete security, correctness, or reliability findings were identified in the authorized PR range.

Findings

No concrete security, correctness, or reliability findings were identified.

Notes

  • Review used read-only source and history inspection. Builds and tests were not run, as requested.

Generated by Codex Security Review |
Requested by: @wesbillman |
Workflow run

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e803da93c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to +145
if (event.createdAt > newest) newest = event.createdAt;
if (event.channelCatchUp) {
ordinary = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Derive the seen frontier only from ordinary events

When the observed set contains an ordinary message plus a newer mention or reply, newest advances to the attention event's timestamp and that value is stored as seen:<channel>. If an ordinary event is subsequently delivered with a timestamp between those two values—such as after reconnect or from a sender with a slower clock—rowSawObservedUnreadEvent treats it as already seen, so the newly arrived activity never highlights the row. Update the channel frontier only while processing event.channelCatchUp; attention events already have their per-message receipts.

AGENTS.md reference: AGENTS.md:L266-L271

Useful? React with 👍 / 👎.

Comment on lines +146 to +147
} else {
marks[seenMessageContextKey(event.id)] = event.createdAt;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Bound locally retained attention receipts

For every attention event observed while a channel is open, this creates a unique seen:msg:<id> context, with no count-based eviction. These contexts accumulate in ReadStateManager._effectiveState; serialization filters old timestamps but never removes them from the live map, while every receipt within the 30-day horizon is rewritten into the journal. Sustained mention/reply traffic therefore makes memory use and each JSON persist grow continuously during a long-running session, so the receipt set needs live pruning or a hard capacity bound.

AGENTS.md reference: AGENTS.md:L249-L256

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Prune expired row receipts from live state

_persistLocalState prunes into a separate observed map, leaving _effectiveState unchanged. As new attention IDs arrive, expired seen:msg: entries therefore remain in memory and participate in subsequent save scans. Please prune these obsolete row receipts from live state too. If adding capacity eviction, dropping a row hint should not advance the read floor—it quiets the row but does not mark anything read.

Posted by Codex (gpt-6.1-sol) on behalf of kylez

@kazemek21 kazemek21 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Kyle reviewed this PR and the Nexus review-tracker notes. Approved with the non-blocking receipt-pruning suggestion above.

Posted by Codex (gpt-6.1-sol) on behalf of kylez

klopez4212 added a commit that referenced this pull request Nov 9, 2026
## Summary

A reply in a thread you started, participated in, or followed can light
a mobile channel's attention dot without appearing in Activity. Activity
now includes eligible replies already observed by the channel unread
pipeline in **All** and **Threads**. Tapping a row uses the existing
oldest-unread reply and thread navigation.

Retain the reply payload alongside its bounded unread evidence, then
merge by event ID with the addressed feed. Mentions retain their
category and do not duplicate. Deletion, eviction, and account/community
resets share the same registry. This adds no relay queries or
subscriptions.

Coverage follows the existing channel unread catch-up and live
subscriptions. This does not introduce complete historical thread
discovery: replies outside that retained window, and replies not
eligible for the channel attention dot, are not newly fetched.

### Related issue

Related to #9271 (clearing channel rows) and closed #9186 (broader
Activity feed expansion). #9213 supplied the existing Activity filters.
This PR connects existing observed replies to those filters.

### Testing

- Full mobile suite, push-unconfigured tests, analysis, formatting and
file-size checks.
- Production-provider regression: cold catch-up, live reply, mention
deduplication, excluded unrelated/quiet replies, thread read markers,
deletion/replay and identity reset.
- Real Activity widget journey with fake relay/storage boundaries: show
the unmentioned reply, select Threads, tap the row, and verify the reply
ID and thread ID passed to the conversation page.
- Mutation check: removing reply-payload retention makes the widget
journey fail because the reply is absent.
- Independent agent source review: no blockers.

### Preview

Actual Flutter widgets at phone width with synthetic data and the new
reply wiring disabled/enabled. These are widget-test captures, not
installed-device or live-relay evidence.

| Before | After |
| --- | --- |
| ![Activity omits the unmentioned
reply](https://github.com/user-attachments/assets/a6fc8193-b1ef-4022-a5f1-a1cbbcdf5fb2)
| ![Activity shows the unmentioned thread
reply](https://github.com/user-attachments/assets/b2a6ba13-384a-4d0f-bda3-88d83307d31e)
|

### Human validation pending

Draft per the repository readiness checklist. On a device, receive an
unmentioned reply in a thread you started, replied in, or followed.
Check Activity → All and Threads, tap the row to reach the reply, then
read it and confirm Unread clears without reading unrelated channel
messages. Native/live-relay testing and human confirmation remain
pending.

---------

Signed-off-by: kenny lopez <klopez4212@gmail.com>
Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Terp <5856f6900e8e0a4e0ea1f4f8d2ee33e4753d2119bc122f94ecafc660b46c0511@buzz.block.builderlab.xyz>
Co-authored-by: Tom Brow <tomb@block.xyz>
Co-authored-by: Tom Brow <tomb@squareup.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

@wesbillman wesbillman 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.

🤖 Star Lord: no blocking findings at e803da9; recommend approval based on source review. Tests and device behavior were not exercised.

Use the current unread evidence revisions and preserve synced manual unread. Store attention receipts locally and expire them with the read horizon.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@github-actions github-actions Bot removed the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 23, 2026
@wesbillman
wesbillman deployed to codex-review November 23, 2026 17:00 — with GitHub Actions Active
@wesbillman

Copy link
Copy Markdown
Collaborator

🤖 Star Lord · Before and after on c3a0693

Opening the channel clears the bold name and attention dot. The Flutter widget test drives the channel list and channel screen with synthetic messages and checks that the visit writes only row hints. The badge and thread read state are covered by tests.

Before opening #general After returning to the list
before-opening after-opening

wesbillman added a commit that referenced this pull request Nov 23, 2026

@wesbillman wesbillman 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.

🤖 Carl, an automated reviewer, commenting via Wes's GitHub account.

Verdict: no blockers. The row-hint design matches buzz-app a905c4865: same seen:<channel> wire key both ways, seen:msg: kept local on publish, peer ingest and own-slot recovery, and the badge simplification is equivalent to the removed backlog branch. Two recommended fixes and two optional suggestions are inline.

PR body is stale against the code: it names markContextsRead and isLocalOnlyContext (the code has markChannelRowSeen and isSeenMessageContext/isReadStateSlotContext). It says seen:<channel> is the newest ordinary message, but the code saves the newest unseen event of any kind, which matches desktop. And it says desktop's Solo inventory keeps raw unread, which it doesn't (see the inline thread on the badge).

Validation gaps: source review only; no device run. Mobile CI was partly pending at review time.

Exit criteria: address or decline the two recommended threads and correct the body.

marks[seenMessageContextKey(event.id)] = event.createdAt;
}
}
if (ordinary) marks[seenContextKey(channelId)] = newest;

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.

🤖 Optional: the saved cutoff depends on frame delivery and never retreats.

Marks are written incrementally while the page is in front, and seen:<channel> only advances when the pass finds unseen ordinary backlog. Two consequences:

  • If ordinary t=100 and a mention t=120 land in one pass, mobile saves 120 (same as desktop). If they land in separate passes, it saves 100, so a late ordinary t=110 relights the row. That's conservative, and the synced value keeps clients consistent, but it isn't deterministic.
  • If a thread reply at t=120 is deleted during the visit after the cut reached 120, the cut stays at 120. Desktop builds its exit snapshot from retained evidence and would cut at the newest remaining event, so a late ordinary message stamped between them stays hidden on mobile but not on desktop.

Desktop freezes the snapshot at visit end (unread.ts seeChannel). Saving the cut once from retained evidence on cover, background or exit would fix both and make it match desktop. The deletion case needs a deletion during the visit plus a delayed message inside that window, so I wouldn't block on it.

var publish = false;
for (final MapEntry(:key, :value) in marks.entries) {
if (value <= floor) continue;
final sync = !isSeenMessageContext(key);

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.

🤖 Optional hardening: row hints compete with real reads at the snapshot cap.

seen:<channel> enters the same slot plan as read frontiers, and _checkSnapshotCapacity rejects the whole batch. Its fallback only drops follow packets. Near the cap, a new row hint can therefore stop an explicit read that would fit on its own from publishing. Any new context has this property and desktop publishes the same keys, and we have no evidence that ordinary accounts approach the cap. Still, row hints are the cheapest thing to drop, so giving them lower priority in the capacity fallback would be a reasonable guard.

Journal the team channel cutoff for the next read-state publish or flush. Match the badge to the raw unread logic used by Home and Me for both labelled and legacy Solo chats.

Co-authored-by: Star Lord <b89298dbe87c6b3fd8a425b535d9d161f23c88d555a47925ae0b04dfe02b201e@buzz.block.builderlab.xyz>
Signed-off-by: Wes <wesb@block.xyz>
@wesbillman
wesbillman deployed to codex-review November 23, 2026 18:42 — with GitHub Actions Active
@github-actions github-actions Bot added the codex-security-review-current The posted Codex security review matches its recorded range. label Nov 23, 2026

This branch was successfully deployed

1 active deployment
codex-review — 18a1cf2d Deployed Nov 23, 2026 by wesbillman via Run Codex Security Review #17476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex-security-review-current The posted Codex security review matches its recorded range.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants