History

Move worktree branch auto-rename into provider turn reactor

- Generate and rename temporary `t3code/*` worktree branches on first user turn in `ProviderCommandReactor` - Remove websocket/client branch-generation RPCs and related contract/API surface - Update Codex text-generation prompt to include attachment metadata only when attachments exist, with expanded tests

Julius Marminge committed 8 months ago

Commit 5e55aa31 parent a21095b12 files · +405 −264Browse files

Showing the changes to apps/server/src/wsServer.test.ts (1 of 12 files). Show all

Unified · Split

apps/server/src/wsServer.test.ts+0−110
@@ -46,7 +46,6 @@ import { Open, type OpenShape } from "./open"; · 45 unmodified lines
4646 import { GitManager, type GitManagerShape } from "./git/Services/GitManager.ts";
4747 import type { GitCoreShape } from "./git/Services/GitCore.ts";
4848 import { GitCore } from "./git/Services/GitCore.ts";
49−import { TextGeneration, type TextGenerationShape } from "./git/Services/TextGeneration.ts";
5049 import { GitCommandError, GitManagerError } from "./git/Errors.ts";
5150 import { MigrationError } from "@effect/sql-sqlite-bun/SqliteMigrator";
5251
@@ -374,7 +373,6 @@ describe("WebSocket Server", () => { · 321 unmodified lines
374373 GitCoreShape,
375374 "listBranches" | "initRepo" | "pullCurrentBranch" | "renameBranch"
376375 >;
377− textGeneration?: Pick<TextGenerationShape, "generateBranchName">;
378376 terminalManager?: TerminalManagerShape;
379377 } = {},
380378 ): Promise<Http.Server> {
@@ -407,9 +405,6 @@ describe("WebSocket Server", () => { · 26 unmodified lines
407405 options.gitCore
408406 ? Layer.succeed(GitCore, options.gitCore as unknown as GitCoreShape)
409407 : Layer.empty,
410− options.textGeneration
411− ? Layer.succeed(TextGeneration, options.textGeneration as unknown as TextGenerationShape)
412− : Layer.empty,
413408 options.terminalManager
414409 ? Layer.succeed(TerminalManager, options.terminalManager)
415410 : Layer.empty,
@@ -1477,7 +1472,6 @@ describe("WebSocket Server", () => { · 1061 unmodified lines
14771472 );
14781473 const initRepo = vi.fn(() => Effect.void);
14791474 const renameBranch = vi.fn(() => Effect.succeed({ branch: "t3code/new-name" }));
1480− const generateBranchName = vi.fn(() => Effect.succeed({ branch: "new-name" as const }));
14811475 const pullCurrentBranch = vi.fn(() =>
14821476 Effect.fail(
14831477 new GitCommandError({
@@ -1497,9 +1491,6 @@ describe("WebSocket Server", () => { · 13 unmodified lines
14971491 renameBranch,
14981492 pullCurrentBranch,
14991493 },
1500− textGeneration: {
1501− generateBranchName,
1502− },
15031494 });
15041495 const addr = server.address();
15051496 const port = typeof addr === "object" && addr !== null ? addr.port : 0;
@@ -1522,61 +1513,6 @@ describe("WebSocket Server", () => { · 16 unmodified lines
15221513 expect(pullResponse.error?.message).toContain("No upstream configured");
15231514 expect(pullCurrentBranch).toHaveBeenCalledWith("/repo/path");
15241515
1525− const generatedBranchResponse = await sendRequest(ws, WS_METHODS.gitGenerateBranchName, {
1526− cwd: "/repo/path",
1527− message: "Add retry logic for websocket reconnects",
1528− attachments: [
1529− {
1530− type: "image",
1531− name: "bug.png",
1532− mimeType: "image/png",
1533− sizeBytes: 5,
1534− dataUrl: "data:image/png;base64,SGVsbG8=",
1535− },
1536− ],
1537− });
1538− expect(generatedBranchResponse.error).toBeUndefined();
1539− expect(generatedBranchResponse.result).toEqual({ branch: "new-name" });
1540− expect(generateBranchName).toHaveBeenCalledWith({
1541− cwd: "/repo/path",
1542− message: "Add retry logic for websocket reconnects",
1543− attachments: [
1544− {
1545− type: "image",
1546− name: "bug.png",
1547− mimeType: "image/png",
1548− sizeBytes: 5,
1549− dataUrl: "data:image/png;base64,SGVsbG8=",
1550− },
1551− ],
1552− });
1553−
1554− const generateAndRenameResponse = await sendRequest(
1555− ws,
1556− WS_METHODS.gitGenerateAndRenameBranch,
1557− {
1558− cwd: "/repo/path",
1559− oldBranch: "t3code/tmp-123",
1560− message: "Add retry logic for websocket reconnects",
1561− attachments: [
1562− {
1563− type: "image",
1564− name: "bug.png",
1565− mimeType: "image/png",
1566− sizeBytes: 5,
1567− dataUrl: "data:image/png;base64,SGVsbG8=",
1568− },
1569− ],
1570− },
1571− );
1572− expect(generateAndRenameResponse.error).toBeUndefined();
1573− expect(generateAndRenameResponse.result).toEqual({ branch: "t3code/new-name" });
1574− expect(renameBranch).toHaveBeenCalledWith({
1575− cwd: "/repo/path",
1576− oldBranch: "t3code/tmp-123",
1577− newBranch: "t3code/new-name",
1578− });
1579−
15801516 const renameResponse = await sendRequest(ws, WS_METHODS.gitRenameBranch, {
15811517 cwd: "/repo/path",
15821518 oldBranch: "t3code/tmp-456",
@@ -1591,52 +1527,6 @@ describe("WebSocket Server", () => { · 8 unmodified lines
15911527 });
15921528 });
15931529
1594− it("skips rename in git.generateAndRenameBranch when branch generation returns null", async () => {
1595− const renameBranch = vi.fn(() => Effect.succeed({ branch: "t3code/new-name" }));
1596− const generateBranchName = vi.fn(() => Effect.succeed({ branch: null }));
1597−
1598− server = await createTestServer({
1599− cwd: "/test",
1600− gitCore: {
1601− listBranches: () =>
1602− Effect.succeed({
1603− branches: [],
1604− isRepo: false,
1605− }),
1606− initRepo: () => Effect.void,
1607− renameBranch,
1608− pullCurrentBranch: () =>
1609− Effect.fail(
1610− new GitCommandError({
1611− operation: "GitCore.test.pullCurrentBranch",
1612− detail: "No upstream configured",
1613− command: "git pull",
1614− cwd: "/repo/path",
1615− }),
1616− ),
1617− },
1618− textGeneration: {
1619− generateBranchName,
1620− },
1621− });
1622− const addr = server.address();
1623− const port = typeof addr === "object" && addr !== null ? addr.port : 0;
1624− const ws = await connectWs(port);
1625− connections.push(ws);
1626− await waitForMessage(ws);
1627−
1628− const response = await sendRequest(ws, WS_METHODS.gitGenerateAndRenameBranch, {
1629− cwd: "/repo/path",
1630− oldBranch: "t3code/tmp-123",
1631− message: "Fix visual regression",
1632− attachments: [],
1633− });
1634−
1635− expect(response.error).toBeUndefined();
1636− expect(response.result).toEqual({ branch: null });
1637− expect(renameBranch).not.toHaveBeenCalled();
1638− });
1639−
16401530 it("supports git.status over websocket", async () => {
16411531 const statusResult = {
16421532 branch: "feature/test",