Skip to content

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.

Stabilize git workspace and terminal tests (#2540)

Julius Marminge25c9d267acbf
diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.ts
index b5c9c0338..4dba7f984 100644
--- a/apps/server/src/git/GitManager.test.ts
+++ b/apps/server/src/git/GitManager.test.ts
@@ -294,6 +294,18 @@ function configureRemote(
});
}
+function configureVisibleRemoteUrlWithLocalRewrite(
+ cwd: string,
+ remoteName: string,
+ visibleUrl: string,
+ localRemotePath: string,
+): Effect.Effect<void, GitCommandError, GitVcsDriver.GitVcsDriver> {
+ return Effect.gen(function* () {
+ yield* runGit(cwd, ["config", `remote.${remoteName}.url`, visibleUrl]);
+ yield* runGit(cwd, ["config", `url.${localRemotePath}.insteadOf`, visibleUrl]);
+ });
+}
+
function createTextGeneration(overrides: Partial<FakeGitTextGeneration> = {}): TextGenerationShape {
const implementation: FakeGitTextGeneration = {
generateCommitMessage: (input) =>
@@ -1012,11 +1024,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]);
yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
- yield* runGit(repoDir, [
- "config",
- "remote.fork-seed.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "fork-seed",
"[email protected]:jasonLaster/codething-mvp.git",
- ]);
+ forkDir,
+ );
const { manager, ghCalls } = yield* makeManager({
ghScenario: {
@@ -1076,17 +1089,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);
yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);
yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);
- yield* runGit(repoDir, [
- "config",
- "remote.origin.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "origin",
"[email protected]:pingdotgg/codething-mvp.git",
- ]);
+ originDir,
+ );
yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);
- yield* runGit(repoDir, [
- "config",
- "remote.my-org/upstream.url",
- "[email protected]:pingdotgg/codething-mvp.git",
- ]);
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "my-org/upstream",
+ "ssh://[email protected]/pingdotgg/codething-mvp.git",
+ upstreamDir,
+ );
yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);
yield* runGit(repoDir, ["checkout", "main"]);
yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);
@@ -1861,11 +1876,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
const forkDir = yield* createBareRemote();
yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);
yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
- yield* runGit(repoDir, [
- "config",
- "remote.fork-seed.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "fork-seed",
"[email protected]:octocat/codething-mvp.git",
- ]);
+ forkDir,
+ );
const { manager, ghCalls } = yield* makeManager({
ghScenario: {
@@ -1923,17 +1939,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);
yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);
yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);
- yield* runGit(repoDir, [
- "config",
- "remote.origin.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "origin",
"[email protected]:pingdotgg/codething-mvp.git",
- ]);
+ originDir,
+ );
yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);
- yield* runGit(repoDir, [
- "config",
- "remote.my-org/upstream.url",
- "[email protected]:pingdotgg/codething-mvp.git",
- ]);
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "my-org/upstream",
+ "ssh://[email protected]/pingdotgg/codething-mvp.git",
+ upstreamDir,
+ );
yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);
yield* runGit(repoDir, ["checkout", "main"]);
yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);
@@ -2013,11 +2031,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);
yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
- yield* runGit(repoDir, [
- "config",
- "remote.fork-seed.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "fork-seed",
"[email protected]:octocat/codething-mvp.git",
- ]);
+ forkDir,
+ );
const { manager, ghCalls } = yield* makeManager({
ghScenario: {
@@ -2083,11 +2102,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);
yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
- yield* runGit(repoDir, [
- "config",
- "remote.fork-seed.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "fork-seed",
"[email protected]:octocat/codething-mvp.git",
- ]);
+ forkDir,
+ );
const { manager, ghCalls } = yield* makeManager({
ghScenario: {
@@ -2263,11 +2283,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-91/statemachine"]);
yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
- yield* runGit(repoDir, [
- "config",
- "remote.fork-seed.url",
+ yield* configureVisibleRemoteUrlWithLocalRewrite(
+ repoDir,
+ "fork-seed",
"[email protected]:octocat/codething-mvp.git",
- ]);
+ forkDir,
+ );
const { manager, ghCalls } = yield* makeManager({
ghScenario: {
@@ -3147,7 +3168,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
fs.writeFileSync(path.join(repoDir, "hooked.txt"), "hooked\n");
fs.writeFileSync(
path.join(repoDir, ".git", "hooks", "pre-commit"),
- '#!/bin/sh\necho "hook: start" >&2\nsleep 1\necho "hook: end" >&2\n',
+ '#!/bin/sh\necho "hook: start" >&2\nsleep 0.05\necho "hook: end" >&2\n',
{ mode: 0o755 },
);
diff --git a/apps/server/src/terminal/Layers/Manager.test.ts b/apps/server/src/terminal/Layers/Manager.test.ts
index 9d41c3de2..7c4f429e4 100644
--- a/apps/server/src/terminal/Layers/Manager.test.ts
+++ b/apps/server/src/terminal/Layers/Manager.test.ts
@@ -238,9 +238,7 @@ const createManager = (
...(options.subprocessPollIntervalMs !== undefined
? { subprocessPollIntervalMs: options.subprocessPollIntervalMs }
: {}),
- ...(options.processKillGraceMs !== undefined
- ? { processKillGraceMs: options.processKillGraceMs }
- : {}),
+ processKillGraceMs: options.processKillGraceMs ?? 1,
...(options.maxRetainedInactiveSessions !== undefined
? { maxRetainedInactiveSessions: options.maxRetainedInactiveSessions }
: {}),