- 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
Showing the changes to apps/server/src/wsServer.test.ts (1 of 12 files). Show all
Unified · Split
| @@ -46,7 +46,6 @@ import { Open, type OpenShape } from "./open"; · 45 unmodified lines | |||
| 46 | import { GitManager, type GitManagerShape } from "./git/Services/GitManager.ts"; | 46 | import { GitManager, type GitManagerShape } from "./git/Services/GitManager.ts"; |
| 47 | import type { GitCoreShape } from "./git/Services/GitCore.ts"; | 47 | import type { GitCoreShape } from "./git/Services/GitCore.ts"; |
| 48 | import { GitCore } from "./git/Services/GitCore.ts"; | 48 | import { GitCore } from "./git/Services/GitCore.ts"; |
| 49 | import { TextGeneration, type TextGenerationShape } from "./git/Services/TextGeneration.ts"; | ||
| 50 | import { GitCommandError, GitManagerError } from "./git/Errors.ts"; | 49 | import { GitCommandError, GitManagerError } from "./git/Errors.ts"; |
| 51 | import { MigrationError } from "@effect/sql-sqlite-bun/SqliteMigrator"; | 50 | import { MigrationError } from "@effect/sql-sqlite-bun/SqliteMigrator"; |
| 52 | 51 | ||
| @@ -374,7 +373,6 @@ describe("WebSocket Server", () => { · 321 unmodified lines | |||
| 374 | GitCoreShape, | 373 | GitCoreShape, |
| 375 | "listBranches" | "initRepo" | "pullCurrentBranch" | "renameBranch" | 374 | "listBranches" | "initRepo" | "pullCurrentBranch" | "renameBranch" |
| 376 | >; | 375 | >; |
| 377 | textGeneration?: Pick<TextGenerationShape, "generateBranchName">; | ||
| 378 | terminalManager?: TerminalManagerShape; | 376 | terminalManager?: TerminalManagerShape; |
| 379 | } = {}, | 377 | } = {}, |
| 380 | ): Promise<Http.Server> { | 378 | ): Promise<Http.Server> { |
| @@ -407,9 +405,6 @@ describe("WebSocket Server", () => { · 26 unmodified lines | |||
| 407 | options.gitCore | 405 | options.gitCore |
| 408 | ? Layer.succeed(GitCore, options.gitCore as unknown as GitCoreShape) | 406 | ? Layer.succeed(GitCore, options.gitCore as unknown as GitCoreShape) |
| 409 | : Layer.empty, | 407 | : Layer.empty, |
| 410 | options.textGeneration | ||
| 411 | ? Layer.succeed(TextGeneration, options.textGeneration as unknown as TextGenerationShape) | ||
| 412 | : Layer.empty, | ||
| 413 | options.terminalManager | 408 | options.terminalManager |
| 414 | ? Layer.succeed(TerminalManager, options.terminalManager) | 409 | ? Layer.succeed(TerminalManager, options.terminalManager) |
| 415 | : Layer.empty, | 410 | : Layer.empty, |
| @@ -1477,7 +1472,6 @@ describe("WebSocket Server", () => { · 1061 unmodified lines | |||
| 1477 | ); | 1472 | ); |
| 1478 | const initRepo = vi.fn(() => Effect.void); | 1473 | const initRepo = vi.fn(() => Effect.void); |
| 1479 | const renameBranch = vi.fn(() => Effect.succeed({ branch: "t3code/new-name" })); | 1474 | const renameBranch = vi.fn(() => Effect.succeed({ branch: "t3code/new-name" })); |
| 1480 | const generateBranchName = vi.fn(() => Effect.succeed({ branch: "new-name" as const })); | ||
| 1481 | const pullCurrentBranch = vi.fn(() => | 1475 | const pullCurrentBranch = vi.fn(() => |
| 1482 | Effect.fail( | 1476 | Effect.fail( |
| 1483 | new GitCommandError({ | 1477 | new GitCommandError({ |
| @@ -1497,9 +1491,6 @@ describe("WebSocket Server", () => { · 13 unmodified lines | |||
| 1497 | renameBranch, | 1491 | renameBranch, |
| 1498 | pullCurrentBranch, | 1492 | pullCurrentBranch, |
| 1499 | }, | 1493 | }, |
| 1500 | textGeneration: { | ||
| 1501 | generateBranchName, | ||
| 1502 | }, | ||
| 1503 | }); | 1494 | }); |
| 1504 | const addr = server.address(); | 1495 | const addr = server.address(); |
| 1505 | const port = typeof addr === "object" && addr !== null ? addr.port : 0; | 1496 | const port = typeof addr === "object" && addr !== null ? addr.port : 0; |
| @@ -1522,61 +1513,6 @@ describe("WebSocket Server", () => { · 16 unmodified lines | |||
| 1522 | expect(pullResponse.error?.message).toContain("No upstream configured"); | 1513 | expect(pullResponse.error?.message).toContain("No upstream configured"); |
| 1523 | expect(pullCurrentBranch).toHaveBeenCalledWith("/repo/path"); | 1514 | expect(pullCurrentBranch).toHaveBeenCalledWith("/repo/path"); |
| 1524 | 1515 | ||
| 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 | |||
| 1580 | const renameResponse = await sendRequest(ws, WS_METHODS.gitRenameBranch, { | 1516 | const renameResponse = await sendRequest(ws, WS_METHODS.gitRenameBranch, { |
| 1581 | cwd: "/repo/path", | 1517 | cwd: "/repo/path", |
| 1582 | oldBranch: "t3code/tmp-456", | 1518 | oldBranch: "t3code/tmp-456", |
| @@ -1591,52 +1527,6 @@ describe("WebSocket Server", () => { · 8 unmodified lines | |||
| 1591 | }); | 1527 | }); |
| 1592 | }); | 1528 | }); |
| 1593 | 1529 | ||
| 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 | |||
| 1640 | it("supports git.status over websocket", async () => { | 1530 | it("supports git.status over websocket", async () => { |
| 1641 | const statusResult = { | 1531 | const statusResult = { |
| 1642 | branch: "feature/test", | 1532 | branch: "feature/test", |