From 8547d4b1ff6f19ab0074abe7204befa4e6c1a8b2 Mon Sep 17 00:00:00 2001 From: JzoNg Date: Thu, 31 Jul 2025 16:18:19 +0800 Subject: [PATCH] memory panel in mobile --- .../chat-with-history/header-in-mobile.tsx | 6 +++ .../header/mobile-operation-dropdown.tsx | 5 +++ .../base/chat/chat-with-history/index.tsx | 16 +++++++- .../memory/card/edit-modal.tsx | 41 ++++++++++++++++++- .../chat-with-history/memory/card/index.tsx | 9 +++- .../chat/chat-with-history/memory/index.tsx | 3 +- 6 files changed, 74 insertions(+), 6 deletions(-) diff --git a/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx b/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx index ec8da7b102..693cea7d47 100644 --- a/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx +++ b/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx @@ -28,6 +28,8 @@ const HeaderInMobile = () => { handleRenameConversation, conversationRenaming, inputsForms, + showChatMemory, + setShowChatMemory, } = useChatWithHistoryContext() const { t } = useTranslation() const isPin = pinnedConversationList.some(item => item.id === currentConversationId) @@ -60,6 +62,9 @@ const HeaderInMobile = () => { if (showRename) handleRenameConversation(showRename.id, newName, { onSuccess: handleCancelRename }) }, [showRename, handleRenameConversation, handleCancelRename]) + const handleChatMemoryToggle = useCallback(() => { + setShowChatMemory(!showChatMemory) + }, [setShowChatMemory, showChatMemory]) const [showSidebar, setShowSidebar] = useState(false) const [showChatSettings, setShowChatSettings] = useState(false) @@ -98,6 +103,7 @@ const HeaderInMobile = () => { )} setShowChatSettings(true)} hideViewChatSettings={inputsForms.length < 1} diff --git a/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx b/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx index 4bb694033d..0726920d75 100644 --- a/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx +++ b/web/app/components/base/chat/chat-with-history/header/mobile-operation-dropdown.tsx @@ -9,12 +9,14 @@ import ActionButton, { ActionButtonState } from '@/app/components/base/action-bu type Props = { handleResetChat: () => void handleViewChatSettings: () => void + handleChatMemoryToggle?: () => void hideViewChatSettings?: boolean } const MobileOperationDropdown = ({ handleResetChat, handleViewChatSettings, + handleChatMemoryToggle, hideViewChatSettings = false, }: Props) => { const { t } = useTranslation() @@ -44,6 +46,9 @@ const MobileOperationDropdown = ({
{t('share.chat.resetChat')}
+
+ {t('share.chat.memory.actionButton')} +
{!hideViewChatSettings && (
{t('share.chat.viewChatSettings')} 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 295a5f2d0e..cb6e174105 100644 --- a/web/app/components/base/chat/chat-with-history/index.tsx +++ b/web/app/components/base/chat/chat-with-history/index.tsx @@ -38,6 +38,7 @@ const ChatWithHistory: FC = ({ themeBuilder, sidebarCollapseState, showChatMemory, + setShowChatMemory, } = useChatWithHistoryContext() const isSidebarCollapsed = sidebarCollapseState const customConfig = appData?.custom_config @@ -84,7 +85,7 @@ const ChatWithHistory: FC = ({
{!isMobile &&
} {appChatListDataLoading && ( @@ -94,7 +95,18 @@ const ChatWithHistory: FC = ({ )}
- + {!isMobile && ( + + )} + {isMobile && showChatMemory && ( +
setShowChatMemory(false)} + > +
e.stopPropagation()}> + +
+
+ )}
) diff --git a/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx b/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx index 44fc14e20b..b3ba52f0e3 100644 --- a/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx +++ b/web/app/components/base/chat/chat-with-history/memory/card/edit-modal.tsx @@ -19,6 +19,7 @@ type Props = { show: boolean onConfirm: (info: MemoryItem) => Promise onHide: () => void + isMobile?: boolean } const MemoryEditModal = ({ @@ -26,6 +27,7 @@ const MemoryEditModal = ({ show = false, onConfirm, onHide, + isMobile, }: Props) => { const { t } = useTranslation() const [content, setContent] = React.useState(memory.content) @@ -39,6 +41,43 @@ const MemoryEditModal = ({ onHide() } + if (isMobile) { + return ( +
+
e.stopPropagation()}> +
+ + + +
+
+
{t('share.chat.memory.editTitle')}
+
+ +
{memory.name}
+ +
+
+
+