Mark newly discovered completed threads unread#4501
Conversation
Co-authored-by: Codex <codex@openai.com> (cherry picked from commit c87567a)
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if ( | ||
| previousThreadKeys !== undefined && | ||
| !previousThreadKeys.has(threadKey) && | ||
| thread.latestTurn?.state === "completed" | ||
| ) { |
There was a problem hiding this comment.
🟡 Medium hooks/useMarkFirstSeenCompletedThreadsUnread.ts:64
resolveFirstSeenCompletedThreads marks a completed thread as seen and pushes it to newlyUnreadThreads even when latestTurn.completedAt is null. Since markThreadUnread ignores null-timestamp threads, the thread is recorded as seen but never actually marked unread. When the real completedAt arrives in a later snapshot, the thread key is already in the previous-seen set, so it is never retried — the thread stays read forever. Consider deferring the push to newlyUnreadThreads until completedAt is non-null, while still tracking the key as seen.
if (
previousThreadKeys !== undefined &&
!previousThreadKeys.has(threadKey) &&
thread.latestTurn?.state === "completed" &&
+ thread.latestTurn.completedAt != null
) {🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts around lines 64-68:
`resolveFirstSeenCompletedThreads` marks a completed thread as seen and pushes it to `newlyUnreadThreads` even when `latestTurn.completedAt` is `null`. Since `markThreadUnread` ignores null-timestamp threads, the thread is recorded as seen but never actually marked unread. When the real `completedAt` arrives in a later snapshot, the thread key is already in the previous-seen set, so it is never retried — the thread stays read forever. Consider deferring the push to `newlyUnreadThreads` until `completedAt` is non-null, while still tracking the key as seen.
What Changed
Why
The existing completion indicator is timestamp-based and intentionally treats threads without a visit marker as read. That leaves a narrow gap for a thread created elsewhere that first appears in the current client only after it has already completed.
This draft explores treating that newly discovered completion as unread without lighting up historical threads from the initial snapshot.
Scope
Mark unreadbehavior.Attribution
The original implementation is authored by Wout Stiens; that authorship is preserved in the commit history.
Verification
Note
Mark newly discovered completed threads as unread on first appearance
useMarkFirstSeenCompletedThreadsUnreadhook that tracks which threads have been seen per snapshot environment and callsmarkThreadUnreadthe first time a completed thread appears after the initial bootstrap.resolveFirstSeenCompletedThreadsutility handles the stateless computation, comparing current thread keys against a previously-seen set to find newly completed threads.EventRouterin __root.tsx so it runs for the lifetime of the app.📊 Macroscope summarized fc354d8. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.