From 87bd56468c56d07ac2826858e82fed91694192b0 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Thu, 4 Jun 2026 13:54:52 +0800 Subject: [PATCH] fix(webui): show platform-specific new chat shortcut --- webui/src/components/Sidebar.tsx | 23 ++++++++++++++++++++++- webui/src/tests/app-layout.test.tsx | 28 +++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/webui/src/components/Sidebar.tsx b/webui/src/components/Sidebar.tsx index 3d4f7a6d2..671ed701f 100644 --- a/webui/src/components/Sidebar.tsx +++ b/webui/src/components/Sidebar.tsx @@ -55,12 +55,29 @@ interface SidebarProps { hostChromeInset?: boolean; } +type NavigatorWithUserAgentData = Navigator & { + userAgentData?: { platform?: string }; +}; + +function isApplePlatform(): boolean { + if (typeof navigator === "undefined") return false; + const platform = navigator.platform || ""; + const userAgentPlatform = + (navigator as NavigatorWithUserAgentData).userAgentData?.platform || ""; + return /mac|iphone|ipad|ipod/i.test(`${platform} ${userAgentPlatform}`); +} + +function newChatShortcutLabel(): string { + return isApplePlatform() ? "⌘⇧O" : "Ctrl+Shift+O"; +} + export function Sidebar(props: SidebarProps) { const { t } = useTranslation(); const [menuPortalContainer, setMenuPortalContainer] = useState(null); const collapsed = Boolean(props.collapsed); const toggleLabel = t("thread.header.toggleSidebar"); + const newChatShortcut = newChatShortcutLabel(); return (