fix: show create-worktree action in jump palette only on empty results (#611)

The "Create worktree" item in Cmd+J now only appears when the search
query produces no matching worktrees, keeping the list uncluttered when
existing worktrees already satisfy the search.
This commit is contained in:
Jinjing 2026-04-13 19:08:10 -07:00 committed by GitHub
parent 10f8ce1a55
commit 8d6caa1f11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -99,9 +99,10 @@ export default function WorktreeJumpPalette(): React.JSX.Element | null {
[sortedWorktrees, query, repoMap, prCache, issueCache]
)
const createWorktreeName = query.trim()
// Why: only surface the create-worktree action after the user has typed a query,
// so it doesn't clutter the default (empty-query) list of recent worktrees.
const showCreateAction = canCreateWorktree && createWorktreeName.length > 0
// Why: only surface the create-worktree action when the query yields no matches,
// so it doesn't clutter the list when existing worktrees already satisfy the search.
const showCreateAction =
canCreateWorktree && createWorktreeName.length > 0 && matches.length === 0
// Build a map of worktreeId -> Worktree for quick lookup
const worktreeMap = useMemo(() => {