Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(webui): make sidebar actions discoverable on touch devices
Xubin Ren6b24ed80ad75
diff --git a/docs/webui.md b/docs/webui.mdindex 704c33665..cc78c439d 100644--- a/docs/webui.md+++ b/docs/webui.md@@ -111,6 +111,11 @@ workspace selection, and linked automations. Use a new topic when you want aseparate context; use fork when you want to continue from an existing pointwithout changing the original thread.+On touch devices, sidebar action buttons stay visible with larger touch areas+for topics, conversation groups, panes, and projects. Tap a title to select it+or the adjacent action button for its menu. Desktop actions still appear on+hover or keyboard focus.+Drag a topic within its current sidebar group to keep frequently used work inyour preferred order. Drag a topic from the sidebar into the composer when youwant to reference it in the next message instead of switching to it.diff --git a/webui/src/components/ChatList.tsx b/webui/src/components/ChatList.tsxindex b015d5147..77b0a6a56 100644--- a/webui/src/components/ChatList.tsx+++ b/webui/src/components/ChatList.tsx@@ -1048,7 +1048,7 @@ export const ChatList = memo(function ChatList({><DropdownMenuTriggerclassName={cn(- "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",+ "sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity","media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover:opacity-100","focus-visible:opacity-100 data-[state=open]:opacity-100",)}@@ -1295,7 +1295,7 @@ function WorkbenchTabHeader({><DropdownMenuTriggerclassName={cn(- "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md",+ "sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md","text-sidebar-muted-foreground opacity-0 transition-opacity","media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover/tab:opacity-100","focus-visible:opacity-100 data-[state=open]:opacity-100",@@ -1491,7 +1491,7 @@ function ActivePaneRows({><DropdownMenuTriggerclassName={cn(- "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",+ "sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity","media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover/pane:opacity-100","focus-visible:opacity-100 data-[state=open]:opacity-100",)}@@ -1787,7 +1787,7 @@ function ProjectGroupHeader({><DropdownMenuTriggerclassName={cn(- "inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity",+ "sidebar-action-trigger touch-target inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-sidebar-muted-foreground opacity-0 transition-opacity","media-hover:hover:bg-sidebar-accent media-hover:hover:text-sidebar-foreground media-hover:group-hover:opacity-100 focus-visible:opacity-100","data-[state=open]:opacity-100",)}diff --git a/webui/src/globals.css b/webui/src/globals.cssindex 4062fff11..40e603685 100644--- a/webui/src/globals.css+++ b/webui/src/globals.css@@ -909,6 +909,11 @@.touch-target.preview-tab-close {opacity: 1;}++ /* Touch users cannot hover a sidebar row to discover its actions. */+ .sidebar-action-trigger {+ opacity: 1;+ }}/* On phones, actions follow the message instead of taking a separate gutter. */diff --git a/webui/src/tests/chat-list.test.tsx b/webui/src/tests/chat-list.test.tsxindex 249620ae6..96517b8b9 100644--- a/webui/src/tests/chat-list.test.tsx+++ b/webui/src/tests/chat-list.test.tsx@@ -99,6 +99,28 @@ describe("ChatList", () => {expect(conversation.querySelector("[data-sidebar-selection-track]")).toBeNull();});+ it("opens topic actions with a dedicated touch target without selecting the topic", async () => {+ const onSelect = vi.fn();+ const onRequestRename = vi.fn();+ render(<ChatList+ sessions={[session({ chatId: "review", title: "Review the patch" })]}+ activeKey={null}+ onSelect={onSelect}+ onRequestDelete={vi.fn()}+ onTogglePin={vi.fn()}+ onRequestRename={onRequestRename}+ onToggleArchive={vi.fn()}+ />);+ const trigger = screen.getByRole("button", { name: "Topic actions for Review the patch" });+ expect(trigger).toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");+ fireEvent.pointerDown(trigger, { button: 0, ctrlKey: false });+ fireEvent.click(await screen.findByRole("menuitem", { name: "Rename" }));+ expect(onRequestRename).toHaveBeenCalledWith("websocket:review", "Review the patch");+ expect(onSelect).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole("button", { name: "Review the patch" }));+ expect(onSelect).toHaveBeenCalledWith("websocket:review");+ });+it("marks a conversation that needs recovery attention with a warning indicator", () => {render(<ChatList@@ -689,7 +711,10 @@ describe("ChatList", () => {.toHaveAttribute("data-active-id", "websocket:root");expect(screen.getByRole("button", {name: "Research pane pane actions",- })).toHaveClass("opacity-0");+ })).toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");+ expect(screen.getByRole("button", {+ name: "Topic actions for Root topic",+ })).toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");expect(within(tabGroup).getByRole("button", { name: "Root topic" })).not.toHaveAttribute("aria-current");expect(tabGroup).not.toHaveTextContent("2/4");@@ -754,6 +779,8 @@ describe("ChatList", () => {fireEvent.click(await screen.findByRole("menuitem", { name: "Select" }));expect(screen.getByText("1 selected")).toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Root topic pane actions" })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Topic actions for Root topic" })).not.toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Group: Root topic" }));expect(screen.getByRole("button", { name: "Group: Root topic" })).toHaveAttribute("aria-pressed", "true");@@ -1189,6 +1216,8 @@ describe("ChatList", () => {);const projectSection = screen.getByRole("region", { name: "Photos" });+ expect(within(projectSection).getByRole("button", { name: "Topic actions for Photos" }))+ .toHaveClass("sidebar-action-trigger", "touch-target", "opacity-0");fireEvent.click(within(projectSection).getByRole("button", { name: "Photos" }));expect(onToggleGroup).toHaveBeenCalledWith("project:/Users/me/nanobot");diff --git a/webui/src/tests/sidebar-hover-css.test.ts b/webui/src/tests/sidebar-hover-css.test.tsindex ac89cc5e9..3c433c2cf 100644--- a/webui/src/tests/sidebar-hover-css.test.ts+++ b/webui/src/tests/sidebar-hover-css.test.ts@@ -7,6 +7,37 @@ import loadConfig from "tailwindcss/loadConfig";import { describe, expect, it } from "vitest";describe("sidebar touch hover isolation", () => {+ it("shows sidebar actions with roomy targets only for coarse pointers", async () => {+ const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));+ const source = readFileSync(resolve(process.cwd(), "src/globals.css"), "utf8");+ const result = await postcss([tailwindcss({ ...config, content: [{+ raw: 'class="sidebar-action-trigger touch-target opacity-0 h-6 w-6"',+ }] })]).process(source, { from: undefined });+ let hiddenIndex = -1;+ let visibleIndex = -1;+ let index = 0;+ let touchTarget = false;+ result.root.walkRules((rule) => {+ index++;+ if (rule.selector === ".opacity-0") hiddenIndex = index;+ if (rule.selector === ".sidebar-action-trigger") {+ visibleIndex = index;+ expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });+ expect(rule.nodes).toContainEqual(expect.objectContaining({ prop: "opacity", value: "1" }));+ }+ if (rule.selector === ".touch-target") {+ touchTarget = true;+ expect(rule.parent).toMatchObject({ type: "atrule", name: "media", params: "(pointer: coarse)" });+ for (const prop of ["min-width", "min-height"]) {+ expect(rule.nodes).toContainEqual(expect.objectContaining({ prop, value: "2.75rem" }));+ }+ }+ });+ expect(hiddenIndex).toBeGreaterThan(0);+ expect(visibleIndex).toBeGreaterThan(hiddenIndex);+ expect(touchTarget).toBe(true);+ });+it("gates ordinary and named-group hover CSS without gating keyboard focus", async () => {const config = loadConfig(resolve(process.cwd(), "tailwind.config.js"));const source = readFileSync(