feat(ui): dock repo and session tools in a desktop side panel

Add a docked desktop tool panel with an icon rail, driven by the shared panel URL param, and keep the mobile dialogs and drawers. Extract dialog bodies into reusable content components, rename the walkthrough dialog to a sheet, and make walkthrough generation asynchronous with client polling.
This commit is contained in:
Chris Scott committed 2026-10-07 23:58:56 -04:00
1 parent bdbcc60716
commit 485ab940aa
49 files changed
+2631 -1753

No files matched your search

@@ -62,6 +62,23 @@ describe('SideDrawer', () => {
expect(handleClose).not.toHaveBeenCalled()
})
it('closes only the topmost drawer on Escape when drawers are stacked', () => {
const closeOuter = vi.fn()
const closeInner = vi.fn()
render(
<>
<SideDrawer isOpen onClose={closeOuter} ariaLabel="Outer">
<div>Outer</div>
</SideDrawer>
<SideDrawer isOpen onClose={closeInner} ariaLabel="Inner">
<div>Inner</div>
</SideDrawer>
</>,
)
fireEvent.keyDown(document, { key: 'Escape' })
expect(closeInner).toHaveBeenCalledTimes(1)
expect(closeOuter).not.toHaveBeenCalled()
})
})
describe('SideDrawerHeader', () => {
+23 -10
View File
@@ -1,8 +1,10 @@
import { useEffect, useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { cn } from '@/lib/utils'
import { MODAL_TRANSITION_MS } from '@/lib/utils'
import { X } from 'lucide-react'
const openDrawerStack: symbol[] = []
export interface SideDrawerProps {
isOpen: boolean
onClose: () => void
@@ -33,23 +35,34 @@ export function SideDrawer({
}
}, [isOpen])
const onCloseRef = useRef(onClose)
useEffect(() => {
onCloseRef.current = onClose
}, [onClose])
useEffect(() => {
if (!isOpen) return
const token = Symbol('side-drawer')
openDrawerStack.push(token)
const handleEscape = (e: KeyboardEvent) => {
if (e.key === 'Escape' && isOpen && !e.defaultPrevented) {
onClose()
}
if (e.key !== 'Escape' || e.defaultPrevented || openDrawerStack.at(-1) !== token) return
e.preventDefault()
onCloseRef.current()
}
if (isOpen) {
document.addEventListener('keydown', handleEscape)
document.body.style.overflow = 'hidden'
}
document.addEventListener('keydown', handleEscape)
document.body.style.overflow = 'hidden'
return () => {
document.removeEventListener('keydown', handleEscape)
document.body.style.overflow = 'unset'
openDrawerStack.splice(openDrawerStack.indexOf(token), 1)
if (openDrawerStack.length === 0) {
document.body.style.overflow = 'unset'
}
}
}, [isOpen, onClose])
}, [isOpen])
if (!isOpen && !shouldRender) return null
+1 -53
View File
@@ -1,6 +1,6 @@
import { describe, it, expect, vi } from 'vitest'
import { render, screen, fireEvent } from '@testing-library/react'
import { Sidebar, SidebarCollapsibleSection, SidebarSection, SidebarItem, SidebarCollapseToggle } from './sidebar'
import { Sidebar, SidebarSection, SidebarItem, SidebarCollapseToggle } from './sidebar'
import { TooltipProvider } from './tooltip'
import { Folder } from 'lucide-react'
@@ -58,58 +58,6 @@ describe('SidebarSection', () => {
})
})
describe('SidebarCollapsibleSection', () => {
it('renders label and children when expanded', () => {
render(
<SidebarCollapsibleSection label="Sessions" collapsed={false} onToggle={vi.fn()}>
<div>Content</div>
</SidebarCollapsibleSection>
)
expect(screen.getByRole('button', { name: 'Sessions' })).toHaveAttribute('aria-expanded', 'true')
expect(screen.getByText('Content')).toBeInTheDocument()
})
it('hides children when collapsed', () => {
render(
<SidebarCollapsibleSection label="Sessions" collapsed={true} onToggle={vi.fn()}>
<div>Content</div>
</SidebarCollapsibleSection>
)
expect(screen.getByRole('button', { name: 'Sessions' })).toHaveAttribute('aria-expanded', 'false')
expect(screen.queryByText('Content')).not.toBeInTheDocument()
})
it('calls onToggle when the header is clicked', () => {
const handleToggle = vi.fn()
render(
<SidebarCollapsibleSection label="Menu" collapsed={false} onToggle={handleToggle}>
<div>Content</div>
</SidebarCollapsibleSection>
)
fireEvent.click(screen.getByRole('button', { name: 'Menu' }))
expect(handleToggle).toHaveBeenCalledTimes(1)
})
it('applies contentClassName to the content wrapper', () => {
render(
<SidebarCollapsibleSection
label="Menu"
collapsed={false}
onToggle={vi.fn()}
contentClassName="overflow-y-auto"
>
<div>Content</div>
</SidebarCollapsibleSection>
)
expect(screen.getByText('Content').parentElement).toHaveClass('overflow-y-auto')
})
})
describe('SidebarItem', () => {
it('fires onClick when clicked', () => {
const handleClick = vi.fn()
+1 -42
View File
@@ -1,6 +1,5 @@
import { useId } from 'react'
import type { LucideIcon } from 'lucide-react'
import { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react'
import { ChevronLeft, ChevronRight } from 'lucide-react'
import { cn } from '@/lib/utils'
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip'
@@ -57,46 +56,6 @@ export function SidebarSection({ label, collapsed, children }: SidebarSectionPro
)
}
export interface SidebarCollapsibleSectionProps {
label: string
collapsed: boolean
onToggle: () => void
className?: string
contentClassName?: string
children: React.ReactNode
}
export function SidebarCollapsibleSection({
label,
collapsed,
onToggle,
className,
contentClassName,
children,
}: SidebarCollapsibleSectionProps) {
const contentId = useId()
return (
<div className={cn('flex min-h-0 flex-col', className)}>
<button
type="button"
onClick={onToggle}
aria-expanded={!collapsed}
aria-controls={contentId}
className="flex w-full items-center justify-between gap-2 px-3 py-1.5 text-xs font-medium uppercase tracking-wider text-muted-foreground transition-colors hover:text-foreground"
>
<span className="truncate">{label}</span>
<ChevronDown className={cn('h-3.5 w-3.5 shrink-0 transition-transform', collapsed && '-rotate-90')} />
</button>
{!collapsed && (
<div id={contentId} className={cn('flex min-h-0 flex-1 flex-col', contentClassName)}>
{children}
</div>
)}
</div>
)
}
export interface SidebarItemProps {
icon: LucideIcon
label: string