fix: show completed status for first-seen threads#3235
Conversation
Co-authored-by: Codex <codex@openai.com>
|
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 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 |
ApprovabilityVerdict: Needs human review This PR introduces new user-facing behavior by automatically marking first-seen completed threads as unread. While the implementation is clean and self-contained, new features affecting notification/read state warrant human review. You can customize Macroscope's approvability policy. Learn more. |
Summary
markThreadUnreadhelper so the sidebar can surface the unreadCompletedstatus.Root cause
Newly observed shell threads seed
threadLastVisitedAtByIdfromthread.updatedAt ?? thread.createdAt. When a completed thread first arrives throughthread-upserted, that seeded timestamp can equal or be later thanlatestTurn.completedAt, so the sidebar strict comparison treats the completed turn as already seen.Impact
Background threads that finish before the web client observes them now show the unread
Completedstatus instead of silently appearing idle/read. Initial snapshot bootstrap behavior is unchanged because this only runs after a real per-environment shell snapshot exists.Validation
PATH="$HOME/.vite-plus/bin:$PATH" vp test apps/web/src/uiStateStore.test.ts apps/web/src/components/Sidebar.logic.test.tsPATH="$HOME/.vite-plus/bin:$PATH" vp checkPATH="$HOME/.vite-plus/bin:$PATH" vp run typecheckvp checkreports the repository's existing unrelated warnings and no errors.Closes #3131
Note
Low Risk
UI-only unread/visit bookkeeping with a narrow trigger (first sighting + completed turn); no auth or server changes.
Overview
Fixes background threads that finish before the client sees them showing as read instead of Completed unread in the sidebar.
Adds
useMarkFirstSeenCompletedThreadsUnread, which runs only after each environment has a real shell snapshot (not during initial bootstrap). It tracks which thread keys were already observed per environment; when a thread appears for the first time withlatestTurn.state === "completed", it calls the existingmarkThreadUnreadwithcompletedAtso visit timestamps no longer treat the turn as already seen.The hook is mounted from
EventRouterin the authenticated app shell alongside other global event routing.Reviewed by Cursor Bugbot for commit c87567a. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Mark first-seen completed threads as unread in snapshot environments
useMarkFirstSeenCompletedThreadsUnread, a hook that tracks which threads have been seen per environment and marks newly seen completed threads as unread using theircompletedAttimestamp.environmentSnapshotIdsAtomto derive the list of environment IDs that currently have a snapshot, used to scope the hook's behavior.EventRouterso it runs globally during the app lifecycle.Macroscope summarized c87567a.