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
This commit is contained in:
Julius Marminge authored and Julius Marminge committed 2026-03-01 20:06:21 -08:00
1 parent a21095bc9a
commit 5e55aa387f
12 files changed
+405 -264

No files matched your search

-72
View File
@@ -247,43 +247,6 @@ function buildTemporaryWorktreeBranchName(message: string): string {
return `${WORKTREE_BRANCH_PREFIX}/${hashBranchSeed(seed)}`;
}
function imageReferenceForBranchNaming(image: ComposerImageAttachment): string {
const maybePath = (image.file as File & { path?: unknown }).path;
if (typeof maybePath === "string" && maybePath.trim().length > 0) {
return maybePath.trim();
}
return image.name;
}
function buildBranchNameGenerationMessage(
text: string,
images: ReadonlyArray<ComposerImageAttachment>,
): string {
const trimmedText = text.trim();
const imageReferences = Array.from(
new Set(
images
.map((image) => imageReferenceForBranchNaming(image).trim())
.filter((reference) => reference.length > 0),
),
);
const attachmentsSection =
imageReferences.length > 0
? `Attached images:\n${imageReferences.map((reference) => `- ${reference}`).join("\n")}`
: "";
if (trimmedText.length > 0 && attachmentsSection.length > 0) {
return `${trimmedText}\n\n${attachmentsSection}`;
}
if (trimmedText.length > 0) {
return trimmedText;
}
if (attachmentsSection.length > 0) {
return attachmentsSection;
}
return "New worktree change";
}
const VscodeEntryIcon = memo(function VscodeEntryIcon(props: {
pathValue: string;
kind: "file" | "directory";
@@ -1530,7 +1493,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
const composerImagesSnapshot = [...composerImages];
const messageIdForSend = newMessageId();
const messageCreatedAt = new Date().toISOString();
const branchNameMessage = buildBranchNameGenerationMessage(trimmed, composerImagesSnapshot);
const turnAttachmentsPromise = Promise.all(
composerImagesSnapshot.map(
async (
@@ -1578,7 +1540,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
setComposerHighlightedItemId(null);
let attemptedTurnStart = false;
let pendingWorktreeBranchRename: Promise<void> | null = null;
try {
// On first message: lock in branch + create worktree if needed.
if (baseBranchForWorktree) {
@@ -1604,36 +1565,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
branch: result.worktree.branch,
worktreePath: result.worktree.path,
});
pendingWorktreeBranchRename = (async () => {
const turnAttachments = await turnAttachmentsPromise;
const renamed = await api.git.generateAndRenameBranch({
cwd: result.worktree.path,
oldBranch: result.worktree.branch,
message: branchNameMessage,
attachments: turnAttachments,
});
if (!renamed.branch || renamed.branch === result.worktree.branch) {
return;
}
await api.orchestration.dispatchCommand({
type: "thread.meta.update",
commandId: newCommandId(),
threadId: threadIdForSend,
branch: renamed.branch,
worktreePath: result.worktree.path,
});
dispatch({
type: "SET_THREAD_BRANCH",
threadId: threadIdForSend,
branch: renamed.branch,
worktreePath: result.worktree.path,
});
})().catch((error) => {
console.warn("Failed to rename generated worktree branch", {
threadId: threadIdForSend,
error: error instanceof Error ? error.message : String(error),
});
});
const setupScript = setupProjectScript(activeProject.scripts);
if (setupScript) {
await runProjectScript(setupScript, {
@@ -1683,9 +1614,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
sandboxMode,
createdAt: messageCreatedAt,
});
if (pendingWorktreeBranchRename) {
void pendingWorktreeBranchRename;
}
} catch (err) {
if (
!attemptedTurnStart &&
-3
View File
@@ -164,9 +164,6 @@ export function createWsNativeApi(): NativeApi {
runStackedAction: (input) => transport.request(WS_METHODS.gitRunStackedAction, input),
listBranches: (input) => transport.request(WS_METHODS.gitListBranches, input),
createWorktree: (input) => transport.request(WS_METHODS.gitCreateWorktree, input),
generateBranchName: (input) => transport.request(WS_METHODS.gitGenerateBranchName, input),
generateAndRenameBranch: (input) =>
transport.request(WS_METHODS.gitGenerateAndRenameBranch, input),
renameBranch: (input) => transport.request(WS_METHODS.gitRenameBranch, input),
removeWorktree: (input) => transport.request(WS_METHODS.gitRemoveWorktree, input),
createBranch: (input) => transport.request(WS_METHODS.gitCreateBranch, input),