From 6b24ed80ad75d82fb3f19fa3b5d7ec9e94d94c41 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 4 Oct 2026 20:36:06 +0800 Subject: [PATCH] fix(webui): make sidebar actions discoverable on touch devices --- docs/webui.md | 5 ++++ webui/src/components/ChatList.tsx | 8 +++--- webui/src/globals.css | 5 ++++ webui/src/tests/chat-list.test.tsx | 31 ++++++++++++++++++++++- webui/src/tests/sidebar-hover-css.test.ts | 31 +++++++++++++++++++++++ 5 files changed, 75 insertions(+), 5 deletions(-) diff --git a/docs/webui.md b/docs/webui.md index 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 a separate context; use fork when you want to continue from an existing point without 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 in your preferred order. Drag a topic from the sidebar into the composer when you want 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.tsx index 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({ > { 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(); + 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( { .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.ts index 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(