diff --git a/.gitignore b/.gitignore index cbb7b4dac0..22a2c42566 100644 --- a/.gitignore +++ b/.gitignore @@ -230,4 +230,8 @@ api/.env.backup # Benchmark scripts/stress-test/setup/config/ -scripts/stress-test/reports/ \ No newline at end of file +scripts/stress-test/reports/ + +# mcp +.playwright-mcp/ +.serena/ \ No newline at end of file diff --git a/web/app/components/base/chat/chat-with-history/hooks.tsx b/web/app/components/base/chat/chat-with-history/hooks.tsx index 0e8da0d26d..fb3e1bb8f3 100644 --- a/web/app/components/base/chat/chat-with-history/hooks.tsx +++ b/web/app/components/base/chat/chat-with-history/hooks.tsx @@ -122,19 +122,31 @@ export const useChatWithHistory = (installedAppInfo?: InstalledApp) => { setLocaleFromProps() }, [appData]) - const [sidebarCollapseState, setSidebarCollapseState] = useState(false) + const [sidebarCollapseState, setSidebarCollapseState] = useState(() => { + if (typeof window !== 'undefined') { + try { + const localState = localStorage.getItem('webappSidebarCollapse') + return localState === 'collapsed' + } + catch (e) { + // localStorage may be disabled in private browsing mode or by security settings + // fallback to default value + return false + } + } + return false + }) const handleSidebarCollapse = useCallback((state: boolean) => { if (appId) { setSidebarCollapseState(state) - localStorage.setItem('webappSidebarCollapse', state ? 'collapsed' : 'expanded') + try { + localStorage.setItem('webappSidebarCollapse', state ? 'collapsed' : 'expanded') + } + catch (e) { + // localStorage may be disabled, continue without persisting state + } } }, [appId, setSidebarCollapseState]) - useEffect(() => { - if (appId) { - const localState = localStorage.getItem('webappSidebarCollapse') - setSidebarCollapseState(localState === 'collapsed') - } - }, [appId]) const [conversationIdInfo, setConversationIdInfo] = useLocalStorageState>>(CONVERSATION_ID_INFO, { defaultValue: {}, }) diff --git a/web/app/components/base/chat/chat-with-history/index.tsx b/web/app/components/base/chat/chat-with-history/index.tsx index cfde517a61..464e30a821 100644 --- a/web/app/components/base/chat/chat-with-history/index.tsx +++ b/web/app/components/base/chat/chat-with-history/index.tsx @@ -47,6 +47,11 @@ const ChatWithHistory: FC = ({ themeBuilder?.buildTheme(site?.chat_color_theme, site?.chat_color_theme_inverted) }, [site, customConfig, themeBuilder]) + useEffect(() => { + if (!isSidebarCollapsed) + setShowSidePanel(false) + }, [isSidebarCollapsed]) + useDocumentTitle(site?.title || 'Chat') return ( @@ -76,7 +81,7 @@ const ChatWithHistory: FC = ({ onMouseEnter={() => setShowSidePanel(true)} onMouseLeave={() => setShowSidePanel(false)} > - + )}
diff --git a/web/app/components/base/chat/chat-with-history/sidebar/index.tsx b/web/app/components/base/chat/chat-with-history/sidebar/index.tsx index 4e50c1cb79..c6a7063d80 100644 --- a/web/app/components/base/chat/chat-with-history/sidebar/index.tsx +++ b/web/app/components/base/chat/chat-with-history/sidebar/index.tsx @@ -23,9 +23,10 @@ import { useGlobalPublicStore } from '@/context/global-public-context' type Props = { isPanel?: boolean + panelVisible?: boolean } -const Sidebar = ({ isPanel }: Props) => { +const Sidebar = ({ isPanel, panelVisible }: Props) => { const { t } = useTranslation() const { isInstalledApp, @@ -138,7 +139,12 @@ const Sidebar = ({ isPanel }: Props) => { )}
- + {/* powered by */}
{!appData?.custom_config?.remove_webapp_brand && ( diff --git a/web/app/components/share/text-generation/menu-dropdown.tsx b/web/app/components/share/text-generation/menu-dropdown.tsx index 1c1b6adfe8..373e3b8699 100644 --- a/web/app/components/share/text-generation/menu-dropdown.tsx +++ b/web/app/components/share/text-generation/menu-dropdown.tsx @@ -1,6 +1,6 @@ 'use client' import type { FC } from 'react' -import React, { useCallback, useRef, useState } from 'react' +import React, { useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import type { Placement } from '@floating-ui/react' import { @@ -25,12 +25,14 @@ type Props = { data?: SiteInfo placement?: Placement hideLogout?: boolean + forceClose?: boolean } const MenuDropdown: FC = ({ data, placement, hideLogout, + forceClose, }) => { const webAppAccessMode = useWebAppStore(s => s.webAppAccessMode) const router = useRouter() @@ -55,6 +57,11 @@ const MenuDropdown: FC = ({ const [show, setShow] = useState(false) + useEffect(() => { + if (forceClose) + setOpen(false) + }, [forceClose, setOpen]) + return ( <>