feat(settings): add shared project defaults and scoped overrides (#9754)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-09-06 02:32:48 -03:00
1 parent b972f1c1df
commit 9f40b2f563
38 files changed
+2237 -647

No files matched your search

@@ -6,6 +6,7 @@ import * as Option from "effect/Option";
import * as Schema from "effect/Schema";
import * as ProjectionSnapshotQuery from "../orchestration/Services/ProjectionSnapshotQuery.ts";
import * as ServerSettings from "../serverSettings.ts";
import * as TerminalManager from "../terminal/Manager.ts";
import * as ProjectSetupScriptRunner from "./ProjectSetupScriptRunner.ts";
@@ -68,13 +69,73 @@ const makeTerminalManagerLayer = (
const testLayer = (
project: OrchestrationProject,
terminal: Pick<TerminalManager.TerminalManager["Service"], "open" | "write">,
settings = ServerSettings.layerTest(),
) =>
ProjectSetupScriptRunner.layer.pipe(
Layer.provideMerge(makeProjectionSnapshotQueryLayer(project)),
Layer.provideMerge(makeTerminalManagerLayer(terminal)),
Layer.provide(settings),
);
describe("ProjectSetupScriptRunner", () => {
it.effect("runs the inherited machine setup action in the checkout's worktree", () => {
const open = vi.fn(() =>
Effect.succeed({
threadId: "thread-1",
terminalId: "setup-default-setup",
cwd: "/repo/worktrees/a",
worktreePath: "/repo/worktrees/a",
status: "running" as const,
pid: 123,
history: "",
exitCode: null,
exitSignal: null,
label: "setup-default-setup",
updatedAt: "2026-01-01T00:00:00.000Z",
}),
);
const write = vi.fn(() => Effect.void);
return Effect.gen(function* () {
const runner = yield* ProjectSetupScriptRunner.ProjectSetupScriptRunner;
const result = yield* runner.runForThread({
threadId: "thread-1",
projectId: "project-1",
worktreePath: "/repo/worktrees/a",
});
expect(result).toMatchObject({ status: "started", scriptId: "default-setup" });
expect(open).toHaveBeenCalledWith({
threadId: "thread-1",
terminalId: "setup-default-setup",
cwd: "/repo/worktrees/a",
worktreePath: "/repo/worktrees/a",
env: { T3CODE_PROJECT_ROOT: "/repo/project", T3CODE_WORKTREE_PATH: "/repo/worktrees/a" },
});
expect(write).toHaveBeenCalledWith({
threadId: "thread-1",
terminalId: "setup-default-setup",
data: "npm install\r",
});
}).pipe(
Effect.provide(
testLayer(
makeProject([]),
{ open, write },
ServerSettings.layerTest({
defaultProjectScripts: [
{
id: "default-setup",
name: "Setup",
command: "npm install",
icon: "configure",
runOnWorktreeCreate: true,
},
],
}),
),
),
);
});
it.effect("returns no-script when no setup script exists", () => {
const open = vi.fn(() => Effect.die("unexpected open"));
const write = vi.fn(() => Effect.die("unexpected write"));