Skip to content

Commit 6584e01

Browse files
fix(server): retain cached remote fields in local refresh responses
1 parent 67123a6 commit 6584e01

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎apps/server/src/vcs/VcsStatusBroadcaster.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,31 @@ describe("VcsStatusBroadcaster", () => {
204204
}).pipe(Effect.provide(layerTestFor(state)));
205205
});
206206

207+
it.effect(
208+
"preserves cached remote status when a local-only refresh stays on the same branch",
209+
() => {
210+
const state = {
211+
currentLocalStatus: baseLocalStatus,
212+
currentRemoteStatus: { ...remoteStatusWithPr, aheadCount: 2, behindCount: 3 },
213+
localStatusCalls: 0,
214+
remoteStatusCalls: 0,
215+
localInvalidationCalls: 0,
216+
remoteInvalidationCalls: 0,
217+
};
218+
219+
return Effect.gen(function* () {
220+
const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
221+
const initial = yield* broadcaster.getStatus({ cwd: "/repo" });
222+
const refreshed = yield* broadcaster.refreshStatus("/repo", { localOnly: true });
223+
assert.deepStrictEqual(refreshed, initial);
224+
assert.deepStrictEqual(yield* broadcaster.getStatus({ cwd: "/repo" }), refreshed);
225+
assert.equal(state.localInvalidationCalls, 1);
226+
assert.equal(state.remoteInvalidationCalls, 0);
227+
assert.equal(state.remoteStatusCalls, 1);
228+
}).pipe(Effect.provide(layerTestFor(state)));
229+
},
230+
);
231+
207232
it.effect("clears the previous branch's remote status after an in-flight PR refresh", () => {
208233
const remoteReadStarted = Deferred.makeUnsafe<void>();
209234
const releaseRemoteRead = Deferred.makeUnsafe<void>();

‎apps/server/src/vcs/VcsStatusBroadcaster.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ export const make = Effect.gen(function* () {
524524
return yield* updateCachedStatus(cwd, local, null, { publish: true });
525525
}
526526
yield* updateCachedLocalStatus(cwd, local, { publish: true });
527-
return mergeGitStatusParts(local, null);
527+
return mergeGitStatusParts(local, previous?.remote?.value ?? null);
528528
}),
529529
);
530530
}

0 commit comments

Comments
 (0)