LLM inference in C/C++
C++ ggml
ui: mask API Key field in settings and error splash to stop browser a… (#26562)
Cristiano Pintoece963f41b0b
diff --git a/tools/ui/src/lib/components/app/server/ServerErrorSplash.svelte b/tools/ui/src/lib/components/app/server/ServerErrorSplash.svelteindex a2e23eecdd..fbdbf19f29 100644--- a/tools/ui/src/lib/components/app/server/ServerErrorSplash.svelte+++ b/tools/ui/src/lib/components/app/server/ServerErrorSplash.svelte@@ -158,6 +158,8 @@<div class="relative"><Inputid="api-key-input"+ type="password"+ autocomplete="new-password"placeholder="Enter your API key..."bind:value={apiKeyInput}onkeydown={handleApiKeyKeydown}diff --git a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelteindex bc9adea420..30f2b9b2a7 100644--- a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte+++ b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChatFields.svelte@@ -81,7 +81,8 @@<div class="relative w-full"><Inputid={field.key}- type={field.isPositiveInteger ? 'number' : 'text'}+ type={field.isPrivate ? 'password' : field.isPositiveInteger ? 'number' : 'text'}+ autocomplete={field.isPrivate ? 'new-password' : undefined}{...field.isPositiveInteger? {min: String(field.min ?? 1),diff --git a/tools/ui/src/lib/constants/settings-registry.constants.ts b/tools/ui/src/lib/constants/settings-registry.constants.tsindex e444599570..bf43a26e86 100644--- a/tools/ui/src/lib/constants/settings-registry.constants.ts+++ b/tools/ui/src/lib/constants/settings-registry.constants.ts@@ -324,6 +324,7 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {{defaultValue: '',help: `Set the API Key if you are using <code> ${CLI_FLAGS.API_KEY} </code> option for the server.`,+ isPrivate: true,key: SETTINGS_KEYS.API_KEY,label: 'API Key',section: SETTINGS_SECTION_SLUGS.GENERAL,@@ -713,6 +714,7 @@ export const SETTINGS_CHAT_SECTIONS: SettingsSection[] = [help: s.help,isExperimental: s.isExperimental,isPositiveInteger: s.isPositiveInteger,+ isPrivate: s.isPrivate,key: s.key,label: s.label,max: s.max,diff --git a/tools/ui/src/lib/types/settings.d.ts b/tools/ui/src/lib/types/settings.d.tsindex 55f304ea24..d04837727d 100644--- a/tools/ui/src/lib/types/settings.d.ts+++ b/tools/ui/src/lib/types/settings.d.ts@@ -31,6 +31,7 @@ export interface SettingsEntry {radioOptions?: Array<{ value: string; label: string; key: string; isExperimental?: boolean }>;isExperimental?: boolean;isPositiveInteger?: boolean;+ isPrivate?: boolean;placeholder?: string;min?: number;max?: number;@@ -55,6 +56,7 @@ export interface SettingsFieldConfig {type: SettingsFieldType;isExperimental?: boolean;isPositiveInteger?: boolean;+ isPrivate?: boolean;placeholder?: string;min?: number;max?: number;diff --git a/tools/ui/tests/unit/settings-private-fields.test.ts b/tools/ui/tests/unit/settings-private-fields.test.tsnew file mode 100644index 0000000000..0716b3cbad--- /dev/null+++ b/tools/ui/tests/unit/settings-private-fields.test.ts@@ -0,0 +1,12 @@+import { SETTINGS_CHAT_SECTIONS, SETTINGS_KEYS } from '$lib/constants';+import { describe, expect, it } from 'vitest';++describe('checkApiKeyField', () => {+ it('should have isPrivate set to true', () => {+ const fields = SETTINGS_CHAT_SECTIONS.flatMap((section) => section.fields);+ const apiKeyField = fields.find((field) => field?.key === SETTINGS_KEYS.API_KEY);++ expect(apiKeyField).toBeDefined();+ expect(apiKeyField?.isPrivate).toBe(true);+ });+});