From f5c6be2608f0201d222a3e8d441a0363485d0000 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 13 Sep 2026 15:15:15 +0800 Subject: [PATCH] fix(webui): polish mobile settings and context interactions --- .../components/settings/SettingsSidebar.tsx | 183 ++++++++++++------ .../thread/ComposerUsagePopover.tsx | 125 ++++++++++-- .../src/tests/composer-usage-popover.test.tsx | 163 ++++++++++++++++ webui/src/tests/settings-sidebar.test.tsx | 160 +++++++++++++++ webui/src/tests/thread-composer.test.tsx | 2 +- 5 files changed, 553 insertions(+), 80 deletions(-) create mode 100644 webui/src/tests/composer-usage-popover.test.tsx create mode 100644 webui/src/tests/settings-sidebar.test.tsx diff --git a/webui/src/components/settings/SettingsSidebar.tsx b/webui/src/components/settings/SettingsSidebar.tsx index aa51caf1a..0ecba8954 100644 --- a/webui/src/components/settings/SettingsSidebar.tsx +++ b/webui/src/components/settings/SettingsSidebar.tsx @@ -1,4 +1,4 @@ -import { useRef } from "react"; +import { useRef, useState } from "react"; import { Activity, Info, @@ -23,12 +23,8 @@ import { } from "@/components/SidebarSelectionHighlight"; import { isCapabilitySection, type SettingsSectionKey } from "@/components/settings/contracts"; import { Button } from "@/components/ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; +import { Sheet, SheetContent, SheetTitle, SheetTrigger } from "@/components/ui/sheet"; +import { useMediaQuery } from "@/hooks/useMediaQuery"; import { cn } from "@/lib/utils"; const SETTINGS_NAV_ITEMS: Array<{ key: SettingsSectionKey; icon: LucideIcon; fallback: string }> = [ @@ -49,17 +45,7 @@ export function standaloneSectionTitle(section: SettingsSectionKey): string { return SETTINGS_NAV_ITEMS.find((item) => item.key === section)?.fallback ?? "Settings"; } -export function SettingsSidebar({ - activeSection, - onSelectSection, - onBackToChat, - onLogout, - hostChromeInset, - onRestart, - isRestarting, - restartPending, - isNativeHost, -}: { +interface SettingsSidebarProps { activeSection: SettingsSectionKey; onSelectSection: (section: SettingsSectionKey) => void; onBackToChat: () => void; @@ -69,8 +55,22 @@ export function SettingsSidebar({ isRestarting?: boolean; restartPending?: boolean; isNativeHost?: boolean; -}) { +} + +export function SettingsSidebar(props: SettingsSidebarProps) { + const { + activeSection, + onSelectSection, + onBackToChat, + onLogout, + hostChromeInset, + onRestart, + isRestarting, + restartPending, + isNativeHost, + } = props; const { t } = useTranslation(); + const mobile = useMediaQuery("(max-width: 1023px)"); const restartLabel = isRestarting ? t(isNativeHost ? "app.system.restartingEngine" : "app.system.restarting") : t("app.system.restartAction"); @@ -78,11 +78,15 @@ export function SettingsSidebar({ const activeNavItemRef = useRef(null); const activeItem = SETTINGS_NAV_ITEMS.find((item) => item.key === navSection) ?? SETTINGS_NAV_ITEMS[0]; - const ActiveIcon = activeItem.icon; const activeLabel = t(`settings.nav.${activeItem.key}`, { defaultValue: activeItem.fallback, }); + if (mobile) { + return ; + } + return (