# R4 branch-switch-subscribe

Evidence for [#33263](https://git.cafe/pingdotgg/t3code/pull/33263). Before: switching A to B publishes two null clears and leaves the fresh active subscription with null for its 6.5-second window. After: one clear, local B, then B upstream/ahead 2/behind 1/default-ahead 2.

Warming used a full RPC, never an active poller; the post-switch subscription is the sole remote-enabled subscription.

AI-assisted; verified with the tests and tools listed above.

| Before | After |
|---|---|
| [4c361199f4](https://git.cafe/pingdotgg/t3code/commit/4c361199f47f6ea32a2c14835df392640d0f7c63) | [456327574c](https://git.cafe/pingdotgg/t3code/commit/456327574c52ad1c7624083bb97eaf382edd1732) |
| [Full timestamped log](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/e70ce7e5f5d3ba0b/R4-before.log) | [Full timestamped log](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/712f5f82112746e2/R4-after.log) |

Before environment: Linux 6.8.0-117-generic x64; Node v26.12.1; `T3CODE_DEV_SEED=0 node apps/server/src/bin.ts serve --host 127.0.0.1 --port 40713 --base-dir /tmp/lead-33263-r1/evidence-capture/2026-11-10T07-12-54.544Z-before-R4/t3 --no-browser --log-level warn --dev-url http://127.0.0.1:40713`; settings: `automaticGitFetchInterval=30 seconds`. Fresh explicit base dir; Replay provisioned by `--dev-url`; forwarding git wrapper first on PATH. No dev runner or live-data seeding.

After environment: Linux 6.8.0-117-generic x64; Node v26.12.1; `T3CODE_DEV_SEED=0 node apps/server/src/bin.ts serve --host 127.0.0.1 --port 32883 --base-dir /tmp/lead-33263-r1/evidence-capture/2026-11-10T07-12-54.530Z-after-R4/t3 --no-browser --log-level warn --dev-url http://127.0.0.1:32883`; settings: `automaticGitFetchInterval=30 seconds`. Fresh explicit base dir; Replay provisioned by `--dev-url`; forwarding git wrapper first on PATH. No dev runner or live-data seeding.

The recordings below preserve action/event order independently in each column. Rows align by event ordinal, not wall-clock synchronization. Full payloads, command traces, and server completion spans are in the linked logs. Bounded windows establish only the recorded absence of an update, not a full 30-second delay.

| Before recording | After recording |
|---|---|
| `2026-11-10T07:12:54.995Z +450ms` SYNTHETIC_SEED {"facts":{"A":{"status":"## feature/A...origin/feature/A [ahead 1]","divergence":"1\t0"},"B":{"status":"## feature/B...origin/feature/B [ahead 2, behind 1]","divergence":"2\t1"}}} | `2026-11-10T07:12:54.968Z +437ms` SYNTHETIC_SEED {"facts":{"A":{"status":"## feature/A...origin/feature/A [ahead 1]","divergence":"1\t0"},"B":{"status":"## feature/B...origin/feature/B [ahead 2, behind 1]","divergence":"2\t1"}}} |
| `2026-11-10T07:12:54.998Z +453ms` SERVER_SPAWNED {"pid":282733} | `2026-11-10T07:12:54.972Z +441ms` SERVER_SPAWNED {"pid":282723} |
| `2026-11-10T07:13:00.817Z +6272ms` RPC_SEND server.updateSettings automaticGitFetchInterval=30000ms | `2026-11-10T07:13:00.729Z +6198ms` RPC_SEND server.updateSettings automaticGitFetchInterval=30000ms |
| `2026-11-10T07:13:00.950Z +6405ms` RPC_RESULT server.updateSettings {"automaticGitFetchInterval":{"_id":"Duration","_tag":"Millis","millis":30000}} | `2026-11-10T07:13:00.890Z +6359ms` RPC_RESULT server.updateSettings {"automaticGitFetchInterval":{"_id":"Duration","_tag":"Millis","millis":30000}} |
| `2026-11-10T07:13:00.950Z +6405ms` RPC_SEND vcs.refreshStatus localOnly=False | `2026-11-10T07:13:00.890Z +6359ms` RPC_SEND vcs.refreshStatus localOnly=False |
| `2026-11-10T07:13:03.457Z +8912ms` RPC_RESULT vcs.refreshStatus branch=feature/A remote={"hasUpstream":true,"aheadCount":1,"behindCount":0,"aheadOfDefaultCount":1} pr=null | `2026-11-10T07:13:03.292Z +8761ms` RPC_RESULT vcs.refreshStatus branch=feature/A remote={"hasUpstream":true,"aheadCount":1,"behindCount":0,"aheadOfDefaultCount":1} pr=null |
| `2026-11-10T07:13:03.461Z +8916ms` SUBSCRIBE passive-1 includeRemote=False | `2026-11-10T07:13:03.296Z +8765ms` SUBSCRIBE passive-1 includeRemote=False |
| `2026-11-10T07:13:03.561Z +9016ms` VCS_EVENT passive-1 snapshot {"isRepo":true,"refName":"feature/A","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":1,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} remote={"hasUpstream":true,"aheadCount":1,"behindCount":0,"aheadOfDefaultCount":1} pr=null | `2026-11-10T07:13:03.364Z +8833ms` VCS_EVENT passive-1 snapshot {"isRepo":true,"refName":"feature/A","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":1,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} remote={"hasUpstream":true,"aheadCount":1,"behindCount":0,"aheadOfDefaultCount":1} pr=null |
| `2026-11-10T07:13:03.565Z +9020ms` EXTERNAL_SWITCH {"branch":"feature/B"} | `2026-11-10T07:13:03.365Z +8834ms` EXTERNAL_SWITCH {"branch":"feature/B"} |
| `2026-11-10T07:13:03.592Z +9047ms` GIT_STATUS {"value":"## feature/B...origin/feature/B [ahead 2, behind 1]"} | `2026-11-10T07:13:03.398Z +8867ms` GIT_STATUS {"value":"## feature/B...origin/feature/B [ahead 2, behind 1]"} |
| `2026-11-10T07:13:03.597Z +9052ms` RPC_SEND vcs.refreshStatus localOnly=True | `2026-11-10T07:13:03.399Z +8868ms` RPC_SEND vcs.refreshStatus localOnly=True |
| `2026-11-10T07:13:04.338Z +9793ms` VCS_EVENT passive-1 remoteUpdated remote=null | `2026-11-10T07:13:04.099Z +9568ms` VCS_EVENT passive-1 remoteUpdated remote=null |
| `2026-11-10T07:13:04.341Z +9796ms` RPC_RESULT vcs.refreshStatus branch=feature/B remote={"hasUpstream":false,"aheadCount":0,"behindCount":0,"aheadOfDefaultCount":0} pr=null | `2026-11-10T07:13:04.106Z +9575ms` RPC_RESULT vcs.refreshStatus branch=feature/B remote={"hasUpstream":false,"aheadCount":0,"behindCount":0,"aheadOfDefaultCount":0} pr=null |
| `2026-11-10T07:13:04.342Z +9797ms` SUBSCRIBE new-branch-active-2 includeRemote=True | `2026-11-10T07:13:04.106Z +9575ms` SUBSCRIBE new-branch-active-2 includeRemote=True |
| `2026-11-10T07:13:04.352Z +9807ms` VCS_EVENT passive-1 localUpdated {"isRepo":true,"refName":"feature/B","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":2,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} | `2026-11-10T07:13:04.111Z +9580ms` VCS_EVENT passive-1 localUpdated {"isRepo":true,"refName":"feature/B","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":2,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} |
| `2026-11-10T07:13:04.353Z +9808ms` VCS_EVENT passive-1 remoteUpdated remote=null | `2026-11-10T07:13:04.165Z +9634ms` VCS_EVENT new-branch-active-2 snapshot {"isRepo":true,"refName":"feature/B","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":2,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} remote=null |
| `2026-11-10T07:13:04.451Z +9906ms` VCS_EVENT new-branch-active-2 snapshot {"isRepo":true,"refName":"feature/B","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":2,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} remote=null | `2026-11-10T07:13:05.560Z +11029ms` VCS_EVENT passive-1 remoteUpdated remote={"hasUpstream":true,"aheadCount":2,"behindCount":1,"aheadOfDefaultCount":2} pr=null |
| `2026-11-10T07:13:10.951Z +16406ms` OBSERVATION_WINDOW_CLOSED {"timeoutMs":6500} | `2026-11-10T07:13:05.561Z +11030ms` VCS_EVENT new-branch-active-2 remoteUpdated remote={"hasUpstream":true,"aheadCount":2,"behindCount":1,"aheadOfDefaultCount":2} pr=null |
| `2026-11-10T07:13:11.459Z +16914ms` OBSERVATION_WINDOW_CLOSED {"timeoutMs":500} | `2026-11-10T07:13:06.062Z +11531ms` OBSERVATION_WINDOW_CLOSED {"timeoutMs":500} |
| `2026-11-10T07:13:11.462Z +16917ms` UNSUBSCRIBE new-branch-active-2 | `2026-11-10T07:13:06.066Z +11535ms` UNSUBSCRIBE new-branch-active-2 |
| `2026-11-10T07:13:11.468Z +16923ms` UNSUBSCRIBED new-branch-active-2 | `2026-11-10T07:13:06.068Z +11537ms` UNSUBSCRIBED new-branch-active-2 |
| `2026-11-10T07:13:11.471Z +16926ms` SUBSCRIBE final-passive-3 includeRemote=False | `2026-11-10T07:13:06.071Z +11540ms` SUBSCRIBE final-passive-3 includeRemote=False |
| `2026-11-10T07:13:11.539Z +16994ms` VCS_EVENT final-passive-3 snapshot {"isRepo":true,"refName":"feature/B","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":2,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} remote=null | `2026-11-10T07:13:06.140Z +11609ms` VCS_EVENT final-passive-3 snapshot {"isRepo":true,"refName":"feature/B","isDefaultRef":false,"hasPrimaryRemote":true,"hasWorkingTreeChanges":false,"branchChanges":{"baseRef":"origin/main","insertions":2,"deletions":0}} worktree={"insertions":0,"deletions":0,"files":[]} remote={"hasUpstream":true,"aheadCount":2,"behindCount":1,"aheadOfDefaultCount":2} pr=null |
| `2026-11-10T07:13:11.542Z +16997ms` UNSUBSCRIBE final-passive-3 | `2026-11-10T07:13:06.141Z +11610ms` UNSUBSCRIBE final-passive-3 |
| `2026-11-10T07:13:11.543Z +16998ms` UNSUBSCRIBED final-passive-3 | `2026-11-10T07:13:06.141Z +11610ms` UNSUBSCRIBED final-passive-3 |
| `2026-11-10T07:13:11.544Z +16999ms` UNSUBSCRIBE passive-1 | `2026-11-10T07:13:06.142Z +11611ms` UNSUBSCRIBE passive-1 |
| `2026-11-10T07:13:11.545Z +17000ms` UNSUBSCRIBED passive-1 | `2026-11-10T07:13:06.142Z +11611ms` UNSUBSCRIBED passive-1 |
| `2026-11-10T07:13:11.548Z +17003ms` ROW_COMPLETE {"row":"R4"} | `2026-11-10T07:13:06.143Z +11612ms` ROW_COMPLETE {"row":"R4"} |
| `2026-11-10T07:13:11.815Z +17270ms` SERVER_STOPPED {"pid":282733,"exitCode":130,"signal":null} | `2026-11-10T07:13:07.170Z +12639ms` SERVER_STOPPED {"pid":282723,"exitCode":130,"signal":null} |

Final before: remote=null

Final after: remote={"hasUpstream":true,"aheadCount":2,"behindCount":1,"aheadOfDefaultCount":2} pr=null
