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.ts (1 of 12 files). Show all

Unified · Split

apps/server/src/wsServer.ts+0−54
@@ -54,7 +54,6 @@ import { clamp } from "effect/Number"; · 53 unmodified lines
5454 import { Open } from "./open";
5555 import { ServerConfig } from "./config";
5656 import { GitCore } from "./git/Services/GitCore.ts";
57−import { TextGeneration } from "./git/Services/TextGeneration.ts";
5857 import { ATTACHMENTS_ROUTE_PREFIX, tryHandleProjectFaviconRequest } from "./projectFaviconRoute";
5958
6059 /**
@@ -136,31 +135,6 @@ function stripRequestTag<T extends { _tag: string }>(body: T) { · 75 unmodified lines
136135 return Struct.omit(body, ["_tag"]);
137136 }
138137
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−
164138 export type ServerCoreRuntimeServices =
165139 | OrchestrationEngineService
166140 | ProjectionSnapshotQuery
@@ -172,7 +146,6 @@ export type ServerRuntimeServices = · 5 unmodified lines
172146 | ServerCoreRuntimeServices
173147 | GitManager
174148 | GitCore
175− | TextGeneration
176149 | TerminalManager
177150 | Keybindings
178151 | Open;
@@ -211,7 +184,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 32 unmodified lines
211184 const terminalManager = yield* TerminalManager;
212185 const keybindingsManager = yield* Keybindings;
213186 const git = yield* GitCore;
214− const textGeneration = yield* TextGeneration;
215187 const fileSystem = yield* FileSystem.FileSystem;
216188 const path = yield* Path.Path;
217189
@@ -600,32 +572,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 382 unmodified lines
600572 return yield* git.createWorktree(body);
601573 }
602574
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−
629575 case WS_METHODS.gitRenameBranch: {
630576 const body = stripRequestTag(request.body);
631577 return yield* git.renameBranch(body);