mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-06 02:48:04 +00:00
Merge 7c9d24baf3 into f50f9e6252
This commit is contained in:
commit
2b080913ed
4 changed files with 2 additions and 55 deletions
|
|
@ -3112,7 +3112,7 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
if name not in tools_dict:
|
||||
tools_dict[name] = tool_dict
|
||||
|
||||
# Only advertise user-shell tools when the originating browser has a connected shell.
|
||||
# Automations and sub-agents never have a user's browser shell, so they never get these tools.
|
||||
shell_tools = {
|
||||
name: tool
|
||||
for name, tool in tools_dict.items()
|
||||
|
|
@ -3128,32 +3128,8 @@ async def process_chat_payload(request, form_data, user, metadata, model):
|
|||
or (tool.get('direct') and tool.get('server', {}).get('url') == terminal_id)
|
||||
)
|
||||
}
|
||||
connected = False
|
||||
if (
|
||||
selected
|
||||
and event_caller
|
||||
and metadata.get('session_id')
|
||||
and metadata.get('chat_id')
|
||||
and not metadata.get('automation_id')
|
||||
and not metadata.get('internal')
|
||||
):
|
||||
try:
|
||||
state = await asyncio.wait_for(
|
||||
event_caller(
|
||||
{
|
||||
'type': 'request:terminal:state',
|
||||
'data': {'terminal_id': terminal_id, 'session_id': metadata['session_id']},
|
||||
}
|
||||
),
|
||||
timeout=2,
|
||||
)
|
||||
connected = isinstance(state, dict) and state.get('connected') is True
|
||||
except Exception:
|
||||
# Old/disconnected browsers cannot confirm availability; other tools still work.
|
||||
pass
|
||||
|
||||
for name in shell_tools:
|
||||
if not connected or name not in selected:
|
||||
if name not in selected or metadata.get('automation_id') or metadata.get('internal'):
|
||||
tools_dict.pop(name)
|
||||
|
||||
if tools_dict:
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
import { WebLinksAddon } from '@xterm/addon-web-links';
|
||||
import '@xterm/xterm/css/xterm.css';
|
||||
import { terminalRequest, type TerminalConnection } from '$lib/apis/terminal';
|
||||
import { connectedUserTerminals } from '$lib/stores';
|
||||
|
||||
export let connection: TerminalConnection;
|
||||
export let chatId: string | null = null;
|
||||
|
|
@ -23,13 +22,8 @@
|
|||
let pingInterval: ReturnType<typeof setInterval>;
|
||||
let destroyed = false;
|
||||
let sessionId = '';
|
||||
const terminalOwner = Symbol();
|
||||
|
||||
function disconnect() {
|
||||
connectedUserTerminals.update((entries) => {
|
||||
entries.delete(terminalOwner);
|
||||
return entries;
|
||||
});
|
||||
connected = false;
|
||||
connecting = false;
|
||||
clearInterval(pingInterval);
|
||||
|
|
@ -75,10 +69,6 @@
|
|||
ws?.send(
|
||||
JSON.stringify({ type: 'auth', token: connection.key.trim(), chat_id: chatId ?? '' })
|
||||
);
|
||||
if (connection.selector && chatId) {
|
||||
const shell = { terminalId: connection.selector, chatId };
|
||||
connectedUserTerminals.update((entries) => entries.set(terminalOwner, shell));
|
||||
}
|
||||
connected = true;
|
||||
connecting = false;
|
||||
fit();
|
||||
|
|
|
|||
|
|
@ -146,9 +146,6 @@ export type FileNavOpenRequest = string | { path: string; page?: number | null }
|
|||
export const showFileNavPath: Writable<FileNavOpenRequest | null> = writable(null);
|
||||
export const showFileNavDir: Writable<string | null> = writable(null);
|
||||
export const selectedTerminalId: Writable<string | null> = writable(null);
|
||||
export const connectedUserTerminals = writable(
|
||||
new Map<symbol, { terminalId: string; chatId: string }>()
|
||||
);
|
||||
|
||||
export const artifactCode = writable(null);
|
||||
export const artifactContents = writable(null);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
channels,
|
||||
channelId,
|
||||
terminalServers,
|
||||
connectedUserTerminals,
|
||||
showControls,
|
||||
showFileNavPath,
|
||||
showFileNavDir,
|
||||
|
|
@ -566,21 +565,6 @@
|
|||
};
|
||||
|
||||
const chatEventHandler = async (event, cb) => {
|
||||
// Answer this session's availability check even when another chat is active.
|
||||
if (
|
||||
event?.data?.type === 'request:terminal:state' &&
|
||||
event.data.data?.session_id === $socket?.id
|
||||
) {
|
||||
cb?.({
|
||||
connected:
|
||||
$config?.features?.enable_tool_servers &&
|
||||
[...$connectedUserTerminals.values()].some(
|
||||
(shell) =>
|
||||
shell.terminalId === event.data.data?.terminal_id && shell.chatId === event.chat_id
|
||||
)
|
||||
});
|
||||
return;
|
||||
}
|
||||
const chat = $page.url.pathname.includes(`/c/${event.chat_id}`);
|
||||
|
||||
// Skip events from temporary chats that are not the current chat.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue