diff --git a/backend/open_webui/config.py b/backend/open_webui/config.py index d71bd389b2..52014b1edd 100644 --- a/backend/open_webui/config.py +++ b/backend/open_webui/config.py @@ -1477,6 +1477,10 @@ USER_PERMISSIONS_CHAT_EDIT = os.environ.get('USER_PERMISSIONS_CHAT_EDIT', 'True' USER_PERMISSIONS_CHAT_SHARE = os.environ.get('USER_PERMISSIONS_CHAT_SHARE', 'True').lower() == 'true' +USER_PERMISSIONS_CHAT_ALLOW_PUBLIC_SHARING = ( + os.environ.get('USER_PERMISSIONS_CHAT_ALLOW_PUBLIC_SHARING', 'False').lower() == 'true' +) + USER_PERMISSIONS_CHAT_EXPORT = os.environ.get('USER_PERMISSIONS_CHAT_EXPORT', 'True').lower() == 'true' USER_PERMISSIONS_CHAT_STT = os.environ.get('USER_PERMISSIONS_CHAT_STT', 'True').lower() == 'true' @@ -1557,6 +1561,7 @@ DEFAULT_USER_PERMISSIONS = { 'public_skills': USER_PERMISSIONS_WORKSPACE_SKILLS_ALLOW_PUBLIC_SHARING, 'notes': USER_PERMISSIONS_NOTES_ALLOW_SHARING, 'public_notes': USER_PERMISSIONS_NOTES_ALLOW_PUBLIC_SHARING, + 'public_chats': USER_PERMISSIONS_CHAT_ALLOW_PUBLIC_SHARING, }, 'access_grants': { 'allow_users': USER_PERMISSIONS_ACCESS_GRANTS_ALLOW_USERS, diff --git a/src/lib/components/admin/Users/Groups/Permissions.svelte b/src/lib/components/admin/Users/Groups/Permissions.svelte index cbfcb67b0a..313834bfdc 100644 --- a/src/lib/components/admin/Users/Groups/Permissions.svelte +++ b/src/lib/components/admin/Users/Groups/Permissions.svelte @@ -392,6 +392,24 @@ {/if} {/if} + + {#if permissions.chat.share} +
+
+
+ {$i18n.t('Chats Public Sharing')} +
+ +
+ {#if defaultPermissions?.sharing?.public_chats && !permissions.sharing.public_chats} +
+
+ {$i18n.t('This is a default user permission and will remain enabled.')} +
+
+ {/if} +
+ {/if}
diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 1468d6b349..eae8d7d233 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -70,6 +70,7 @@ import { archiveChatById, createNewChat, + deleteChatById, getAllTags, getChatById, getChatList, @@ -101,6 +102,7 @@ import Navbar from '$lib/components/chat/Navbar.svelte'; import ChatControls from './ChatControls.svelte'; import EventConfirmDialog from '../common/ConfirmDialog.svelte'; + import DeleteConfirmDialog from '../common/ConfirmDialog.svelte'; import Placeholder from './Placeholder.svelte'; import FilesOverlay from './MessageInput/FilesOverlay.svelte'; import NotificationToast from '../NotificationToast.svelte'; @@ -2793,6 +2795,33 @@ toast.error($i18n.t('Failed to archive chat.')); } }; + + let showDeleteConfirm = false; + + const deleteChatHandler = async (id: string) => { + showDeleteConfirm = true; + }; + + const confirmDeleteChat = async () => { + const id = $chatId; + if (!id) return; + + try { + const res = await deleteChatById(localStorage.token, id); + if (res) { + currentChatPage.set(1); + initNewChat(); + await goto('/'); + chats.set(await getChatList(localStorage.token, $currentChatPage)); + pinnedChats.set(await getPinnedChatList(localStorage.token)); + allTags.set(await getAllTags(localStorage.token)); + toast.success($i18n.t('Chat deleted.')); + } + } catch (error) { + console.error('Error deleting chat:', error); + toast.error(`${error}`); + } + }; @@ -2805,6 +2834,18 @@ + { + confirmDeleteChat(); + }} +> +
+ {$i18n.t('This will delete')} {$chatTitle}. +
+
+ { try { diff --git a/src/lib/components/chat/Navbar.svelte b/src/lib/components/chat/Navbar.svelte index 5c4e1364b4..e2a49f7621 100644 --- a/src/lib/components/chat/Navbar.svelte +++ b/src/lib/components/chat/Navbar.svelte @@ -53,6 +53,7 @@ export let onSaveTempChat: () => {}; export let archiveChatHandler: (id: string) => void; + export let deleteChatHandler: (id: string) => void; export let moveChatHandler: (id: string, folderId: string) => void; let closedBannerIds = []; @@ -199,6 +200,9 @@ archiveChatHandler={() => { archiveChatHandler(chat.id); }} + deleteChatHandler={() => { + deleteChatHandler(chat.id); + }} {moveChatHandler} > + +
diff --git a/src/lib/constants/permissions.ts b/src/lib/constants/permissions.ts index 69a8a3a664..c740696ee1 100644 --- a/src/lib/constants/permissions.ts +++ b/src/lib/constants/permissions.ts @@ -24,7 +24,8 @@ export const DEFAULT_PERMISSIONS = { skills: false, public_skills: false, notes: false, - public_notes: false + public_notes: false, + public_chats: false }, access_grants: { allow_users: true diff --git a/src/lib/i18n/locales/en-US/translation.json b/src/lib/i18n/locales/en-US/translation.json index a84604c76a..ca04c11f0c 100644 --- a/src/lib/i18n/locales/en-US/translation.json +++ b/src/lib/i18n/locales/en-US/translation.json @@ -309,6 +309,7 @@ "Chart new frontiers": "", "Chat": "", "Chat archived.": "", + "Chat deleted.": "", "Chat Background Image": "", "Chat Bubble UI": "", "Chat Completions": "",