fix(server): rename worktree branches from prompt + attachments

Replace top-level `attachments` and `nameContext` on `create_paseo_worktree_request` with `firstAgentContext: { prompt?, attachments? }`, the single signal driving auto-rename. Drop the `worktreeSlug || …` short-circuits so a random placeholder slug no longer blocks renaming, drop the attachment-as-PR fallback in favor of explicit `githubPrNumber`, and reshape the MCP `create_worktree` tool around a `target` discriminated union (`branch-off` / `checkout-branch` / `checkout-pr`) with concise field descriptions so callers stop misreading `prompt` as a name field.
This commit is contained in:
Mohamed Boudra
2026-05-02 12:12:44 +07:00
parent 8e9134d255
commit 2f177dde7a
19 changed files with 312 additions and 534 deletions
@@ -293,6 +293,7 @@ interface CreateChatAgentInput {
composerState: ReturnType<typeof useAgentInputDraft>["composerState"];
ensureWorkspace: (input: {
cwd: string;
prompt: string;
attachments: AgentAttachment[];
}) => Promise<ReturnType<typeof normalizeWorkspaceDescriptor>>;
serverId: string;
@@ -310,7 +311,11 @@ async function runCreateChatAgent(input: CreateChatAgentInput): Promise<void> {
throw new Error("Select a model");
}
const { attachments: reviewAttachments } = splitComposerAttachmentsForSubmit(attachments);
const ensuredWorkspace = await ensureWorkspace({ cwd, attachments: reviewAttachments });
const ensuredWorkspace = await ensureWorkspace({
cwd,
prompt: text,
attachments: reviewAttachments,
});
submitWorkspaceDraft({
serverId,
draftKey,
@@ -588,13 +593,22 @@ export function NewWorkspaceScreen({
}, []);
const buildCreateWorktreeInput = useCallback(
(input: { cwd: string; attachments: AgentAttachment[] }) => {
(input: { cwd: string; prompt: string; attachments: AgentAttachment[] }) => {
const checkoutRequest = pickerItemToCheckoutRequest(selectedItem);
const trimmedPrompt = input.prompt.trim();
const hasFirstAgentContext = trimmedPrompt.length > 0 || input.attachments.length > 0;
return {
cwd: input.cwd,
worktreeSlug: createNameId(),
...(input.attachments.length > 0 ? { attachments: input.attachments } : {}),
...(hasFirstAgentContext
? {
firstAgentContext: {
...(trimmedPrompt ? { prompt: trimmedPrompt } : {}),
...(input.attachments.length > 0 ? { attachments: input.attachments } : {}),
},
}
: {}),
...checkoutRequest,
};
},
@@ -602,7 +616,7 @@ export function NewWorkspaceScreen({
);
const ensureWorkspace = useCallback(
async (input: { cwd: string; attachments: AgentAttachment[] }) => {
async (input: { cwd: string; prompt: string; attachments: AgentAttachment[] }) => {
if (createdWorkspace) {
return createdWorkspace;
}