Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(server): status subscribe and branch switch no longer read local Git status twice #38949

Openamv146(GitHub profile, opens in a new tab)wants to merge 12 commits intomain fromrefs/pull/38949/headopened View on GitHub

Showing 2 changed files with 156 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
156 additions and 0 deletionsapps/server/src/vcs/VcsStatusBroadcaster.test.tsModified
View file
@@ -2462,6 +2462,55 @@
+ it.effect("a checkout's own refresh also serves the HEAD watch it set off", () =>
+ Effect.gen(function* () {
+ const events = yield* Queue.unbounded<FileSystem.WatchEvent>();
+ const state: Parameters<typeof layerTestFor>[0] = {
+ currentLocalStatus: { ...baseLocalStatus, isDefaultRef: true, refName: "main" },
+ currentRemoteStatus: baseRemoteStatus,
+ localStatusCalls: 0,
+ remoteStatusCalls: 0,
+ localInvalidationCalls: 0,
+ remoteInvalidationCalls: 0,
+ headPath: "/repo/.git/HEAD",
+ fileSystem: FileSystem.makeNoop({
+ realPath: (target) => Effect.succeed(target),
+ exists: () => Effect.succeed(true),
+ watch: (_target, options) =>
+ Stream.fromQueue(events).pipe(Stream.onStart(Effect.sync(() => options?.onReady?.()))),
+ }),
+ };
+​
+ yield* Effect.gen(function* () {
+ const broadcaster = yield* VcsStatusBroadcaster.VcsStatusBroadcaster;
+ yield* broadcaster.getStatus({ cwd: "/repo" });
+ const subscribed = yield* Deferred.make<void>();
+ yield* broadcaster.streamStatus({ cwd: "/repo" }).pipe(
+ Stream.runForEach(() => Deferred.succeed(subscribed, undefined)),
+ Effect.forkScoped,