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} {deleteSelectionMode ? ( ) : null} - {title} @@ -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 ( - + @@ -265,7 +265,6 @@ export function Sidebar(props: SidebarProps) { diff --git a/webui/src/components/SidebarSelectionHighlight.tsx b/webui/src/components/SidebarSelectionHighlight.tsx index d7bd6a037..370408f77 100644 --- a/webui/src/components/SidebarSelectionHighlight.tsx +++ b/webui/src/components/SidebarSelectionHighlight.tsx @@ -6,7 +6,8 @@ import { } from "react"; interface SidebarSelectionHighlightProps extends HTMLAttributes { - targetRef: RefObject; + targetRef?: RefObject; + targetSelector?: string; activeId: string | null; scope: string; } @@ -19,6 +20,7 @@ export const SIDEBAR_SELECTION_ACTION_ITEM_CLASS = export function SidebarSelectionHighlight({ targetRef, + targetSelector, activeId, scope, children, @@ -31,7 +33,9 @@ export function SidebarSelectionHighlight({ useLayoutEffect(() => { const highlight = highlightRef.current; const container = containerRef.current; - const target = targetRef.current; + const target = targetRef?.current ?? (targetSelector + ? container?.querySelector(targetSelector) + : null); if (!highlight) return; if (!activeId || !container || !target) { highlight.style.opacity = "0"; diff --git a/webui/src/components/thread/ThreadShell.tsx b/webui/src/components/thread/ThreadShell.tsx index a7f2c34d9..9c096ee61 100644 --- a/webui/src/components/thread/ThreadShell.tsx +++ b/webui/src/components/thread/ThreadShell.tsx @@ -1686,7 +1686,6 @@ export function ThreadShell({ const threadHeader = !hideHeader ? ( { expect(underline?.getAttribute("style")) .toContain(sessionHandleColor("handle_1234")); - const activeTrack = conversation.querySelector("[data-sidebar-selection-track]"); - expect(activeTrack).toHaveClass( - "origin-left", - "scale-x-100", - "transition-transform", - "motion-reduce:transition-none", - ); + expect(conversation.closest("[data-chat-row]")) + .toHaveClass("rounded-xl"); + expect(conversation.querySelector("[data-sidebar-selection-track]")).toBeNull(); }); it("marks a conversation that needs recovery attention with a warning indicator", () => { @@ -683,25 +679,21 @@ describe("ChatList", () => { expect(tabHeader).not.toHaveAttribute("data-chat-row"); expect(tabHeader).not.toHaveAttribute("data-sidebar-pane"); expect(tabButton).not.toHaveAttribute("aria-current"); - expect(tabButton.querySelector(".lucide-folder-tree")).toBeInTheDocument(); + expect(tabHeader.querySelector(".lucide-folder-tree")).toBeNull(); const paneList = within(tabGroup).getByRole("list", { name: "Panes in Root topic" }); expect(tabSurface).toContainElement(paneList); const activePane = within(tabGroup).getByRole("button", { name: "Research pane" }); expect(activePane).toHaveAttribute("aria-current", "true"); - expect(activePane.closest("[data-sidebar-pane]")).toHaveClass("rounded-control"); - expect(activePane.querySelector("[data-sidebar-selection-track]")) - .toHaveAttribute("data-active", "true"); + expect(activePane.closest("[data-sidebar-pane]")).toHaveClass("rounded-xl"); + expect(screen.getByTestId("chats-selection-highlight")) + .toHaveAttribute("data-active-id", "websocket:root"); expect(screen.getByRole("button", { name: "Research pane pane actions", })).toHaveClass("opacity-0"); expect(within(tabGroup).getByRole("button", { name: "Root topic" })) .not.toHaveAttribute("aria-current"); expect(tabGroup).not.toHaveTextContent("2/4"); - expect(paneList).toHaveClass( - "rounded-es-[14px]", - "border-s-2", - "border-sidebar-foreground/25", - ); + expect(paneList).toHaveClass("ms-4"); const collapse = within(tabGroup).getByRole("button", { name: "Collapse panes in Root topic", @@ -1025,11 +1017,7 @@ describe("ChatList", () => { ); expect(screen.getByRole("region", { name: "nanobot-bench" })).toBeInTheDocument(); - expect(projectSurface).toHaveClass( - "rounded-es-[16px]", - "border-s-2", - "border-sidebar-foreground/10", - ); + expect(projectSurface).toHaveClass("ms-4"); expect(within(nanobotSection).getByText("Alpha task")).toBeInTheDocument(); expect( within(nanobotSection) @@ -1090,7 +1078,7 @@ describe("ChatList", () => { expect(within(chatsSection).queryByText("Project chat")).not.toBeInTheDocument(); }); - it("grows and retracts the row-owned selection track", () => { + it("moves the selected background between topic rows", () => { const props = { sessions: [ session({ chatId: "active", title: "Active topic" }), @@ -1112,10 +1100,9 @@ describe("ChatList", () => { const activeButton = screen.getByRole("button", { name: "Active topic" }); expect(activeButton).toHaveAttribute("aria-current", "page"); - expect(activeButton.querySelector("[data-sidebar-selection-track]")) - .toHaveClass("origin-left", "scale-x-100", "transition-transform"); - expect(activeButton.querySelector("[data-sidebar-selection-track]")) - .toHaveStyle({ backgroundColor: "currentColor" }); + expect(screen.getByTestId("chats-selection-highlight")) + .toHaveAttribute("data-active-id", "websocket:active"); + expect(activeButton.querySelector("[data-sidebar-selection-track]")).toBeNull(); rerender( { expect(screen.getByRole("button", { name: "Inactive topic" })) .toHaveAttribute("aria-current", "page"); expect(screen.getByRole("button", { name: "Active topic" }) - .querySelector("[data-sidebar-selection-track]")) - .toHaveClass("scale-x-0"); - expect(screen.getByRole("button", { name: "Inactive topic" }) - .querySelector("[data-sidebar-selection-track]")) - .toHaveClass("scale-x-100"); + .closest("[data-chat-row]")) + .not.toHaveClass("bg-sidebar-foreground/[0.055]"); + expect(screen.getByTestId("chats-selection-highlight")) + .toHaveAttribute("data-active-id", "websocket:inactive"); }); it("restores collapsed tabs from the local UI preference", () => { @@ -1282,9 +1268,9 @@ describe("ChatList", () => { "ease-out", "motion-reduce:transition-none", ); - expect(expandedIcon).not.toHaveClass("rotate-90"); + expect(expandedIcon).not.toHaveClass("-rotate-90"); expect(screen.getByRole("button", { name: "Topic actions for Alpha project" }) - .compareDocumentPosition(disclosureButton) & Node.DOCUMENT_POSITION_FOLLOWING) + .compareDocumentPosition(disclosureButton) & Node.DOCUMENT_POSITION_PRECEDING) .toBeTruthy(); fireEvent.click(disclosureButton); @@ -1296,7 +1282,7 @@ describe("ChatList", () => { expect(screen.getByRole("button", { name: "Projects: Alpha project" }) .querySelector("[data-sidebar-project-disclosure-icon]")) - .toHaveClass("rotate-90"); + .toHaveClass("-rotate-90"); expect(projectButton).toHaveAttribute("aria-expanded", "false"); expect(animate).toHaveBeenCalledWith( [ diff --git a/webui/src/tests/thread-shell.test.tsx b/webui/src/tests/thread-shell.test.tsx index 9dfcd0938..ecf8fda3a 100644 --- a/webui/src/tests/thread-shell.test.tsx +++ b/webui/src/tests/thread-shell.test.tsx @@ -569,7 +569,7 @@ describe("ThreadShell", () => { />, )); - expect(within(portal).getByText("@soro")).toBeInTheDocument(); + expect(within(portal).queryByText("@soro")).not.toBeInTheDocument(); expect(screen.queryByLabelText("Session @soro")).not.toBeInTheDocument(); unmount();