From 39a817e72d9ec753fd8ee6f19928b002861ae710 Mon Sep 17 00:00:00 2001 From: chengyongru Date: Thu, 10 Sep 2026 13:27:01 +0800 Subject: [PATCH] feat(webui): refine sidebar hierarchy and selection feedback --- webui/src/App.tsx | 2 +- webui/src/components/ChatList.tsx | 222 ++++++++++-------- webui/src/components/Sidebar.tsx | 3 +- .../components/SidebarSelectionHighlight.tsx | 8 +- webui/src/components/thread/ThreadShell.tsx | 1 - webui/src/globals.css | 75 +++++- webui/src/tests/chat-list.test.tsx | 54 ++--- webui/src/tests/thread-shell.test.tsx | 2 +- 8 files changed, 220 insertions(+), 147 deletions(-) diff --git a/webui/src/App.tsx b/webui/src/App.tsx index 3e9a90b73..0bac91278 100644 --- a/webui/src/App.tsx +++ b/webui/src/App.tsx @@ -2782,7 +2782,7 @@ function Shell({ hideSidebarToggleForHostChrome={context.active} hideThemeButton={!context.active} hideHeaderTitle - inlineHandle={workbenchPaneSessions.length > 1} + inlineHandle={!mobileWorkbench && workbenchPaneSessions.length > 1} headerActions={context.headerActions} headerPortalTarget={context.headerPortalTarget} headerActive={context.active} diff --git a/webui/src/components/ChatList.tsx b/webui/src/components/ChatList.tsx index bf84185fc..b38aa9dac 100644 --- a/webui/src/components/ChatList.tsx +++ b/webui/src/components/ChatList.tsx @@ -13,8 +13,6 @@ import { ArchiveRestore, AlertTriangle, ChevronDown, - Folder, - FolderTree, ListChecks, MessageCircleDashed, MoreHorizontal, @@ -50,7 +48,10 @@ import { TooltipTrigger, } from "@/components/ui/tooltip"; import { MAX_WORKBENCH_PANES } from "@/components/workbench/workbench-model"; -import { SIDEBAR_SELECTION_ITEM_CLASS } from "@/components/SidebarSelectionHighlight"; +import { + SIDEBAR_SELECTION_ITEM_CLASS, + SidebarSelectionHighlight, +} from "@/components/SidebarSelectionHighlight"; import { relativeTime, visibleSessionPreview } from "@/lib/format"; import { COLLAPSED_CHATS_VISIBLE_COUNT, @@ -103,30 +104,6 @@ function SidebarItemTooltip({ ); } -function SidebarSelectionTrack({ - active, - handle, -}: { - active: boolean; - handle: ChatSummary["handle"]; -}) { - return ( - - ); -} - function SidebarSessionHandle({ handle }: { handle: ChatSummary["handle"] }) { if (!handle) return null; return ( @@ -317,6 +294,34 @@ export const ChatList = memo(function ChatList({ }: ChatListProps) { const { t } = useTranslation(); const [visibleLimit, setVisibleLimit] = useState(INITIAL_VISIBLE_SESSIONS); + const scrollViewportRef = useRef(null); + useLayoutEffect(() => { + const viewport = scrollViewportRef.current; + if (!viewport) return; + const updateEdges = () => { + const remaining = viewport.scrollHeight - viewport.clientHeight - viewport.scrollTop; + viewport.style.setProperty("--sidebar-fade-top", `${Math.min(8, Math.max(0, viewport.scrollTop))}px`); + viewport.style.setProperty("--sidebar-fade-bottom", `${Math.min(8, Math.max(0, remaining))}px`); + }; + let idleTimer: ReturnType | undefined; + const onScroll = () => { + updateEdges(); + viewport.dataset.scrolling = "true"; + clearTimeout(idleTimer); + idleTimer = setTimeout(() => { delete viewport.dataset.scrolling; }, 800); + }; + updateEdges(); + viewport.addEventListener("scroll", onScroll, { passive: true }); + const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(updateEdges); + observer?.observe(viewport); + if (viewport.firstElementChild) observer?.observe(viewport.firstElementChild); + return () => { + viewport.removeEventListener("scroll", onScroll); + clearTimeout(idleTimer); + delete viewport.dataset.scrolling; + observer?.disconnect(); + }; + }, [loading, sessions.length, temporarySessions.length]); const layoutRowRefs = useRef(new Map()); const pendingLayoutRectsRef = useRef | null>(null); const layoutAnimationsRef = useRef(new Map()); @@ -628,8 +633,11 @@ export const ChatList = memo(function ChatList({ }; return ( -
-
+ {index === firstProjectGroupIndex ? ( -
+
{labels.projects}
) : null} @@ -729,6 +737,7 @@ export const ChatList = memo(function ChatList({ {group.kind === "project" ? ( session.key === activeKey)} path={group.projectPath} actionMenuId={`project:${group.id}`} actionMenus={actionMenus} @@ -756,7 +765,7 @@ export const ChatList = memo(function ChatList({ data-sidebar-project-surface={group.kind === "project" ? "true" : undefined} className={cn( group.kind === "project" - && "rounded-es-[16px] border-s-2 border-sidebar-foreground/10 pb-1", + && "sidebar-child-list ms-4 pb-1", )} >
    @@ -800,7 +809,7 @@ export const ChatList = memo(function ChatList({ data-pane-drop-target={ paneDropTarget === resolvedPaneGroup.tabKey ? "true" : undefined } - className="relative my-1.5 min-w-0" + className="relative min-w-0" >
    ) : null} - + ) : ( @@ -1013,7 +1022,7 @@ export const ChatList = memo(function ChatList({ {title} {isPinned ? : null} - + )} {showPreview ? ( @@ -1172,13 +1181,14 @@ export const ChatList = memo(function ChatList({
    ) : null} -
+
); }); function WorkbenchTabHeader({ + active, title, actionMenuId, actionMenus, @@ -1194,6 +1204,7 @@ function WorkbenchTabHeader({ onRequestDelete, actionMenuPortalContainer, }: { + active: boolean; title: string; actionMenuId: string; actionMenus: SidebarActionMenuController; @@ -1220,10 +1231,36 @@ function WorkbenchTabHeader({ data-workbench-tab onContextMenu={(event) => actionMenus.openFromContextMenu(event, actionMenuId)} className={cn( - "group/tab flex min-w-0 items-center gap-0.5 rounded-control px-1.5 text-sidebar-content", - collapsed ? "min-h-6" : "min-h-7", + "group/tab flex min-h-8 min-w-0 items-center gap-0.5 rounded-xl px-2", + active ? "text-sidebar-foreground" : "text-sidebar-content", )} > + {!deleteSelectionMode ? ( + + + + ) : null} @@ -1299,30 +1332,7 @@ function WorkbenchTabHeader({ - - - + ) : null}
@@ -1393,7 +1403,7 @@ function ActivePaneRows({
    {panes.map((pane) => { const active = tabActive && pane.key === group.activePaneKey; @@ -1426,7 +1436,7 @@ function ActivePaneRows({ actionMenus.openFromContextMenu(event, actionMenuId) )} className={cn( - "group/pane flex min-w-0 max-w-full items-center gap-1 rounded-control px-2 text-[13px] font-normal leading-5", + "group/pane flex min-w-0 max-w-full items-center gap-1 rounded-xl px-2 text-[13px] font-normal leading-5", SIDEBAR_SELECTION_ITEM_CLASS, compact ? "min-h-7" : "min-h-8", active @@ -1470,7 +1480,7 @@ function ActivePaneRows({ {pane.title} {isPinned ? : null} - + @@ -1641,11 +1651,12 @@ function TemporaryChatSection({
  • @@ -1684,6 +1695,7 @@ function TemporaryChatSection({ } function ProjectGroupHeader({ + active, label, path, actionMenuId, @@ -1695,6 +1707,7 @@ function ProjectGroupHeader({ actionMenuPortalContainer, updatedAt, }: { + active: boolean; label: string; path?: string; actionMenuId: string; @@ -1712,9 +1725,11 @@ function ProjectGroupHeader({ type="button" aria-expanded={!collapsed} onClick={onToggle} - className="flex min-w-0 flex-1 items-center gap-2 rounded-lg px-1.5 py-1 text-left transition-colors hover:bg-sidebar-accent/45 hover:text-sidebar-foreground" + className={cn( + "flex min-w-0 flex-1 items-center gap-2 rounded-lg py-1 text-left transition-colors hover:text-sidebar-foreground", + active ? "font-medium text-sidebar-foreground" : "font-normal", + )} > - {label} ); @@ -1725,8 +1740,32 @@ function ProjectGroupHeader({ onContextMenu={onRequestRename || onNewChat ? (event) => actionMenus.openFromContextMenu(event, actionMenuId) : undefined} - className="group flex min-w-0 items-center gap-1 px-1 pb-1 pt-1 text-[13px] font-normal leading-5 text-sidebar-content" + className="group flex min-h-8 min-w-0 items-center gap-0.5 rounded-xl px-2 text-[13px] leading-5 text-sidebar-content" > + + + {path ? ( {projectButton} @@ -1778,37 +1817,14 @@ function ProjectGroupHeader({ ) : null} - - - +
    ); } function ChatsGroupHeader({ label }: { label: string }) { return ( -
    +
    {label}
    ); @@ -1841,7 +1857,7 @@ function ChatsFoldFooter({ : `${hiddenCount} hidden topics`; return ( -
    +