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): harden mobile context sheet interactions
Xubin Ren08b130cdd1e8
diff --git a/webui/src/components/thread/ComposerUsagePopover.tsx b/webui/src/components/thread/ComposerUsagePopover.tsxindex 0dfe8774b..d5a34229e 100644--- a/webui/src/components/thread/ComposerUsagePopover.tsx+++ b/webui/src/components/thread/ComposerUsagePopover.tsx@@ -328,6 +328,7 @@ export function ComposerUsagePopover({key={round.id}className={cn("flex h-full min-w-0 flex-1 items-end justify-center rounded-sm",+ bottomSheet && "relative","opacity-70 transition-opacity hover:opacity-100",index === 0 && "justify-start",normalizedRounds.length > 1@@ -347,7 +348,9 @@ export function ComposerUsagePopover({className={cn("flex w-full max-w-7 flex-col overflow-hidden rounded-t-[3px] bg-muted","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",- bottomSheet && "data-[state=open]:ring-2 data-[state=open]:ring-foreground/20",+ // Let touch users hit the entire column, even when a+ // round's proportional bar is less than a pixel high.+ bottomSheet && "before:absolute before:inset-0 before:content-[''] data-[state=open]:ring-2 data-[state=open]:ring-foreground/20",)}style={{ height: `${barHeight}px` }}>diff --git a/webui/src/tests/composer-usage-popover.test.tsx b/webui/src/tests/composer-usage-popover.test.tsxindex 1c5a3084f..e68f42faa 100644--- a/webui/src/tests/composer-usage-popover.test.tsx+++ b/webui/src/tests/composer-usage-popover.test.tsx@@ -37,6 +37,25 @@ async function openSheet() {}describe("Mobile context usage sheet", () => {+ it("keeps tiny rounds tappable without exaggerating their visual token usage", async () => {+ const user = userEvent.setup();+ render(<ComposerUsagePopover bottomSheet context={null} rounds={[+ { id: "small", timestamp: 0, inputTokens: 1000 },+ { id: "large", timestamp: 60000, inputTokens: 500000 },+ ]} />);+ await user.click(screen.getByTestId("composer-context-usage"));+ const [small, large] = screen.getAllByTestId("round-usage-bar");+ for (const bar of [small, large]) {+ expect(bar.parentElement).toHaveClass("relative", "h-full", "flex-1");+ expect(bar).toHaveClass("before:absolute", "before:inset-0");+ }+ expect(small).toHaveStyle({ height: "0.216px" });+ expect(large).toHaveStyle({ height: "108px" });+ await user.pointer([{ keys: "[TouchA>]", target: small }, { keys: "[/TouchA]", target: small }]);+ expect(within(screen.getByRole("dialog", { name: "Context usage" })).getByRole("dialog"))+ .toHaveTextContent("1,000");+ });+it("replaces the X with a keyboard-accessible drag handle", async () => {const { user, handle, sheet, trigger } = await openSheet();expect(within(sheet).getAllByRole("button", { name: "Close" })).toEqual([handle]);diff --git a/webui/src/tests/vite-config.test.ts b/webui/src/tests/vite-config.test.tsindex 7825f27fb..10c46fecf 100644--- a/webui/src/tests/vite-config.test.ts+++ b/webui/src/tests/vite-config.test.ts@@ -4,13 +4,21 @@ import path from "node:path";import { gunzipSync } from "node:zlib";import { describe, expect, it } from "vitest";-import {+import webuiConfig, {entryLazyFeatureImports,gzipWebuiAssets,webuiManualChunk,writeCompressedWebuiAssets,} from "../../vite.config";+describe("development overlay dependencies", () => {+ it("pre-bundles Dialog so sheets share layer and focus state with popovers", () => {+ const config = webuiConfig({ command: "serve", mode: "test" });+ expect(config.optimizeDeps?.include).toContain("@radix-ui/react-dialog");+ expect(config.optimizeDeps?.exclude ?? []).not.toContain("@radix-ui/react-dialog");+ });+});+describe("gzipWebuiAssets", () => {it("compresses finalized files after Rollup writes the bundle", () => {const plugin = gzipWebuiAssets();diff --git a/webui/vite.config.ts b/webui/vite.config.tsindex 991791c14..5f2cd3be0 100644--- a/webui/vite.config.ts+++ b/webui/vite.config.ts@@ -129,10 +129,10 @@ export default defineConfig(({ mode }) => {dedupe: ["react", "react-dom", "lucide-react", "react-i18next", "qrcode"],},optimizeDeps: {- // Radix Dialog can rewrite its optimized chunk while a dev tab is open.- // Syntax highlighting must remain pre-bundled because Refractor's core- // still uses CommonJS internally.- exclude: ["@radix-ui/react-dialog"],+ // Pre-bundle Dialog up front, including lazy settings/sheets. Excluding+ // it splits its layer/focus state from optimized Popover and DropdownMenu,+ // so nested overlays can dismiss the wrong layer in development.+ include: ["@radix-ui/react-dialog"],},build: {outDir: path.resolve(__dirname, "../nanobot/web/dist"),