Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
fix(server): allow long-running git pushes (#6499)
Dev Talan86fb47afd724
diff --git a/apps/server/src/vcs/GitVcsDriver.ts b/apps/server/src/vcs/GitVcsDriver.tsindex 8f7f7bd19..fdfd4eac5 100644--- a/apps/server/src/vcs/GitVcsDriver.ts+++ b/apps/server/src/vcs/GitVcsDriver.ts@@ -41,7 +41,7 @@ export interface ExecuteGitInput {readonly stdin?: string;readonly env?: NodeJS.ProcessEnv;readonly allowNonZeroExit?: boolean;- readonly timeoutMs?: number;+ readonly timeoutMs?: number | null;readonly maxOutputBytes?: number;readonly appendTruncationMarker?: boolean;readonly progress?: ExecuteGitProgress;diff --git a/apps/server/src/vcs/GitVcsDriverCore.test.ts b/apps/server/src/vcs/GitVcsDriverCore.test.tsindex fc1b4d127..66dc7b96a 100644--- a/apps/server/src/vcs/GitVcsDriverCore.test.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.test.ts@@ -1611,6 +1611,43 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => {}),);+ it.effect("allows pushes to run longer than the default command timeout", () =>+ Effect.gen(function* () {+ const delegate = yield* ChildProcessSpawner.ChildProcessSpawner;+ const pushStarted = yield* Deferred.make<void>();+ const delayedPushSpawner = ChildProcessSpawner.make((command) =>+ Effect.gen(function* () {+ if (ChildProcess.isStandardCommand(command) && command.args[0] === "push") {+ yield* Deferred.succeed(pushStarted, undefined);+ yield* Effect.sleep("31 seconds");+ }+ return yield* delegate.spawn(command);+ }),+ );+ const driver = yield* makeGitVcsDriverCore().pipe(+ Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, delayedPushSpawner),+ Effect.provide(ServerConfigLayer),+ );+ const cwd = yield* makeTmpDir();+ const remote = yield* makeTmpDir("git-remote-");+ yield* initRepoWithCommit(cwd);+ yield* git(remote, ["init", "--bare"]);+ yield* git(cwd, ["remote", "add", "origin", remote]);++ const pushing = yield* driver+ .pushCurrentBranch(cwd, null)+ .pipe(Effect.forkChild({ startImmediately: true }));+ yield* Deferred.await(pushStarted);+ yield* TestClock.adjust("31 seconds");+ const pushed = yield* Fiber.join(pushing);++ assert.deepInclude(pushed, {+ status: "pushed",+ setUpstream: true,+ });+ }),+ );+it.effect("pushes upstream branches to the remote branch name, not the upstream shorthand",() =>diff --git a/apps/server/src/vcs/GitVcsDriverCore.ts b/apps/server/src/vcs/GitVcsDriverCore.tsindex 916286537..5930caf49 100644--- a/apps/server/src/vcs/GitVcsDriverCore.ts+++ b/apps/server/src/vcs/GitVcsDriverCore.ts@@ -139,7 +139,7 @@ interface GitRefsSnapshot {interface ExecuteGitOptions {stdin?: string | undefined;- timeoutMs?: number | undefined;+ timeoutMs?: number | null | undefined;allowNonZeroExit?: boolean | undefined;fallbackErrorDetail?: string | undefined;env?: NodeJS.ProcessEnv | undefined;@@ -712,7 +712,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*...input,args: [...input.args],} as const;- const timeoutMs = input.timeoutMs ?? DEFAULT_TIMEOUT_MS;+ const timeoutMs = input.timeoutMs === undefined ? DEFAULT_TIMEOUT_MS : input.timeoutMs;const maxOutputBytes = input.maxOutputBytes ?? DEFAULT_MAX_OUTPUT_BYTES;const appendTruncationMarker = input.appendTruncationMarker ?? false;@@ -813,8 +813,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*} satisfies GitVcsDriver.ExecuteGitResult;});- return yield* runGitCommand().pipe(- Effect.scoped,+ const execution = runGitCommand().pipe(Effect.scoped);+ if (timeoutMs === null) {+ return yield* execution;+ }++ return yield* execution.pipe(Effect.timeoutOption(timeoutMs),Effect.flatMap((result) =>Option.match(result, {@@ -905,9 +909,9 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*operation: string,cwd: string,args: readonly string[],- allowNonZeroExit = false,+ options: ExecuteGitOptions = {},): Effect.Effect<void, GitCommandError> =>- executeGit(operation, cwd, args, { allowNonZeroExit }).pipe(Effect.asVoid);+ executeGit(operation, cwd, args, options).pipe(Effect.asVoid);const runGitStdout = (operation: string,@@ -1905,12 +1909,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*const requestedRemoteName = options?.remoteName?.trim() || null;if (requestedRemoteName) {const publishBranch = yield* resolvePublishBranchName(cwd, branch);- yield* runGit("GitVcsDriver.pushCurrentBranch.pushWithRequestedRemote", cwd, [- "push",- "-u",- requestedRemoteName,- `HEAD:refs/heads/${publishBranch}`,- ]);+ yield* runGit(+ "GitVcsDriver.pushCurrentBranch.pushWithRequestedRemote",+ cwd,+ ["push", "-u", requestedRemoteName, `HEAD:refs/heads/${publishBranch}`],+ { timeoutMs: null },+ );return {status: "pushed" as const,branch,@@ -1968,12 +1972,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*});}const publishBranch = yield* resolvePublishBranchName(cwd, branch);- yield* runGit("GitVcsDriver.pushCurrentBranch.pushWithUpstream", cwd, [- "push",- "-u",- publishRemoteName,- `HEAD:refs/heads/${publishBranch}`,- ]);+ yield* runGit(+ "GitVcsDriver.pushCurrentBranch.pushWithUpstream",+ cwd,+ ["push", "-u", publishRemoteName, `HEAD:refs/heads/${publishBranch}`],+ { timeoutMs: null },+ );return {status: "pushed" as const,branch,@@ -1986,11 +1990,12 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*Effect.orElseSucceed(() => null),);if (currentUpstream) {- yield* runGit("GitVcsDriver.pushCurrentBranch.pushUpstream", cwd, [- "push",- currentUpstream.remoteName,- `HEAD:refs/heads/${currentUpstream.branchName}`,- ]);+ yield* runGit(+ "GitVcsDriver.pushCurrentBranch.pushUpstream",+ cwd,+ ["push", currentUpstream.remoteName, `HEAD:refs/heads/${currentUpstream.branchName}`],+ { timeoutMs: null },+ );return {status: "pushed" as const,branch,@@ -1999,7 +2004,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*};}- yield* runGit("GitVcsDriver.pushCurrentBranch.push", cwd, ["push"]);+ yield* runGit("GitVcsDriver.pushCurrentBranch.push", cwd, ["push"], { timeoutMs: null });return {status: "pushed" as const,branch,