- 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.ts (1 of 12 files). Show all
Unified · Split
| @@ -54,7 +54,6 @@ import { clamp } from "effect/Number"; · 53 unmodified lines | |||
| 54 | import { Open } from "./open"; | 54 | import { Open } from "./open"; |
| 55 | import { ServerConfig } from "./config"; | 55 | import { ServerConfig } from "./config"; |
| 56 | import { GitCore } from "./git/Services/GitCore.ts"; | 56 | import { GitCore } from "./git/Services/GitCore.ts"; |
| 57 | import { TextGeneration } from "./git/Services/TextGeneration.ts"; | ||
| 58 | import { ATTACHMENTS_ROUTE_PREFIX, tryHandleProjectFaviconRequest } from "./projectFaviconRoute"; | 57 | import { ATTACHMENTS_ROUTE_PREFIX, tryHandleProjectFaviconRequest } from "./projectFaviconRoute"; |
| 59 | 58 | ||
| 60 | /** | 59 | /** |
| @@ -136,31 +135,6 @@ function stripRequestTag<T extends { _tag: string }>(body: T) { · 75 unmodified lines | |||
| 136 | return Struct.omit(body, ["_tag"]); | 135 | return Struct.omit(body, ["_tag"]); |
| 137 | } | 136 | } |
| 138 | 137 | ||
| 139 | const WORKTREE_BRANCH_PREFIX = "t3code"; | ||
| 140 | |||
| 141 | function buildGeneratedWorktreeBranchName(raw: string): string { | ||
| 142 | const normalized = raw | ||
| 143 | .trim() | ||
| 144 | .toLowerCase() | ||
| 145 | .replace(/^refs\/heads\//, "") | ||
| 146 | .replace(/['"`]/g, ""); | ||
| 147 | |||
| 148 | const withoutPrefix = normalized.startsWith(`${WORKTREE_BRANCH_PREFIX}/`) | ||
| 149 | ? normalized.slice(`${WORKTREE_BRANCH_PREFIX}/`.length) | ||
| 150 | : normalized; | ||
| 151 | |||
| 152 | const branchFragment = withoutPrefix | ||
| 153 | .replace(/[^a-z0-9/_-]+/g, "-") | ||
| 154 | .replace(/\/+/g, "/") | ||
| 155 | .replace(/-+/g, "-") | ||
| 156 | .replace(/^[./_-]+|[./_-]+$/g, "") | ||
| 157 | .slice(0, 64) | ||
| 158 | .replace(/[./_-]+$/g, ""); | ||
| 159 | |||
| 160 | const safeFragment = branchFragment.length > 0 ? branchFragment : "update"; | ||
| 161 | return `${WORKTREE_BRANCH_PREFIX}/${safeFragment}`; | ||
| 162 | } | ||
| 163 | |||
| 164 | export type ServerCoreRuntimeServices = | 138 | export type ServerCoreRuntimeServices = |
| 165 | | OrchestrationEngineService | 139 | | OrchestrationEngineService |
| 166 | | ProjectionSnapshotQuery | 140 | | ProjectionSnapshotQuery |
| @@ -172,7 +146,6 @@ export type ServerRuntimeServices = · 5 unmodified lines | |||
| 172 | | ServerCoreRuntimeServices | 146 | | ServerCoreRuntimeServices |
| 173 | | GitManager | 147 | | GitManager |
| 174 | | GitCore | 148 | | GitCore |
| 175 | | TextGeneration | ||
| 176 | | TerminalManager | 149 | | TerminalManager |
| 177 | | Keybindings | 150 | | Keybindings |
| 178 | | Open; | 151 | | Open; |
| @@ -211,7 +184,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 32 unmodified lines | |||
| 211 | const terminalManager = yield* TerminalManager; | 184 | const terminalManager = yield* TerminalManager; |
| 212 | const keybindingsManager = yield* Keybindings; | 185 | const keybindingsManager = yield* Keybindings; |
| 213 | const git = yield* GitCore; | 186 | const git = yield* GitCore; |
| 214 | const textGeneration = yield* TextGeneration; | ||
| 215 | const fileSystem = yield* FileSystem.FileSystem; | 187 | const fileSystem = yield* FileSystem.FileSystem; |
| 216 | const path = yield* Path.Path; | 188 | const path = yield* Path.Path; |
| 217 | 189 | ||
| @@ -600,32 +572,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 382 unmodified lines | |||
| 600 | return yield* git.createWorktree(body); | 572 | return yield* git.createWorktree(body); |
| 601 | } | 573 | } |
| 602 | 574 | ||
| 603 | case WS_METHODS.gitGenerateBranchName: { | ||
| 604 | const body = stripRequestTag(request.body); | ||
| 605 | return yield* textGeneration.generateBranchName(body); | ||
| 606 | } | ||
| 607 | |||
| 608 | case WS_METHODS.gitGenerateAndRenameBranch: { | ||
| 609 | const body = stripRequestTag(request.body); | ||
| 610 | const generated = yield* textGeneration.generateBranchName({ | ||
| 611 | cwd: body.cwd, | ||
| 612 | message: body.message, | ||
| 613 | ...(body.attachments !== undefined ? { attachments: body.attachments } : {}), | ||
| 614 | }); | ||
| 615 | if (!generated.branch) { | ||
| 616 | return { branch: null }; | ||
| 617 | } | ||
| 618 | const targetBranch = buildGeneratedWorktreeBranchName(generated.branch); | ||
| 619 | if (targetBranch === body.oldBranch) { | ||
| 620 | return { branch: body.oldBranch }; | ||
| 621 | } | ||
| 622 | return yield* git.renameBranch({ | ||
| 623 | cwd: body.cwd, | ||
| 624 | oldBranch: body.oldBranch, | ||
| 625 | newBranch: targetBranch, | ||
| 626 | }); | ||
| 627 | } | ||
| 628 | |||
| 629 | case WS_METHODS.gitRenameBranch: { | 575 | case WS_METHODS.gitRenameBranch: { |
| 630 | const body = stripRequestTag(request.body); | 576 | const body = stripRequestTag(request.body); |
| 631 | return yield* git.renameBranch(body); | 577 | return yield* git.renameBranch(body); |