Skip to content

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

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

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

Conversation

@StiensWout

@StiensWout StiensWout commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Mark first-seen completed shell threads unread after thread-upserted seeds sidebar visit state.
  • Reuses the existing markThreadUnread helper so the sidebar can surface the unread Completed status.
  • No tests were added; existing focused UI-state/sidebar tests cover the helper behavior used by this fix.

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 for first-seen live thread-upserted events.

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

Mark first-seen completed threads as unread in snapshot-enabled environments

  • Adds useMarkFirstSeenCompletedThreadsUnread in useMarkFirstSeenCompletedThreadsUnread.ts that tracks which threads have been seen per environment and calls markThreadUnread when a completed thread is observed for the first time.
  • Adds environmentSnapshotIdsAtom to reactively compute which environments currently have a snapshot present, scoping the unread-marking logic to those environments only.
  • Activates the hook in __root.tsx via the EventRouter component so it runs globally.

Macroscope summarized c87567a.


Note

Low Risk
Scoped UI-state fix using an existing markThreadUnread helper; 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, calls markThreadUnread when a thread appears for the first time with latestTurn.state === "completed". That works around visit state seeded from thread-upserted timestamps that can be at or after completedAt, so the sidebar’s strict comparison no longer treats the turn as already seen.

The hook is mounted from EventRouter in __root.tsx so 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.

@coderabbitai

coderabbitai Bot commented Jun 18, 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: fa35702f-bc89-4b21-9f7b-26cacd875a26

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 size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jun 18, 2026
@StiensWout StiensWout marked this pull request as ready for review June 18, 2026 09:07
@StiensWout StiensWout changed the title [codex] fix: show completed status for first-seen threads fix: show completed status for first-seen threads Jun 18, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 18, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 18, 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 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.

@juliusmarminge

Copy link
Copy Markdown
Member

conflicts

@StiensWout StiensWout force-pushed the fix/first-seen-completed-threads branch from 224241e to 5a37418 Compare June 19, 2026 03:59
@macroscopeapp macroscopeapp Bot dismissed their stale review June 19, 2026 03:59

Dismissing prior approval to re-evaluate 5a37418

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Jun 19, 2026
@StiensWout

Copy link
Copy Markdown
Contributor Author

conflicts

Should be fixed :)

Comment thread apps/web/src/hooks/useMarkFirstSeenCompletedThreadsUnread.ts Outdated
@StiensWout

Copy link
Copy Markdown
Contributor Author

Damn it hahaha spoke to soon

@StiensWout StiensWout force-pushed the fix/first-seen-completed-threads branch from 5a37418 to 127334e Compare June 19, 2026 04:06
Co-authored-by: Codex <codex@openai.com>
@StiensWout

Copy link
Copy Markdown
Contributor Author

Closing in favor of the fresh current-main replacement: #3235

@StiensWout StiensWout closed this Jun 20, 2026
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

2 participants