- PaneShell: per-pane chrome (kind label + close) - ChatPane: extracts message+input rendering, subscribes to useSessionStream - FileBrowserPane: tree + filter (debounced 100ms) + inline viewer via Shiki - PaneTab: tab with kind icon + context menu (Split, Close, Close others, Close to right, Close all) via shadcn ContextMenu - Workspace: tab strip + pane grid (CSS grid repeat(N,1fr)), native HTML5 drag-to-reorder, "+" button (disabled at 5), subscribes to open_file_in_browser (focus existing file-browser pane or spawn one) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
264 lines
8.2 KiB
TypeScript
264 lines
8.2 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { ContextMenu as ContextMenuPrimitive } from "radix-ui"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { CheckIcon, ChevronRightIcon } from "lucide-react"
|
|
|
|
function ContextMenu({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Root>) {
|
|
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />
|
|
}
|
|
|
|
function ContextMenuPortal({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Portal>) {
|
|
return (
|
|
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
|
)
|
|
}
|
|
|
|
function ContextMenuTrigger({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>) {
|
|
return (
|
|
<ContextMenuPrimitive.Trigger
|
|
data-slot="context-menu-trigger"
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function ContextMenuContent({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Content>) {
|
|
return (
|
|
<ContextMenuPrimitive.Portal>
|
|
<ContextMenuPrimitive.Content
|
|
data-slot="context-menu-content"
|
|
className={cn("z-50 min-w-32 overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
|
{...props}
|
|
/>
|
|
</ContextMenuPrimitive.Portal>
|
|
)
|
|
}
|
|
|
|
function ContextMenuGroup({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Group>) {
|
|
return (
|
|
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
|
)
|
|
}
|
|
|
|
function ContextMenuItem({
|
|
className,
|
|
inset,
|
|
variant = "default",
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
|
inset?: boolean
|
|
variant?: "default" | "destructive"
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.Item
|
|
data-slot="context-menu-item"
|
|
data-inset={inset}
|
|
data-variant={variant}
|
|
className={cn(
|
|
"group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function ContextMenuCheckboxItem({
|
|
className,
|
|
children,
|
|
checked,
|
|
inset,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem> & {
|
|
inset?: boolean
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.CheckboxItem
|
|
data-slot="context-menu-checkbox-item"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
checked={checked}
|
|
{...props}
|
|
>
|
|
<span
|
|
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
data-slot="context-menu-checkbox-item-indicator"
|
|
>
|
|
<ContextMenuPrimitive.ItemIndicator>
|
|
<CheckIcon />
|
|
</ContextMenuPrimitive.ItemIndicator>
|
|
</span>
|
|
{children}
|
|
</ContextMenuPrimitive.CheckboxItem>
|
|
)
|
|
}
|
|
|
|
function ContextMenuRadioGroup({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>) {
|
|
return (
|
|
<ContextMenuPrimitive.RadioGroup
|
|
data-slot="context-menu-radio-group"
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function ContextMenuRadioItem({
|
|
className,
|
|
children,
|
|
inset,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.RadioItem> & {
|
|
inset?: boolean
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.RadioItem
|
|
data-slot="context-menu-radio-item"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
<span
|
|
className="pointer-events-none absolute right-2 flex items-center justify-center"
|
|
data-slot="context-menu-radio-item-indicator"
|
|
>
|
|
<ContextMenuPrimitive.ItemIndicator>
|
|
<CheckIcon />
|
|
</ContextMenuPrimitive.ItemIndicator>
|
|
</span>
|
|
{children}
|
|
</ContextMenuPrimitive.RadioItem>
|
|
)
|
|
}
|
|
|
|
function ContextMenuLabel({
|
|
className,
|
|
inset,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
|
inset?: boolean
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.Label
|
|
data-slot="context-menu-label"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function ContextMenuSeparator({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Separator>) {
|
|
return (
|
|
<ContextMenuPrimitive.Separator
|
|
data-slot="context-menu-separator"
|
|
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function ContextMenuShortcut({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<"span">) {
|
|
return (
|
|
<span
|
|
data-slot="context-menu-shortcut"
|
|
className={cn(
|
|
"ml-auto text-xs tracking-widest text-muted-foreground group-focus/context-menu-item:text-accent-foreground",
|
|
className
|
|
)}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
function ContextMenuSub({
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Sub>) {
|
|
return <ContextMenuPrimitive.Sub data-slot="context-menu-sub" {...props} />
|
|
}
|
|
|
|
function ContextMenuSubTrigger({
|
|
className,
|
|
inset,
|
|
children,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
inset?: boolean
|
|
}) {
|
|
return (
|
|
<ContextMenuPrimitive.SubTrigger
|
|
data-slot="context-menu-sub-trigger"
|
|
data-inset={inset}
|
|
className={cn(
|
|
"flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
className
|
|
)}
|
|
{...props}
|
|
>
|
|
{children}
|
|
<ChevronRightIcon className="ml-auto" />
|
|
</ContextMenuPrimitive.SubTrigger>
|
|
)
|
|
}
|
|
|
|
function ContextMenuSubContent({
|
|
className,
|
|
...props
|
|
}: React.ComponentProps<typeof ContextMenuPrimitive.SubContent>) {
|
|
return (
|
|
<ContextMenuPrimitive.SubContent
|
|
data-slot="context-menu-sub-content"
|
|
className={cn("z-50 min-w-[96px] overflow-hidden rounded-lg bg-popover p-1 text-popover-foreground shadow-lg ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95", className )}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|
|
|
|
export {
|
|
ContextMenu,
|
|
ContextMenuPortal,
|
|
ContextMenuTrigger,
|
|
ContextMenuContent,
|
|
ContextMenuGroup,
|
|
ContextMenuLabel,
|
|
ContextMenuItem,
|
|
ContextMenuCheckboxItem,
|
|
ContextMenuRadioGroup,
|
|
ContextMenuRadioItem,
|
|
ContextMenuSeparator,
|
|
ContextMenuShortcut,
|
|
ContextMenuSub,
|
|
ContextMenuSubTrigger,
|
|
ContextMenuSubContent,
|
|
}
|