The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 04:30 UTC
fix(server): refresh divergence after a merged branch ref changes (#31342)
Yash Singh committed
Nov 5, 2026 at 02:35 UTC
01a8db0aad27fa18010c552340e1b36168707ae8
2 files changed
+12
-17
apps/server/src/vcs/VcsStatusBroadcaster.test.ts
+11
-8
@@ -382,13 +382,14 @@ describe("VcsStatusBroadcaster", () => {
382
);
383
384
it.effect("refreshes a loaded cwd without reusing a previous branch's PR", () => {
385
- const state = {
385
+ const state: Parameters<typeof layerTestFor>[0] = {
386
currentLocalStatus: baseLocalStatus,
387
- currentRemoteStatus: baseRemoteStatus,
387
+ currentRemoteStatus: { ...baseRemoteStatus, aheadCount: 3, behindCount: 5 },
388
localStatusCalls: 0,
389
remoteStatusCalls: 0,
390
localInvalidationCalls: 0,
391
remoteInvalidationCalls: 0,
392
+ remoteStatusRefreshUpstreamValues: [],
393
};
394
395
return Effect.gen(function* () {
@@ -400,9 +401,14 @@ describe("VcsStatusBroadcaster", () => {
401
yield* broadcaster.getStatus({ cwd: "/repo" });
402
assert.equal(state.remoteStatusCalls, 1);
403
403
- state.currentRemoteStatus = remoteStatusWithPr;
404
+ state.backgroundWorkEnabled = false;
405
+ state.currentRemoteStatus = { ...remoteStatusWithPr, aheadCount: 7 };
406
const refreshed = yield* broadcaster.refreshPullRequestStatus("/repo");
405
- assert.deepStrictEqual(refreshed, remoteStatusWithPr);
407
+ assert.deepStrictEqual(refreshed, state.currentRemoteStatus);
408
+ const merged = yield* broadcaster.getStatus({ cwd: "/repo" });
409
+ assert.equal(merged.aheadCount, 7);
410
+ assert.equal(merged.behindCount, 0);
411
+ assert.equal(state.remoteStatusRefreshUpstreamValues?.at(-1), false);
412
assert.equal(state.remoteStatusCalls, 2);
413
assert.equal(state.remoteInvalidationCalls, 2);
414
@@ -944,7 +950,7 @@ describe("VcsStatusBroadcaster", () => {
950
},
951
);
952
947
- it.effect("recovers a discarded branch lookup on the next permitted turn-end refresh", () => {
953
+ it.effect("recovers a discarded branch lookup on the next turn-end refresh", () => {
954
const state: Parameters<typeof layerTestFor>[0] = {
955
currentLocalStatus: baseLocalStatus,
956
currentRemoteStatus: { ...remoteStatusWithPr, aheadCount: 3, behindCount: 5 },
@@ -983,9 +989,6 @@ describe("VcsStatusBroadcaster", () => {
989
pr: { ...remoteStatusWithPr.pr!, number: 2979, headRef: "feature/next-status" },
990
};
991
state.backgroundWorkEnabled = false;
986
- yield* broadcaster.refreshPullRequestStatus("/repo");
987
- assert.equal(state.remoteStatusCalls, 1);
988
- state.backgroundWorkEnabled = true;
992
const recovered = yield* broadcaster.refreshPullRequestStatus("/repo");
993
assert.deepStrictEqual(recovered, state.currentRemoteStatus);
994
const cached = yield* broadcaster.getStatus({ cwd: "/repo" });
apps/server/src/vcs/VcsStatusBroadcaster.ts
+1
-9
@@ -540,15 +540,7 @@ export const make = Effect.gen(function* () {
540
Effect.gen(function* () {
541
const cached = yield* getCachedStatus(cwd);
542
if (!cached?.local || cached.remote?.value === null) return null;
543
- const poller = (yield* SynchronizedRef.get(pollersRef)).get(cwd);
544
- const demandCwds = poller ? [...(yield* Ref.get(poller.demandCwds)).keys()] : [rawCwd];
545
- const shouldRefresh = (yield* Effect.forEach(
546
- demandCwds,
547
- (demandCwd) =>
548
- backgroundPolicy.shouldRunScopeWork({ type: "vcs-status", cwd: demandCwd }),
549
- { concurrency: "unbounded" },
550
- )).some(Boolean);
551
- if (!shouldRefresh) return null;
543
+ // Turn completion must update divergence even when background polling is paused.
544
const remoteRead = yield* readRemoteStatus(cwd, {
545
refreshUpstream: false,
546
refreshMissingPullRequest: true,