Skip to content

Commit 0f5fd9d

Browse files
Avoid no-op git status cache rewrites (#9)
Skip replacing the broadcaster cache Map when refreshed local or remote status fingerprints are unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 90dc692 commit 0f5fd9d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

apps/server/src/git/Layers/GitStatusBroadcaster.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,16 @@ export const GitStatusBroadcasterLive = Layer.effect(
8989
} satisfies CachedValue<GitStatusLocalResult>;
9090
const shouldPublish = yield* Ref.modify(cacheRef, (cache) => {
9191
const previous = cache.get(cwd) ?? { local: null, remote: null };
92+
if (previous.local?.fingerprint === nextLocal.fingerprint) {
93+
return [false, cache] as const;
94+
}
95+
9296
const nextCache = new Map(cache);
9397
nextCache.set(cwd, {
9498
...previous,
9599
local: nextLocal,
96100
});
97-
return [previous.local?.fingerprint !== nextLocal.fingerprint, nextCache] as const;
101+
return [true, nextCache] as const;
98102
});
99103

100104
if (options?.publish && shouldPublish) {
@@ -121,12 +125,16 @@ export const GitStatusBroadcasterLive = Layer.effect(
121125
} satisfies CachedValue<GitStatusRemoteResult | null>;
122126
const shouldPublish = yield* Ref.modify(cacheRef, (cache) => {
123127
const previous = cache.get(cwd) ?? { local: null, remote: null };
128+
if (previous.remote?.fingerprint === nextRemote.fingerprint) {
129+
return [false, cache] as const;
130+
}
131+
124132
const nextCache = new Map(cache);
125133
nextCache.set(cwd, {
126134
...previous,
127135
remote: nextRemote,
128136
});
129-
return [previous.remote?.fingerprint !== nextRemote.fingerprint, nextCache] as const;
137+
return [true, nextCache] as const;
130138
});
131139

132140
if (options?.publish && shouldPublish) {

0 commit comments

Comments
 (0)