refac
This commit is contained in:
+25
-7
@@ -1,3 +1,4 @@
|
||||
import type { Writable } from 'svelte/store';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import sha256 from 'js-sha256';
|
||||
import { WEBUI_BASE_URL } from '$lib/constants';
|
||||
@@ -361,9 +362,9 @@ export const generateInitialsImage = (name) => {
|
||||
const initials =
|
||||
sanitizedName.length > 0
|
||||
? sanitizedName[0] +
|
||||
(sanitizedName.split(' ').length > 1
|
||||
? sanitizedName[sanitizedName.lastIndexOf(' ') + 1]
|
||||
: '')
|
||||
(sanitizedName.split(' ').length > 1
|
||||
? sanitizedName[sanitizedName.lastIndexOf(' ') + 1]
|
||||
: '')
|
||||
: '';
|
||||
|
||||
ctx.fillText(initials.toUpperCase(), canvas.width / 2, canvas.height / 2);
|
||||
@@ -519,10 +520,10 @@ export const compareVersion = (latest, current) => {
|
||||
return current === '0.0.0'
|
||||
? false
|
||||
: current.localeCompare(latest, undefined, {
|
||||
numeric: true,
|
||||
sensitivity: 'case',
|
||||
caseFirst: 'upper'
|
||||
}) < 0;
|
||||
numeric: true,
|
||||
sensitivity: 'case',
|
||||
caseFirst: 'upper'
|
||||
}) < 0;
|
||||
};
|
||||
|
||||
export const extractCurlyBraceWords = (text) => {
|
||||
@@ -1720,3 +1721,20 @@ export const parseFrontmatter = (content) => {
|
||||
export const formatSkillName = (name) => {
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user