diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 2d1aeddd05..23b5276786 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -305,6 +305,7 @@ class ChatTitleIdResponse(BaseModel): last_read_at: int | None = None snippet: str | None = None active: bool = False + archived: bool = False class SharedChatResponse(BaseModel): diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 9f7cd98c82..c3eb390a78 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -888,6 +888,7 @@ async def search_user_chats( created_at=chat.created_at, last_read_at=chat.last_read_at, snippet=chat_search_snippet(chat.chat, search_text), + archived=chat.archived, ) ) diff --git a/src/lib/components/layout/SearchModal.svelte b/src/lib/components/layout/SearchModal.svelte index c687b9b4bc..a3c0e78be3 100644 --- a/src/lib/components/layout/SearchModal.svelte +++ b/src/lib/components/layout/SearchModal.svelte @@ -101,7 +101,7 @@ const archiveChatHandler = async (id) => { try { - await archiveChatById(localStorage.token, id); + const res = await archiveChatById(localStorage.token, id); chatList = chatList?.filter((c) => c.id !== id) ?? null; @@ -111,7 +111,7 @@ } await refreshSidebar(); - toast.success($i18n.t('Chat archived.')); + toast.success(res?.archived ? $i18n.t('Chat archived.') : $i18n.t('Chat unarchived.')); } catch (error) { toast.error($i18n.t('Failed to archive chat.')); } @@ -816,6 +816,7 @@
{ menuChatId = chat.id; showShareChatModal = true; diff --git a/src/lib/components/layout/Sidebar/ChatMenu.svelte b/src/lib/components/layout/Sidebar/ChatMenu.svelte index 509b171f9a..5e2100d48c 100644 --- a/src/lib/components/layout/Sidebar/ChatMenu.svelte +++ b/src/lib/components/layout/Sidebar/ChatMenu.svelte @@ -43,6 +43,7 @@ export let markUnreadHandler: Function = () => {}; export let chatId = ''; + export let archived = false; let dropdown: Dropdown; let show = false; @@ -457,7 +458,9 @@ }} > -
{$i18n.t('Archive')}
+
+ {archived ? $i18n.t('Unarchive') : $i18n.t('Archive')} +
{#if $user?.role === 'admin' || ($user?.permissions?.chat?.delete ?? true)} diff --git a/src/lib/i18n/locales/en-US/translation.json b/src/lib/i18n/locales/en-US/translation.json index e6a47ff9af..e67c1d5a3f 100644 --- a/src/lib/i18n/locales/en-US/translation.json +++ b/src/lib/i18n/locales/en-US/translation.json @@ -343,6 +343,7 @@ "Chat Menu": "", "Chat moved successfully": "", "Chat Permissions": "", + "Chat unarchived.": "", "Chat unshared successfully.": "", "Chat Uploads": "", "Chat Variables": "", @@ -3304,6 +3305,7 @@ "Type Hugging Face Resolve (Download) URL": "", "Type your answer": "", "Uh-oh! There was an issue with the response.": "", + "Unarchive": "", "Unarchive Chat": "", "Unassigned": "", "Underline": "",