Skip to content

armgit / alook

Public Imported from GitHub
0

Multi-Agent Collaboration for Team and Friends

refactor: upgrade Select & Resizable to shadcn, unify sheet resize (#185)

Gener9b57d003cf71
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b9c2d567a..a1a18cde8 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -285,6 +285,9 @@ importers:
react-dom:
specifier: 19.2.6
version: 19.2.6([email protected])
+ react-resizable-panels:
+ specifier: ^4.11.2
rehype-pretty-code:
specifier: ^0.14.3
version: 0.14.3([email protected])
@@ -6273,6 +6276,12 @@ packages:
resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==}
+ resolution: {integrity: sha512-+kfFbDZ8mygc7g0vxOcDzCVGuwiIUOnILqPoUHo6/uP+Mmyx6HzZU+kj1aOPDlktXuobYbr6BtQekvJwHRX4Eg==}
+ peerDependencies:
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+
resolution: {integrity: sha512-sfWGGfavi0xr8Pg0sVsyHMAOziVYKgPLNrS7ig+ivMNb3wbCBw3KxtflsGBAwD3gYQlE/AEZsTLgToRrSCjb0Q==}
engines: {node: '>=0.10.0'}
@@ -11656,7 +11665,7 @@ snapshots:
'@next/eslint-plugin-next': 16.2.6
eslint: 9.39.4([email protected])
eslint-import-resolver-node: 0.3.10
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
eslint-plugin-jsx-a11y: 6.10.2([email protected]([email protected]))
eslint-plugin-react: 7.37.5([email protected]([email protected]))
@@ -11679,7 +11688,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@nolyfill/is-core-module': 1.0.39
debug: 4.4.3
@@ -11694,13 +11703,13 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
debug: 3.2.7
optionalDependencies:
eslint: 9.39.4([email protected])
eslint-import-resolver-node: 0.3.10
+ eslint-import-resolver-typescript: 3.10.1([email protected])([email protected]([email protected]))
transitivePeerDependencies:
- supports-color
@@ -11715,7 +11724,7 @@ snapshots:
doctrine: 2.1.0
eslint: 9.39.4([email protected])
eslint-import-resolver-node: 0.3.10
hasown: 2.0.3
is-core-module: 2.16.2
is-glob: 4.0.3
@@ -14241,6 +14250,11 @@ snapshots:
+ dependencies:
+ react: 19.2.6
+ react-dom: 19.2.6([email protected])
+
diff --git a/src/web/package.json b/src/web/package.json
index 92d38a231..dd46c7115 100644
--- a/src/web/package.json
+++ b/src/web/package.json
@@ -62,6 +62,7 @@
"postal-mime": "^2.7.4",
"react": "19.2.6",
"react-dom": "19.2.6",
+ "react-resizable-panels": "^4.11.2",
"rehype-pretty-code": "^0.14.3",
"shadcn": "^4.8.0",
"shiki": "^4.1.0",
diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/activity/page.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/activity/page.tsx
index 4f24dab4a..533ff79db 100644
--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/activity/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/activity/page.tsx
@@ -12,7 +12,7 @@ import {
Select,
SelectTrigger,
SelectValue,
- SelectPopup,
+ SelectContent,
SelectItem,
} from "@/components/ui/select";
import {
@@ -321,26 +321,26 @@ export default function AgentActivityPage() {
<SelectTrigger className="w-35 border-none bg-transparent shadow-none text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors">
<SelectValue placeholder="Status: All" />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{STATUS_OPTIONS.map((opt) => (
<SelectItem key={opt.value} value={opt.value}>
{opt.label === "All" ? "Status: All" : opt.label}
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
<Select value={typeFilter} onValueChange={(v) => updateFilter("type", v ?? "")}>
<SelectTrigger className="w-32.5 border-none bg-transparent shadow-none text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors">
<SelectValue placeholder="Type: All" />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{TYPE_OPTIONS.map((opt) => (
<SelectItem key={opt.value} value={opt.value}>
{opt.label === "All" ? "Type: All" : opt.label}
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
</div>
diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx
index ccde9b678..c140f8455 100644
--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx
@@ -15,7 +15,7 @@ import { toast } from "sonner";
import { Skeleton } from "@/components/ui/skeleton";
import { ArrowLeft, Loader2, Mail, Inbox, Send, Plus, Trash2, Forward, Reply, Paperclip, File as FileIcon, Copy, Check, ShieldAlert, ChevronDown } from "lucide-react";
import { useIsMobile } from "@/hooks/use-mobile";
-import { ResizablePanels } from "@/components/ui/resizable-panels";
+import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@/components/ui/resizable";
import { EmailBodyFrame } from "@/components/email-body-frame";
type Folder = "inbox" | "sent" | "untrust";
@@ -782,14 +782,19 @@ export default function AgentEmailPage() {
{isMobile ? (
mobileContent
) : (
- <ResizablePanels
- storageKey="email-panel-sizes"
- panels={[
- { defaultWidth: 180, minWidth: 120, maxWidth: 240, children: sidebarContent },
- { defaultWidth: 300, minWidth: 200, maxWidth: 480, children: emailListContent },
- { children: readingPaneContent, minWidth: 300 },
- ]}
- />
+ <ResizablePanelGroup orientation="horizontal">
+ <ResizablePanel defaultSize="15%" minSize="10%" maxSize="20%">
+ {sidebarContent}
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ <ResizablePanel defaultSize="30%" minSize="15%" maxSize="40%">
+ {emailListContent}
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ <ResizablePanel defaultSize="55%" minSize="25%">
+ {readingPaneContent}
+ </ResizablePanel>
+ </ResizablePanelGroup>
)}
{/* Delete confirmation dialog */}
diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/files/page.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/files/page.tsx
index 549bcd18f..f0cdc181b 100644
--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/files/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/files/page.tsx
@@ -8,7 +8,7 @@ import { requestWorkspaceBrowse } from "@/lib/api";
import { Skeleton } from "@/components/ui/skeleton";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
import { ScrollArea } from "@/components/ui/scroll-area";
-import { ResizablePanels } from "@/components/ui/resizable-panels";
+import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@/components/ui/resizable";
import { useIsMobile } from "@/hooks/use-mobile";
import { Streamdown } from "streamdown";
import type { WsMessage, WorkspaceFileEntry } from "@alook/shared";
@@ -369,22 +369,15 @@ export default function AgentFilesPage() {
return (
<div className="flex-1 flex flex-col min-h-0 overflow-hidden">
{pathBar}
- <ResizablePanels
- storageKey="agent-files-panel-sizes"
- panels={[
- {
- defaultWidth: 280,
- minWidth: 180,
- maxWidth: 480,
- children: treePanel,
- className: "overflow-hidden",
- },
- {
- children: fileViewer,
- className: "overflow-hidden flex flex-col",
- },
- ]}
- />
+ <ResizablePanelGroup orientation="horizontal">
+ <ResizablePanel defaultSize="25%" minSize="15%" maxSize="40%" className="overflow-hidden">
+ {treePanel}
+ </ResizablePanel>
+ <ResizableHandle withHandle />
+ <ResizablePanel defaultSize="75%" className="overflow-hidden flex flex-col">
+ {fileViewer}
+ </ResizablePanel>
+ </ResizablePanelGroup>
</div>
);
}
diff --git a/src/web/src/app/(app)/w/[slug]/issues/page.tsx b/src/web/src/app/(app)/w/[slug]/issues/page.tsx
index 3908832b1..ecf8f8d6d 100644
--- a/src/web/src/app/(app)/w/[slug]/issues/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/issues/page.tsx
@@ -22,7 +22,6 @@ import { IssueSheet } from "@/components/issues/issue-sheet";
import { ArtifactSheet } from "@/components/agent-chat/artifact-sheet";
import { isPreviewable, getArtifactUrl, computeArtifactVersions } from "@/components/artifact-content-renderer";
-const SIDECAR_DEFAULT_WIDTH = 448;
const COLUMNS = [
{ id: "todo", label: "Todo", statuses: ["todo"] },
@@ -249,7 +248,6 @@ export default function IssuesPage() {
const [detail, setDetail] = useState<{ issue: Issue & { trace_id?: string | null }; messages: Message[]; comments: IssueComment[]; artifacts: Artifact[] } | null>(null);
const [detailLoading, setDetailLoading] = useState(false);
const [activeTask, setActiveTask] = useState<TaskApi | null>(null);
- const [sidecarWidth, setSidecarWidth] = useState(SIDECAR_DEFAULT_WIDTH);
const [traceTasks, setTraceTasks] = useState<TraceTask[] | null>(null);
const [activeDragId, setActiveDragId] = useState<string | null>(null);
const [artifactSheetOpen, setArtifactSheetOpen] = useState(false);
@@ -805,8 +803,6 @@ export default function IssuesPage() {
defaultAgentId={recentAgentId}
slug={slug}
workspaceId={workspaceId}
- width={sidecarWidth}
- onWidthChange={setSidecarWidth}
draft={draft}
onDraftChange={setDraft}
onCreate={handleCreate}
diff --git a/src/web/src/app/(app)/w/[slug]/threads/page.tsx b/src/web/src/app/(app)/w/[slug]/threads/page.tsx
index ee5f47a8c..ff420f9e2 100644
--- a/src/web/src/app/(app)/w/[slug]/threads/page.tsx
+++ b/src/web/src/app/(app)/w/[slug]/threads/page.tsx
@@ -12,7 +12,7 @@ import {
Select,
SelectTrigger,
SelectValue,
- SelectPopup,
+ SelectContent,
SelectItem,
} from "@/components/ui/select";
import { GitBranch, RefreshCw } from "lucide-react";
@@ -303,20 +303,20 @@ export default function TracesPage() {
<SelectTrigger className="w-35 border-none bg-transparent shadow-none text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors">
<SelectValue placeholder="Status: All" />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{STATUS_OPTIONS.map((opt) => (
<SelectItem key={opt.value} value={opt.value}>
{opt.label === "All" ? "Status: All" : opt.label}
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
<Select value={agentFilter} onValueChange={(v) => updateFilter("agentId", v ?? "")}>
<SelectTrigger className="w-40 border-none bg-transparent shadow-none text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors">
{agentFilter ? agents.find((a) => a.id === agentFilter)?.name ?? agentFilter : "Agent: All"}
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
<SelectItem value="">Agent: All</SelectItem>
{agents.map((a) => (
<SelectItem key={a.id} value={a.id}>
@@ -326,21 +326,21 @@ export default function TracesPage() {
</span>
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
<Select value={channelFilter} onValueChange={(v) => updateFilter("channel", v ?? "")}>
<SelectTrigger className="w-40 border-none bg-transparent shadow-none text-xs text-muted-foreground hover:bg-muted hover:text-foreground transition-colors">
<SelectValue placeholder="Channel: All" />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
<SelectItem value="">Channel: All</SelectItem>
{channels.map((ch) => (
<SelectItem key={ch.id} value={ch.name}>
#{ch.name}
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
</div>
diff --git a/src/web/src/components/agent-chat/agent-chat-view.tsx b/src/web/src/components/agent-chat/agent-chat-view.tsx
index 81f65088a..1c5f016ef 100644
--- a/src/web/src/components/agent-chat/agent-chat-view.tsx
+++ b/src/web/src/components/agent-chat/agent-chat-view.tsx
@@ -359,7 +359,6 @@ export function AgentChatView({
const [issueDetailLoading, setIssueDetailLoading] = useState(false);
const [issueTraceTasks, setIssueTraceTasks] = useState<TraceTask[] | null>(null);
const [issueActiveTask, setIssueActiveTask] = useState<Task | null>(null);
- const [issueSidecarWidth, setIssueSidecarWidth] = useState(448);
const [pendingFiles, setPendingFiles] = useState<File[]>([]);
const [bufferedMessages, setBufferedMessages] = useState<Message[]>([]);
const [caretIndex, setCaretIndex] = useState<number | null>(null);
@@ -2237,8 +2236,6 @@ export function AgentChatView({
traceTasks={issueTraceTasks}
slug={slug}
workspaceId={workspaceId}
- width={issueSidecarWidth}
- onWidthChange={setIssueSidecarWidth}
onUpdate={async (issueId, patch) => {
try {
const updated = await updateIssue(workspaceId, issueId, patch);
diff --git a/src/web/src/components/agent-chat/artifact-sheet.tsx b/src/web/src/components/agent-chat/artifact-sheet.tsx
index e7ee4c86c..860937aae 100644
--- a/src/web/src/components/agent-chat/artifact-sheet.tsx
+++ b/src/web/src/components/agent-chat/artifact-sheet.tsx
@@ -1,6 +1,7 @@
"use client";
-import React, { useState, useEffect, useRef, useCallback } from "react";
+import React, { useState, useEffect } from "react";
+import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle";
import {
Sheet,
SheetContent,
@@ -36,8 +37,11 @@ const DEFAULT_WIDTH = 448;
export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, initialArtifact = null, versionMap, duplicateFilenames }: ArtifactSheetProps) {
const [selectedArtifact, setSelectedArtifact] = useState<Artifact | null>(null);
- const [width, setWidth] = useState(DEFAULT_WIDTH);
- const dragging = useRef(false);
+ const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
+ defaultWidth: DEFAULT_WIDTH,
+ minWidth: MIN_WIDTH,
+ maxWidthRatio: MAX_WIDTH_RATIO,
+ });
useEffect(() => {
if (open && initialArtifact) {
@@ -53,21 +57,6 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, init
}
};
- const onPointerDown = useCallback((e: React.PointerEvent) => {
- e.preventDefault();
- dragging.current = true;
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- }, []);
-
- const onPointerMove = useCallback((e: React.PointerEvent) => {
- if (!dragging.current) return;
- const maxW = window.innerWidth * MAX_WIDTH_RATIO;
- setWidth(Math.min(maxW, Math.max(MIN_WIDTH, window.innerWidth - e.clientX)));
- }, []);
-
- const onPointerUp = useCallback(() => {
- dragging.current = false;
- }, []);
return (
<Sheet open={open} onOpenChange={handleOpenChange}>
@@ -77,12 +66,7 @@ export function ArtifactSheet({ open, onOpenChange, artifacts, workspaceId, init
style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border"
>
- <div
- onPointerDown={onPointerDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
- className="hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
- />
+ <SheetResizeHandle onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} />
{selectedArtifact ? (
<>
<SheetHeader>
diff --git a/src/web/src/components/agent-chat/email-event-sheet.tsx b/src/web/src/components/agent-chat/email-event-sheet.tsx
index 5475d22de..dede9e6a2 100644
--- a/src/web/src/components/agent-chat/email-event-sheet.tsx
+++ b/src/web/src/components/agent-chat/email-event-sheet.tsx
@@ -1,6 +1,7 @@
"use client";
-import React, { useState, useEffect, useRef, useCallback } from "react";
+import React, { useState, useEffect, useRef } from "react";
+import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle";
import {
Sheet,
SheetContent,
@@ -30,8 +31,11 @@ export function EmailEventSheet({ open, onOpenChange, emailId, workspaceId }: Em
const [email, setEmail] = useState<Email | null>(null);
const [body, setBody] = useState<{ content: string; isHtml: boolean } | null>(null);
const [loading, setLoading] = useState(false);
- const [width, setWidth] = useState(DEFAULT_WIDTH);
- const dragging = useRef(false);
+ const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
+ defaultWidth: DEFAULT_WIDTH,
+ minWidth: MIN_WIDTH,
+ maxWidthRatio: MAX_WIDTH_RATIO,
+ });
const onOpenChangeRef = useRef(onOpenChange);
useEffect(() => { onOpenChangeRef.current = onOpenChange; });
@@ -66,21 +70,6 @@ export function EmailEventSheet({ open, onOpenChange, emailId, workspaceId }: Em
}
};
- const onPointerDown = useCallback((e: React.PointerEvent) => {
- e.preventDefault();
- dragging.current = true;
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- }, []);
-
- const onPointerMove = useCallback((e: React.PointerEvent) => {
- if (!dragging.current) return;
- const maxW = window.innerWidth * MAX_WIDTH_RATIO;
- setWidth(Math.min(maxW, Math.max(MIN_WIDTH, window.innerWidth - e.clientX)));
- }, []);
-
- const onPointerUp = useCallback(() => {
- dragging.current = false;
- }, []);
return (
<Sheet open={open} onOpenChange={handleOpenChange}>
@@ -90,12 +79,7 @@ export function EmailEventSheet({ open, onOpenChange, emailId, workspaceId }: Em
style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border"
>
- <div
- onPointerDown={onPointerDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
- className="hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
- />
+ <SheetResizeHandle onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} />
<SheetHeader>
<div className="flex items-center gap-2">
<Mail className="h-4 w-4 shrink-0 text-muted-foreground" />
diff --git a/src/web/src/components/agent-form-fields.tsx b/src/web/src/components/agent-form-fields.tsx
index 22d54feb4..039a7ba4f 100644
--- a/src/web/src/components/agent-form-fields.tsx
+++ b/src/web/src/components/agent-form-fields.tsx
@@ -8,7 +8,7 @@ import {
Select,
SelectTrigger,
SelectValue,
- SelectPopup,
+ SelectContent,
SelectItem,
} from "@/components/ui/select";
import {
@@ -798,13 +798,13 @@ export function AgentAccessTab({
<SelectTrigger className="flex-1 text-xs">
<SelectValue placeholder="Add a member..." />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{availableMembers.map((m) => (
<SelectItem key={m.user_id} value={m.user_id}>
{m.name || m.email}
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
</div>
) : (
diff --git a/src/web/src/components/calendar/calendar-event-sheet.tsx b/src/web/src/components/calendar/calendar-event-sheet.tsx
index 21540d56b..9596dce85 100644
--- a/src/web/src/components/calendar/calendar-event-sheet.tsx
+++ b/src/web/src/components/calendar/calendar-event-sheet.tsx
@@ -1,6 +1,6 @@
"use client";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
import { toast } from "sonner";
import { getCalendarEvent } from "@/lib/api";
import {
@@ -20,6 +20,13 @@ import {
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { MarkdownEditor } from "@/components/ui/markdown-editor";
+import {
+ Select,
+ SelectTrigger,
+ SelectValue,
+ SelectContent,
+ SelectItem,
+} from "@/components/ui/select";
import {
CalendarDays,
CalendarOff,
@@ -36,6 +43,7 @@ import type {
} from "@alook/shared";
import { AutoResizeTextarea } from "@/components/ui/auto-resize-textarea";
import { Kbd } from "@/components/ui/kbd";
+import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle";
import { CalendarDatePicker } from "./calendar-date-picker";
import { CalendarTimePicker } from "./calendar-time-picker";
import {
@@ -120,10 +128,6 @@ function normalizedDescription(value: string | null | undefined): string {
const GHOST_CONTROL =
"h-7 border-0 bg-transparent px-1.5 text-sm text-foreground hover:bg-accent transition-colors -ml-1.5";
-const GHOST_SELECT = cn(
- GHOST_CONTROL,
- "rounded-md outline-none focus-visible:bg-accent focus-visible:ring-0 appearance-none pr-6"
-);
const TIME_INPUT =
"h-7 w-12 border-0 bg-transparent px-0.5 text-sm tabular-nums text-foreground rounded-md outline-none focus-visible:ring-0";
@@ -289,24 +293,11 @@ export function CalendarEventSheet({
};
// --- Resizable drag handle ---
- const [sheetWidth, setSheetWidth] = useState(DRAG_DEFAULT_WIDTH);
- const draggingRef = useRef(false);
-
- const onDragPointerDown = useCallback((e: React.PointerEvent) => {
- e.preventDefault();
- draggingRef.current = true;
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- }, []);
-
- const onDragPointerMove = useCallback((e: React.PointerEvent) => {
- if (!draggingRef.current) return;
- const maxW = window.innerWidth * DRAG_MAX_WIDTH_RATIO;
- setSheetWidth(Math.min(maxW, Math.max(DRAG_MIN_WIDTH, window.innerWidth - e.clientX)));
- }, []);
-
- const onDragPointerUp = useCallback(() => {
- draggingRef.current = false;
- }, []);
+ const { width: sheetWidth, onPointerDown: onDragPointerDown, onPointerMove: onDragPointerMove, onPointerUp: onDragPointerUp } = useSheetResize({
+ defaultWidth: DRAG_DEFAULT_WIDTH,
+ minWidth: DRAG_MIN_WIDTH,
+ maxWidthRatio: DRAG_MAX_WIDTH_RATIO,
+ });
const mode = resolvedEvent ? "edit" : "create";
@@ -602,19 +593,22 @@ export function CalendarEventSheet({
) : (
<div className="flex flex-col gap-1.5">
<PropertyRow icon={<User className="size-3.5" />}>
- <select
- aria-label="Agent"
+ <Select
value={agentId}
- onChange={(e) => setAgentId(e.target.value)}
- className={GHOST_SELECT}
+ onValueChange={(val) => { if (val) setAgentId(val); }}
+ items={agents.map((a) => ({ value: a.id, label: a.name }))}
>
- {agents.length === 0 && <option value="">No agents</option>}
- {agents.map((a) => (
- <option key={a.id} value={a.id}>
- {a.name}
- </option>
- ))}
- </select>
+ <SelectTrigger className="h-7 w-auto border-none bg-transparent px-1.5 shadow-none text-sm text-foreground hover:bg-accent transition-colors rounded-md">
+ <SelectValue placeholder={agents.length === 0 ? "No agents" : "Select agent"} />
+ </SelectTrigger>
+ <SelectContent>
+ {agents.map((a) => (
+ <SelectItem key={a.id} value={a.id}>
+ {a.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
</PropertyRow>
<PropertyRow icon={<CalendarDays className="size-3.5" />}>
@@ -653,18 +647,16 @@ export function CalendarEventSheet({
<PropertyRow icon={<RepeatIcon className="size-3.5" />}>
{!repeatEnabled ? (
- <select
- aria-label="Repeat"
+ <Select
value=""
- onChange={(e) => {
- const v = e.target.value;
- if (!v) return;
- if (v === "__custom__") {
+ onValueChange={(val) => {
+ if (!val) return;
+ if (val === "__custom__") {
setRepeatEnabled(true);
setRepeatCount("1");
setRepeatUnit("day");
} else {
- const parsed = parseRepeatInterval(v);
+ const parsed = parseRepeatInterval(val);
if (parsed) {
setRepeatEnabled(true);
setRepeatCount(String(parsed.count));
@@ -672,16 +664,25 @@ export function CalendarEventSheet({
}
}
}}
- className={GHOST_SELECT}
+ items={[
+ { value: "", label: "Does not repeat" },
+ ...PRESET_INTERVALS.map((o) => ({ value: o.value, label: o.label })),
+ { value: "__custom__", label: "Custom…" },
+ ]}
>
- <option value="">Does not repeat</option>
- {PRESET_INTERVALS.map((o) => (
- <option key={o.value} value={o.value}>
- {o.label}
- </option>
- ))}
- <option value="__custom__">Custom…</option>
- </select>
+ <SelectTrigger className="h-7 w-auto border-none bg-transparent px-1.5 shadow-none text-sm text-foreground hover:bg-accent transition-colors rounded-md">
+ <SelectValue placeholder="Does not repeat" />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="">Does not repeat</SelectItem>
+ {PRESET_INTERVALS.map((o) => (
+ <SelectItem key={o.value} value={o.value}>
+ {o.label}
+ </SelectItem>
+ ))}
+ <SelectItem value="__custom__">Custom…</SelectItem>
+ </SelectContent>
+ </Select>
) : (
<div className="-ml-1.5 flex items-center gap-0.5">
<span className="px-1 text-sm text-foreground">Every</span>
@@ -701,20 +702,22 @@ export function CalendarEventSheet({
style={{ width: `${Math.max(1, repeatCount.length) + 1.5}ch` }}
className="h-7 shrink-0 border-0 bg-transparent px-0 text-center text-sm tabular-nums text-foreground rounded-md outline-none hover:bg-accent focus-visible:bg-accent focus-visible:ring-0 transition-colors"
/>
- <select
- aria-label="Repeat unit"
+ <Select
value={repeatUnit}
- onChange={(e) => {
- if (isValidUnit(e.target.value)) setRepeatUnit(e.target.value);
- }}
- className="h-7 border-0 bg-transparent px-1 text-center text-sm text-foreground rounded-md outline-none appearance-none hover:bg-accent focus-visible:bg-accent focus-visible:ring-0 transition-colors"
+ onValueChange={(val) => { if (val && isValidUnit(val)) setRepeatUnit(val); }}
+ items={REPEAT_UNITS.map((u) => ({ value: u, label: unitLabel(u, parseInt(repeatCount, 10) || 1) }))}
>
- {REPEAT_UNITS.map((u) => (
- <option key={u} value={u}>
- {unitLabel(u, parseInt(repeatCount, 10) || 1)}
- </option>
- ))}
- </select>
+ <SelectTrigger className="h-7 w-auto border-none bg-transparent px-1 shadow-none text-sm text-foreground hover:bg-accent transition-colors rounded-md">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {REPEAT_UNITS.map((u) => (
+ <SelectItem key={u} value={u}>
+ {unitLabel(u, parseInt(repeatCount, 10) || 1)}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
<button
type="button"
aria-label="Remove repeat"
@@ -770,12 +773,7 @@ export function CalendarEventSheet({
);
const dragHandle = (
- <div
- onPointerDown={onDragPointerDown}
- onPointerMove={onDragPointerMove}
- onPointerUp={onDragPointerUp}
- className="hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
- />
+ <SheetResizeHandle onPointerDown={onDragPointerDown} onPointerMove={onDragPointerMove} onPointerUp={onDragPointerUp} />
);
const sheetBody = fetchLoading ? (
diff --git a/src/web/src/components/canvas/agent-chat-sheet.tsx b/src/web/src/components/canvas/agent-chat-sheet.tsx
index abe30d58c..84ded5250 100644
--- a/src/web/src/components/canvas/agent-chat-sheet.tsx
+++ b/src/web/src/components/canvas/agent-chat-sheet.tsx
@@ -1,6 +1,7 @@
"use client";
-import React, { useState, useCallback } from "react";
+import React from "react";
+import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle";
import { useRouter } from "next/navigation";
import {
Sheet,
@@ -17,7 +18,6 @@ import { ChannelBar } from "@/components/channel-bar";
import { AgentChatView } from "@/components/agent-chat/agent-chat-view";
import { ArrowUpRight, XIcon } from "lucide-react";
import { Button, buttonVariants } from "@/components/ui/button";
-import { ResizeHandle } from "@/components/ui/resizable-panels";
import { Tooltip, TooltipTrigger, TooltipContent } from "@/components/ui/tooltip";
interface AgentChatSheetProps {
@@ -37,14 +37,11 @@ export function AgentChatSheet({ open, onOpenChange, agent, targetConvId, scroll
const { runtimes, activeTaskCounts } = useAgentContext();
const { slug } = useWorkspace();
const router = useRouter();
- const [width, setWidth] = useState(DEFAULT_WIDTH);
-
- const handleResize = useCallback((delta: number) => {
- setWidth((w) => {
- const maxW = window.innerWidth * MAX_WIDTH_RATIO;
- return Math.min(maxW, Math.max(MIN_WIDTH, w + delta));
- });
- }, []);
+ const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
+ defaultWidth: DEFAULT_WIDTH,
+ minWidth: MIN_WIDTH,
+ maxWidthRatio: MAX_WIDTH_RATIO,
+ });
return (
<Sheet open={open} onOpenChange={onOpenChange}>
@@ -54,12 +51,7 @@ export function AgentChatSheet({ open, onOpenChange, agent, targetConvId, scroll
style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
className="data-[side=right]:sm:inset-y-2 data-[side=right]:sm:right-2 data-[side=right]:sm:h-auto data-[side=right]:sm:rounded-xl data-[side=right]:sm:border flex flex-col"
>
- {/* Resize handle */}
- <ResizeHandle
- onResize={handleResize}
- direction="left"
- className="hidden sm:block absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
- />
+ <SheetResizeHandle onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} />
{/* Top-right action buttons */}
<div className="absolute top-3 right-3 z-10 flex items-center gap-1">
diff --git a/src/web/src/components/issues/issue-sheet.tsx b/src/web/src/components/issues/issue-sheet.tsx
index 4a7709894..70db99a9c 100644
--- a/src/web/src/components/issues/issue-sheet.tsx
+++ b/src/web/src/components/issues/issue-sheet.tsx
@@ -12,7 +12,15 @@ import {
import { Button } from "@/components/ui/button";
import { MarkdownEditor } from "@/components/ui/markdown-editor";
import { Skeleton } from "@/components/ui/skeleton";
+import { useSheetResize, SheetResizeHandle } from "@/components/ui/sheet-resize-handle";
import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
+import {
+ Select,
+ SelectTrigger,
+ SelectValue,
+ SelectContent,
+ SelectItem,
+} from "@/components/ui/select";
import {
ArrowUp,
Check,
@@ -47,10 +55,6 @@ const MAX_WIDTH_RATIO = 0.8;
const GHOST_CONTROL =
"h-7 border-0 bg-transparent px-1.5 text-xs text-foreground hover:bg-accent transition-colors -ml-1.5";
-const GHOST_SELECT = cn(
- GHOST_CONTROL,
- "rounded-md outline-none focus-visible:bg-accent focus-visible:ring-0 appearance-none pr-6"
-);
const SELECTOR_STATUSES = ["todo", "in_progress", "review", "done"] as const;
@@ -197,8 +201,6 @@ export interface IssueSheetProps {
defaultAgentId?: string;
slug: string;
workspaceId: string;
- width?: number;
- onWidthChange?: (width: number) => void;
draft?: { title: string; description: string; agentId: string };
onDraftChange?: (draft: { title: string; description: string; agentId: string }) => void;
onCreate?: (values: { agent_id?: string; title: string; description: string }) => Promise<void>;
@@ -222,8 +224,6 @@ export function IssueSheet({
defaultAgentId,
slug,
workspaceId,
- width = 448,
- onWidthChange,
draft,
onDraftChange,
onCreate,
@@ -247,7 +247,6 @@ export function IssueSheet({
const descriptionRef = useRef<HTMLDivElement>(null);
const timelineRef = useRef<HTMLDivElement>(null);
- const dragging = useRef(false);
const isTaskActive = activeTask && !["completed", "failed", "cancelled", "superseded"].includes(activeTask.status);
const hasActiveTraceTasks = traceTasks?.some(t => ["queued", "dispatched", "running"].includes(t.status)) ?? false;
@@ -327,22 +326,11 @@ export function IssueSheet({
}, [open, mode, flushAutoSave]);
// --- Drag handle ---
- const onPointerDown = useCallback((e: React.PointerEvent) => {
- e.preventDefault();
- dragging.current = true;
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- }, []);
-
- const onPointerMove = useCallback((e: React.PointerEvent) => {
- if (!dragging.current) return;
- const maxW = window.innerWidth * MAX_WIDTH_RATIO;
- const newWidth = Math.min(maxW, Math.max(MIN_WIDTH, window.innerWidth - e.clientX));
- onWidthChange?.(newWidth);
- }, [onWidthChange]);
-
- const onPointerUp = useCallback(() => {
- dragging.current = false;
- }, []);
+ const { width, onPointerDown, onPointerMove, onPointerUp } = useSheetResize({
+ defaultWidth: 448,
+ minWidth: MIN_WIDTH,
+ maxWidthRatio: MAX_WIDTH_RATIO,
+ });
// --- Handlers ---
const handleCreate = async () => {
@@ -585,18 +573,23 @@ export function IssueSheet({
{/* Status row (detail mode only) */}
{mode === "detail" && issue && (
<PropertyRow icon={<CircleDot className="size-3.5" />}>
- <select
+ <Select
value={issue.status}
- onChange={(e) => handleStatusChange(e.target.value)}
- className={GHOST_SELECT}
+ onValueChange={(val) => { if (val) handleStatusChange(val); }}
+ items={(isTodoDraft ? (["todo", "done"] as const) : SELECTOR_STATUSES).map((s) => ({ value: s, label: statusLabel(s) }))}
>
- {(isTodoDraft
- ? (["todo", "done"] as const)
- : SELECTOR_STATUSES
- ).map((s) => (
- <option key={s} value={s}>{statusLabel(s)}</option>
- ))}
- </select>
+ <SelectTrigger className="h-7 w-auto border-none bg-transparent px-1.5 shadow-none text-xs text-foreground hover:bg-accent transition-colors rounded-md">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {(isTodoDraft
+ ? (["todo", "done"] as const)
+ : SELECTOR_STATUSES
+ ).map((s) => (
+ <SelectItem key={s} value={s}>{statusLabel(s)}</SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
</PropertyRow>
)}
@@ -662,13 +655,7 @@ export function IssueSheet({
style={{ width: `min(${width}px, 100vw)`, maxWidth: "none" }}
>
{/* Resize drag handle */}
- <div
- onPointerDown={onPointerDown}
- onPointerMove={onPointerMove}
- onPointerUp={onPointerUp}
- onLostPointerCapture={onPointerUp}
- className="hidden sm:block absolute -left-px top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors rounded-l-xl"
- />
+ <SheetResizeHandle onPointerDown={onPointerDown} onPointerMove={onPointerMove} onPointerUp={onPointerUp} />
{/* Mobile close button */}
<SheetClose
diff --git a/src/web/src/components/runtime-select.tsx b/src/web/src/components/runtime-select.tsx
index 0036a3419..082807a61 100644
--- a/src/web/src/components/runtime-select.tsx
+++ b/src/web/src/components/runtime-select.tsx
@@ -7,10 +7,10 @@ import {
Select,
SelectTrigger,
SelectValue,
- SelectPopup,
+ SelectContent,
SelectItem,
SelectGroup,
- SelectGroupLabel,
+ SelectLabel,
} from "@/components/ui/select";
interface RuntimeSelectProps {
@@ -75,12 +75,12 @@ export function RuntimeSelect({
<SelectTrigger {...triggerProps}>
<SelectValue placeholder={getPlaceholder(runtimes)} />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{Array.from(groups.entries()).map(([key, group]) => (
<SelectGroup key={key}>
- <SelectGroupLabel className="truncate">
+ <SelectLabel className="truncate">
{group.label}
- </SelectGroupLabel>
+ </SelectLabel>
{group.runtimes.map((rt) => (
<SelectItem
key={rt.id}
@@ -98,7 +98,7 @@ export function RuntimeSelect({
))}
</SelectGroup>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
);
}
diff --git a/src/web/src/components/studio-onboarding/ai-tool-step.tsx b/src/web/src/components/studio-onboarding/ai-tool-step.tsx
index 416dab94f..ca4dac00d 100644
--- a/src/web/src/components/studio-onboarding/ai-tool-step.tsx
+++ b/src/web/src/components/studio-onboarding/ai-tool-step.tsx
@@ -5,7 +5,7 @@ import {
Select,
SelectTrigger,
SelectValue,
- SelectPopup,
+ SelectContent,
SelectItem,
} from "@/components/ui/select";
import { ProviderLogo } from "@/components/provider-logo";
@@ -37,7 +37,7 @@ export function AiToolStep({
<SelectTrigger className="h-8 text-xs">
<SelectValue />
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{runtimes.map((rt) => (
<SelectItem key={rt.id} value={rt.id}>
<div className="flex items-center gap-2">
@@ -46,7 +46,7 @@ export function AiToolStep({
</div>
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
</div>
</div>
diff --git a/src/web/src/components/studio-onboarding/team-preview.tsx b/src/web/src/components/studio-onboarding/team-preview.tsx
index 54b519fa0..a79133b86 100644
--- a/src/web/src/components/studio-onboarding/team-preview.tsx
+++ b/src/web/src/components/studio-onboarding/team-preview.tsx
@@ -8,7 +8,7 @@ import { AvatarRenderer, parseAvatarUrl } from "@/components/avatar";
import {
Select,
SelectTrigger,
- SelectPopup,
+ SelectContent,
SelectItem,
} from "@/components/ui/select";
import { ProviderLogo } from "@/components/provider-logo";
@@ -106,13 +106,13 @@ export function TeamPreview({
<span className="truncate">{selectedRt?.provider || selectedRt?.runtime_mode || "Select"}</span>
</div>
</SelectTrigger>
- <SelectPopup>
+ <SelectContent>
{runtimes.map((rt) => (
<SelectItem key={rt.id} value={rt.id}>
{rt.provider || rt.runtime_mode}
</SelectItem>
))}
- </SelectPopup>
+ </SelectContent>
</Select>
</div>
);
diff --git a/src/web/src/components/ui/resizable-panels.tsx b/src/web/src/components/ui/resizable-panels.tsx
deleted file mode 100644
index 3040bc4dd..000000000
--- a/src/web/src/components/ui/resizable-panels.tsx
+++ /dev/null
@@ -1,179 +0,0 @@
-"use client";
-
-import {
- useRef,
- useCallback,
- type ReactNode,
- type CSSProperties,
-} from "react";
-import { useLocalStorage } from "@/hooks/use-local-storage";
-
-export interface PanelConfig {
- /** Default width in px. Omit (or set 0) for the flex panel. */
- defaultWidth?: number;
- minWidth?: number;
- maxWidth?: number;
- children: ReactNode;
- className?: string;
-}
-
-interface ResizablePanelsProps {
- panels: PanelConfig[];
- /** localStorage key for persisting widths */
- storageKey: string;
-}
-
-export function ResizablePanels({ panels, storageKey }: ResizablePanelsProps) {
- const defaults = panels.map((p) => p.defaultWidth ?? 0);
- const [widths, setWidths] = useLocalStorage<number[]>(storageKey, defaults);
-
- // Ensure stored array length matches panels
- const safeWidths =
- widths.length === panels.length ? widths : defaults;
-
- const dragging = useRef<{
- index: number;
- startX: number;
- startLeft: number;
- startRight: number;
- } | null>(null);
-
- const handlePointerDown = useCallback(
- (dividerIndex: number, e: React.PointerEvent) => {
- e.preventDefault();
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- dragging.current = {
- index: dividerIndex,
- startX: e.clientX,
- startLeft: safeWidths[dividerIndex],
- startRight: safeWidths[dividerIndex + 1],
- };
- },
- [safeWidths]
- );
-
- const handlePointerMove = useCallback(
- (e: React.PointerEvent) => {
- if (!dragging.current) return;
- const { index, startX, startLeft, startRight } = dragging.current;
- const delta = e.clientX - startX;
-
- const leftPanel = panels[index];
- const rightPanel = panels[index + 1];
- const minL = leftPanel.minWidth ?? 60;
- const maxL = leftPanel.maxWidth ?? Infinity;
- const minR = rightPanel.minWidth ?? 60;
- const maxR = rightPanel.maxWidth ?? Infinity;
-
- // If right panel is the flex panel (defaultWidth 0), only resize left
- if ((rightPanel.defaultWidth ?? 0) === 0) {
- const newLeft = Math.max(minL, Math.min(maxL, startLeft + delta));
- setWidths((prev) => {
- const next = [...(prev.length === panels.length ? prev : defaults)];
- next[index] = newLeft;
- return next;
- });
- return;
- }
-
- // Both fixed panels — redistribute
- let newLeft = startLeft + delta;
- let newRight = startRight - delta;
-
- if (newLeft < minL) { newLeft = minL; newRight = startLeft + startRight - minL; }
- if (newLeft > maxL) { newLeft = maxL; newRight = startLeft + startRight - maxL; }
- if (newRight < minR) { newRight = minR; newLeft = startLeft + startRight - minR; }
- if (newRight > maxR) { newRight = maxR; newLeft = startLeft + startRight - maxR; }
-
- setWidths((prev) => {
- const next = [...(prev.length === panels.length ? prev : defaults)];
- next[index] = newLeft;
- next[index + 1] = newRight;
- return next;
- });
- },
- [panels, defaults, setWidths]
- );
-
- const handlePointerUp = useCallback(() => {
- dragging.current = null;
- }, []);
-
- return (
- <div
- className="flex flex-1 min-h-0"
- onPointerMove={handlePointerMove}
- onPointerUp={handlePointerUp}
- >
- {panels.map((panel, i) => {
- const isFlex = (panel.defaultWidth ?? 0) === 0;
- const style: CSSProperties = isFlex
- ? { flex: 1, minWidth: 0, overflow: "auto" }
- : { width: safeWidths[i], flexShrink: 0 };
-
- return (
- <div key={i} className="flex min-h-0" style={isFlex ? { flex: 1, minWidth: 0 } : undefined}>
- <div style={style} className={panel.className}>
- {panel.children}
- </div>
- {i < panels.length - 1 && (
- <div
- onPointerDown={(e) => handlePointerDown(i, e)}
- className="relative w-0 shrink-0 cursor-col-resize group z-10"
- >
- {/* Visible line */}
- <div className="absolute inset-y-0 -left-px w-px bg-border/40 group-hover:bg-border transition-colors" />
- {/* Wider hit area */}
- <div className="absolute inset-y-0 -left-1.5 w-3" />
- </div>
- )}
- </div>
- );
- })}
- </div>
- );
-}
-
-export interface ResizeHandleProps {
- onResize: (delta: number) => void;
- className?: string;
- direction?: "left" | "right";
-}
-
-export function ResizeHandle({ onResize, className, direction = "right" }: ResizeHandleProps) {
- const dragging = useRef(false);
- const startX = useRef(0);
-
- const handlePointerDown = useCallback(
- (e: React.PointerEvent) => {
- e.preventDefault();
- (e.target as HTMLElement).setPointerCapture(e.pointerId);
- dragging.current = true;
- startX.current = e.clientX;
- },
- []
- );
-
- const handlePointerMove = useCallback(
- (e: React.PointerEvent) => {
- if (!dragging.current) return;
- const delta = e.clientX - startX.current;
- startX.current = e.clientX;
- onResize(direction === "left" ? -delta : delta);
- },
- [onResize, direction]
- );
-
- const handlePointerUp = useCallback(() => {
- dragging.current = false;
- }, []);
-
- return (
- <div
- onPointerDown={handlePointerDown}
- onPointerMove={handlePointerMove}
- onPointerUp={handlePointerUp}
- className={className ?? "absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 hover:bg-primary/20 active:bg-primary/30 transition-colors"}
- />
- );
-}
diff --git a/src/web/src/components/ui/resizable.tsx b/src/web/src/components/ui/resizable.tsx
new file mode 100644
index 000000000..c9e767a94
--- /dev/null
+++ b/src/web/src/components/ui/resizable.tsx
@@ -0,0 +1,50 @@
+"use client"
+
+import * as ResizablePrimitive from "react-resizable-panels"
+
+import { cn } from "@/lib/utils"
+
+function ResizablePanelGroup({
+ className,
+ ...props
+}: ResizablePrimitive.GroupProps) {
+ return (
+ <ResizablePrimitive.Group
+ data-slot="resizable-panel-group"
+ className={cn(
+ "flex h-full w-full aria-[orientation=vertical]:flex-col",
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+function ResizablePanel({ ...props }: ResizablePrimitive.PanelProps) {
+ return <ResizablePrimitive.Panel data-slot="resizable-panel" {...props} />
+}
+
+function ResizableHandle({
+ withHandle,
+ className,
+ ...props
+}: ResizablePrimitive.SeparatorProps & {
+ withHandle?: boolean
+}) {
+ return (
+ <ResizablePrimitive.Separator
+ data-slot="resizable-handle"
+ className={cn(
+ "relative flex w-px items-center justify-center bg-border ring-offset-background after:absolute after:inset-y-0 after:left-1/2 after:w-1 after:-translate-x-1/2 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline-hidden aria-[orientation=horizontal]:h-px aria-[orientation=horizontal]:w-full aria-[orientation=horizontal]:after:left-0 aria-[orientation=horizontal]:after:h-1 aria-[orientation=horizontal]:after:w-full aria-[orientation=horizontal]:after:translate-x-0 aria-[orientation=horizontal]:after:-translate-y-1/2 [&[aria-orientation=horizontal]>div]:rotate-90",
+ className
+ )}
+ {...props}
+ >
+ {withHandle && (
+ <div className="z-10 flex h-6 w-1 shrink-0 rounded-lg bg-border" />
+ )}
+ </ResizablePrimitive.Separator>
+ )
+}
+
+export { ResizableHandle, ResizablePanel, ResizablePanelGroup }
diff --git a/src/web/src/components/ui/select.tsx b/src/web/src/components/ui/select.tsx
index 4382201c4..e8021f5f2 100644
--- a/src/web/src/components/ui/select.tsx
+++ b/src/web/src/components/ui/select.tsx
@@ -2,138 +2,200 @@
import * as React from "react"
import { Select as SelectPrimitive } from "@base-ui/react/select"
+
import { cn } from "@/lib/utils"
-import { ChevronDownIcon, CheckIcon } from "lucide-react"
+import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"
-function Select({
- modal = false,
- ...props
-}: SelectPrimitive.Root.Props<string>) {
- return <SelectPrimitive.Root data-slot="select" modal={modal} {...props} />
+const Select = SelectPrimitive.Root
+
+function SelectGroup({ className, ...props }: SelectPrimitive.Group.Props) {
+ return (
+ <SelectPrimitive.Group
+ data-slot="select-group"
+ className={cn("scroll-my-1 p-1", className)}
+ {...props}
+ />
+ )
+}
+
+function SelectValue({ className, ...props }: SelectPrimitive.Value.Props) {
+ return (
+ <SelectPrimitive.Value
+ data-slot="select-value"
+ className={cn("flex flex-1 text-left", className)}
+ {...props}
+ />
+ )
}
function SelectTrigger({
className,
+ size = "default",
children,
- hideIcon = false,
...props
-}: SelectPrimitive.Trigger.Props & { hideIcon?: boolean }) {
+}: SelectPrimitive.Trigger.Props & {
+ size?: "sm" | "default"
+}) {
return (
<SelectPrimitive.Trigger
data-slot="select-trigger"
+ data-size={size}
className={cn(
- "flex h-8 w-full items-center justify-between gap-2 overflow-hidden rounded-lg border border-input bg-transparent px-3 py-1 text-sm transition-colors outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 data-placeholder:text-muted-foreground [&>*:first-child]:truncate",
+ "flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
>
{children}
- {!hideIcon && (
- <SelectPrimitive.Icon className="shrink-0">
- <ChevronDownIcon className="size-3.5 opacity-50" />
- </SelectPrimitive.Icon>
- )}
+ <SelectPrimitive.Icon
+ render={
+ <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />
+ }
+ />
</SelectPrimitive.Trigger>
)
}
-function SelectValue({ ...props }: SelectPrimitive.Value.Props) {
- return <SelectPrimitive.Value data-slot="select-value" {...props} />
-}
-
-function SelectPortal({ ...props }: SelectPrimitive.Portal.Props) {
- return <SelectPrimitive.Portal data-slot="select-portal" {...props} />
-}
-
-function SelectPopup({
+function SelectContent({
className,
children,
- portal = true,
- alignItemWithTrigger,
- side,
- align,
- sideOffset,
+ side = "bottom",
+ sideOffset = 4,
+ align = "center",
+ alignOffset = 0,
+ alignItemWithTrigger = true,
...props
-}: SelectPrimitive.Popup.Props & { portal?: boolean; alignItemWithTrigger?: boolean; side?: "top" | "bottom" | "left" | "right"; align?: "start" | "center" | "end"; sideOffset?: number }) {
- const content = (
- <SelectPrimitive.Positioner alignItemWithTrigger={alignItemWithTrigger} side={side} align={align} sideOffset={sideOffset}>
- <SelectPrimitive.Popup
- data-slot="select-popup"
- className={cn(
- "z-50 min-w-(--anchor-width) overflow-hidden rounded-lg border bg-popover p-1 text-popover-foreground shadow-md outline-none 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}
+}: SelectPrimitive.Popup.Props &
+ Pick<
+ SelectPrimitive.Positioner.Props,
+ "align" | "alignOffset" | "side" | "sideOffset" | "alignItemWithTrigger"
+ >) {
+ return (
+ <SelectPrimitive.Portal>
+ <SelectPrimitive.Positioner
+ side={side}
+ sideOffset={sideOffset}
+ align={align}
+ alignOffset={alignOffset}
+ alignItemWithTrigger={alignItemWithTrigger}
+ className="isolate z-50"
>
- {children}
- </SelectPrimitive.Popup>
- </SelectPrimitive.Positioner>
+ <SelectPrimitive.Popup
+ data-slot="select-content"
+ data-align-trigger={alignItemWithTrigger}
+ className={cn("relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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}
+ >
+ <SelectScrollUpButton />
+ <SelectPrimitive.List>{children}</SelectPrimitive.List>
+ <SelectScrollDownButton />
+ </SelectPrimitive.Popup>
+ </SelectPrimitive.Positioner>
+ </SelectPrimitive.Portal>
)
+}
- if (!portal) {
- return content
- }
-
- return <SelectPortal>{content}</SelectPortal>
+function SelectLabel({
+ className,
+ ...props
+}: SelectPrimitive.GroupLabel.Props) {
+ return (
+ <SelectPrimitive.GroupLabel
+ data-slot="select-label"
+ className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}
+ {...props}
+ />
+ )
}
function SelectItem({
className,
children,
...props
-}: SelectPrimitive.Item.Props & { className?: string }) {
+}: SelectPrimitive.Item.Props) {
return (
<SelectPrimitive.Item
data-slot="select-item"
className={cn(
- "relative flex w-full cursor-default select-none items-center rounded-md py-1.5 pl-2 pr-8 text-sm outline-none transition-colors data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
+ "relative flex w-full 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 not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
className
)}
{...props}
>
- <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
- <SelectPrimitive.ItemIndicator className="absolute right-2">
- <CheckIcon className="size-3.5" />
+ <SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">
+ {children}
+ </SelectPrimitive.ItemText>
+ <SelectPrimitive.ItemIndicator
+ render={
+ <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
+ }
+ >
+ <CheckIcon className="pointer-events-none" />
</SelectPrimitive.ItemIndicator>
</SelectPrimitive.Item>
)
}
-function SelectGroup({
+function SelectSeparator({
className,
...props
-}: React.ComponentProps<typeof SelectPrimitive.Group>) {
+}: SelectPrimitive.Separator.Props) {
return (
- <SelectPrimitive.Group
- data-slot="select-group"
- className={cn("", className)}
+ <SelectPrimitive.Separator
+ data-slot="select-separator"
+ className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}
{...props}
/>
)
}
-function SelectGroupLabel({
+function SelectScrollUpButton({
className,
...props
-}: React.ComponentProps<typeof SelectPrimitive.GroupLabel>) {
+}: React.ComponentProps<typeof SelectPrimitive.ScrollUpArrow>) {
return (
- <SelectPrimitive.GroupLabel
- data-slot="select-group-label"
+ <SelectPrimitive.ScrollUpArrow
+ data-slot="select-scroll-up-button"
className={cn(
- "px-2 py-1.5 text-[11px] font-medium text-muted-foreground uppercase tracking-wider",
+ "top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
className
)}
{...props}
- />
+ >
+ <ChevronUpIcon
+ />
+ </SelectPrimitive.ScrollUpArrow>
+ )
+}
+
+function SelectScrollDownButton({
+ className,
+ ...props
+}: React.ComponentProps<typeof SelectPrimitive.ScrollDownArrow>) {
+ return (
+ <SelectPrimitive.ScrollDownArrow
+ data-slot="select-scroll-down-button"
+ className={cn(
+ "bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",
+ className
+ )}
+ {...props}
+ >
+ <ChevronDownIcon
+ />
+ </SelectPrimitive.ScrollDownArrow>
)
}
export {
Select,
+ SelectContent,
+ SelectGroup,
+ SelectItem,
+ SelectLabel,
+ SelectScrollDownButton,
+ SelectScrollUpButton,
+ SelectSeparator,
SelectTrigger,
SelectValue,
- SelectPopup,
- SelectItem,
- SelectGroup,
- SelectGroupLabel,
}
diff --git a/src/web/src/components/ui/sheet-resize-handle.tsx b/src/web/src/components/ui/sheet-resize-handle.tsx
new file mode 100644
index 000000000..57153e361
--- /dev/null
+++ b/src/web/src/components/ui/sheet-resize-handle.tsx
@@ -0,0 +1,72 @@
+"use client";
+
+import { useCallback, useRef, useState } from "react";
+import { cn } from "@/lib/utils";
+
+const DEFAULT_MIN_WIDTH = 320;
+const DEFAULT_MAX_WIDTH_RATIO = 0.8;
+const DEFAULT_WIDTH = 480;
+
+export function useSheetResize({
+ defaultWidth = DEFAULT_WIDTH,
+ minWidth = DEFAULT_MIN_WIDTH,
+ maxWidthRatio = DEFAULT_MAX_WIDTH_RATIO,
+}: {
+ defaultWidth?: number;
+ minWidth?: number;
+ maxWidthRatio?: number;
+} = {}) {
+ const [width, setWidth] = useState(defaultWidth);
+ const dragging = useRef(false);
+
+ const onPointerDown = useCallback((e: React.PointerEvent) => {
+ e.preventDefault();
+ (e.target as HTMLElement).setPointerCapture(e.pointerId);
+ dragging.current = true;
+ }, []);
+
+ const onPointerMove = useCallback(
+ (e: React.PointerEvent) => {
+ if (!dragging.current) return;
+ const maxW = window.innerWidth * maxWidthRatio;
+ setWidth(Math.min(maxW, Math.max(minWidth, window.innerWidth - e.clientX)));
+ },
+ [minWidth, maxWidthRatio]
+ );
+
+ const onPointerUp = useCallback((e: React.PointerEvent) => {
+ dragging.current = false;
+ (e.target as HTMLElement).releasePointerCapture(e.pointerId);
+ }, []);
+
+ return { width, onPointerDown, onPointerMove, onPointerUp };
+}
+
+export function SheetResizeHandle({
+ onPointerDown,
+ onPointerMove,
+ onPointerUp,
+ className,
+ withHandle = true,
+}: {
+ onPointerDown: (e: React.PointerEvent) => void;
+ onPointerMove: (e: React.PointerEvent) => void;
+ onPointerUp: (e: React.PointerEvent) => void;
+ className?: string;
+ withHandle?: boolean;
+}) {
+ return (
+ <div
+ onPointerDown={onPointerDown}
+ onPointerMove={onPointerMove}
+ onPointerUp={onPointerUp}
+ onLostPointerCapture={onPointerUp}
+ className={cn(
+ "hidden sm:flex absolute left-0 top-0 bottom-0 w-1.5 cursor-col-resize z-10 items-center justify-center hover:bg-primary/10 active:bg-primary/20 transition-colors rounded-l-xl",
+ className
+ )}
+ >
+ {withHandle && <div className="h-6 w-1 rounded-lg bg-border" />}
+ </div>
+ );
+}