Skip to content

Commit 795676e

Browse files
committed
fix(server): validate branch before returning complete cached status
1 parent bf01203 commit 795676e

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ describe("VcsStatusBroadcaster", () => {
207207
}).pipe(Effect.provide(layerTestFor(state)), Effect.scoped);
208208
});
209209

210-
it.effect("publishes a terminal branch switch without reading remote status", () => {
211-
const state = {
210+
it.effect("publishes terminal branch switches and validates cached status reads", () => {
211+
const state: Parameters<typeof layerTestFor>[0] = {
212212
currentLocalStatus: baseLocalStatus,
213213
currentRemoteStatus: remoteStatusWithPr,
214214
localStatusCalls: 0,
@@ -251,6 +251,10 @@ describe("VcsStatusBroadcaster", () => {
251251
state.currentLocalStatus = { ...state.currentLocalStatus, hasWorkingTreeChanges: true };
252252
yield* broadcaster.refreshLocalStatus("/repo");
253253
state.currentLocalStatus = { ...baseLocalStatus, refName: "union" };
254+
state.currentRemoteStatus = null;
255+
const queried = yield* broadcaster.getStatus({ cwd: "/repo" });
256+
assert.equal(queried.refName, "union");
257+
assert.isNull(queried.pr);
254258
const snapshot = yield* broadcaster
255259
.streamStatus({ cwd: "/repo", includeRemote: false })
256260
.pipe(Stream.take(1), Stream.runCollect);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ export const make = Effect.gen(function* () {
358358
"VcsStatusBroadcaster.getStatus",
359359
)(function* (input) {
360360
const cwd = yield* withFileSystem(normalizeCwd(input.cwd));
361+
yield* getOrLoadLocalStatus(cwd);
361362
const cached = yield* getCachedStatus(cwd);
362363
if (cached?.local && cached.remote) {
363364
return mergeGitStatusParts(cached.local.value, cached.remote.value);
364365
}
365-
yield* getOrLoadLocalStatus(cwd);
366366
return yield* withRemoteWriteLock(
367367
cwd,
368368
Effect.gen(function* () {

0 commit comments

Comments
 (0)