This commit is contained in:
Timothy Jaeryang Baek
2026-05-09 01:50:58 +09:00
parent 6bdc2ffa79
commit ef6d4f2d6c
8 changed files with 87 additions and 3 deletions
+5
View File
@@ -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,
@@ -392,6 +392,24 @@
{/if}
</div>
{/if}
{#if permissions.chat.share}
<div class="flex flex-col w-full">
<div class="flex w-full justify-between my-1">
<div class=" self-center text-xs font-medium">
{$i18n.t('Chats Public Sharing')}
</div>
<Switch bind:state={permissions.sharing.public_chats} />
</div>
{#if defaultPermissions?.sharing?.public_chats && !permissions.sharing.public_chats}
<div>
<div class="text-xs text-gray-500">
{$i18n.t('This is a default user permission and will remain enabled.')}
</div>
</div>
{/if}
</div>
{/if}
</div>
<hr class=" border-gray-100/30 dark:border-gray-850/30" />
+42
View File
@@ -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}`);
}
};
</script>
<svelte:head>
@@ -2805,6 +2834,18 @@
<audio id="audioElement" src="" style="display: none;"></audio>
<DeleteConfirmDialog
bind:show={showDeleteConfirm}
title={$i18n.t('Delete chat?')}
on:confirm={() => {
confirmDeleteChat();
}}
>
<div class=" text-sm text-gray-500 flex-1 line-clamp-3">
{$i18n.t('This will delete')} <span class=" font-semibold">{$chatTitle}</span>.
</div>
</DeleteConfirmDialog>
<EventConfirmDialog
bind:show={showEventConfirmation}
title={eventConfirmationTitle}
@@ -2876,6 +2917,7 @@
shareEnabled={!!history.currentId}
{initNewChat}
{archiveChatHandler}
{deleteChatHandler}
{moveChatHandler}
onSaveTempChat={async () => {
try {
+4
View File
@@ -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}
>
<button
@@ -1,6 +1,6 @@
<script lang="ts">
import { getContext, onMount } from 'svelte';
import { models, config } from '$lib/stores';
import { models, config, user } from '$lib/stores';
import { toast } from 'svelte-sonner';
import {
@@ -155,7 +155,7 @@
{#if chat.share_id}
<div class="mt-3">
<AccessControl bind:accessGrants accessRoles={['read']} onChange={saveAccessGrants} />
<AccessControl bind:accessGrants accessRoles={['read']} sharePublic={$user?.permissions?.sharing?.public_chats || $user?.role === 'admin'} onChange={saveAccessGrants} />
</div>
{/if}
@@ -32,6 +32,7 @@
import Folder from '$lib/components/icons/Folder.svelte';
import Share from '$lib/components/icons/Share.svelte';
import ArchiveBox from '$lib/components/icons/ArchiveBox.svelte';
import GarbageBin from '$lib/components/icons/GarbageBin.svelte';
import Messages from '$lib/components/chat/Messages.svelte';
import Download from '$lib/components/icons/Download.svelte';
@@ -43,6 +44,7 @@
export let moveChatHandler: Function;
export let archiveChatHandler: Function;
export let deleteChatHandler: Function;
// export let tagHandler: Function;
@@ -446,6 +448,17 @@
<div class="flex items-center">{$i18n.t('Archive')}</div>
</button>
<button
draggable="false"
class="flex gap-2 items-center px-3 py-1.5 text-sm cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 rounded-xl select-none w-full"
on:click={() => {
deleteChatHandler();
}}
>
<GarbageBin strokeWidth="1.5" />
<div class="flex items-center">{$i18n.t('Delete')}</div>
</button>
<hr class="border-gray-50/30 dark:border-gray-800/30 my-1" />
<div class="flex p-1">
+2 -1
View File
@@ -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
@@ -309,6 +309,7 @@
"Chart new frontiers": "",
"Chat": "",
"Chat archived.": "",
"Chat deleted.": "",
"Chat Background Image": "",
"Chat Bubble UI": "",
"Chat Completions": "",