From 1b8e7c5bb5d59cbd7a52851a2b42e2624931b385 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sun, 28 Jun 2026 14:46:28 -0700 Subject: [PATCH] Improve sidebar search button styling and shortcut rendering (#6601) * Redesign the search button in the sidebar to look like a standard input field with a border, background, and absolute icon positioning. * Replace the basic `` label with `ShortcutKeyCombo` elements driven by `useShortcutKeyComboDetails`. * Show the shortcut combinations when the search container is focused as well as hovered. --- .../components/sidebar/SidebarNav.test.tsx | 19 +++++++++++++- .../src/components/sidebar/SidebarNav.tsx | 26 +++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/components/sidebar/SidebarNav.test.tsx b/src/renderer/src/components/sidebar/SidebarNav.test.tsx index 5558a5120..3b919f7f8 100644 --- a/src/renderer/src/components/sidebar/SidebarNav.test.tsx +++ b/src/renderer/src/components/sidebar/SidebarNav.test.tsx @@ -36,7 +36,7 @@ vi.mock('@/components/activity/useActivityUnreadCount', () => ({ })) vi.mock('@/hooks/useShortcutLabel', () => ({ - useShortcutLabel: () => '⌘P' + useShortcutKeyComboDetails: () => [{ keys: ['⌘', 'J'], doubleTap: false }] })) vi.mock('./mobile-sidebar-onboarding-badge', () => ({ @@ -273,6 +273,23 @@ describe('SidebarNav', () => { expect(mocks.updateSettings).toHaveBeenCalledWith({ showMobileButton: false }) }) + it('hides the worktree palette shortcut until the search field is hovered or focused', async () => { + const container = await renderSidebarNav() + + const searchButton = container.querySelector( + 'button[aria-label="Search worktrees and browser tabs"]' + ) + expect(searchButton).not.toBeNull() + + const shortcuts = searchButton?.querySelector('span.hidden') + expect(shortcuts?.className).toContain('hidden') + expect(shortcuts?.className).toContain('group-hover:inline-flex') + expect(shortcuts?.className).toContain('group-focus-within:inline-flex') + expect(shortcuts?.textContent).toContain('⌘') + expect(shortcuts?.textContent).toContain('J') + expect(searchButton?.querySelector('kbd')).toBeNull() + }) + it('hides task source shortcuts until the Tasks row is hovered or focused', async () => { const container = await renderSidebarNav() diff --git a/src/renderer/src/components/sidebar/SidebarNav.tsx b/src/renderer/src/components/sidebar/SidebarNav.tsx index d099f0d83..7474259a9 100644 --- a/src/renderer/src/components/sidebar/SidebarNav.tsx +++ b/src/renderer/src/components/sidebar/SidebarNav.tsx @@ -4,7 +4,8 @@ import { useAppStore } from '@/store' import { cn } from '@/lib/utils' import type { GlobalSettings } from '../../../../shared/types' import { useActivityUnreadCount } from '@/components/activity/useActivityUnreadCount' -import { useShortcutLabel } from '@/hooks/useShortcutLabel' +import { useShortcutKeyComboDetails } from '@/hooks/useShortcutLabel' +import { ShortcutKeyCombo } from '@/components/ShortcutKeyCombo' import { useMobileSidebarOnboardingBadge } from './mobile-sidebar-onboarding-badge' import { ContextMenu, ContextMenuTrigger } from '@/components/ui/context-menu' import { SetupGuideSidebarEntry } from './SetupGuideSidebarEntry' @@ -33,7 +34,7 @@ export function shouldShowAutomationsButton( } const SidebarNav = React.memo(function SidebarNav() { - const worktreePaletteShortcut = useShortcutLabel('worktree.palette') + const worktreePaletteShortcutCombos = useShortcutKeyComboDetails('worktree.palette') const openAutomationsPage = useAppStore((s) => s.openAutomationsPage) const openActivityPage = useAppStore((s) => s.openActivityPage) const openMobilePage = useAppStore((s) => s.openMobilePage) @@ -164,18 +165,27 @@ const SidebarNav = React.memo(function SidebarNav() { 'auto.components.sidebar.SidebarNav.0c3395fd32', 'Search worktrees and browser tabs' )} - className="group flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] font-medium tracking-tight text-worktree-sidebar-foreground/60 transition-colors hover:bg-worktree-sidebar-foreground/8" + className="group relative flex h-7 w-full items-center rounded-md border border-worktree-sidebar-border/70 bg-worktree-sidebar-foreground/5 pl-7 pr-1.5 text-left text-[12px] font-medium tracking-tight text-worktree-sidebar-foreground/45 transition-colors hover:border-worktree-sidebar-border hover:bg-worktree-sidebar-foreground/8 hover:text-worktree-sidebar-foreground/60 focus-visible:outline-none focus-visible:ring-[3px] focus-visible:ring-worktree-sidebar-ring/50" > - + {translate('auto.components.sidebar.SidebarNav.80611a8b10', 'Search')} - - {worktreePaletteShortcut} - + + {worktreePaletteShortcutCombos.map((combo) => ( + + ))} + )