From 8a938cdd8994822e1421055e12e0f376b4d3a314 Mon Sep 17 00:00:00 2001 From: brennanb2025 Date: Thu, 11 Jun 2026 17:43:13 -0700 Subject: [PATCH] Enable first-input rename for folder workspaces Co-authored-by: Orca --- .../AutoRenameBranchFromWorkSetting.tsx | 4 +- .../settings/auto-rename-branch-search.ts | 2 +- .../folder-workspace-composer-submit.test.ts | 114 ++++++++++++++++++ .../folder-workspace-composer-submit.ts | 33 ++--- src/renderer/src/i18n/locales/en.json | 4 +- 5 files changed, 138 insertions(+), 19 deletions(-) diff --git a/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx b/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx index 04e7a0b94b8..b8540cdefa9 100644 --- a/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx +++ b/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx @@ -126,7 +126,7 @@ export function AutoRenameBranchFromWorkSetting({ {translate( 'auto.components.settings.AutoRenameBranchFromWorkSetting.ef787db0e3', - 'Auto-Rename Branch' + 'Auto-rename branch & worktree' )}

diff --git a/src/renderer/src/components/settings/auto-rename-branch-search.ts b/src/renderer/src/components/settings/auto-rename-branch-search.ts index 74fb9331773..0fd2d1938bc 100644 --- a/src/renderer/src/components/settings/auto-rename-branch-search.ts +++ b/src/renderer/src/components/settings/auto-rename-branch-search.ts @@ -7,7 +7,7 @@ export const getAutoRenameBranchParentSearchEntry = createLocalizedCatalog( (): SettingsSearchEntry => ({ title: translate( 'auto.components.settings.auto.rename.branch.search.427f2cd1eb', - 'Auto-Rename Branch' + 'Auto-rename branch & worktree' ), description: translate( 'auto.components.settings.auto.rename.branch.search.ea94b9da8a', diff --git a/src/renderer/src/components/sidebar/folder-workspace-composer-submit.test.ts b/src/renderer/src/components/sidebar/folder-workspace-composer-submit.test.ts index 3c2b4690c3c..d881afaa0fd 100644 --- a/src/renderer/src/components/sidebar/folder-workspace-composer-submit.test.ts +++ b/src/renderer/src/components/sidebar/folder-workspace-composer-submit.test.ts @@ -88,4 +88,118 @@ describe('submitFolderWorkspaceCreate', () => { expect.any(Error) ) }) + + it('marks a blank folder workspace for first-input rename when launching an agent with a note', async () => { + const createFolderWorkspace = vi.fn(async () => makeFolderWorkspace()) + const onOpenChange = vi.fn() + + await submitFolderWorkspaceCreate({ + projectGroup: makeProjectGroup(), + name: '', + lastAutoName: '', + linkedWorkItem: null, + note: 'Fix the flaky checkout flow', + quickAgent: 'codex', + autoRenameBranchFromWork: true, + agentCmdOverrides: {}, + createFolderWorkspace, + onOpenChange + }) + + expect(createFolderWorkspace).toHaveBeenCalledWith({ + projectGroupId: 'group-1', + name: 'Platform workspace', + linkedTask: null, + createdWithAgent: 'codex', + pendingFirstAgentMessageRename: true + }) + expect(mocks.activateAndRevealFolderWorkspace).toHaveBeenCalledWith( + 'folder-workspace-1', + expect.objectContaining({ + startup: expect.objectContaining({ + command: expect.stringContaining('codex') + }) + }) + ) + }) + + it('does not mark first-input rename when the folder workspace has an explicit name', async () => { + const createFolderWorkspace = vi.fn(async () => makeFolderWorkspace()) + + await submitFolderWorkspaceCreate({ + projectGroup: makeProjectGroup(), + name: 'Checkout polish', + lastAutoName: '', + linkedWorkItem: null, + note: 'Fix the flaky checkout flow', + quickAgent: 'codex', + autoRenameBranchFromWork: true, + agentCmdOverrides: {}, + createFolderWorkspace, + onOpenChange: vi.fn() + }) + + expect(createFolderWorkspace).toHaveBeenCalledWith({ + projectGroupId: 'group-1', + name: 'Checkout polish', + linkedTask: null, + createdWithAgent: 'codex' + }) + }) + + it('does not mark first-input rename when a linked work item owns the folder workspace name', async () => { + const createFolderWorkspace = vi.fn(async () => makeFolderWorkspace()) + const linkedWorkItem = { + provider: 'github' as const, + type: 'issue' as const, + number: 42, + title: 'Restore checkout polish', + url: 'https://github.com/stablyai/orca/issues/42', + repoId: 'repo-1' + } + + await submitFolderWorkspaceCreate({ + projectGroup: makeProjectGroup(), + name: '', + lastAutoName: '', + linkedWorkItem, + note: 'Use the issue context', + quickAgent: 'codex', + autoRenameBranchFromWork: true, + agentCmdOverrides: {}, + createFolderWorkspace, + onOpenChange: vi.fn() + }) + + expect(createFolderWorkspace).toHaveBeenCalledWith({ + projectGroupId: 'group-1', + name: 'Restore checkout polish', + linkedTask: linkedWorkItem, + createdWithAgent: 'codex' + }) + }) + + it('does not mark first-input rename without submitted first input', async () => { + const createFolderWorkspace = vi.fn(async () => makeFolderWorkspace()) + + await submitFolderWorkspaceCreate({ + projectGroup: makeProjectGroup(), + name: '', + lastAutoName: '', + linkedWorkItem: null, + note: ' ', + quickAgent: 'codex', + autoRenameBranchFromWork: true, + agentCmdOverrides: {}, + createFolderWorkspace, + onOpenChange: vi.fn() + }) + + expect(createFolderWorkspace).toHaveBeenCalledWith({ + projectGroupId: 'group-1', + name: 'Platform workspace', + linkedTask: null, + createdWithAgent: 'codex' + }) + }) }) diff --git a/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts b/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts index b4f1913e7b4..71c4a6d2ccd 100644 --- a/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts +++ b/src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts @@ -54,20 +54,6 @@ export async function submitFolderWorkspaceCreate({ nameIsAutoManaged && linkedName ? linkedName : name.trim() || linkedName || `${projectGroup.name} workspace` - const pendingFirstAgentMessageRename = - autoRenameBranchFromWork === true && !name.trim() && !linkedWorkItem && Boolean(quickAgent) - - const workspace = await createFolderWorkspace({ - projectGroupId: projectGroup.id, - name: workspaceName, - linkedTask: toFolderWorkspaceLinkedTask(linkedWorkItem), - ...(quickAgent ? { createdWithAgent: quickAgent } : {}), - ...(pendingFirstAgentMessageRename ? { pendingFirstAgentMessageRename: true } : {}) - }) - if (!workspace) { - return - } - const linearCliAvailable = linkedWorkItem?.linearIdentifier ? await isOrcaCliAvailableForLaunch({ remote: projectGroup.connectionId != null }) : false @@ -80,6 +66,25 @@ export async function submitFolderWorkspaceCreate({ linkedPromptContext.linkedUrls, linkedPromptContext.linkedContextBlocks ) + // Why: the pending badge should only appear when the submitted prompt can + // actually produce the first agent message that names the workspace. + const pendingFirstAgentMessageRename = + autoRenameBranchFromWork === true && + !name.trim() && + !linkedWorkItem && + Boolean(quickAgent) && + startupPrompt.trim().length > 0 + + const workspace = await createFolderWorkspace({ + projectGroupId: projectGroup.id, + name: workspaceName, + linkedTask: toFolderWorkspaceLinkedTask(linkedWorkItem), + ...(quickAgent ? { createdWithAgent: quickAgent } : {}), + ...(pendingFirstAgentMessageRename ? { pendingFirstAgentMessageRename: true } : {}) + }) + if (!workspace) { + return + } const startupPlan = quickAgent ? buildAgentStartupPlan({ agent: quickAgent, diff --git a/src/renderer/src/i18n/locales/en.json b/src/renderer/src/i18n/locales/en.json index a28c9ac11d1..e8ea6a15a07 100644 --- a/src/renderer/src/i18n/locales/en.json +++ b/src/renderer/src/i18n/locales/en.json @@ -4064,7 +4064,7 @@ "e784ea62dc": "Advanced", "d9b65054ef": ") to a short name summarizing the task. Only branches Orca named itself are renamed, and never after they have been pushed.", "12ea4a408d": "When an agent starts working in a new workspace, Orca renames its auto-generated branch (e.g.", - "ef787db0e3": "Auto-Rename Branch", + "ef787db0e3": "Auto-rename branch & worktree", "6a051586d2": "Rename the auto-generated branch based on the work once an agent starts.", "ec3e0c388e": "Save", "cfd82406dd": "Saving...", @@ -6108,7 +6108,7 @@ "55a1860e47": "rename", "9319bd9827": "branch", "ea94b9da8a": "Rename the auto-generated branch based on the work once an agent starts.", - "427f2cd1eb": "Auto-Rename Branch" + "427f2cd1eb": "Auto-rename branch & worktree" } } }