Skip to content

fix(web): retain terminal PR badges after checkout switch - #4755

Open
sebbonit wants to merge 5 commits into
pingdotgg:mainfrom
sebbonit:fix/sidebar-v2-retain-terminal-pr-snapshot
Open

fix(web): retain terminal PR badges after checkout switch#4755
sebbonit wants to merge 5 commits into
pingdotgg:mainfrom
sebbonit:fix/sidebar-v2-retain-terminal-pr-snapshot

Conversation

@sebbonit

@sebbonit sebbonit commented Jul 28, 2026

Copy link
Copy Markdown

What Changed

Fixes #4752.

Sidebar V2 now keeps a parent-level PR snapshot (branch, full PR object, provider) instead of only "open" | "merged" | "closed".

  • Snapshots update only when live VCS status matches the thread branch.
  • Branch mismatch / missing VCS data leaves the snapshot alone.
  • Display and settlement both use one resolver: live PR on match; cached merged/closed PR on mismatch.
  • Open PRs are not retained across a checkout switch.

Why

After a local-checkout thread’s PR was observed as merged/closed, switching the shared checkout to main made resolveThreadPr return null (branch mismatch). That cleared the parent map, unssettled the thread, and dropped the PR badge. Retaining the previously verified terminal PR at the Sidebar V2 parent is enough; no contracts/server changes.

UI Changes

Settled local-checkout rows keep their PR number, link, title, provider terminology, and terminal color after switching away from the thread branch. No layout changes.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Retain terminal PR badges in sidebar and chat view after checkout switch

  • Adds threadChangeRequestSnapshotsAtom to persist per-thread PR snapshots (branch, PR state, provider) in memory across component unmounts.
  • Introduces resolveDisplayedThreadPr and resolveDisplayedThreadPrProvider to fall back to a cached merged/closed PR snapshot when the active checkout branch no longer matches the thread branch, but only for local (non-worktree) checkouts.
  • Updates SidebarV2Row and ChatViewContent to use the new resolver and snapshot atom, so thread settlement classification (settled vs inbox) correctly accounts for retained terminal PRs.
  • Worktree threads clear their snapshot on branch mismatch rather than retaining it.
  • Behavioral Change: sidebar thread partitioning now considers cached PR state for local threads, which may change how threads are classified after a checkout switch.

Macroscope summarized 703413f.


Note

Medium Risk
Touches sidebar partitioning, chat settlement UI, and shared atom state; behavior is well-covered by tests but incorrect retention could mis-label PR status or settled rows.

Overview
Fixes sidebar and chat losing merged/closed PR badges and auto-settlement when a local-checkout thread’s shared git checkout moves off the thread branch (e.g. to main).

Sidebar V2 and ChatView now share a parent-level threadChangeRequestSnapshotsAtom (branch, full PR, provider) instead of bubbling only PR state. Rows update snapshots via nextThreadChangeRequestSnapshot only on authoritative VCS when the live ref matches the thread branch; branch mismatch or missing VCS no longer clears a verified terminal snapshot for local threads (worktreePath === null). resolveDisplayedThreadPr / resolveDisplayedThreadPrProvider drive badges and effectiveSettled the same way in the sidebar partition and chat banner. Open PRs are never shown or retained across mismatch; worktree threads clear snapshots on branch mismatch.

Reviewed by Cursor Bugbot for commit 703413f. Bugbot is set up for automated code reviews on this repo. Configure here.

Keep merged/closed local-checkout PR metadata in Sidebar V2 when the shared checkout moves to another branch, so settled rows stay settled with their original badge.
@coderabbitai

coderabbitai Bot commented Jul 28, 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 Plus

Run ID: d038222f-7da5-4be6-941a-f6ac8f3cc61d

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 28, 2026
@sebbonit
sebbonit marked this pull request as ready for review July 28, 2026 15:25
Comment thread apps/web/src/components/SidebarV2.tsx
@macroscopeapp

macroscopeapp Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This is a self-contained UI bug fix that caches terminal PR badge states (merged/closed) so they persist when users switch branches. The majority of the additions are comprehensive unit tests. No security, auth, or billing implications.

You can customize Macroscope's approvability policy. Learn more.

Comment thread apps/web/src/components/ThreadStatusIndicators.tsx Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 87e936b. Configure here.

Comment thread apps/web/src/components/ThreadStatusIndicators.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 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.

[Bug]: Settled local thread unsettles and loses merged PR# when switching back to main for pull / new branch

1 participant