mirror of
https://github.com/open-webui/computer.git
synced 2026-11-20 21:41:54 +03:00
refac
This commit is contained in:
@@ -4,7 +4,12 @@
|
||||
import { workspaceList, removeWorkspace, reorderWorkspaces, sidebarOpen } from '$lib/stores';
|
||||
import { chatEnabled } from '$lib/stores/chat';
|
||||
import { socketStore } from '$lib/stores/socket.svelte';
|
||||
import { deleteChat as apiDeleteChat, getChats, type ChatInfo } from '$lib/apis/chat';
|
||||
import {
|
||||
deleteChat as apiDeleteChat,
|
||||
getChats,
|
||||
updateChatTitle,
|
||||
type ChatInfo
|
||||
} from '$lib/apis/chat';
|
||||
import { t } from '$lib/i18n';
|
||||
import { tooltip } from '$lib/tooltip';
|
||||
import Sortable from 'sortablejs';
|
||||
@@ -123,6 +128,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRenameChat() {
|
||||
if (!chatMenu) return;
|
||||
const { chatId, wsPath } = chatMenu;
|
||||
const chat = (wsChatsCache.get(wsPath) ?? []).find((item) => item.id === chatId);
|
||||
const title = window.prompt($t('files.rename'), chat?.title)?.trim();
|
||||
if (!title || title === chat?.title) return;
|
||||
await updateChatTitle(chatId, title);
|
||||
const chats = wsChatsCache.get(wsPath) ?? [];
|
||||
wsChatsCache = new Map([
|
||||
...wsChatsCache,
|
||||
[wsPath, chats.map((item) => (item.id === chatId ? { ...item, title } : item))]
|
||||
]);
|
||||
}
|
||||
|
||||
function copyChatPath() {
|
||||
if (!chatMenu) return;
|
||||
const { chatId, wsPath } = chatMenu;
|
||||
const chat = (wsChatsCache.get(wsPath) ?? []).find((item) => item.id === chatId);
|
||||
if (!chat) return;
|
||||
navigator.clipboard.writeText(
|
||||
`${wsPath.replace(/\/$/, '')}/.cptr/chats/${chat.folder ? `${chat.folder}/` : ''}${chat.id}.json`
|
||||
);
|
||||
}
|
||||
|
||||
const seenChatIds = new Set<string>();
|
||||
|
||||
function handleChatEvent(data: {
|
||||
@@ -301,6 +330,16 @@
|
||||
anchor={chatMenu.anchor}
|
||||
align="end"
|
||||
items={[
|
||||
{
|
||||
label: $t('files.copyPath'),
|
||||
icon: 'copy',
|
||||
onclick: copyChatPath
|
||||
},
|
||||
{
|
||||
label: $t('files.rename'),
|
||||
icon: 'pencil',
|
||||
onclick: handleRenameChat
|
||||
},
|
||||
{
|
||||
label: $t('chat.history.delete'),
|
||||
icon: 'trash',
|
||||
|
||||
Reference in New Issue
Block a user