Skip to content

Commit ccfb73d

Browse files
committed
fix(server): keep checkout details consistent in the local status cache
1 parent 439e1e2 commit ccfb73d

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

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

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,22 @@ export const make = Effect.gen(function* () {
339339
},
340340
);
341341

342+
const readLocalStatus = Effect.fn("VcsStatusBroadcaster.readLocalStatus")(function* (
343+
cwd: string,
344+
) {
345+
const includeCheckoutDetails = yield* Ref.get(checkoutDetailDemandRef).pipe(
346+
Effect.map((demand) => demand.has(cwd)),
347+
);
348+
return yield* workflow.localStatus({
349+
cwd,
350+
...(includeCheckoutDetails ? { includeCheckoutDetails: true } : {}),
351+
});
352+
});
353+
342354
const loadLocalStatus = Effect.fn("VcsStatusBroadcaster.loadLocalStatus")(function* (
343355
cwd: string,
344356
) {
345-
const local = yield* workflow.localStatus({ cwd });
357+
const local = yield* readLocalStatus(cwd);
346358
return yield* updateCachedLocalStatus(cwd, local);
347359
});
348360

@@ -409,13 +421,7 @@ export const make = Effect.gen(function* () {
409421
if (shared !== undefined && shared.startedAt >= requestedAt) return shared.local;
410422
const startedAt = localRefreshRequests.get(cwd) ?? requestedAt;
411423
yield* workflow.invalidateLocalStatus(cwd);
412-
const includeCheckoutDetails = yield* Ref.get(checkoutDetailDemandRef).pipe(
413-
Effect.map((demand) => demand.has(cwd)),
414-
);
415-
const local = yield* workflow.localStatus({
416-
cwd,
417-
...(includeCheckoutDetails ? { includeCheckoutDetails: true } : {}),
418-
});
424+
const local = yield* readLocalStatus(cwd);
419425
localRefreshResults.set(cwd, { startedAt, local });
420426
return yield* updateCachedLocalStatus(cwd, local, { publish: true });
421427
}),
@@ -765,7 +771,7 @@ export const make = Effect.gen(function* () {
765771
return yield* Effect.gen(function* () {
766772
const subscription = yield* PubSub.subscribe(changesPubSub);
767773
const initialLocal = input.includeCheckoutDetails
768-
? yield* workflow.localStatus({ cwd, includeCheckoutDetails: true })
774+
? yield* loadLocalStatus(cwd)
769775
: yield* getOrLoadLocalStatus(cwd);
770776
const cachedStatus = yield* getCachedStatus(cwd);
771777
const initialRemote = cachedStatus?.remote?.value ?? null;

0 commit comments

Comments
 (0)