Move auto-name branch settings into the Git AI Author pane (#4725)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Brennan Benson
2026-06-07 15:30:54 -07:00
committed by GitHub
co-authored by Orca
parent f75dfc1e14
commit ee43304b0a
11 changed files with 269 additions and 555 deletions
@@ -19,8 +19,8 @@ export default function AutoRenameBranchHint(): React.JSX.Element {
const closeModal = useAppStore((s) => s.closeModal)
const handleOpenSettings = React.useCallback((): void => {
// Why: the setting lives in the Git pane; closing the composer first keeps
// the settings page from rendering behind the modal.
// Why: the toggle lives in the Git settings page (Git AI Author pane);
// closing the composer first keeps it from rendering behind the modal.
closeModal()
openSettingsTarget({ pane: 'git', repoId: null })
openSettingsPage()
@@ -1,419 +0,0 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { ChevronDown } from 'lucide-react'
import type { GlobalSettings } from '../../../../shared/types'
import type {
SourceControlAiModelChoice,
SourceControlAiSettingsPatch,
SourceControlAiSettings
} from '../../../../shared/source-control-ai-types'
import {
clearSourceControlAiModelChoiceForHost,
normalizeSourceControlAiSettings,
readSourceControlAiModelChoiceForHost,
selectSourceControlAiModelChoiceForHost
} from '../../../../shared/source-control-ai'
import {
getCommitMessageAgentCapability,
isCustomAgentId,
resolveCommitMessageAgentChoice,
type CommitMessageAgentCapability,
type CommitMessageModelCapability
} from '../../../../shared/commit-message-agent-spec'
import {
getCommitMessageModelDiscoveryHostKeyForScope,
LOCAL_COMMIT_MESSAGE_HOST_KEY
} from '../../../../shared/commit-message-host-key'
import { getConnectionId } from '@/lib/connection-context'
import { cn } from '@/lib/utils'
import { getRuntimeGitScope } from '../../runtime/runtime-git-client'
import { useAppStore } from '../../store'
import { useActiveWorktree } from '../../store/selectors'
import { Button } from '../ui/button'
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '../ui/collapsible'
import { Label } from '../ui/label'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'
import { AUTO_RENAME_BRANCH_ADVANCED_SEARCH_ENTRIES } from './auto-rename-branch-search'
import { AutoRenameBranchPromptEditor } from './AutoRenameBranchPromptEditor'
import { SearchableSetting } from './SearchableSetting'
import { matchesSettingsSearch, normalizeSettingsSearchQuery } from './settings-search'
type AutoRenameBranchFromWorkSettingProps = {
settings: GlobalSettings
updateSettings: (updates: Partial<GlobalSettings>) => void | Promise<void>
writeSourceControlAiSettings: (patch: SourceControlAiSettingsPatch) => Promise<void>
forceVisible?: boolean
onBranchPromptDirtyChange?: (dirty: boolean) => void
branchPromptDiscardSignal?: number
settingsSearchQuery?: string
}
const INHERIT_BRANCH_MODEL_VALUE = '__inherit_branch_model__'
export function shouldOpenAutoRenameBranchAdvanced(searchQuery: string): boolean {
return (
normalizeSettingsSearchQuery(searchQuery) !== '' &&
matchesSettingsSearch(searchQuery, AUTO_RENAME_BRANCH_ADVANCED_SEARCH_ENTRIES)
)
}
function readSourceControlSettings(settings: GlobalSettings): SourceControlAiSettings {
return normalizeSourceControlAiSettings(settings.sourceControlAi, settings.commitMessageAi)
}
function mergeModelCapabilities(
fallbackModels: CommitMessageModelCapability[],
discoveredModels: CommitMessageModelCapability[] | undefined
): CommitMessageModelCapability[] {
const models: CommitMessageModelCapability[] = []
const seen = new Set<string>()
for (const model of [...(discoveredModels ?? []), ...fallbackModels]) {
if (!model.id || seen.has(model.id)) {
continue
}
seen.add(model.id)
models.push(model)
}
return models
}
function getCapabilityWithDiscoveredModels(
config: SourceControlAiSettings,
capability: CommitMessageAgentCapability,
hostKey: string
): CommitMessageAgentCapability {
const discoveredModels =
config.discoveredModelsByAgentByHost?.[hostKey]?.[capability.id] ??
(hostKey === LOCAL_COMMIT_MESSAGE_HOST_KEY
? config.discoveredModelsByAgent?.[capability.id]
: undefined)
const models = mergeModelCapabilities(capability.models, discoveredModels)
const defaultModelId = models.some((model) => model.id === capability.defaultModelId)
? capability.defaultModelId
: (models[0]?.id ?? capability.defaultModelId)
return { ...capability, models, defaultModelId }
}
function resolveSelectedThinking(
config: SourceControlAiSettings,
model: CommitMessageModelCapability,
operationChoice: SourceControlAiModelChoice | undefined
): string | undefined {
if (!model.thinkingLevels) {
return undefined
}
const persisted =
operationChoice?.selectedThinkingByModel?.[model.id] ?? config.selectedThinkingByModel[model.id]
return model.thinkingLevels.some((level) => level.id === persisted)
? persisted
: model.defaultThinkingLevel
}
export function AutoRenameBranchFromWorkSetting({
settings,
updateSettings,
writeSourceControlAiSettings,
forceVisible = false,
onBranchPromptDirtyChange,
branchPromptDiscardSignal,
settingsSearchQuery
}: AutoRenameBranchFromWorkSettingProps): React.JSX.Element {
const storeSearchQuery = useAppStore((state) => state.settingsSearchQuery)
const searchQuery = settingsSearchQuery ?? storeSearchQuery
const activeWorktree = useActiveWorktree()
const activeConnectionId = getConnectionId(activeWorktree?.id ?? null)
const discoveryHostKey = getCommitMessageModelDiscoveryHostKeyForScope(
activeWorktree?.id ? getRuntimeGitScope(settings, activeConnectionId) : activeConnectionId
)
const config = readSourceControlSettings(settings)
const [optionsOpen, setOptionsOpen] = useState(false)
const advancedSearchOpen = shouldOpenAutoRenameBranchAdvanced(searchQuery)
const advancedOpen = optionsOpen || advancedSearchOpen
const persistedBranchNamePrompt = config.instructionsByOperation.branchName ?? ''
const persistedBranchNamePromptRef = useRef(persistedBranchNamePrompt)
persistedBranchNamePromptRef.current = persistedBranchNamePrompt
const [branchNamePromptDraft, setBranchNamePromptDraft] = useState(persistedBranchNamePrompt)
const [isSavingPrompt, setIsSavingPrompt] = useState(false)
const branchNamePromptDirty = branchNamePromptDraft !== persistedBranchNamePrompt
useEffect(() => {
if (!branchNamePromptDirty) {
setBranchNamePromptDraft(persistedBranchNamePrompt)
}
}, [branchNamePromptDirty, persistedBranchNamePrompt])
useEffect(() => {
setBranchNamePromptDraft(persistedBranchNamePromptRef.current)
// Why: Settings owns the discard confirmation, but the draft lives here so
// the row can keep its prompt-specific save/discard affordances.
}, [branchPromptDiscardSignal])
useEffect(() => {
onBranchPromptDirtyChange?.(branchNamePromptDirty)
}, [branchNamePromptDirty, onBranchPromptDirtyChange])
const onBranchPromptDirtyChangeRef = useRef(onBranchPromptDirtyChange)
onBranchPromptDirtyChangeRef.current = onBranchPromptDirtyChange
const setSettingRootRef = useCallback((node: HTMLDivElement | null): void => {
if (node !== null) {
return
}
// Why: Settings owns the global unsaved-branch-prompt guard; reset it
// when this setting detaches without a passive cleanup-only Effect.
onBranchPromptDirtyChangeRef.current?.(false)
}, [])
const resolvedAgentId = resolveCommitMessageAgentChoice(
config.agentId,
settings.defaultTuiAgent,
settings.disabledTuiAgents
)
const activeAgentId =
resolvedAgentId && !isCustomAgentId(resolvedAgentId) ? resolvedAgentId : null
const activeCapability = useMemo(() => {
if (!activeAgentId) {
return undefined
}
const capability = getCommitMessageAgentCapability(activeAgentId)
return capability
? getCapabilityWithDiscoveredModels(config, capability, discoveryHostKey)
: undefined
}, [activeAgentId, config, discoveryHostKey])
const branchModelChoice = config.modelOverridesByOperation?.branchName
const branchModelOverrideId = activeCapability
? readSourceControlAiModelChoiceForHost(
branchModelChoice,
discoveryHostKey,
activeCapability.id
)
: undefined
const selectedBranchModel = branchModelOverrideId
? activeCapability?.models.find((model) => model.id === branchModelOverrideId)
: undefined
const selectedBranchThinking = selectedBranchModel
? resolveSelectedThinking(config, selectedBranchModel, branchModelChoice)
: undefined
const onBranchModelChange = (modelId: string): void => {
if (!activeCapability) {
return
}
if (modelId === INHERIT_BRANCH_MODEL_VALUE) {
void writeSourceControlAiSettings((current) => {
const nextOverrides = { ...current.modelOverridesByOperation }
const nextChoice = clearSourceControlAiModelChoiceForHost(
nextOverrides.branchName,
discoveryHostKey,
activeCapability.id
)
if (nextChoice) {
nextOverrides.branchName = nextChoice
} else {
delete nextOverrides.branchName
}
return { modelOverridesByOperation: nextOverrides }
})
return
}
const model = activeCapability.models.find((candidate) => candidate.id === modelId)
if (!model) {
return
}
void writeSourceControlAiSettings((current) => {
const nextChoice = selectSourceControlAiModelChoiceForHost(
current.modelOverridesByOperation?.branchName,
discoveryHostKey,
activeCapability.id,
model.id
)
if (
model.thinkingLevels &&
model.defaultThinkingLevel &&
!nextChoice.selectedThinkingByModel?.[model.id]
) {
nextChoice.selectedThinkingByModel = {
...nextChoice.selectedThinkingByModel,
[model.id]: model.defaultThinkingLevel
}
}
return {
modelOverridesByOperation: {
...current.modelOverridesByOperation,
branchName: nextChoice
}
}
})
}
const onBranchThinkingChange = (modelId: string, thinkingId: string): void => {
void writeSourceControlAiSettings((current) => ({
modelOverridesByOperation: {
...current.modelOverridesByOperation,
branchName: {
...current.modelOverridesByOperation?.branchName,
selectedThinkingByModel: {
...current.modelOverridesByOperation?.branchName?.selectedThinkingByModel,
[modelId]: thinkingId
}
}
}
}))
}
const onSavePrompt = async (): Promise<void> => {
if (!branchNamePromptDirty || isSavingPrompt) {
return
}
setIsSavingPrompt(true)
try {
await writeSourceControlAiSettings((current) => ({
instructionsByOperation: {
...current.instructionsByOperation,
branchName: branchNamePromptDraft
}
}))
} finally {
setIsSavingPrompt(false)
}
}
const onDiscardPrompt = (): void => {
setBranchNamePromptDraft(persistedBranchNamePrompt)
}
return (
<SearchableSetting
title="Auto-Name From First Message"
description="Use the first task to name blank new workspaces and their unpublished branches."
keywords={[
'workspace',
'title',
'branch',
'rename',
'name',
'auto',
'creature name',
'agent',
'prompt',
'worktree',
'model',
'prompt',
'slug'
]}
forceVisible={forceVisible || branchNamePromptDirty || advancedSearchOpen}
className="space-y-3 py-2"
>
<div ref={setSettingRootRef} className="flex items-center justify-between gap-4">
<div className="space-y-0.5">
<Label>Auto-name from first message</Label>
<p className="text-xs text-muted-foreground">
When a blank new workspace starts work, Orca uses the first task to rename the sidebar
title and unpublished generated branch (e.g. <code>Nautilus</code>). Workspaces created
from linked issues or pull requests are named up front from the same short identity.
</p>
</div>
<button
role="switch"
aria-checked={settings.autoRenameBranchFromWork}
onClick={() =>
updateSettings({
autoRenameBranchFromWork: !settings.autoRenameBranchFromWork
})
}
className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors ${
settings.autoRenameBranchFromWork ? 'bg-foreground' : 'bg-muted-foreground/30'
}`}
>
<span
className={`pointer-events-none block size-3.5 rounded-full bg-background shadow-sm transition-transform ${
settings.autoRenameBranchFromWork ? 'translate-x-4' : 'translate-x-0.5'
}`}
/>
</button>
</div>
<Collapsible open={advancedOpen} onOpenChange={setOptionsOpen}>
<CollapsibleTrigger asChild>
<Button
type="button"
variant="ghost"
size="sm"
className="-ml-2 h-7 px-2 text-xs text-muted-foreground hover:text-foreground"
>
Advanced
<ChevronDown
className={cn('size-3.5 transition-transform', advancedOpen && 'rotate-180')}
/>
</Button>
</CollapsibleTrigger>
<CollapsibleContent>
<div className="mt-2 space-y-3 rounded-md border border-border/60 bg-muted/20 px-3 py-3">
<AutoRenameBranchPromptEditor
draft={branchNamePromptDraft}
dirty={branchNamePromptDirty}
saving={isSavingPrompt}
onDraftChange={setBranchNamePromptDraft}
onDiscard={onDiscardPrompt}
onSave={onSavePrompt}
/>
<div className="flex flex-col gap-3 border-t border-border/50 pt-3 sm:flex-row sm:items-start sm:justify-between">
<div className="space-y-0.5">
<Label>Branch name model</Label>
<p className="text-xs text-muted-foreground">
Use a different model for branch name generation.
</p>
</div>
{activeCapability ? (
<div className="flex w-full flex-col items-end gap-2 sm:w-auto">
<Select
value={branchModelOverrideId ?? INHERIT_BRANCH_MODEL_VALUE}
onValueChange={onBranchModelChange}
>
<SelectTrigger size="sm" className="h-8 w-full shrink-0 text-xs sm:w-[220px]">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value={INHERIT_BRANCH_MODEL_VALUE} className="cursor-pointer">
Use default model
</SelectItem>
{activeCapability.models.map((model) => (
<SelectItem key={model.id} value={model.id} className="cursor-pointer">
{model.label}
</SelectItem>
))}
</SelectContent>
</Select>
{selectedBranchModel?.thinkingLevels && selectedBranchThinking ? (
<div className="flex w-full items-center justify-end gap-2 sm:w-auto">
<span className="text-[11px] text-muted-foreground">Thinking</span>
<Select
value={selectedBranchThinking}
onValueChange={(value) =>
onBranchThinkingChange(selectedBranchModel.id, value)
}
>
<SelectTrigger size="sm" className="h-7 w-[150px] text-xs">
<SelectValue />
</SelectTrigger>
<SelectContent>
{selectedBranchModel.thinkingLevels.map((level) => (
<SelectItem key={level.id} value={level.id} className="cursor-pointer">
{level.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
) : null}
</div>
) : (
<p className="max-w-[260px] text-right text-xs text-muted-foreground">
Choose a Git AI Author agent that supports model selection.
</p>
)}
</div>
</div>
</CollapsibleContent>
</Collapsible>
</SearchableSetting>
)
}
@@ -26,9 +26,11 @@ export function AutoRenameBranchPromptEditor({
onSave
}: AutoRenameBranchPromptEditorProps): React.JSX.Element {
return (
<div className="space-y-2">
// Why: py-2 matches the sibling rows so the editor doesn't hug the group's
// divide-y divider the way the model/prompt rows are spaced.
<div className="space-y-2 py-2">
<div className="space-y-0.5">
<Label htmlFor="git-auto-rename-branch-name-prompt">Branch name prompt</Label>
<Label htmlFor="git-auto-rename-branch-name-prompt">Prompt</Label>
<p className="text-xs text-muted-foreground">
Appended to Orca&apos;s{' '}
<Popover>
@@ -50,7 +50,8 @@ describe('CommitMessageAiPane', () => {
const state = createCommitMessageInstructionDraftState(
{
commitMessage: 'commit-a',
pullRequest: 'pr-a'
pullRequest: 'pr-a',
branchName: 'branch-a'
},
1
)
@@ -59,14 +60,16 @@ describe('CommitMessageAiPane', () => {
state,
{
commitMessage: 'commit-b',
pullRequest: 'pr-a'
pullRequest: 'pr-a',
branchName: 'branch-b'
},
1
)
expect(resolved.draft).toEqual({
commitMessage: 'commit-b',
pullRequest: 'pr-a'
pullRequest: 'pr-a',
branchName: 'branch-b'
})
})
@@ -74,7 +77,8 @@ describe('CommitMessageAiPane', () => {
const state = createCommitMessageInstructionDraftState(
{
commitMessage: 'commit-a',
pullRequest: 'pr-a'
pullRequest: 'pr-a',
branchName: 'branch-a'
},
1
)
@@ -84,26 +88,30 @@ describe('CommitMessageAiPane', () => {
state,
{
commitMessage: 'commit-b',
pullRequest: 'pr-b'
pullRequest: 'pr-b',
branchName: 'branch-b'
},
1
)
expect(withExternalChange.draft).toEqual({
commitMessage: 'local edit',
pullRequest: 'pr-b'
pullRequest: 'pr-b',
branchName: 'branch-b'
})
const afterDiscard = resolveCommitMessageInstructionDraftState(
withExternalChange,
{
commitMessage: 'commit-b',
pullRequest: 'pr-b'
pullRequest: 'pr-b',
branchName: 'branch-b'
},
2
)
expect(afterDiscard.draft).toEqual({
commitMessage: 'commit-b',
pullRequest: 'pr-b'
pullRequest: 'pr-b',
branchName: 'branch-b'
})
})
@@ -115,9 +123,40 @@ describe('CommitMessageAiPane', () => {
expect(markup).toContain('aria-checked="false"')
expect(markup).not.toContain('Orca invokes this CLI')
expect(markup).not.toContain('Thinking Effort')
// The auto-name toggle depends on Git AI Author, so it is hidden while off.
expect(markup).not.toContain('Auto-name new workspaces from first message')
})
it('renders model, thinking, and collapsed commit and PR customization for enabled preset agents', () => {
it('renders the auto-name toggle once Git AI Author is enabled', () => {
const markup = renderPane(
buildSettings({
autoRenameBranchFromWork: true,
commitMessageAi: {
enabled: true,
agentId: 'codex',
selectedModelByAgent: { codex: 'gpt-5.5' },
selectedThinkingByModel: { 'gpt-5.5': 'medium' },
customPrompt: '',
customAgentCommand: ''
}
})
)
expect(markup).toContain('Auto-name new workspaces from first message')
// Tuning lives in the Advanced -> Branch Names group, not on the toggle row.
expect(markup).toContain('Tune the model and prompt under Advanced')
})
it('surfaces the enable row when searching for auto-name while the feature is off', () => {
const markup = renderPane(buildSettings(), 'auto-name')
// Why: the toggle can't render while disabled, so an auto-name search should
// still guide the user to the Enable Git AI Author row.
expect(markup).toContain('Enable Git AI Author')
expect(markup).not.toContain('Auto-name new workspaces from first message')
})
it('renders model, thinking, and collapsed advanced customization for enabled preset agents', () => {
const markup = renderPane(
buildSettings({
commitMessageAi: {
@@ -135,13 +174,16 @@ describe('CommitMessageAiPane', () => {
expect(markup).toContain('Orca invokes this CLI')
expect(markup).toContain('Model')
expect(markup).toContain('Thinking Effort')
expect(markup).toContain('Commit and PR customization')
expect(markup).toContain('Advanced')
expect(markup).toContain('aria-expanded="false"')
expect(markup).not.toContain('Commit Messages')
expect(markup).not.toContain('Pull Requests')
// Match the group headings specifically: the auto-name toggle copy mentions
// "Branch Names", but the collapsed group heading must not be rendered.
expect(markup).not.toContain('>Commit Messages</h4>')
expect(markup).not.toContain('>Pull Requests</h4>')
expect(markup).not.toContain('>Branch Names</h4>')
expect(markup).not.toContain('Use a different model for commit message generation.')
expect(markup).not.toContain('Creation defaults')
expect(markup).not.toContain('Branch name model')
expect(markup).not.toContain('Use a different model for branch name generation.')
expect(markup).not.toContain('Higher effort produces more careful messages')
expect(markup).not.toContain('Use Conventional Commits.')
expect(markup).not.toContain('Saved')
@@ -153,10 +195,11 @@ describe('CommitMessageAiPane', () => {
expect(markup).toContain('Git AI Author')
expect(markup).toContain('Enable Git AI Author')
expect(markup).toContain('aria-checked="false"')
expect(markup).not.toContain('Commit and PR customization')
expect(markup).not.toContain('aria-expanded="false"')
expect(markup).not.toContain('Branch Names')
})
it('opens commit and PR customization for matching settings search terms', () => {
it('opens advanced customization for matching settings search terms', () => {
const markup = renderPane(
buildSettings({
commitMessageAi: {
@@ -174,9 +217,30 @@ describe('CommitMessageAiPane', () => {
expect(markup).toContain('aria-expanded="true"')
expect(markup).toContain('Commit Messages')
expect(markup).toContain('Pull Requests')
expect(markup).toContain('Branch Names')
expect(markup).toContain('Creation defaults')
})
it('shows the nested branch name model control for branch name model search', () => {
const markup = renderPane(
buildSettings({
commitMessageAi: {
enabled: true,
agentId: 'codex',
selectedModelByAgent: { codex: 'gpt-5.5' },
selectedThinkingByModel: { 'gpt-5.5': 'medium' },
customPrompt: '',
customAgentCommand: ''
}
}),
'branch name model'
)
expect(markup).toContain('aria-expanded="true"')
expect(markup).toContain('Branch Names')
expect(markup).toContain('Use a different model for branch name generation.')
})
it('shows the nested commit model control for commit message model search', () => {
const markup = renderPane(
buildSettings({
@@ -43,6 +43,8 @@ import {
} from '../../runtime/runtime-git-client'
import { useAppStore } from '../../store'
import { useActiveWorktree } from '../../store/selectors'
import { AutoRenameBranchPromptEditor } from './AutoRenameBranchPromptEditor'
import { AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY } from './auto-rename-branch-search'
import { SearchableSetting } from './SearchableSetting'
import { COMMIT_MESSAGE_AI_PANE_SEARCH_ENTRIES } from './commit-message-ai-search'
import { matchesSettingsSearch } from './settings-search'
@@ -66,7 +68,7 @@ type ModelDiscoveryState = {
type CommitMessageInstructionOperation = Extract<
SourceControlAiOperation,
'commitMessage' | 'pullRequest'
'commitMessage' | 'pullRequest' | 'branchName'
>
type CommitMessageInstructionDraftValues = Record<CommitMessageInstructionOperation, string>
@@ -79,7 +81,8 @@ type CommitMessageInstructionDraftState = {
const COMMIT_MESSAGE_INSTRUCTION_OPERATIONS: readonly CommitMessageInstructionOperation[] = [
'commitMessage',
'pullRequest'
'pullRequest',
'branchName'
]
function cloneInstructionDraftValues(
@@ -87,7 +90,8 @@ function cloneInstructionDraftValues(
): CommitMessageInstructionDraftValues {
return {
commitMessage: values.commitMessage,
pullRequest: values.pullRequest
pullRequest: values.pullRequest,
branchName: values.branchName
}
}
@@ -301,9 +305,11 @@ export function CommitMessageAiPane({
const [outputOverridesOpen, setOutputOverridesOpen] = useState(false)
const persistedCommitInstructions = config.instructionsByOperation.commitMessage ?? ''
const persistedPullRequestInstructions = config.instructionsByOperation.pullRequest ?? ''
const persistedBranchNameInstructions = config.instructionsByOperation.branchName ?? ''
const persistedInstructionDraftValues: CommitMessageInstructionDraftValues = {
commitMessage: persistedCommitInstructions,
pullRequest: persistedPullRequestInstructions
pullRequest: persistedPullRequestInstructions,
branchName: persistedBranchNameInstructions
}
const [instructionDraftState, setInstructionDraftState] = useState(() =>
createCommitMessageInstructionDraftState(
@@ -324,6 +330,7 @@ export function CommitMessageAiPane({
}
const commitInstructionsDraft = resolvedInstructionDraftState.draft.commitMessage
const pullRequestInstructionsDraft = resolvedInstructionDraftState.draft.pullRequest
const branchNameInstructionsDraft = resolvedInstructionDraftState.draft.branchName
const updateInstructionDraft = (
operation: CommitMessageInstructionOperation,
value: string
@@ -346,11 +353,16 @@ export function CommitMessageAiPane({
const isCommitInstructionsDirty = commitInstructionsDraft !== persistedCommitInstructions
const isPullRequestInstructionsDirty =
pullRequestInstructionsDraft !== persistedPullRequestInstructions
const isCustomPromptDirty = isCommitInstructionsDirty || isPullRequestInstructionsDirty
const isBranchNameInstructionsDirty =
branchNameInstructionsDraft !== persistedBranchNameInstructions
const isCustomPromptDirty =
isCommitInstructionsDirty || isPullRequestInstructionsDirty || isBranchNameInstructionsDirty
const commitPromptDraft = commitInstructionsDraft
const pullRequestPromptDraft = pullRequestInstructionsDraft
const branchNamePromptDraft = branchNameInstructionsDraft
const isCommitPromptDirty = isCommitInstructionsDirty
const isPullRequestPromptDirty = isPullRequestInstructionsDirty
const isBranchNamePromptDirty = isBranchNameInstructionsDirty
const isSavingPrompt = isSavingInstructions
useEffect(() => {
@@ -788,9 +800,12 @@ export function CommitMessageAiPane({
const onSavePrompt = async (operation: CommitMessageInstructionOperation): Promise<void> => {
const draft = resolvedInstructionDraftState.draft[operation]
const dirty =
operation === 'commitMessage' ? isCommitInstructionsDirty : isPullRequestInstructionsDirty
if (!dirty || isSavingInstructions) {
const dirtyByOperation: Record<CommitMessageInstructionOperation, boolean> = {
commitMessage: isCommitInstructionsDirty,
pullRequest: isPullRequestInstructionsDirty,
branchName: isBranchNameInstructionsDirty
}
if (!dirtyByOperation[operation] || isSavingInstructions) {
return
}
setIsSavingInstructions(true)
@@ -1182,15 +1197,68 @@ export function CommitMessageAiPane({
)
}
// Why: auto-name fires automatically and runs through the same agent as the
// other operations, so it can't work unless Git AI Author is on — keep its
// toggle here (gated on config.enabled) rather than orphaned in Git settings.
if (
config.enabled &&
matchesSettingsSearch(searchQuery, AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY)
) {
sections.push(
<SearchableSetting
key="auto-rename-branch-from-work"
{...AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY}
className="flex items-center justify-between gap-4 py-2"
>
<div className="space-y-0.5">
<Label>Auto-name new workspaces from first message</Label>
<p className="text-xs text-muted-foreground">
When a blank new workspace starts work, Orca uses the first task to rename the sidebar
title and unpublished generated branch (e.g. <code>Nautilus</code>). Workspaces created
from linked issues or pull requests are named up front from the same short identity.
Tune the model and prompt under Advanced → Branch Names below.
</p>
</div>
<button
role="switch"
aria-checked={settings.autoRenameBranchFromWork}
onClick={() =>
updateSettings({ autoRenameBranchFromWork: !settings.autoRenameBranchFromWork })
}
className={`relative inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border border-transparent transition-colors ${
settings.autoRenameBranchFromWork ? 'bg-foreground' : 'bg-muted-foreground/30'
}`}
>
<span
className={`pointer-events-none block size-3.5 rounded-full bg-background shadow-sm transition-transform ${
settings.autoRenameBranchFromWork ? 'translate-x-4' : 'translate-x-0.5'
}`}
/>
</button>
</SearchableSetting>
)
}
const commitMessagesGroupEntry = {
title: 'Commit Messages',
description: 'Commit message generation settings.',
keywords: ['commit', 'message', 'model', 'prompt', 'conventional commits']
}
const commitAndPrCustomizationEntry = {
title: 'Commit and PR customization',
description: 'Configure behavior for commit message generation and PR creation.',
keywords: ['customization', 'advanced', 'commit', 'pull request', 'pr', 'model', 'prompt']
title: 'Advanced',
description:
'Override the model and prompt for commit messages, pull requests, and branch names.',
keywords: [
'customization',
'advanced',
'commit',
'pull request',
'pr',
'branch',
'name',
'model',
'prompt'
]
}
const commitAndPrCustomizationMatches =
config.enabled && matchesSettingsSearch(searchQuery, commitAndPrCustomizationEntry)
@@ -1277,6 +1345,51 @@ export function CommitMessageAiPane({
</div>
) : null
const branchNamesGroupEntry = {
title: 'Branch Names',
description: 'Branch name generation settings for auto-named workspaces.',
keywords: ['branch', 'name', 'rename', 'model', 'prompt', 'slug', 'workspace']
}
const branchNamesGroupMatches =
config.enabled && matchesSettingsSearch(searchQuery, branchNamesGroupEntry)
const branchNamePromptMatches = matchesSettingsSearch(searchQuery, {
title: 'Branch name prompt',
description: 'Additional prompt text appended only when generating branch names.',
keywords: ['prompt', 'instructions', 'built-in prompt', 'slug', 'kebab-case']
})
const branchNameChildren = [
renderOperationModelControls(
'branchName',
'Model',
'Use a different model for branch name generation.',
['model', 'override', 'branch', 'name', 'branch name model', 'slug', 'thinking'],
branchNamesGroupMatches || commitAndPrCustomizationMatches
),
(config.enabled || isBranchNamePromptDirty) &&
(branchNamesGroupMatches ||
commitAndPrCustomizationMatches ||
isBranchNamePromptDirty ||
branchNamePromptMatches) ? (
<AutoRenameBranchPromptEditor
key="branch-name-prompt"
draft={branchNamePromptDraft}
dirty={isBranchNamePromptDirty}
saving={isSavingPrompt}
onDraftChange={(value) => updateInstructionDraft('branchName', value)}
onDiscard={() => onDiscardPrompt('branchName')}
onSave={() => void onSavePrompt('branchName')}
/>
) : null
].filter(Boolean)
const branchNamesGroup =
branchNameChildren.length > 0 ? (
<div key="branch-names" className="space-y-3">
<h4 className="text-sm font-semibold">Branch Names</h4>
<div className="divide-y divide-border/50">{branchNameChildren}</div>
</div>
) : null
const pullRequestsGroupEntry = {
title: 'Pull Requests',
description: 'Pull request authoring and creation settings.',
@@ -1423,13 +1536,16 @@ export function CommitMessageAiPane({
</div>
) : null
const outputOverrideChildren = [commitMessagesGroup, pullRequestsGroup].filter(Boolean)
const outputOverrideChildren = [commitMessagesGroup, pullRequestsGroup, branchNamesGroup].filter(
Boolean
)
const outputOverridesSearchOpen = searchQuery.trim() !== '' && outputOverrideChildren.length > 0
const outputOverridesVisible =
outputOverridesOpen ||
outputOverridesSearchOpen ||
isCommitPromptDirty ||
isPullRequestPromptDirty
isPullRequestPromptDirty ||
isBranchNamePromptDirty
if (outputOverrideChildren.length > 0) {
sections.push(
@@ -1444,11 +1560,7 @@ export function CommitMessageAiPane({
<button
type="button"
className="flex w-full cursor-pointer items-start gap-2 rounded-md py-1 text-left outline-none transition-colors hover:text-foreground focus-visible:ring-1 focus-visible:ring-ring"
aria-label={
outputOverridesVisible
? 'Collapse commit and PR customization'
: 'Expand commit and PR customization'
}
aria-label={outputOverridesVisible ? 'Collapse advanced' : 'Expand advanced'}
>
<span className="mt-0.5 flex size-5 shrink-0 items-center justify-center text-muted-foreground">
<ChevronDown
@@ -1460,10 +1572,11 @@ export function CommitMessageAiPane({
</span>
<span className="space-y-0.5">
<span className="block cursor-pointer text-sm leading-none font-medium">
Commit and PR customization
Advanced
</span>
<span className="block text-xs text-muted-foreground">
Configure behavior for commit message generation and PR creation.
Override the model and prompt for commit messages, pull requests, and branch
names.
</span>
</span>
</button>
@@ -3,8 +3,7 @@ import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it } from 'vitest'
import { getDefaultSettings } from '../../../../shared/constants'
import { useAppStore } from '../../store'
import { shouldOpenAutoRenameBranchAdvanced } from './AutoRenameBranchFromWorkSetting'
import { GitPane, shouldShowAutoRenameBranchSetting } from './GitPane'
import { GitPane } from './GitPane'
function renderGitPane(searchQuery: string): string {
useAppStore.setState({ settingsSearchQuery: searchQuery })
@@ -12,7 +11,6 @@ function renderGitPane(searchQuery: string): string {
React.createElement(GitPane, {
settings: getDefaultSettings('/tmp'),
updateSettings: () => {},
writeSourceControlAiSettings: async () => {},
displayedGitUsername: 'brennan',
settingsSearchQuery: searchQuery
})
@@ -20,37 +18,16 @@ function renderGitPane(searchQuery: string): string {
}
describe('GitPane', () => {
it('keeps the auto-rename branch setting visible while its prompt draft is dirty', () => {
expect(shouldShowAutoRenameBranchSetting('zz-no-match', true)).toBe(true)
it('still renders its own git settings (e.g. Branch Prefix) on a matching search', () => {
expect(renderGitPane('branch prefix')).toContain('Branch Prefix')
})
it('shows the auto-rename branch setting for advanced prompt and model searches', () => {
expect(shouldShowAutoRenameBranchSetting('instructions', false)).toBe(true)
expect(shouldShowAutoRenameBranchSetting('built-in prompt', false)).toBe(true)
expect(shouldShowAutoRenameBranchSetting('thinking', false)).toBe(true)
expect(shouldShowAutoRenameBranchSetting('override', false)).toBe(true)
})
it('hides the auto-rename branch setting when search misses and the prompt draft is clean', () => {
expect(shouldShowAutoRenameBranchSetting('zz-no-match', false)).toBe(false)
})
it('opens auto-rename advanced controls when search matches hidden prompt or model fields', () => {
expect(shouldOpenAutoRenameBranchAdvanced('prompt')).toBe(true)
expect(shouldOpenAutoRenameBranchAdvanced('model')).toBe(true)
expect(shouldOpenAutoRenameBranchAdvanced('instructions')).toBe(true)
expect(shouldOpenAutoRenameBranchAdvanced('built-in prompt')).toBe(true)
expect(shouldOpenAutoRenameBranchAdvanced('thinking')).toBe(true)
expect(shouldOpenAutoRenameBranchAdvanced('override')).toBe(true)
})
it('renders auto-rename advanced controls for advanced-only search terms', () => {
expect(renderGitPane('instructions')).toContain('Branch name prompt')
expect(renderGitPane('thinking')).toContain('Branch name model')
})
it('keeps auto-rename advanced controls collapsed without an advanced search match', () => {
expect(shouldOpenAutoRenameBranchAdvanced('')).toBe(false)
expect(shouldOpenAutoRenameBranchAdvanced('creature name')).toBe(false)
it('no longer renders the auto-name toggle or the relocated branch-name controls', () => {
// Why: the auto-name toggle moved to the Git AI Author pane (it depends on
// that feature), and its model/prompt tuning lives under Advanced -> Branch Names.
const markup = renderGitPane('rename')
expect(markup).not.toContain('Auto-name new workspaces from first message')
expect(markup).not.toContain('Branch name prompt')
expect(markup).not.toContain('Branch name model')
})
})
@@ -1,5 +1,4 @@
import type { GlobalSettings } from '../../../../shared/types'
import type { SourceControlAiSettingsPatch } from '../../../../shared/source-control-ai-types'
import { Input } from '../ui/input'
import { Label } from '../ui/label'
import { useAppStore } from '../../store'
@@ -7,41 +6,21 @@ import { GIT_PANE_SEARCH_ENTRIES } from './git-search'
import { SearchableSetting } from './SearchableSetting'
import { matchesSettingsSearch } from './settings-search'
import { GitHubRateLimitPanel } from '../github/github-rate-limit-display'
import { AutoRenameBranchFromWorkSetting } from './AutoRenameBranchFromWorkSetting'
import { AUTO_RENAME_BRANCH_SEARCH_ENTRIES } from './auto-rename-branch-search'
import { GitLabRateLimitPanel } from '../gitlab/gitlab-rate-limit-display'
export { GIT_PANE_SEARCH_ENTRIES }
export function shouldShowAutoRenameBranchSetting(
searchQuery: string,
hasUnsavedBranchPromptChanges: boolean
): boolean {
return (
hasUnsavedBranchPromptChanges ||
matchesSettingsSearch(searchQuery, AUTO_RENAME_BRANCH_SEARCH_ENTRIES)
)
}
type GitPaneProps = {
settings: GlobalSettings
updateSettings: (updates: Partial<GlobalSettings>) => void | Promise<void>
writeSourceControlAiSettings: (patch: SourceControlAiSettingsPatch) => Promise<void>
displayedGitUsername: string
hasUnsavedBranchPromptChanges?: boolean
onBranchPromptDirtyChange?: (dirty: boolean) => void
branchPromptDiscardSignal?: number
settingsSearchQuery?: string
}
export function GitPane({
settings,
updateSettings,
writeSourceControlAiSettings,
displayedGitUsername,
hasUnsavedBranchPromptChanges = false,
onBranchPromptDirtyChange,
branchPromptDiscardSignal,
settingsSearchQuery
}: GitPaneProps): React.JSX.Element {
const storeSearchQuery = useAppStore((s) => s.settingsSearchQuery)
@@ -162,18 +141,6 @@ export function GitPane({
</button>
</SearchableSetting>
) : null,
shouldShowAutoRenameBranchSetting(searchQuery, hasUnsavedBranchPromptChanges) ? (
<AutoRenameBranchFromWorkSetting
key="auto-rename-branch-from-work"
settings={settings}
updateSettings={updateSettings}
writeSourceControlAiSettings={writeSourceControlAiSettings}
forceVisible={hasUnsavedBranchPromptChanges}
onBranchPromptDirtyChange={onBranchPromptDirtyChange}
branchPromptDiscardSignal={branchPromptDiscardSignal}
settingsSearchQuery={searchQuery}
/>
) : null,
matchesSettingsSearch(searchQuery, {
title: 'GitHub API Budget',
description: 'Current GitHub CLI REST, Search, and GraphQL rate limits.',
@@ -239,7 +239,6 @@ function Settings(): React.JSX.Element {
const [pendingNavRequestTick, setPendingNavRequestTick] = useState(0)
const [quickCommandAddIntentSignal, setQuickCommandAddIntentSignal] = useState(0)
const [hasUnsavedCommitPromptChanges, setHasUnsavedCommitPromptChanges] = useState(false)
const [hasUnsavedBranchPromptChanges, setHasUnsavedBranchPromptChanges] = useState(false)
const [sourceControlAiPromptDiscardSignal, setSourceControlAiPromptDiscardSignal] = useState(0)
const confirm = useConfirmationDialog()
// Why: the hidden-experimental group is an unlock — Shift-clicking the
@@ -258,8 +257,9 @@ function Settings(): React.JSX.Element {
const shortcutsEscapeConfirmUntilRef = useRef(0)
const sourceControlAiWriteQueueRef = useRef<Promise<void>>(Promise.resolve())
const hasUnsavedSourceControlAiPromptChanges =
hasUnsavedCommitPromptChanges || hasUnsavedBranchPromptChanges
// Why: the commit pane now owns every Git AI Author prompt draft (commit, PR,
// and branch name), so its single dirty signal covers all unsaved prompt edits.
const hasUnsavedSourceControlAiPromptChanges = hasUnsavedCommitPromptChanges
const writeSourceControlAiSettings = useCallback(
(patch: SourceControlAiSettingsPatch): Promise<void> => {
@@ -315,7 +315,6 @@ function Settings(): React.JSX.Element {
if (shouldDiscard) {
setSourceControlAiPromptDiscardSignal((signal) => signal + 1)
setHasUnsavedCommitPromptChanges(false)
setHasUnsavedBranchPromptChanges(false)
}
return shouldDiscard
}, [confirm, hasUnsavedSourceControlAiPromptChanges])
@@ -1040,11 +1039,7 @@ function Settings(): React.JSX.Element {
<GitPane
settings={settings}
updateSettings={updateSettings}
writeSourceControlAiSettings={writeSourceControlAiSettings}
displayedGitUsername={displayedGitUsername}
hasUnsavedBranchPromptChanges={hasUnsavedBranchPromptChanges}
onBranchPromptDirtyChange={setHasUnsavedBranchPromptChanges}
branchPromptDiscardSignal={sourceControlAiPromptDiscardSignal}
/>
<CommitMessageAiPane
settings={settings}
@@ -1,5 +1,8 @@
import type { SettingsSearchEntry } from './settings-search'
// The auto-name toggle lives in the Git AI Author pane (it depends on that
// feature being enabled); its model/prompt tuning is under Advanced → Branch
// Names. This identity entry is searched as part of that pane's search set.
export const AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY: SettingsSearchEntry = {
title: 'Auto-Name From First Message',
description: 'Use the first task to name blank new workspaces and their unpublished branches.',
@@ -10,6 +13,7 @@ export const AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY: SettingsSearchEntry = {
'rename',
'name',
'auto',
'auto-name',
'creature name',
'agent',
'prompt',
@@ -18,21 +22,3 @@ export const AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY: SettingsSearchEntry = {
'slug'
]
}
export const AUTO_RENAME_BRANCH_ADVANCED_SEARCH_ENTRIES: SettingsSearchEntry[] = [
{
title: 'Branch name prompt',
description: 'Additional prompt text appended only when generating branch names.',
keywords: ['prompt', 'instructions', 'built-in prompt', 'slug', 'kebab-case']
},
{
title: 'Branch name model',
description: 'Use a different model for branch name generation.',
keywords: ['model', 'override', 'thinking']
}
]
export const AUTO_RENAME_BRANCH_SEARCH_ENTRIES: SettingsSearchEntry[] = [
AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY,
...AUTO_RENAME_BRANCH_ADVANCED_SEARCH_ENTRIES
]
@@ -1,6 +1,11 @@
import type { SettingsSearchEntry } from './settings-search'
import { AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY } from './auto-rename-branch-search'
export const COMMIT_MESSAGE_AI_PANE_SEARCH_ENTRIES: SettingsSearchEntry[] = [
// Why: the auto-name toggle now lives in this pane (it depends on Git AI
// Author), so its search identity belongs here — matching it surfaces the
// Enable row when the feature is off, guiding the user to turn it on.
AUTO_RENAME_BRANCH_PARENT_SEARCH_ENTRY,
{
title: 'Enable Git AI Author',
description: 'Adds AI generation to git commit, pull request, and branch-name flows.',
@@ -32,9 +37,20 @@ export const COMMIT_MESSAGE_AI_PANE_SEARCH_ENTRIES: SettingsSearchEntry[] = [
keywords: ['thinking', 'effort', 'reasoning']
},
{
title: 'Commit and PR customization',
description: 'Configure behavior for commit message generation and PR creation.',
keywords: ['customization', 'advanced', 'commit', 'pull request', 'pr', 'model', 'prompt']
title: 'Advanced',
description:
'Override the model and prompt for commit messages, pull requests, and branch names.',
keywords: [
'customization',
'advanced',
'commit',
'pull request',
'pr',
'branch',
'name',
'model',
'prompt'
]
},
{
title: 'Commit Messages',
@@ -71,6 +87,21 @@ export const COMMIT_MESSAGE_AI_PANE_SEARCH_ENTRIES: SettingsSearchEntry[] = [
description: 'Defaults used when the Create PR composer opens.',
keywords: ['pull request', 'pr', 'draft', 'template', 'generate', 'open']
},
{
title: 'Branch Names',
description: 'Branch name generation settings for auto-named workspaces.',
keywords: ['branch', 'name', 'rename', 'model', 'prompt', 'slug', 'workspace']
},
{
title: 'Branch name model',
description: 'Optional model choice for branch name generation.',
keywords: ['model', 'override', 'branch', 'name', 'branch name model', 'slug', 'thinking']
},
{
title: 'Branch name prompt',
description: 'Additional prompt text appended only when generating branch names.',
keywords: ['prompt', 'instructions', 'built-in prompt', 'slug', 'kebab-case']
},
{
title: 'Custom command',
description: 'Command line Orca runs to generate the commit message.',
@@ -1,5 +1,4 @@
import type { SettingsSearchEntry } from './settings-search'
import { AUTO_RENAME_BRANCH_SEARCH_ENTRIES } from './auto-rename-branch-search'
export const GIT_PANE_SEARCH_ENTRIES: SettingsSearchEntry[] = [
{
@@ -21,7 +20,6 @@ export const GIT_PANE_SEARCH_ENTRIES: SettingsSearchEntry[] = [
'worktree'
]
},
...AUTO_RENAME_BRANCH_SEARCH_ENTRIES,
{
title: 'GitHub API Budget',
description: 'Current GitHub CLI REST, Search, and GraphQL rate limits.',