# fix\(web\): refresh the current branch when opening the picker · PR \#22807 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/22807)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: merged

Source repository: Unavailable fork

Source branch: fix/refresh-branch-picker-on-open

Target branch: main

Head commit: 8cf88b8ed18a74763350225c93699fb6af7bf049

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/22807)

[Commits](https://git.cafe/pingdotgg/t3code/pull/22807/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/22807/diffs?format=markdown)

## Description

---

## Problem

After switching branches with `git switch` or `git checkout` in a terminal, the branch picker can keep showing the previous branch as current, even after it has been deleted. Opening the picker does not currently request fresh local status.

## Change

Refresh local Git status when the branch picker opens, including through its keyboard shortcut. Add a local-only option to the existing status refresh RPC so this does not initiate a fetch or PR lookup. The existing client command invalidates cached refs afterward, updating the list and its current marker too.

When the checked-out branch changes, publish a snapshot that also clears the previous branch's cached remote counts and PR. Coordinate this update with in-flight remote reads using the existing per-repository lock. The local refresh may wait for an existing remote read, but starts no new remote work.

## Scope and approval

This is a focused fix for an obvious stale-state bug in the existing branch picker. It adds no polling or settings. It covers the shared web and desktop picker; mobile behavior is unchanged.

## Verification

Before:

https://github.com/user-attachments/assets/5100c4c2-aa2c-4446-b6bf-e7c8314fa4d0

After:

https://github.com/user-attachments/assets/c60bd76e-fc47-4e26-a9d8-b3dd9d51228f

- `vp test run apps/server/src/vcs/VcsStatusBroadcaster.test.ts`: 11 tests passed. Regression coverage verifies branch updates without new remote reads, clears stale remote data for cached reads and existing/new subscribers, covers an in-flight PR refresh, and preserves cached remote fields in the response when the branch is unchanged.
- `vp test run packages/client-runtime/src/state/vcs.test.ts`: 7 tests passed, including the existing ref-cache invalidation behavior.
- `vp run --filter t3 typecheck`: passed after the RPC optional-field fix.
- Initial `vp run check:changed HEAD`: format, lint, knip, generated GraphQL checks, and adjacent tests passed. Web typechecking failed in the unchanged `MermaidDiagram.tsx` because `pele/lazy` could not be resolved locally. CI build and typechecking subsequently passed at a1503cb.

- Review follow-up `vp run check:changed HEAD` against a1503cb: all checks passed, including formatting, lint, knip, generated GraphQL checks, server typechecking, and the 10 broadcaster tests.

- Response-consistency follow-up `vp run check:changed HEAD` against 67123a6: all checks passed, including server typechecking and all 11 broadcaster tests.

Model: gpt-6.1-sol. Harness: Codex in T3 Code.




