From ef29fb12f1f641bf1d83b434a37298846d211deb Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 29 Oct 2026 16:44:26 +0900 Subject: [PATCH] refac --- backend/open_webui/tools/builtin.py | 4 ++-- backend/open_webui/utils/middleware.py | 5 ++--- src/lib/components/chat/Chat.svelte | 21 ------------------- .../Messages/StructuredOutputRenderer.svelte | 5 +++++ .../chat/Messages/structuredOutput.ts | 19 +++++++++++++++++ 5 files changed, 28 insertions(+), 26 deletions(-) diff --git a/backend/open_webui/tools/builtin.py b/backend/open_webui/tools/builtin.py index 999cca0a1c..f545667b49 100644 --- a/backend/open_webui/tools/builtin.py +++ b/backend/open_webui/tools/builtin.py @@ -3150,7 +3150,7 @@ async def display_file( :param path: Terminal file path, or file_id or /api/v1/files//content for a chat or knowledge base file :param page: For PDF, DOCX, and PPTX files, open the preview at this 1-based page or slide number - :param inline: Show the file inline in chat instead of opening the file viewer + :param inline: Show terminal files inline instead of opening the file viewer; uploaded files always display inline :return: JSON with the file's path, name, content type, and display state """ if __request__ is None: @@ -3182,7 +3182,7 @@ async def display_file( 'type': 'file', 'source': 'open_webui', 'exists': True, - 'displayed': inline, + 'displayed': True, 'path': path, 'full_path': path, 'name': file_meta.get('name') or file.filename, diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 31ed987dc8..819349958d 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -973,8 +973,8 @@ async def terminal_event_handler( path = result.get('path') or tool_function_params.get('path', '') if not path: return - # Only emit if the file actually exists - if result.get('exists') is False: + # Only open the viewer for existing files that are not displayed inline. + if result.get('exists') is False or result.get('displayed') is True: return page = tool_function_params.get('page') @@ -982,7 +982,6 @@ async def terminal_event_handler( { 'type': f'terminal:{tool_function_name}', 'data': { - **result, 'path': path, **({'page': page} if page else {}), }, diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 751e7c0e4d..ba296f72c1 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -136,7 +136,6 @@ import NotificationToast from '../NotificationToast.svelte'; import Spinner from '../common/Spinner.svelte'; import Modal from '../common/Modal.svelte'; - import ToolOutputFile from './Messages/ToolOutputFile.svelte'; import { isEmbedWindow } from '../common/FullHeightIframe.svelte'; import Tooltip from '../common/Tooltip.svelte'; import Sidebar from '../icons/Sidebar.svelte'; @@ -523,8 +522,6 @@ let params = {}; let chatVariables = {}; let showChatVariablesModal = false; - let showDisplayedFile = false; - let displayedFile: Record | null = null; let loadedChatIdProp = ''; let currentDraftKey = ''; @@ -1298,13 +1295,6 @@ }; const terminalEventHandler = (type: string, data: any, message: any) => { - if (type === 'terminal:display_file' && data?.source === 'open_webui') { - if ($settings?.terminalFileDisplay !== 'inline') { - displayedFile = data; - showDisplayedFile = true; - } - return; - } const attachment = history.messages[message?.parentId]?.files?.find( (file: any) => file.type === 'filesystem' ); @@ -5062,17 +5052,6 @@ - - - - - {#if getChatVariablesForm(selectedModelIds, chatVariables, $models).conflicts.length > 0}
diff --git a/src/lib/components/chat/Messages/StructuredOutputRenderer.svelte b/src/lib/components/chat/Messages/StructuredOutputRenderer.svelte index 19080ede50..1082ff6d17 100644 --- a/src/lib/components/chat/Messages/StructuredOutputRenderer.svelte +++ b/src/lib/components/chat/Messages/StructuredOutputRenderer.svelte @@ -1,5 +1,7 @@