# fix\(server\): update branch labels after terminal checkouts · PR \#23422 · pingdotgg/t3code

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

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

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: fix/issue-7409

Target branch: main

Head commit: 42eb1f0890aebbd5d0fb8031c0889e333a0368df

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

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

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

## Description

---

## Problem

Creating or switching branches in the integrated terminal leaves the session composer and Thread details branch labels stale until the window regains focus. Reproduced with the real web dev server on Linux using an isolated Git repository and stopped threads.

## Change

Watch each subscribed checkout’s HEAD directory, including linked worktrees, and refresh status when Git replaces HEAD. Share the watch between subscribers and release it after the last subscriber leaves. Retry failed checkout refreshes with backoff capped at 30 seconds, and restart a completed watcher when a later subscriber joins while preserving existing owners. Publish the checked-out branch with its corresponding PR and upstream metadata, retrying reads interrupted by a checkout. Background status polling also refreshes local branch state. A failed local read leaves remote counts uncached so the next poll retries local status. Read canonical branch names so a same-named tag cannot prevent the refresh.

## Scope and approval

Fixes #7409

Triaged bug via the automated issue flow: [#7409](https://git.cafe/pingdotgg/t3code/issues/7409). Synthetic fixture data and its seed script are included as required by the triage evidence procedure. No client contract or provider protocol changes.

## Verification

- Red proof on the before revision: the original external-checkout regression fails with `expected [] to deeply equal ['repro']`. [Failure transcript](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/1928afa1403d06e4/7409-red-recovery.log).
- Checkout-refresh retry regression: before the fix, the new branch never arrived and the test timed out; after [b95a27bccc](https://git.cafe/pingdotgg/t3code/commit/b95a27bccc), the combined broadcaster and Git workflow suites passed 16 tests.
- Completed-watcher regression: before the fix, `expected 1 to equal 2`; after [bd7fbe65f8](https://git.cafe/pingdotgg/t3code/commit/bd7fbe65f8), all 15 broadcaster tests passed in three runs. The regression verifies replacement startup, updates to both subscribers, and continued updates to the earlier subscriber after the later subscriber releases.
- Git workflow helper tests: 2 passed before the watcher-only changes, including a branch and tag both named `main` and detached HEAD.
- Scoped server typecheck passed at [bd7fbe65f8](https://git.cafe/pingdotgg/t3code/commit/bd7fbe65f8); existing Effect suggestions remain.
- Bounded HEAD failure logging at [42eb1f0890](https://git.cafe/pingdotgg/t3code/commit/42eb1f0890): broadcaster suite 15/15 passed, targeted lint and `git diff --check` passed. Local server typecheck timed out at 240 seconds; CI must establish final-head typecheck. The preceding revision passed all required CI checks.

- Fixture environment isolation: seeder succeeded with all four inherited Git repository/index variables pointing at sentinel paths; fixture HEADs stayed inside the synthetic root and sentinel contents were unchanged.

### Evidence

[Original real-app reproduction recording](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/4801250a75761fd6/mcp-launch-client-3ac90f89f8-548c-450a-b3ad-68bcb15a0387-fwd-3a1379c0b0ed54b7029-a0b5ea81-4901-4c1a-8df3-947d35fe3f32-mp4.mp4): terminal checkout succeeds; composer and details labels remain stale for more than 50 seconds; refocus refreshes them. This records the bug, not the fixed behavior.

Fresh paired evidence is incomplete. Two bundled-dev attempts failed with `factory.fn is not a function`; the final normal-dev attempt did not produce a usable client, and both snapshot attempts timed out. [Evidence report](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/1fb1bf0d7168da18/7409-evidence-report.md), [sanitized startup failure log](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/996d51882aba4357/7409-evidence-startup-failure.log).

| Fixture | Before | After | Diff0 | Diff8 |
| --- | --- | --- | --- | --- |
| Core checkout: 1440/light, 1440/dark, 390/light, 390/dark | Unverified | Unverified | Missing | Missing |
| Linked checkout, reverse checkout and action state | Unverified | Unverified | Missing | Missing |
| Branch-specific PR metadata | Unverified visually; service tests cover coherence | Unverified visually | Missing | Missing |

Cannot verify fresh web before/after behavior, native macOS/Electron, mobile, relay/tunnel or multi-environment behavior on this VM. No claim of visual equivalence or merge readiness. Proof audit: [insufficient](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/7ace556a0110c099/7409-proof-pass2.md) because paired recordings and image diffs could not be obtained. [Fixture matrix](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/e5cf6853632180d1/7409-recovery-matrix.md).

Models: Claude Opus 5.5 and GPT-6.1-Sol through T3 Code (Claude Agent and Codex harnesses).

