The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 13:30 UTC
fix(server): a zero Git fetch interval also stops the status upstream fetch (#33845)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Mateusz Choma committed
Nov 14, 2026 at 18:32 UTC
eec0a372274ff20a236665b82d55829ca131e770
6 files changed
+69
-21
apps/server/src/server.ts
+4
-1
@@ -130,6 +130,7 @@ import * as KnownWorkspaces from "./workspace/KnownWorkspaces.ts";
130
import * as WorkspaceFileSystem from "./workspace/WorkspaceFileSystem.ts";
131
import * as WorkspacePaths from "./workspace/WorkspacePaths.ts";
132
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
133
+import * as VcsAutomaticFetchInterval from "./vcs/VcsAutomaticFetchInterval.ts";
134
import * as VcsDriverRegistry from "./vcs/VcsDriverRegistry.ts";
135
import * as VcsProjectConfig from "./vcs/VcsProjectConfig.ts";
136
import * as VcsProcess from "./vcs/VcsProcess.ts";
@@ -489,7 +490,6 @@ const layerVcs = Layer.empty.pipe(
490
Layer.provideMerge(
491
VcsStatusBroadcaster.layer.pipe(
492
Layer.provide(layerGitWorkflow),
492
- Layer.provide(VcsStatusBroadcaster.layerAutomaticFetchInterval),
493
// The orchestration runtime also consumes the broadcaster (run
494
// finalization), so the policy cannot read the store from the runtime's
495
// output.
@@ -802,6 +802,9 @@ const layerRuntimeDependencies = layerRuntimeCoreDependencies.pipe(
802
Layer.provideMerge(RemoteOpenTargets.layer),
803
Layer.provideMerge(DirectEndpoints.layer.pipe(Layer.provide(layerServerEnvironment))),
804
Layer.provideMerge(ServerLifecycleEvents.layer),
805
+ // GitVcsDriver.layer is memoized and some of its build sites live outside this file, so the
806
+ // fetch interval goes in context here, before the first build captures it.
807
+ Layer.provideMerge(VcsAutomaticFetchInterval.layer.pipe(Layer.provide(layerServerSettings))),
808
Layer.provide(NetService.layer),
809
);
810
apps/server/src/vcs/GitVcsDriverCore.test.ts
+33
@@ -12,6 +12,7 @@ import { afterAll, vi } from "vite-plus/test";
12
import * as Cause from "effect/Cause";
13
import * as Clock from "effect/Clock";
14
import * as Deferred from "effect/Deferred";
15
+import * as Duration from "effect/Duration";
16
import * as Effect from "effect/Effect";
17
import * as Exit from "effect/Exit";
18
import * as FileSystem from "effect/FileSystem";
@@ -50,6 +51,7 @@ import {
51
windowsLongPathConfigEnv,
52
} from "./GitVcsDriverCore.ts";
53
import * as GitVcsDriver from "./GitVcsDriver.ts";
54
+import { VcsAutomaticFetchInterval } from "./VcsAutomaticFetchInterval.ts";
55
import { gitConfigEnv } from "./VcsProcess.ts";
56
57
const encodeGitCommandError = Schema.encodeEffect(Schema.fromJsonString(GitCommandError));
@@ -1831,6 +1833,37 @@ it.effect("does not fetch for status when the branch tracks a local branch", ()
1833
).pipe(Effect.provide(layerTest)),
1834
);
1835
1836
+it.effect("does not fetch for status when the automatic fetch interval is zero", () =>
1837
+ Effect.scoped(
1838
+ Effect.gen(function* () {
1839
+ const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;
1840
+ const fetches: Array<ReadonlyArray<string>> = [];
1841
+ const spawner = ChildProcessSpawner.make((command) => {
1842
+ if (ChildProcess.isStandardCommand(command) && command.args.includes("fetch")) {
1843
+ fetches.push(command.args.map(String));
1844
+ }
1845
+ return delegate.spawn(command);
1846
+ });
1847
+ const driver = yield* makeGitVcsDriverCore().pipe(
1848
+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, spawner),
1849
+ Effect.provideService(VcsAutomaticFetchInterval, Effect.succeed(Duration.zero)),
1850
+ );
1851
+ const cwd = yield* makeTmpDir();
1852
+ const remote = yield* makeTmpDir("git-vcs-driver-remote-");
1853
+ const { initialBranch } = yield* initRepoWithCommit(cwd);
1854
+ yield* git(remote, ["init", "--bare"]);
1855
+ yield* git(cwd, ["remote", "add", "origin", remote]);
1856
+ yield* git(cwd, ["push", "--set-upstream", "origin", initialBranch]);
1857
+
1858
+ yield* driver.statusDetails(cwd);
1859
+ const status = yield* driver.statusDetailsRemote(cwd);
1860
+
1861
+ assert.equal(status.upstreamRef, `origin/${initialBranch}`);
1862
+ assert.deepStrictEqual(fetches, []);
1863
+ }),
1864
+ ).pipe(Effect.provide(layerTest)),
1865
+);
1866
+
1867
it.effect("lets a worktree checkout that is still working run past five minutes", () =>
1868
Effect.gen(function* () {
1869
const checkoutStarted = yield* Deferred.make<void>();
apps/server/src/vcs/GitVcsDriverCore.ts
+3
@@ -44,6 +44,7 @@ import { resolveProjectFileBackedSetting } from "@t3tools/shared/projectSettings
44
import { gitCommandDuration, gitCommandsTotal, withMetrics } from "../observability/Metrics.ts";
45
import * as GitVcsDriver from "./GitVcsDriver.ts";
46
import { removeEmptyDirectory, type RemoveEmptyDirectoryError } from "./removeEmptyDirectory.ts";
47
+import { VcsAutomaticFetchInterval } from "./VcsAutomaticFetchInterval.ts";
48
import {
49
explicitBareRepositoryEnv,
50
gitConfigEnv,
@@ -992,6 +993,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
993
const random = yield* SecureRandom.SecureRandom;
994
const hostPlatform = yield* HostProcess.Platform;
995
const serviceScope = yield* Effect.scope;
996
+ const automaticFetchInterval = yield* VcsAutomaticFetchInterval;
997
const statusFetches = new Map<string, Fiber.Fiber<void, GitCommandError>>();
998
const statusFetchProcesses = yield* Semaphore.make(4);
999
@@ -1710,6 +1712,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
1712
const refreshStatusUpstreamIfStale = Effect.fn("refreshStatusUpstreamIfStale")(function* (
1713
cwd: string,
1714
) {
1715
+ if (Duration.isZero(yield* automaticFetchInterval)) return;
1716
const headRef = yield* runGitStdout(
1717
"GitVcsDriver.refreshStatusUpstreamIfStale.headRef",
1718
cwd,
apps/server/src/vcs/VcsAutomaticFetchInterval.ts
new
+26
@@ -0,0 +1,26 @@
1
+import * as Context from "effect/Context";
2
+import * as Duration from "effect/Duration";
3
+import * as Effect from "effect/Effect";
4
+import * as Layer from "effect/Layer";
5
+import { DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL } from "@t3tools/contracts";
6
+import { resolveServerBackgroundActivitySettings } from "@t3tools/shared/backgroundActivitySettings";
7
+
8
+import * as ServerSettings from "../serverSettings.ts";
9
+
10
+export class VcsAutomaticFetchInterval extends Context.Reference<Effect.Effect<Duration.Duration>>(
11
+ "t3/vcs/VcsAutomaticFetchInterval",
12
+ { defaultValue: () => Effect.succeed(DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL) },
13
+) {}
14
+
15
+export const layer = Layer.effect(
16
+ VcsAutomaticFetchInterval,
17
+ Effect.gen(function* () {
18
+ const serverSettings = yield* ServerSettings.ServerSettingsService;
19
+ return serverSettings.getSettings.pipe(
20
+ Effect.map(
21
+ (settings) => resolveServerBackgroundActivitySettings(settings).automaticGitFetchInterval,
22
+ ),
23
+ Effect.orElseSucceed(() => DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL),
24
+ );
25
+ }),
26
+);
apps/server/src/vcs/VcsStatusBroadcaster.test.ts
+2
-1
@@ -28,6 +28,7 @@ import type {
28
import { GitCommandError, GitManagerError } from "@t3tools/contracts";
29
import { applyGitStatusStreamEvent } from "@t3tools/shared/git";
30
31
+import * as VcsAutomaticFetchInterval from "./VcsAutomaticFetchInterval.ts";
32
import * as VcsStatusBroadcaster from "./VcsStatusBroadcaster.ts";
33
import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
34
import * as GitWorkflowService from "../git/GitWorkflowService.ts";
@@ -101,7 +102,7 @@ function layerTestFor(state: {
102
Layer.provide(layerBackgroundPolicy(() => state.backgroundWorkEnabled !== false)),
103
Layer.provide(
104
Layer.succeed(
104
- VcsStatusBroadcaster.VcsAutomaticFetchInterval,
105
+ VcsAutomaticFetchInterval.VcsAutomaticFetchInterval,
106
state.automaticFetchInterval ?? Effect.succeed(Duration.seconds(30)),
107
),
108
),
apps/server/src/vcs/VcsStatusBroadcaster.ts
+1
-19
@@ -25,7 +25,6 @@ import type {
25
VcsStatusSubscriptionInput,
26
} from "@t3tools/contracts";
27
import { DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL } from "@t3tools/contracts";
28
-import { resolveServerBackgroundActivitySettings } from "@t3tools/shared/backgroundActivitySettings";
28
import { mergeGitStatusParts } from "@t3tools/shared/git";
29
import * as KeyedLock from "@t3tools/shared/KeyedLock";
30
import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
@@ -34,6 +33,7 @@ import * as BackgroundPolicy from "../background/BackgroundPolicy.ts";
33
import * as GitWorkflowService from "../git/GitWorkflowService.ts";
34
import * as ProjectStore from "../orchestration-v2/ProjectStore.ts";
35
import * as ServerSettings from "../serverSettings.ts";
36
+import { VcsAutomaticFetchInterval } from "./VcsAutomaticFetchInterval.ts";
37
38
const VCS_STATUS_REFRESH_FAILURE_BASE_DELAY = Duration.seconds(30);
39
const VCS_STATUS_REFRESH_FAILURE_MAX_DELAY = Duration.minutes(15);
@@ -160,24 +160,6 @@ interface ActiveRemotePoller {
160
readonly demandCwds: Ref.Ref<ReadonlyMap<string, number>>;
161
}
162
163
-export class VcsAutomaticFetchInterval extends Context.Reference<Effect.Effect<Duration.Duration>>(
164
- "t3/vcs/VcsAutomaticFetchInterval",
165
- { defaultValue: () => Effect.succeed(DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL) },
166
-) {}
167
-
168
-export const layerAutomaticFetchInterval = Layer.effect(
169
- VcsAutomaticFetchInterval,
170
- Effect.gen(function* () {
171
- const serverSettings = yield* ServerSettings.ServerSettingsService;
172
- return serverSettings.getSettings.pipe(
173
- Effect.map(
174
- (settings) => resolveServerBackgroundActivitySettings(settings).automaticGitFetchInterval,
175
- ),
176
- Effect.orElseSucceed(() => DEFAULT_AUTOMATIC_GIT_FETCH_INTERVAL),
177
- );
178
- }),
179
-);
180
-
163
export class VcsAutoPullPolicy extends Context.Reference<{
164
readonly isEnabled: (cwd: string) => Effect.Effect<boolean, never>;
165
}>("t3/vcs/VcsAutoPullPolicy", {