fix: preserve edited PR workspace names (#6774)

This commit is contained in:
Jinjing
2026-06-29 12:04:40 -07:00
committed by GitHub
parent 62de4e1b6e
commit 82d275c3ac
2 changed files with 70 additions and 4 deletions
@@ -5,6 +5,7 @@ import {
canResolveFolderSmartGitHubSubmit,
getInitialAutoManagedWorkspaceName,
isExplicitWorkspaceNameInput,
resolveSmartGitHubCreateNames,
resolveInitialWorkspaceRunSeed
} from './useComposerState'
@@ -45,6 +46,30 @@ describe('useComposerState host-context boundaries', () => {
).toBe('')
})
it('preserves explicit names when a linked PR start point resolves at submit time', () => {
expect(
resolveSmartGitHubCreateNames({
resolutionKind: 'pr-start-point',
smartWorkspaceName: 'title-derived-name',
smartDisplayName: 'Title derived name',
fallbackWorkspaceName: 'edited workspace',
nameIsAutoManaged: false
})
).toEqual({ workspaceName: 'edited workspace', displayName: undefined })
})
it('keeps smart GitHub names for auto-managed PR start-point submissions', () => {
expect(
resolveSmartGitHubCreateNames({
resolutionKind: 'pr-start-point',
smartWorkspaceName: 'title-derived-name',
smartDisplayName: 'Title derived name',
fallbackWorkspaceName: 'https://github.com/stablyai/orca/pull/6772',
nameIsAutoManaged: true
})
).toEqual({ workspaceName: 'title-derived-name', displayName: 'Title derived name' })
})
it('auto-owns linked-item generated prefilled names', () => {
expect(
getInitialAutoManagedWorkspaceName({
+45 -4
View File
@@ -434,6 +434,27 @@ export function isExplicitWorkspaceNameInput({
return Boolean(name.trim()) && name !== lastAutoName && !isWorkItemLookupText(name)
}
export function resolveSmartGitHubCreateNames({
resolutionKind,
smartWorkspaceName,
smartDisplayName,
fallbackWorkspaceName,
nameIsAutoManaged
}: {
resolutionKind: Exclude<PendingSmartGitHubSubmitResolution['kind'], 'none'>
smartWorkspaceName: string
smartDisplayName: string
fallbackWorkspaceName: string
nameIsAutoManaged: boolean
}): { workspaceName: string; displayName: string | undefined } {
if (resolutionKind === 'pr-start-point' && !nameIsAutoManaged && fallbackWorkspaceName) {
// Why: submit-time PR start-point resolution augments an already-linked PR;
// it must not reclaim a workspace name the user edited after selection.
return { workspaceName: fallbackWorkspaceName, displayName: undefined }
}
return { workspaceName: smartWorkspaceName, displayName: smartDisplayName }
}
function getLinkedWorkItemSeedName(item: LinkedWorkItemSummary | null | undefined): string {
if (!item) {
return ''
@@ -3227,12 +3248,22 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS
name,
lastAutoName: lastAutoNameRef.current
})
const smartGitHubCreateNames =
smartGitHubResolution.kind === 'none'
? { workspaceName: workspaceSeedName, displayName: undefined }
: resolveSmartGitHubCreateNames({
resolutionKind: smartGitHubResolution.kind,
smartWorkspaceName: smartGitHubResolution.workspaceName,
smartDisplayName: smartGitHubResolution.displayName,
fallbackWorkspaceName: workspaceSeedName,
nameIsAutoManaged
})
const workspaceName =
smartGitHubResolution.kind === 'none'
? nameIsAutoManaged && submitTitleName
? submitTitleName.seedName
: workspaceSeedName
: smartGitHubResolution.workspaceName
: smartGitHubCreateNames.workspaceName
if (!workspaceName) {
return
}
@@ -3342,7 +3373,7 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS
? nameIsAutoManaged
? submitTitleName?.displayName
: undefined
: smartGitHubResolution.displayName
: smartGitHubCreateNames.displayName
// Why: the first-work hook only renames blank, auto-generated git workspaces
// that actually launch an agent. Persist that known-pending state for the card.
const pendingFirstAgentMessageRename =
@@ -3634,12 +3665,22 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS
name,
lastAutoName: lastAutoNameRef.current
})
const smartGitHubCreateNames =
smartGitHubResolution.kind === 'none'
? { workspaceName: workspaceNameSeed, displayName: undefined }
: resolveSmartGitHubCreateNames({
resolutionKind: smartGitHubResolution.kind,
smartWorkspaceName: smartGitHubResolution.workspaceName,
smartDisplayName: smartGitHubResolution.displayName,
fallbackWorkspaceName: workspaceNameSeed,
nameIsAutoManaged
})
const workspaceName =
smartGitHubResolution.kind === 'none'
? nameIsAutoManaged && submitTitleName
? submitTitleName.seedName
: workspaceNameSeed
: smartGitHubResolution.workspaceName
: smartGitHubCreateNames.workspaceName
if (!workspaceName) {
return
}
@@ -3739,7 +3780,7 @@ export function useComposerState(options: UseComposerStateOptions): UseComposerS
? nameIsAutoManaged
? submitTitleName?.displayName
: undefined
: smartGitHubResolution.displayName
: smartGitHubCreateNames.displayName
// Why: quick create uses the same blank-name creature branch flow; the card
// needs an explicit marker rather than guessing from the generated title.
const pendingFirstAgentMessageRename =