diff --git a/src/main/agent-hooks/first-work-branch-rename.ts b/src/main/agent-hooks/first-work-branch-rename.ts index 59bd8f04403..e93bbb6be35 100644 --- a/src/main/agent-hooks/first-work-branch-rename.ts +++ b/src/main/agent-hooks/first-work-branch-rename.ts @@ -1,8 +1,8 @@ -// Why: when "Auto-Rename Branch From Work" is on, the first time an agent -// starts working in a freshly-created workspace we replace the auto-generated -// creature branch (e.g. `you/Nautilus`) with a short, work-derived name. This -// module owns the orchestration: gate on the signal, enforce the safety -// guardrails, summarize the prompt via the configured agent, and rename. +// Why: when first-message auto-name is on, the first time an agent starts +// working in a freshly-created workspace we replace the auto-generated creature +// branch (e.g. `you/Nautilus`) with a short, work-derived name. This module +// owns the orchestration: gate on the signal, enforce the safety guardrails, +// summarize the prompt via the configured agent, and rename. import type { GlobalSettings, Repo } from '../../shared/types' import { getRepoIdFromWorktreeId, splitWorktreeId } from '../../shared/worktree-id' import { parsePaneKey } from '../../shared/stable-pane-id' diff --git a/src/renderer/src/components/TaskPage.tsx b/src/renderer/src/components/TaskPage.tsx index de3e9a67cb5..c03a42da12b 100644 --- a/src/renderer/src/components/TaskPage.tsx +++ b/src/renderer/src/components/TaskPage.tsx @@ -130,6 +130,7 @@ import { JiraIcon } from '@/components/icons/JiraIcon' import { cn } from '@/lib/utils' import { getLinkedWorkItemSuggestedName, + getWorkspaceIntentName, getTaskPresetQuery, PER_REPO_FETCH_LIMIT, CROSS_REPO_DISPLAY_LIMIT @@ -330,6 +331,40 @@ const GITHUB_TASK_ROW_SURFACE_CLASS = '[background:color-mix(in_srgb,var(--muted)_50%,var(--background))]' const GITHUB_TASK_ROW_HOVER_SURFACE_CLASS = 'group-hover/github-task-row:[background:color-mix(in_srgb,var(--muted)_70%,var(--background))]' + +function getGitHubWorkItemWorkspaceSeed(item: GitHubWorkItem): string { + return ( + getWorkspaceIntentName({ workItem: item })?.seedName ?? getLinkedWorkItemSuggestedName(item) + ) +} + +function getGitLabWorkItemWorkspaceSeed(item: GitLabWorkItem): string { + return ( + getWorkspaceIntentName({ + workItem: { + type: item.type, + provider: 'gitlab', + number: item.number, + title: item.title + } + })?.seedName ?? getLinkedWorkItemSuggestedName(item) + ) +} + +function getJiraIssueWorkspaceSeed(issue: JiraIssue): string { + return ( + getWorkspaceIntentName({ + workItem: { + type: 'issue', + provider: 'jira', + number: 0, + title: `${issue.key} ${issue.title}`, + jiraIdentifier: issue.key + } + })?.seedName ?? getLinkedWorkItemSuggestedName(issue) + ) +} + // Why: the row's px-3 left padding leaves a 12px gap between the scroll-viewport // edge and the sticky ID column; without a covering ::before, scrolled cell text // bleeds through that strip. Same trick as the title column for its 8px gap. @@ -5134,7 +5169,7 @@ export default function TaskPage(): React.JSX.Element { } openModal('new-workspace-composer', { linkedWorkItem, - prefilledName: getLinkedWorkItemSuggestedName(item), + prefilledName: getGitHubWorkItemWorkspaceSeed(item), initialRepoId: item.repoId, telemetrySource: 'sidebar' }) @@ -5191,7 +5226,7 @@ export default function TaskPage(): React.JSX.Element { } openModal('new-workspace-composer', { linkedWorkItem, - prefilledName: getLinkedWorkItemSuggestedName(item), + prefilledName: getGitLabWorkItemWorkspaceSeed(item), initialRepoId: item.repoId, telemetrySource: 'sidebar' }) @@ -6183,7 +6218,7 @@ export default function TaskPage(): React.JSX.Element { } openModal('new-workspace-composer', { linkedWorkItem, - prefilledName: getLinkedWorkItemSuggestedName(issue), + prefilledName: getJiraIssueWorkspaceSeed(issue), telemetrySource: 'sidebar' }) }, diff --git a/src/renderer/src/components/WorktreeJumpPalette.tsx b/src/renderer/src/components/WorktreeJumpPalette.tsx index dac7e58f02a..00a5cdc108e 100644 --- a/src/renderer/src/components/WorktreeJumpPalette.tsx +++ b/src/renderer/src/components/WorktreeJumpPalette.tsx @@ -13,7 +13,7 @@ import { } from '@/components/ui/command' import { branchName } from '@/lib/git-utils' import { parseGitHubIssueOrPRNumber, parseGitHubIssueOrPRLink } from '@/lib/github-links' -import { getLinkedWorkItemSuggestedName } from '@/lib/new-workspace' +import { getLinkedWorkItemSuggestedName, getWorkspaceIntentName } from '@/lib/new-workspace' import type { LinkedWorkItemSummary } from '@/lib/new-workspace' import { sortWorktreesSmart } from '@/components/sidebar/smart-sort' import { isDefaultBranchWorkspace } from '@/components/sidebar/visible-worktrees' @@ -1034,7 +1034,9 @@ export default function WorktreeJumpPalette(): React.JSX.Element | null { url: item.url } data.linkedWorkItem = linkedWorkItem - data.prefilledName = getLinkedWorkItemSuggestedName({ title: item.title }) + data.prefilledName = + getWorkspaceIntentName({ sourceText: trimmed, workItem: linkedWorkItem })?.seedName ?? + getLinkedWorkItemSuggestedName({ title: item.title }) } else { // Fallback: we couldn't resolve the URL, just seed the name. data.prefilledName = `${slug.owner}-${slug.repo}-${number}` @@ -1097,7 +1099,9 @@ export default function WorktreeJumpPalette(): React.JSX.Element | null { url: item.url } data.linkedWorkItem = linkedWorkItem - data.prefilledName = getLinkedWorkItemSuggestedName({ title: item.title }) + data.prefilledName = + getWorkspaceIntentName({ sourceText: trimmed, workItem: linkedWorkItem })?.seedName ?? + getLinkedWorkItemSuggestedName({ title: item.title }) } else { data.prefilledName = trimmed } diff --git a/src/renderer/src/components/new-workspace/AutoRenameBranchHint.tsx b/src/renderer/src/components/new-workspace/AutoRenameBranchHint.tsx index e6ed9d7c905..c7127f83dc5 100644 --- a/src/renderer/src/components/new-workspace/AutoRenameBranchHint.tsx +++ b/src/renderer/src/components/new-workspace/AutoRenameBranchHint.tsx @@ -7,9 +7,9 @@ import { cn } from '@/lib/utils' /** * Gear affordance on the workspace Name label row. Its popover explains that a - * blank name lets Orca auto-rename the branch from the work, and lets the user - * flip the `autoRenameBranchFromWork` setting inline without leaving the - * composer. Only relevant for git repos, where a branch exists to rename. + * blank name lets Orca auto-name the workspace title and branch from the work, + * and lets the user flip the `autoRenameBranchFromWork` setting inline without + * leaving the composer. Only relevant for git repos, where a branch exists. */ export default function AutoRenameBranchHint(): React.JSX.Element { const autoRenameBranchFromWork = useAppStore((s) => s.settings?.autoRenameBranchFromWork ?? false) @@ -37,7 +37,7 @@ export default function AutoRenameBranchHint(): React.JSX.Element { // order like the adjacent agent-settings gear. tabIndex={-1} className="size-5 shrink-0 rounded-sm text-muted-foreground hover:text-foreground data-[state=open]:text-foreground" - aria-label="Auto-rename branch settings" + aria-label="Auto-name settings" > @@ -46,12 +46,12 @@ export default function AutoRenameBranchHint(): React.JSX.Element {
- Auto-rename branch + Auto-name from work

- When you leave the name blank, Orca renames the branch to match the work once an agent - starts. + When you leave the name blank, Orca uses the first task to rename the sidebar title + and unpublished generated branch.

diff --git a/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx b/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx index c856712394b..dd747ddbbdc 100644 --- a/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx +++ b/src/renderer/src/components/settings/AutoRenameBranchFromWorkSetting.tsx @@ -281,11 +281,14 @@ export function AutoRenameBranchFromWorkSetting({ return (
- +

- When an agent starts working in a new workspace, Orca renames its auto-generated branch - (e.g. Nautilus) to a short name summarizing the task. Only branches Orca - named itself are renamed, and never after they have been pushed. + When a blank new workspace starts work, Orca uses the first task to rename the sidebar + title and unpublished generated branch (e.g. Nautilus). Workspaces created + from linked issues or pull requests are named up front from the same short identity.