This commit is contained in:
Timothy Jaeryang Baek
2026-02-27 16:41:52 -06:00
parent bbbcf27dd5
commit 3be06132db
3 changed files with 35 additions and 13 deletions
+8 -2
View File
@@ -43,7 +43,8 @@
selectedFolder, selectedFolder,
pinnedChats, pinnedChats,
showEmbeds, showEmbeds,
selectedTerminalId selectedTerminalId,
showFileNavPath
} from '$lib/stores'; } from '$lib/stores';
import { WEBUI_API_BASE_URL } from '$lib/constants'; import { WEBUI_API_BASE_URL } from '$lib/constants';
@@ -57,7 +58,8 @@
processDetails, processDetails,
removeAllDetails, removeAllDetails,
getCodeBlockContents, getCodeBlockContents,
isYoutubeUrl isYoutubeUrl,
displayFileHandler
} from '$lib/utils'; } from '$lib/utils';
import { AudioQueue } from '$lib/utils/audio'; import { AudioQueue } from '$lib/utils/audio';
@@ -576,6 +578,10 @@
eventConfirmationInputPlaceholder = data.placeholder; eventConfirmationInputPlaceholder = data.placeholder;
eventConfirmationInputValue = data?.value ?? ''; eventConfirmationInputValue = data?.value ?? '';
eventConfirmationInputType = data?.type ?? ''; eventConfirmationInputType = data?.type ?? '';
} else if (type === 'display_file') {
if (data?.path) {
displayFileHandler(data.path, { showControls, showFileNavPath });
}
} else { } else {
console.log('Unknown message type', data); console.log('Unknown message type', data);
} }
+25 -7
View File
@@ -1,3 +1,4 @@
import type { Writable } from 'svelte/store';
import { v4 as uuidv4 } from 'uuid'; import { v4 as uuidv4 } from 'uuid';
import sha256 from 'js-sha256'; import sha256 from 'js-sha256';
import { WEBUI_BASE_URL } from '$lib/constants'; import { WEBUI_BASE_URL } from '$lib/constants';
@@ -361,9 +362,9 @@ export const generateInitialsImage = (name) => {
const initials = const initials =
sanitizedName.length > 0 sanitizedName.length > 0
? sanitizedName[0] + ? sanitizedName[0] +
(sanitizedName.split(' ').length > 1 (sanitizedName.split(' ').length > 1
? sanitizedName[sanitizedName.lastIndexOf(' ') + 1] ? sanitizedName[sanitizedName.lastIndexOf(' ') + 1]
: '') : '')
: ''; : '';
ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2); ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2);
@@ -519,10 +520,10 @@ export const compareVersion = (latest, current) => {
return current === '0.0.0' return current === '0.0.0'
? false ? false
: current.localeCompare(latest, undefined, { : current.localeCompare(latest, undefined, {
numeric: true, numeric: true,
sensitivity: 'case', sensitivity: 'case',
caseFirst: 'upper' caseFirst: 'upper'
}) < 0; }) < 0;
}; };
export const extractCurlyBraceWords = (text) => { export const extractCurlyBraceWords = (text) => {
@@ -1720,3 +1721,20 @@ export const parseFrontmatter = (content) => {
export const formatSkillName = (name) => { export const formatSkillName = (name) => {
return name.replace(/[-_]/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()); return name.replace(/[-_]/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase());
}; };
/**
* Open the file browser panel to display a specific file.
* Used by both the direct tool execution path (client-side) and the
* backend event path (server-side) so behaviour is consistent.
*
* Stores are passed in by the caller to keep this utility pure.
*/
export const displayFileHandler = (
path: string,
stores: { showControls: Writable<boolean>; showFileNavPath: Writable<string | null> }
) => {
if (path) {
stores.showControls.set(true);
stores.showFileNavPath.set(path);
}
};
+2 -4
View File
@@ -52,7 +52,7 @@
import { chatCompletion } from '$lib/apis/openai'; import { chatCompletion } from '$lib/apis/openai';
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL, WEBUI_HOSTNAME } from '$lib/constants'; import { WEBUI_API_BASE_URL, WEBUI_BASE_URL, WEBUI_HOSTNAME } from '$lib/constants';
import { bestMatchingLanguage } from '$lib/utils'; import { bestMatchingLanguage, displayFileHandler } from '$lib/utils';
import { setTextScale } from '$lib/utils/text-scale'; import { setTextScale } from '$lib/utils/text-scale';
import NotificationToast from '$lib/components/NotificationToast.svelte'; import NotificationToast from '$lib/components/NotificationToast.svelte';
@@ -331,11 +331,9 @@
console.log('executeToolServer', res); console.log('executeToolServer', res);
// Intercept display_file result to handle UI
if (data?.name === 'display_file' && data?.params?.path) { if (data?.name === 'display_file' && data?.params?.path) {
if (res?.exists !== false) { if (res?.exists !== false) {
showControls.set(true); displayFileHandler(data.params.path, { showControls, showFileNavPath });
showFileNavPath.set(data.params.path);
} }
} }