Skip to content

fix: show completed status for first-seen threads#3235

Open
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:fix/first-seen-completed-threads-fresh
Open

fix: show completed status for first-seen threads#3235
StiensWout wants to merge 1 commit into
pingdotgg:mainfrom
StiensWout:fix/first-seen-completed-threads-fresh

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Mark first-seen completed shell threads unread after an environment shell snapshot exists.
  • Reuse the existing markThreadUnread helper so the sidebar can surface the unread Completed status.
  • Replaces fix: show completed status for first-seen threads #3139 with a fresh branch based on current main.

Root cause

Newly observed shell threads seed threadLastVisitedAtById from thread.updatedAt ?? thread.createdAt. When a completed thread first arrives through thread-upserted, that seeded timestamp can equal or be later than latestTurn.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 Completed status 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.ts
  • PATH="$HOME/.vite-plus/bin:$PATH" vp check
  • PATH="$HOME/.vite-plus/bin:$PATH" vp run typecheck

vp check reports 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 with latestTurn.state === "completed", it calls the existing markThreadUnread with completedAt so visit timestamps no longer treat the turn as already seen.

The hook is mounted from EventRouter in 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

  • Adds useMarkFirstSeenCompletedThreadsUnread, a hook that tracks which threads have been seen per environment and marks newly seen completed threads as unread using their completedAt timestamp.
  • Adds environmentSnapshotIdsAtom to derive the list of environment IDs that currently have a snapshot, used to scope the hook's behavior.
  • Mounts the hook in EventRouter so it runs globally during the app lifecycle.

Macroscope summarized c87567a.

Co-authored-by: Codex <codex@openai.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1674f201-1407-4adc-acc9-51e40d32a46a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sidebar can miss unread Completed status for newly finished threads

1 participant