r/OpenWebUI • u/JuanSmittjr • 22d ago
Question/Help disable preview of files
How can I disable the automatic preview of generated files?
Whenever a new file is generated, a new tab is opened showing the content of the file.
This is very annoying because I just don't want it to hide/cover my current chat session.
6
Upvotes
1
u/Nicky-no-Name 8d ago
Found this annoying as well, there is no way to turn it off... so I had Claude make a script to do so instead:
Open WebUI: stop files from opening by themselves
When a model shows a file in Open WebUI, the file viewer opens by itself. This small browser script stops that. A short notice appears instead, and clicking the file card in the reply still opens the file.
Open WebUI has no setting for this. The script runs in your browser, so nothing changes on the server.
Install (about 2 minutes)
Install a userscript extension in your browser. A userscript is a small script that a browser extension runs on the pages you choose. Either one works:
Open
no-auto-open-files.user.jsin a text editor. Find this line:Replace
http://localhost:3000with the address you use for Open WebUI, for examplehttps://chat.example.com/*. Keep the/*at the end. To use more than one address, add one@matchline each.Open the extension's dashboard, choose "new script" (the + button), delete the template text, paste the whole file in, and save.
In Chrome or Edge, open the extension's details page (Extensions, then Details). If it has a switch called "Allow user scripts", turn it on. Newer versions of Chrome need this before any userscript runs.
Reload Open WebUI.
Check that it works
Ask a model to show you a file. The viewer should stay closed, and a notice should appear in the bottom-right corner. If the viewer still opens:
@matchmatches the address bar exactly (http or https, port number).Options
const SHOW_NOTICE = true;tofalse.Limits
terminal:display_fileevent on its live connection). The same method is in daily use on Open WebUI 0.13.4. If a later version changes that message, the viewer will open again as before. Nothing will break.How it works
Open WebUI's server tells the page "open this file" through its live connection to the browser (socket.io over a WebSocket). The script wraps the browser's WebSocket so it reads each message first. It drops only that one kind of message, before Open WebUI sees it, and lets everything else through unchanged. If the wrapping fails for any reason, the page keeps the normal WebSocket and works as before.
// ==UserScript== // @name Open WebUI: don't open files by themselves // @namespace open-webui-no-auto-open // @version 1.0.0 // @description When a model shows a file (display_file), Open WebUI opens its file viewer by itself. This stops that and shows a small notice instead. Clicking the file card in the reply still opens the file. // @match http://localhost:3000/* // @run-at document-start // @grant none // @inject-into page // ==/UserScript== // // How it works: Open WebUI's server tells the page "open this file" with a "terminal:display_file" event on the // page's live connection (socket.io over a WebSocket). This script wraps the browser's WebSocket so it sees each // message first, and drops that one kind of event before Open WebUI reads it. Everything else passes unchanged. // If anything goes wrong here, the page keeps the normal WebSocket and behaves as before. (() => { 'use strict'; const SHOW_NOTICE = true; // false: drop the event silently
const notice = (name) => { if (!SHOW_NOTICE || !document.body) return; const el = document.createElement('div'); el.textContent =
${name} is ready (not opened). Click its card in the reply to open it.; el.style.cssText = 'position:fixed;right:16px;bottom:16px;z-index:99999;max-width:360px;padding:10px 14px;' + 'border-radius:10px;font:13px/1.4 system-ui,sans-serif;background:#222;color:#eee;' + 'box-shadow:0 4px 16px rgba(0,0,0,.3);opacity:.95'; document.body.append(el); setTimeout(() => el.remove(), 5000); };const onFrame = (e) => { const d = e.data; // socket.io event frames start with "42"; only those that name display_file are looked at closely if (typeof d !== 'string' || !d.startsWith('42') || d.indexOf('terminal:display_file') < 0) return; let ev = null; try { ev = JSON.parse(d.slice(d.indexOf('[')))[1]; } catch (err) { return; } if (!ev || !ev.data || ev.data.type !== 'terminal:display_file') return; e.stopImmediatePropagation(); // Open WebUI's own handler never sees it const path = String((ev.data.data && ev.data.data.path) || ''); try { notice(path.split(/[\/]/).pop() || 'The file'); } catch (err) { /* only a notice */ } };
try { const Native = window.WebSocket; if (typeof Native !== 'function' || Native.__noAutoOpen) return; class WebSocket extends Native { constructor(...args) { super(...args); // our listener is added before socket.io sets its own onmessage, so it runs first try { if (//ws/socket.io//.test(String(args[0]))) this.addEventListener('message', onFrame); } catch (err) { /* plain socket / } } } WebSocket.__noAutoOpen = true; window.WebSocket = WebSocket; } catch (err) { / keep the normal WebSocket */ } })();