Repository navigation
feat(mobile): opening a channel quiets its list row #9271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| import 'dart:math'; | ||
|
|
||
| import '../../shared/read_state/read_state_format.dart'; | ||
| import '../../shared/read_state/read_state_provider.dart'; | ||
| import 'channel.dart'; | ||
| import 'channels_provider.dart'; | ||
|
|
@@ -139,31 +142,63 @@ int _channelHighlights({ | |
| if (channelReadAt != null && latestObserved <= channelReadAt) return flags; | ||
| if (observedEvents == null) return flags; | ||
|
|
||
| final seenAt = separateAttention | ||
| ? readState.contexts['seen:${channel.id}'] | ||
| : null; | ||
| final applyRowMarks = separateAttention && !forced && !channel.isDm; | ||
| for (final event in observedEvents.values) { | ||
| final readAt = observedUnreadEventReadAt( | ||
| event, | ||
| channel.id, | ||
| readState.effectiveTimestamp, | ||
| ); | ||
| if (readAt != null && event.createdAt <= readAt) continue; | ||
| final rowShowsEvent = | ||
| !applyRowMarks || | ||
| !rowSawObservedUnreadEvent(event, channel.id, readState.contexts); | ||
| if (!separateAttention || channel.isDm || !event.attention) { | ||
| flags |= _unread; | ||
| if (separateAttention && | ||
| (channel.isDm || seenAt == null || event.createdAt > seenAt)) { | ||
| flags |= _rowUnread; | ||
| } | ||
| if (separateAttention && rowShowsEvent) flags |= _rowUnread; | ||
| } | ||
| if (separateAttention && (channel.isDm || event.attention)) { | ||
| if (separateAttention && | ||
| rowShowsEvent && | ||
| (channel.isDm || event.attention)) { | ||
| flags |= _attention; | ||
| } | ||
| if (flags == decided) break; | ||
| } | ||
| return flags; | ||
| } | ||
|
|
||
| /// The marks earned by a visit. Attention uses per-message receipts so it | ||
| /// can light up the row even when it arrives later with an older timestamp. | ||
| Map<String, int> channelRowSeenMarks( | ||
| String channelId, | ||
| Map<String, ObservedUnreadEvent> events, | ||
| ReadStateState readState, | ||
| ) { | ||
| final marks = <String, int>{}; | ||
| var newest = 0; | ||
| var ordinary = false; | ||
| for (final event in events.values) { | ||
| final readAt = observedUnreadEventReadAt( | ||
| event, | ||
| channelId, | ||
| readState.effectiveTimestamp, | ||
| ); | ||
| if (readAt != null && event.createdAt <= readAt) continue; | ||
| if (rowSawObservedUnreadEvent(event, channelId, readState.contexts)) { | ||
| continue; | ||
| } | ||
|
|
||
| newest = max(newest, event.createdAt); | ||
| if (event.channelCatchUp) { | ||
| ordinary = true; | ||
| } else { | ||
| marks[seenMessageContextKey(event.id)] = event.createdAt; | ||
| } | ||
| } | ||
| if (ordinary) marks[seenContextKey(channelId)] = newest; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Desktop freezes the snapshot at visit end ( |
||
| return marks; | ||
| } | ||
|
|
||
| typedef _MemoEntry = ({ | ||
| int revision, | ||
| int? latestObserved, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 inReadStateManager._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 👍 / 👎.
There was a problem hiding this comment.
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
_persistLocalStateprunes into a separateobservedmap, leaving_effectiveStateunchanged. As new attention IDs arrive, expiredseen: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