fix: show completed status for first-seen threads#3139
Conversation
|
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 self-contained, this represents a new feature affecting global thread state management that warrants human review. You can customize Macroscope's approvability policy. Learn more. |
|
conflicts |
224241e to
5a37418
Compare
Dismissing prior approval to re-evaluate 5a37418
Should be fixed :) |
|
Damn it hahaha spoke to soon |
5a37418 to
127334e
Compare
Co-authored-by: Codex <codex@openai.com>
21f5002 to
c87567a
Compare
|
Closing in favor of the fresh current-main replacement: #3235 |
Summary
thread-upsertedseeds sidebar visit state.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 for first-seen livethread-upsertedevents.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
Mark first-seen completed threads as unread in snapshot-enabled environments
useMarkFirstSeenCompletedThreadsUnreadin useMarkFirstSeenCompletedThreadsUnread.ts that tracks which threads have been seen per environment and callsmarkThreadUnreadwhen a completed thread is observed for the first time.environmentSnapshotIdsAtomto reactively compute which environments currently have a snapshot present, scoping the unread-marking logic to those environments only.EventRoutercomponent so it runs globally.Macroscope summarized c87567a.
Note
Low Risk
Scoped UI-state fix using an existing
markThreadUnreadhelper; no auth, data, or API changes.Overview
Fixes background threads that finish before the client sees them showing as idle/read instead of unread Completed in the sidebar.
Adds
useMarkFirstSeenCompletedThreadsUnread, which tracks per-environment thread keys and, only for environments with an active shell snapshot, callsmarkThreadUnreadwhen a thread appears for the first time withlatestTurn.state === "completed". That works around visit state seeded fromthread-upsertedtimestamps that can be at or aftercompletedAt, so the sidebar’s strict comparison no longer treats the turn as already seen.The hook is mounted from
EventRouterin__root.tsxso it runs globally for authenticated sessions. Initial snapshot bootstrap is unchanged; the logic targets first-seen live upserts.Reviewed by Cursor Bugbot for commit c87567a. Bugbot is set up for automated code reviews on this repo. Configure here.