mirror of
https://github.com/open-webui/computer.git
synced 2026-11-29 16:35:22 -05:00
refac
This commit is contained in:
1 parent
7c0d69fdb9
commit
10507c0cef
17 files changed
+323
-123
No files matched your search
@@ -21,9 +21,13 @@
|
||||
nextTab: $t('keyboard.nextTab'),
|
||||
prevTab: $t('keyboard.prevTab'),
|
||||
quickOpen: $t('keyboard.quickOpen'),
|
||||
searchAll: $t('keyboard.searchAll'),
|
||||
openSettings: $t('keyboard.openSettings'),
|
||||
toggleSplit: $t('keyboard.toggleSplit'),
|
||||
toggleSidebar: $t('keyboard.toggleSidebar')
|
||||
toggleSidebar: $t('keyboard.toggleSidebar'),
|
||||
approveToolCall: $t('keyboard.approveToolCall'),
|
||||
rejectToolCall: $t('keyboard.rejectToolCall'),
|
||||
voiceMemo: $t('keyboard.voiceMemo')
|
||||
});
|
||||
|
||||
/** Translated action labels for display. */
|
||||
@@ -40,6 +44,8 @@
|
||||
openSettings: $t('keyboard.action.openSettings'),
|
||||
toggleSplit: $t('keyboard.action.toggleSplit'),
|
||||
toggleSidebar: $t('keyboard.action.toggleSidebar'),
|
||||
approveToolCall: $t('keyboard.action.approveToolCall'),
|
||||
rejectToolCall: $t('keyboard.action.rejectToolCall'),
|
||||
voiceMemo: $t('keyboard.action.voiceMemo')
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
streamingChatTabs,
|
||||
registerStreamingChat,
|
||||
unregisterStreamingChat,
|
||||
updateChatStatuses
|
||||
updateChatStatuses,
|
||||
registerToolApprovalShortcutHandler
|
||||
} from '$lib/stores/chat';
|
||||
import { socketStore } from '$lib/stores/socket.svelte';
|
||||
import { onMount, onDestroy, tick } from 'svelte';
|
||||
@@ -763,7 +764,7 @@
|
||||
}
|
||||
refreshCommandSessions();
|
||||
commandSessionsTimer = setInterval(refreshCommandSessions, 5000);
|
||||
window.addEventListener('cptr:inspect-command-session', handleInspectCommandSession);
|
||||
window.addEventListener('computer:inspectCommandSession', handleInspectCommandSession);
|
||||
|
||||
const offChat = socketStore.on('events:chat', handleSocketEvent);
|
||||
const offConnect = socketStore.on('connect', handleReconnect);
|
||||
@@ -779,7 +780,7 @@
|
||||
unbindSocketListeners = null;
|
||||
if (commandSessionsTimer) clearInterval(commandSessionsTimer);
|
||||
commandSessionsTimer = null;
|
||||
window.removeEventListener('cptr:inspect-command-session', handleInspectCommandSession);
|
||||
window.removeEventListener('computer:inspectCommandSession', handleInspectCommandSession);
|
||||
if (landingRefreshTimer) clearTimeout(landingRefreshTimer);
|
||||
if (taskClearTimer) clearTimeout(taskClearTimer);
|
||||
// Don't clear streamingChatTabs here -- the global listener in
|
||||
@@ -821,6 +822,11 @@
|
||||
return () => unregisterStreamingChat(chatId!, tabId!);
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!active) return;
|
||||
return registerToolApprovalShortcutHandler(handleApproveToolCallShortcut);
|
||||
});
|
||||
|
||||
// ── Persist read state separately from visibility tracking ──
|
||||
|
||||
$effect(() => {
|
||||
@@ -1265,7 +1271,8 @@
|
||||
item.type === 'function_call' && item.call_id === callId && item.status === 'pending'
|
||||
);
|
||||
if (call) {
|
||||
call.status = approved ? 'running' : 'rejected';
|
||||
call.status = approved ? 'queued' : 'rejected';
|
||||
if (approved) call.approved = true;
|
||||
allMessages = [...allMessages]; // trigger reactivity
|
||||
}
|
||||
}
|
||||
@@ -1277,6 +1284,22 @@
|
||||
});
|
||||
}
|
||||
|
||||
function handleApproveToolCallShortcut(approved: boolean) {
|
||||
for (const { msg } of [...activePath].reverse()) {
|
||||
const item = msg.output?.find(
|
||||
(output: any) =>
|
||||
output.type === 'function_call' &&
|
||||
output.name !== 'ask_user' &&
|
||||
output.status === 'pending'
|
||||
);
|
||||
if (!item) continue;
|
||||
|
||||
handleApprove(msg.id, item.call_id, approved);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function handleAskUserAnswer(
|
||||
messageId: string,
|
||||
callId: string,
|
||||
|
||||
Reference in new issue
Block a user