From d6812c851b073bd067433069c76e00cef5fdc993 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 26 Nov 2026 03:08:54 +0400 Subject: [PATCH] refac --- src/lib/components/AddToolServerModal.svelte | 4 ++-- src/lib/components/chat/Tabs.svelte | 12 +++++++++++- src/lib/components/layout/Sidebar/ChatItem.svelte | 15 +++++++++++++++ .../layout/Sidebar/RecursiveFolder.svelte | 1 + src/lib/stores/index.ts | 2 +- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/lib/components/AddToolServerModal.svelte b/src/lib/components/AddToolServerModal.svelte index 79bb93caac..529813bfa1 100644 --- a/src/lib/components/AddToolServerModal.svelte +++ b/src/lib/components/AddToolServerModal.svelte @@ -42,7 +42,7 @@ // Earlier wording, kept so i18n:parse does not drop its translations: // $i18n.t('MCP support is experimental and its specification changes often, which can lead to incompatibilities. OpenAPI specification support is directly maintained by the Open WebUI team, making it the more reliable option for compatibility.') // $i18n.t('Read more →') - let type = 'openapi'; // 'openapi', 'mcp' + let type = 'mcp'; // 'openapi', 'mcp' let url = ''; @@ -422,7 +422,7 @@ show = false; // reset form - type = 'openapi'; + type = 'mcp'; url = ''; spec_type = 'url'; diff --git a/src/lib/components/chat/Tabs.svelte b/src/lib/components/chat/Tabs.svelte index e15ae3cb4f..4d14814c4f 100644 --- a/src/lib/components/chat/Tabs.svelte +++ b/src/lib/components/chat/Tabs.svelte @@ -211,8 +211,18 @@ 'folderId' in $chatTabRequest && $chatTabRequest.folderId === mainTabFolder?.id ) { + const savedId = $chatTabRequest.chatId; chatTabRequest.set(null); - if (mainTabFolder?.canEdit) openFeatureTab('chat'); + if (savedId) { + // A chat in this folder opens among the folder's tabs, or shows the tab it already has. + const existing = tabs.tabs.find((tab) => tab.kind === 'chat' && tab.chatId === savedId); + openPanel({ + id: existing?.id ?? uuidv4(), + kind: 'chat', + label: $i18n.t('Chat'), + chatId: savedId + }); + } else if (mainTabFolder?.canEdit) openFeatureTab('chat'); } export let mainChatHref = '/'; export let tabTitleEditor: import('svelte').Snippet | undefined = undefined; diff --git a/src/lib/components/layout/Sidebar/ChatItem.svelte b/src/lib/components/layout/Sidebar/ChatItem.svelte index 0e7eec6eac..9267175bc4 100644 --- a/src/lib/components/layout/Sidebar/ChatItem.svelte +++ b/src/lib/components/layout/Sidebar/ChatItem.svelte @@ -40,6 +40,7 @@ } from '$lib/apis/chats'; import { activeChatTabId, + chatTabRequest, openEmbeddedChatIds, selectedFolder, chatId, @@ -98,6 +99,8 @@ export let id; export let title; + /** The folder the chat is in, when it is listed under one. */ + export let folderId: string | null = null; export let createdAt: number | null = null; export let updatedAt: number | null = null; export let lastReadAt: number | null = null; @@ -223,6 +226,18 @@ event?.preventDefault(); void goto(`/c/${id}`); showSidebar.set(false); + } else if ( + // On its folder's page, the chat opens as a tab there instead of leaving the folder. + folderId && + !$chatId && + $selectedFolder?.id === folderId && + !event?.metaKey && + !event?.ctrlKey && + !event?.altKey && + !event?.shiftKey + ) { + event?.preventDefault(); + chatTabRequest.set({ folderId, chatId: id }); } }; diff --git a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte index b2945de805..4b04056565 100644 --- a/src/lib/components/layout/Sidebar/RecursiveFolder.svelte +++ b/src/lib/components/layout/Sidebar/RecursiveFolder.svelte @@ -1057,6 +1057,7 @@ >(new Set()); /** The saved chat whose tab is in front, when it is not the main chat. */ export const activeChatTabId = writable(null); export const chatTabRequest = writable< - { parentChatId: string; prompt: string } | { folderId: string } | null + { parentChatId: string; prompt: string } | { folderId: string; chatId?: string } | null >(null); export type QueryData = {