mirror of
https://github.com/stablyai/orca.git
synced 2026-11-19 04:23:57 +00:00
fix(sidebar): show the workspace name you set instead of a linked task title (#41470)
* fix(sidebar): keep a user-set workspace name over linked task titles The card title guessed whether a name was user-set by comparing it with the branch, so a pinned name equal to the branch lost to a linked issue or PR title. It now reads displayNameMode. The Workspace details dialog also pins the name when the field was edited, even if the text ends up equal to the branch. * test(sidebar): drop title case that passes without the fix
This commit is contained in:
+1
@@ -94,6 +94,7 @@ export function useWorktreeCardLinkedDetails({
|
||||
const jiraIssueDisplay = getWorktreeCardJiraIssueDisplay(worktree)
|
||||
const cardTitleDisplay = getWorktreeCardTitleDisplay({
|
||||
storedDisplayName: worktree.displayName,
|
||||
displayNameMode: worktree.displayNameMode,
|
||||
branchName: branch,
|
||||
// Fetched titles only: display fallbacks hold localized loading/unavailable placeholders.
|
||||
linearIssueTitle: linearIssue?.title,
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { getWorktreeCardTitleDisplay } from './worktree-card-title-display'
|
||||
|
||||
describe('getWorktreeCardTitleDisplay', () => {
|
||||
it('keeps a user-set name that matches the branch over a linked task title', () => {
|
||||
expect(
|
||||
getWorktreeCardTitleDisplay({
|
||||
storedDisplayName: 'release/rc-11',
|
||||
displayNameMode: 'fixed',
|
||||
branchName: 'release/rc-11',
|
||||
jiraIssueTitle: 'Refactor billing export'
|
||||
})
|
||||
).toBe('release/rc-11')
|
||||
})
|
||||
})
|
||||
+7
-1
@@ -1,5 +1,8 @@
|
||||
import type { Worktree } from '../../../../../../shared/worktree/types'
|
||||
|
||||
type WorktreeCardTitleDisplayInput = {
|
||||
storedDisplayName: string | null | undefined
|
||||
displayNameMode: Worktree['displayNameMode']
|
||||
branchName: string | null | undefined
|
||||
linearIssueTitle?: string | null
|
||||
jiraIssueTitle?: string | null
|
||||
@@ -37,6 +40,7 @@ export function coerceWorktreeCardVisibleTitle(value: string | null | undefined)
|
||||
|
||||
export function getWorktreeCardTitleDisplay({
|
||||
storedDisplayName,
|
||||
displayNameMode,
|
||||
branchName,
|
||||
linearIssueTitle,
|
||||
jiraIssueTitle,
|
||||
@@ -51,9 +55,11 @@ export function getWorktreeCardTitleDisplay({
|
||||
return normalizedStoredDisplayName ? visibleStoredDisplayName : ''
|
||||
}
|
||||
|
||||
// User-set names win even when they match the branch; mode is absent from older hosts.
|
||||
if (
|
||||
normalizedStoredDisplayName &&
|
||||
!isBranchTitle(normalizedStoredDisplayName, normalizedBranchName)
|
||||
(displayNameMode === 'fixed' ||
|
||||
!isBranchTitle(normalizedStoredDisplayName, normalizedBranchName))
|
||||
) {
|
||||
return visibleStoredDisplayName
|
||||
}
|
||||
|
||||
+11
@@ -207,4 +207,15 @@ describe('workspace linked work editor', () => {
|
||||
expect(screen.getByRole('button', { name: 'Save' }).hasAttribute('disabled')).toBe(false)
|
||||
expect(screen.getByRole('textbox', { name: 'Notes' }).textContent).toBe('Remote draft')
|
||||
})
|
||||
it('saves a retyped branch name as the display name', async () => {
|
||||
const original = openDialog({ displayName: 'release/rc-11', branch: 'release/rc-11' })
|
||||
const field = screen.getByRole('textbox', { name: 'Display Name' })
|
||||
fireEvent.change(field, { target: { value: 'release/rc-1' } })
|
||||
fireEvent.change(field, { target: { value: 'release/rc-11' } })
|
||||
await save()
|
||||
expect(updateWorktreeMeta.mock.calls[0]).toEqual([
|
||||
original.id,
|
||||
{ displayName: 'release/rc-11' }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
+7
-2
@@ -91,6 +91,8 @@ const WorktreeMetaDialogDraft = React.memo(function WorktreeMetaDialogDraft() {
|
||||
items: getWorkspaceAttachments(worktree ?? {})
|
||||
}))
|
||||
const [displayNameInput, setDisplayNameInput] = useState(initial.displayName)
|
||||
// Why: retyping the automatic branch name is still an explicit name, so editing pins it.
|
||||
const [displayNameEdited, setDisplayNameEdited] = useState(false)
|
||||
const [commentInput, setCommentInput] = useState(initial.comment)
|
||||
const [items, setItems] = useState<WorkspaceAttachment[]>(initial.items)
|
||||
const [notesOpen, setNotesOpen] = useState(
|
||||
@@ -114,7 +116,7 @@ const WorktreeMetaDialogDraft = React.memo(function WorktreeMetaDialogDraft() {
|
||||
setSaveError(null)
|
||||
try {
|
||||
const updates = {
|
||||
...(displayNameInput.trim() !== initial.displayName
|
||||
...(displayNameEdited || displayNameInput.trim() !== initial.displayName
|
||||
? { displayName: displayNameInput.trim() }
|
||||
: {}),
|
||||
...(commentInput.trim() !== initial.comment ? { comment: commentInput.trim() } : {}),
|
||||
@@ -220,7 +222,10 @@ const WorktreeMetaDialogDraft = React.memo(function WorktreeMetaDialogDraft() {
|
||||
disabled={saving}
|
||||
inputRef={displayNameInputRef}
|
||||
onEnter={handleSave}
|
||||
onValueChange={setDisplayNameInput}
|
||||
onValueChange={(value) => {
|
||||
setDisplayNameInput(value)
|
||||
setDisplayNameEdited(true)
|
||||
}}
|
||||
portalContainer={dialogElement}
|
||||
value={displayNameInput}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user