LLM inference in C/C++
C++ ggml
ui: Settings navigation cleanup (#27241)
Aleksander Grygier5b6ddc9675a9
diff --git a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelteindex 4233039eff..97ff30ba7a 100644--- a/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte+++ b/tools/ui/src/lib/components/app/settings/SettingsChat/SettingsChat.svelte@@ -15,7 +15,7 @@NUMERIC_FIELDS,POSITIVE_INTEGER_FIELDS,SETTINGS_CHAT_SECTIONS,- SETTINGS_SECTION_TITLES+ SETTINGS_SECTION_SLUGS} from '$lib/constants';import { ColorMode } from '$lib/enums/ui.enums';import { RouterService } from '$lib/services/router.service';@@ -46,7 +46,7 @@let fetchInitiated = false;$effect(() => {- if (serverStore.isRouterMode && currentSection.fields && !fetchInitiated) {+ if (serverStore.isRouterMode && currentSection.fields?.length && !fetchInitiated) {fetchInitiated = true;void modelsStore@@ -148,9 +148,9 @@<h3 class="text-lg font-semibold">{currentSection.title}</h3></div>- {#if currentSection.title === SETTINGS_SECTION_TITLES.TOOLS}+ {#if currentSection.slug === SETTINGS_SECTION_SLUGS.TOOLS}<SettingsChatToolsTab />- {:else if currentSection.title === SETTINGS_SECTION_TITLES.IMPORT_EXPORT}+ {:else if currentSection.slug === SETTINGS_SECTION_SLUGS.IMPORT_EXPORT}<SettingsChatImportExportTab />{:else if currentSection.fields}<div class="space-y-6">@@ -161,7 +161,7 @@onThemeChange={handleThemeChange}/>- {#if currentSection.title === SETTINGS_SECTION_TITLES.GENERAL}+ {#if currentSection.slug === SETTINGS_SECTION_SLUGS.GENERAL}<div class="flex justify-end"><Button variant="outline" onclick={() => window.location.reload()}><RefreshCw class="h-3 w-3" />diff --git a/tools/ui/src/lib/constants/index.ts b/tools/ui/src/lib/constants/index.tsindex 8ab921d758..3b60b21687 100644--- a/tools/ui/src/lib/constants/index.ts+++ b/tools/ui/src/lib/constants/index.ts@@ -48,7 +48,7 @@ export * from './pwa.constants';export * from './routes.constants';export * from './sandbox.constants';export * from './settings-keys.constants';-export * from './settings-registry.constants';+export * from './settings.constants';export * from './special-characters.constants';export * from './stream.constants';export * from './supported-file-types.constants';diff --git a/tools/ui/src/lib/constants/routes.constants.ts b/tools/ui/src/lib/constants/routes.constants.tsindex 84b0f5300b..e4cce77399 100644--- a/tools/ui/src/lib/constants/routes.constants.ts+++ b/tools/ui/src/lib/constants/routes.constants.ts@@ -10,18 +10,6 @@ export const URL_PARAMS = {QUERY: 'q'} as const;-/** Settings section slugs — used for routes and navigation. */-export const SETTINGS_SECTION_SLUGS = {- AGENTIC: 'agentic',- DEVELOPER: 'developer',- DISPLAY: 'display',- GENERAL: 'general',- IMPORT_EXPORT: 'import-export',- PENALTIES: 'penalties',- SAMPLING: 'sampling',- TOOLS: 'tools'-} as const;-export const ROUTES = {/** Chat base — for dynamic chat URLs use RouterService. */CHAT: '#/chat',@@ -33,6 +21,8 @@ export const ROUTES = {SEARCH: '#/search',/** Settings base — for dynamic settings URLs use RouterService. */SETTINGS: '#/settings',+ /** Exit destination for the settings view (fallback when no referrer). */+ SETTINGS_EXIT: '#/',/** Root — start of the app. */START: '#/'} as const;diff --git a/tools/ui/src/lib/constants/settings-registry.constants.ts b/tools/ui/src/lib/constants/settings.constants.tssimilarity index 74%rename from tools/ui/src/lib/constants/settings-registry.constants.tsrename to tools/ui/src/lib/constants/settings.constants.tsindex bf43a26e86..7f8db226da 100644--- a/tools/ui/src/lib/constants/settings-registry.constants.ts+++ b/tools/ui/src/lib/constants/settings.constants.ts@@ -1,11 +1,9 @@import { CLI_FLAGS } from './cli-flags.constants';import { DEFAULT_MCP_CONFIG } from './mcp.constants';-import { ROUTES, SETTINGS_SECTION_SLUGS } from './routes.constants';import { SETTINGS_KEYS } from './settings-keys.constants';import { TITLE_GENERATION } from './title-generation.constants';import { FILE_GLOB_SEARCH_PICKERS } from './working-directory.constants';import {- AlertTriangle,Code,Database,Funnel,@@ -13,7 +11,7 @@ import {Monitor,Moon,PencilRuler,- Sliders,+ SlidersVertical,Sun} from '@lucide/svelte';import { SyncableParameterType } from '$lib/enums';@@ -22,174 +20,175 @@ import { ColorMode } from '$lib/enums/ui.enums';import type {SettingsConfigValue,SettingsEntry,+ SettingsFieldConfig,SettingsSection,- SettingsSectionEntry,- SettingsSectionTitle,- SyncableParameter+ SettingsSectionEntry} from '$lib/types';-import type { Component } from 'svelte';++/** Settings sections — slug is the routing identity, title is the display label. */+export const SETTINGS_SECTIONS = {+ AGENTIC: { slug: 'agentic', title: 'Agentic' },+ DEVELOPER: { slug: 'developer', title: 'Developer' },+ DISPLAY: { slug: 'display', title: 'Display' },+ GENERAL: { slug: 'general', title: 'General' },+ IMPORT_EXPORT: { slug: 'import-export', title: 'Import/Export' },+ SAMPLING_PENALTIES: { slug: 'sampling-penalties', title: 'Sampling & Penalties' },+ TOOLS: { slug: 'tools', title: 'Tools' }+} as const;++export const SETTINGS_SECTION_SLUGS = {+ AGENTIC: SETTINGS_SECTIONS.AGENTIC.slug,+ DEVELOPER: SETTINGS_SECTIONS.DEVELOPER.slug,+ DISPLAY: SETTINGS_SECTIONS.DISPLAY.slug,+ GENERAL: SETTINGS_SECTIONS.GENERAL.slug,+ IMPORT_EXPORT: SETTINGS_SECTIONS.IMPORT_EXPORT.slug,+ SAMPLING_PENALTIES: SETTINGS_SECTIONS.SAMPLING_PENALTIES.slug,+ TOOLS: SETTINGS_SECTIONS.TOOLS.slug+} as const;export const SETTINGS_SECTION_TITLES = {- AGENTIC: 'Agentic',- DEVELOPER: 'Developer',- DISPLAY: 'Display',- GENERAL: 'General',- IMPORT_EXPORT: 'Import/Export',- PENALTIES: 'Penalties',- SAMPLING: 'Sampling',- TOOLS: 'Tools'+ AGENTIC: SETTINGS_SECTIONS.AGENTIC.title,+ DEVELOPER: SETTINGS_SECTIONS.DEVELOPER.title,+ DISPLAY: SETTINGS_SECTIONS.DISPLAY.title,+ GENERAL: SETTINGS_SECTIONS.GENERAL.title,+ IMPORT_EXPORT: SETTINGS_SECTIONS.IMPORT_EXPORT.title,+ SAMPLING_PENALTIES: SETTINGS_SECTIONS.SAMPLING_PENALTIES.title,+ TOOLS: SETTINGS_SECTIONS.TOOLS.title} as const;-const STANDALONE_SECTIONS: { title: SettingsSectionTitle; slug: string; icon: Component }[] = [- { icon: PencilRuler, slug: SETTINGS_SECTION_SLUGS.TOOLS, title: SETTINGS_SECTION_TITLES.TOOLS },- {- icon: Database,- slug: SETTINGS_SECTION_SLUGS.IMPORT_EXPORT,- title: SETTINGS_SECTION_TITLES.IMPORT_EXPORT- }-];-const COLOR_MODE_OPTIONS: Array<{ value: string; label: string; icon: Component }> = [- { icon: Monitor, label: 'System', value: ColorMode.SYSTEM },- { icon: Sun, label: 'Light', value: ColorMode.LIGHT },- { icon: Moon, label: 'Dark', value: ColorMode.DARK }-];-// Shared options for the title-generation radio group. Both paired registry entries-// (USE_FIRST_LINE, USE_LLM) reference this list so labels stay in lockstep.-const TITLE_GENERATION_RADIO_OPTIONS: Array<{- value: string;- label: string;- key: string;- isExperimental?: boolean;-}> = [- {- key: SETTINGS_KEYS.TITLE_GENERATION_USE_FIRST_LINE,- label: 'Use first non-empty line for the conversation title',- value: 'firstLine'- },+export const SETTINGS_REGISTRY: SettingsSectionEntry[] = [+ // General{- isExperimental: true,- key: SETTINGS_KEYS.TITLE_GENERATION_USE_LLM,- label: 'Generate title with LLM',- value: 'llm'- }-];-// Common shape for the conversation title radio entry.-const TITLE_GENERATION_BASE = {- radioOptions: TITLE_GENERATION_RADIO_OPTIONS,- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.RADIO-} as const;-const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {- [SETTINGS_SECTION_SLUGS.AGENTIC]: {- icon: ListRestart,+ icon: SlidersVertical,settings: [{- defaultValue: 10,- help: 'Maximum number of tool execution cycles before stopping (prevents infinite loops).',- isPositiveInteger: true,- key: SETTINGS_KEYS.AGENTIC_MAX_TURNS,- label: 'Agentic turns',- section: SETTINGS_SECTION_SLUGS.AGENTIC,- type: SettingsFieldType.INPUT+ defaultValue: ColorMode.SYSTEM,+ help: 'Choose the color theme for the interface. You can choose between System (follows your device settings), Light, or Dark.',+ key: SETTINGS_KEYS.THEME,+ label: 'Theme',+ options: [+ { icon: Monitor, label: 'System', value: ColorMode.SYSTEM },+ { icon: Sun, label: 'Light', value: ColorMode.LIGHT },+ { icon: Moon, label: 'Dark', value: ColorMode.DARK }+ ],+ type: SettingsFieldType.SELECT},{- defaultValue: DEFAULT_MCP_CONFIG.requestTimeoutSeconds,- help: 'Timeout for individual MCP tool calls.',- isPositiveInteger: true,- key: SETTINGS_KEYS.MCP_REQUEST_TIMEOUT_SECONDS,- label: 'MCP request timeout (seconds)',- section: SETTINGS_SECTION_SLUGS.AGENTIC,+ 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',type: SettingsFieldType.INPUT},{- defaultValue: FILE_GLOB_SEARCH_PICKERS.DEFAULT_SEARCH_DEPTH,- help: 'How many directory levels below the working directory the @-mention file search descends. Larger values surface deeply nested files but take longer on large trees.',- isPositiveInteger: true,- key: SETTINGS_KEYS.MENTION_SEARCH_MAX_DEPTH,- label: 'Mention search depth',- max: FILE_GLOB_SEARCH_PICKERS.MAX_SEARCH_DEPTH,- min: 1,- placeholder: `${FILE_GLOB_SEARCH_PICKERS.DEFAULT_SEARCH_DEPTH}`,- section: SETTINGS_SECTION_SLUGS.AGENTIC,- type: SettingsFieldType.INPUT- }- ],- slug: SETTINGS_SECTION_SLUGS.AGENTIC,- title: SETTINGS_SECTION_TITLES.AGENTIC- },- [SETTINGS_SECTION_SLUGS.DEVELOPER]: {- icon: Code,- settings: [+ defaultValue: '',+ help: 'The starting message that defines how model should behave.',+ key: SETTINGS_KEYS.SYSTEM_MESSAGE,+ label: 'System Message',+ type: SettingsFieldType.TEXTAREA+ },{- defaultValue: false,- help: 'After each response, re-submit the conversation to pre-fill the server KV cache. Makes the next turn faster since the prompt is already encoded while you read the response.',- key: SETTINGS_KEYS.PRE_ENCODE_CONVERSATION,- label: 'Pre-fill KV cache after response',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,+ defaultValue: true,+ help: 'Display the system message at the top of each conversation.',+ key: SETTINGS_KEYS.SHOW_SYSTEM_MESSAGE,+ label: 'Show system message',+ standaloneField: false,type: SettingsFieldType.CHECKBOX},{- defaultValue: false,- help: 'Send reasoning_format=none so the server returns thinking tokens inline instead of extracting them into a separate field.',- key: SETTINGS_KEYS.DISABLE_REASONING_PARSING,- label: 'Disable reasoning content parsing',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,+ defaultValue: 2500,+ help: 'On pasting long text, it will be converted to a file. You can control the file length by setting the value of this parameter. Value 0 means disable.',+ key: SETTINGS_KEYS.PASTE_LONG_TEXT_TO_FILE_LEN,+ label: 'Paste long text to file length',+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: true,+ help: 'Use Enter to send messages and Shift + Enter for new lines. When disabled, use Ctrl/Cmd + Enter.',+ key: SETTINGS_KEYS.SEND_ON_ENTER,+ label: 'Send message on Enter',type: SettingsFieldType.CHECKBOX},{defaultValue: false,- help: 'Strip thinking from previous messages before sending. When off, thinking is sent back via the reasoning_content field so the model sees its own chain-of-thought across turns.',- key: SETTINGS_KEYS.EXCLUDE_REASONING_FROM_CONTEXT,- label: 'Exclude reasoning from context',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,+ help: 'Automatically show microphone button instead of send button when textarea is empty for models with audio modality support.',+ isExperimental: true,+ key: SETTINGS_KEYS.AUTO_MIC_ON_EMPTY,+ label: 'Show microphone on empty input',type: SettingsFieldType.CHECKBOX},{defaultValue: false,- help: 'Show toggle button to display messages as plain text instead of Markdown-formatted content',- key: SETTINGS_KEYS.SHOW_RAW_OUTPUT_SWITCH,- label: 'Enable raw output toggle',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,+ help: 'Enable "Continue" button for assistant messages, including reasoning models.',+ isExperimental: true,+ key: SETTINGS_KEYS.ENABLE_CONTINUE_GENERATION,+ label: 'Enable "Continue" button',type: SettingsFieldType.CHECKBOX},+ {+ defaultValue: true,+ help: 'Choose how conversation titles are generated. The first non-empty line uses a fast deterministic rule; the LLM option uses a model-generated title from the first message exchange.',+ key: SETTINGS_KEYS.TITLE_GENERATION_USE_FIRST_LINE,+ label: 'Conversation title',+ radioOptions: [+ {+ key: SETTINGS_KEYS.TITLE_GENERATION_USE_FIRST_LINE,+ label: 'Use first non-empty line for the conversation title',+ value: 'firstLine'+ },+ {+ isExperimental: true,+ key: SETTINGS_KEYS.TITLE_GENERATION_USE_LLM,+ label: 'Generate title with LLM',+ value: 'llm'+ }+ ],+ type: SettingsFieldType.RADIO+ },+ {+ defaultValue: TITLE_GENERATION.DEFAULT_PROMPT,+ dependsOn: SETTINGS_KEYS.TITLE_GENERATION_USE_LLM,+ help: 'Optional template for the title generation prompt. Use {{USER}} for the user message and {{ASSISTANT}} for the assistant message.',+ key: SETTINGS_KEYS.TITLE_GENERATION_PROMPT,+ label: 'LLM title generation prompt',+ type: SettingsFieldType.TEXTAREA+ },{defaultValue: false,- help: 'Expose a run_javascript tool to the model. Code runs in a Web Worker inside a sandboxed iframe with an opaque origin, isolated from the WebUI and its API, with a hard timeout.',- key: SETTINGS_KEYS.JS_SANDBOX_ENABLED,- label: 'JavaScript sandbox tool',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,+ help: 'Counterpart of the conversation title radio; stored and synced without a dedicated UI field.',+ key: SETTINGS_KEYS.TITLE_GENERATION_USE_LLM,+ label: 'Generate title with LLM',+ standaloneField: false,type: SettingsFieldType.CHECKBOX},{defaultValue: false,- dependsOn: SETTINGS_KEYS.JS_SANDBOX_ENABLED,- help: 'Pre-load nerdamer in the sandbox for symbolic computation: simplify, diff, integrate, solve, and more. Requires "JavaScript sandbox tool" to be enabled.',- key: SETTINGS_KEYS.SYMBOLIC_MATH_ENABLED,- label: 'Symbolic math (nerdamer)',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,+ help: 'When copying a message with text attachments, combine them into a single plain text string instead of a special format that can be pasted back as attachments.',+ key: SETTINGS_KEYS.COPY_TEXT_ATTACHMENTS_AS_PLAIN_TEXT,+ label: 'Copy text attachments as plain text',type: SettingsFieldType.CHECKBOX},{- defaultValue: '',- help: 'Custom JSON parameters to send to the API. Must be valid JSON format.',- key: SETTINGS_KEYS.CUSTOM_JSON,- label: 'Custom JSON',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,- type: SettingsFieldType.TEXTAREA+ defaultValue: false,+ help: 'Parse PDF as image instead of text. Automatically falls back to text processing for non-vision models.',+ key: SETTINGS_KEYS.PDF_AS_IMAGE,+ label: 'Parse PDF as image',+ type: SettingsFieldType.CHECKBOX},{- defaultValue: '',- help: 'CSS injected into the page at runtime. Set it here, or ship it server side via the --ui-config customCss field.',- key: SETTINGS_KEYS.CUSTOM_CSS,- label: 'Custom CSS',- section: SETTINGS_SECTION_SLUGS.DEVELOPER,- type: SettingsFieldType.TEXTAREA+ defaultValue: 0,+ help: 'Images larger than this will be resized before sending to server. Set to 0 to disable.',+ key: SETTINGS_KEYS.MAX_IMAGE_RESOLUTION,+ label: 'Maximum image resolution (megapixels)',+ type: SettingsFieldType.INPUT}],- slug: SETTINGS_SECTION_SLUGS.DEVELOPER,- title: SETTINGS_SECTION_TITLES.DEVELOPER+ slug: SETTINGS_SECTION_SLUGS.GENERAL,+ title: SETTINGS_SECTION_TITLES.GENERAL},- [SETTINGS_SECTION_SLUGS.DISPLAY]: {+ // Display+ {icon: Monitor,settings: [{@@ -197,7 +196,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display generation statistics (tokens/second, token count, duration) below each assistant message.',key: SETTINGS_KEYS.SHOW_MESSAGE_STATS,label: 'Show message generation statistics',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -206,7 +204,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display per-turn statistics (tokens, duration) under each turn in agentic responses. Shown only when "Show message generation statistics" is enabled.',key: SETTINGS_KEYS.SHOW_AGENTIC_TURN_STATS,label: 'Show statistics for individual agentic turns',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -214,7 +211,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Expand thought process by default when generating messages.',key: SETTINGS_KEYS.SHOW_THOUGHT_IN_PROGRESS,label: 'Show thought in progress',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -222,7 +218,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Automatically expand tool call details while executing and keep them expanded after completion.',key: SETTINGS_KEYS.ALWAYS_SHOW_TOOL_CALL_CONTENT,label: 'Always show tool call content',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -230,7 +225,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Render user messages using markdown formatting in the chat. Turn this off to keep a message exactly as typed; @-mention badges show either way.',key: SETTINGS_KEYS.RENDER_USER_CONTENT_AS_MARKDOWN,label: 'Render user content as Markdown',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -238,7 +232,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Render the reasoning/thinking block content as formatted Markdown instead of plain text.',key: SETTINGS_KEYS.RENDER_THINKING_AS_MARKDOWN,label: 'Render thinking as Markdown',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -246,7 +239,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Always display code blocks at their full natural height, overriding any height limits.',key: SETTINGS_KEYS.FULL_HEIGHT_CODE_BLOCKS,label: 'Use full height code blocks',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -254,7 +246,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Disable automatic scrolling while messages stream so you can control the viewport position manually.',key: SETTINGS_KEYS.DISABLE_AUTO_SCROLL,label: 'Disable automatic scroll',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -262,7 +253,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Always keep the sidebar visible on desktop instead of auto-hiding it.',key: SETTINGS_KEYS.ALWAYS_SHOW_SIDEBAR_ON_DESKTOP,label: 'Always show sidebar on desktop',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -270,7 +260,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display full raw model identifiers (e.g. "ggml-org/GLM-4.7-Flash-GGUF:Q8_0") instead of parsed names with badges.',key: SETTINGS_KEYS.SHOW_RAW_MODEL_NAMES,label: 'Show raw model names',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -278,7 +267,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display quantization badges (e.g. Q8_0, Q4_K_M) next to model names throughout the interface.',key: SETTINGS_KEYS.SHOW_MODEL_QUANTIZATION,label: 'Show model quantization information',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -286,7 +274,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display model tags (e.g. "vision", "reasoning") next to model names throughout the interface.',key: SETTINGS_KEYS.SHOW_MODEL_TAGS,label: 'Show model tags',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -294,7 +281,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display the current build version in the bottom-right corner of the interface.',key: SETTINGS_KEYS.SHOW_BUILD_VERSION,label: 'Show build version information',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX},{@@ -302,221 +288,72 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Display the full file system path inside file and folder @-mention badges instead of just the file or folder name.',key: SETTINGS_KEYS.SHOW_FULL_PATH_IN_MENTIONS,label: 'Show full path in mentions',- section: SETTINGS_SECTION_SLUGS.DISPLAY,type: SettingsFieldType.CHECKBOX}],slug: SETTINGS_SECTION_SLUGS.DISPLAY,title: SETTINGS_SECTION_TITLES.DISPLAY},- [SETTINGS_SECTION_SLUGS.GENERAL]: {- icon: Sliders,+ // MCP Servers (non-UI config object)+ {+ icon: PencilRuler,settings: [{- defaultValue: ColorMode.SYSTEM,- help: 'Choose the color theme for the interface. You can choose between System (follows your device settings), Light, or Dark.',- key: SETTINGS_KEYS.THEME,- label: 'Theme',- options: COLOR_MODE_OPTIONS,- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.SELECT- },- {- 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,- type: SettingsFieldType.INPUT- },- {- defaultValue: '',- help: 'The starting message that defines how model should behave.',- key: SETTINGS_KEYS.SYSTEM_MESSAGE,- label: 'System Message',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.TEXTAREA- },- {- defaultValue: 2500,- help: 'On pasting long text, it will be converted to a file. You can control the file length by setting the value of this parameter. Value 0 means disable.',- key: SETTINGS_KEYS.PASTE_LONG_TEXT_TO_FILE_LEN,- label: 'Paste long text to file length',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.INPUT- },- {- defaultValue: true,- help: 'Use Enter to send messages and Shift + Enter for new lines. When disabled, use Ctrl/Cmd + Enter.',- key: SETTINGS_KEYS.SEND_ON_ENTER,- label: 'Send message on Enter',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.CHECKBOX- },- {- defaultValue: false,- help: 'Automatically show microphone button instead of send button when textarea is empty for models with audio modality support.',- isExperimental: true,- key: SETTINGS_KEYS.AUTO_MIC_ON_EMPTY,- label: 'Show microphone on empty input',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.CHECKBOX- },- {- defaultValue: false,- help: 'Enable "Continue" button for assistant messages, including reasoning models.',- isExperimental: true,- key: SETTINGS_KEYS.ENABLE_CONTINUE_GENERATION,- label: 'Enable "Continue" button',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.CHECKBOX- },- {- ...TITLE_GENERATION_BASE,- defaultValue: true,- help: 'Choose how conversation titles are generated. The first non-empty line uses a fast deterministic rule; the LLM option uses a model-generated title from the first message exchange.',- key: SETTINGS_KEYS.TITLE_GENERATION_USE_FIRST_LINE,- label: 'Conversation title'- },- {- defaultValue: TITLE_GENERATION.DEFAULT_PROMPT,- dependsOn: SETTINGS_KEYS.TITLE_GENERATION_USE_LLM,- help: 'Optional template for the title generation prompt. Use {{USER}} for the user message and {{ASSISTANT}} for the assistant message.',- key: SETTINGS_KEYS.TITLE_GENERATION_PROMPT,- label: 'LLM title generation prompt',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.TEXTAREA- },- {- defaultValue: false,- help: 'When copying a message with text attachments, combine them into a single plain text string instead of a special format that can be pasted back as attachments.',- key: SETTINGS_KEYS.COPY_TEXT_ATTACHMENTS_AS_PLAIN_TEXT,- label: 'Copy text attachments as plain text',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.CHECKBOX- },- {- defaultValue: false,- help: 'Parse PDF as image instead of text. Automatically falls back to text processing for non-vision models.',- key: SETTINGS_KEYS.PDF_AS_IMAGE,- label: 'Parse PDF as image',- section: SETTINGS_SECTION_SLUGS.GENERAL,- type: SettingsFieldType.CHECKBOX- },- {- defaultValue: 0,- help: 'Images larger than this will be resized before sending to server. Set to 0 to disable.',- key: SETTINGS_KEYS.MAX_IMAGE_RESOLUTION,- label: 'Maximum image resolution (megapixels)',- section: SETTINGS_SECTION_SLUGS.GENERAL,+ defaultValue: '[]',+ help: 'Configure MCP servers as a JSON list. Use the form in the MCP Client settings section to edit.',+ key: SETTINGS_KEYS.MCP_SERVERS,+ label: 'MCP servers',+ standaloneField: false,type: SettingsFieldType.INPUT}],- slug: SETTINGS_SECTION_SLUGS.GENERAL,- title: SETTINGS_SECTION_TITLES.GENERAL+ slug: SETTINGS_SECTION_SLUGS.TOOLS,+ title: SETTINGS_SECTION_TITLES.TOOLS},- [SETTINGS_SECTION_SLUGS.PENALTIES]: {- icon: AlertTriangle,+ // Tools+ {+ icon: ListRestart,settings: [{- defaultValue: undefined,- help: 'Last n tokens to consider for penalizing repetition',- key: SETTINGS_KEYS.REPEAT_LAST_N,- label: 'Repeat last N',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.REPEAT_LAST_N- },- type: SettingsFieldType.INPUT- },- {- defaultValue: undefined,- help: 'Controls the repetition of token sequences in the generated text',- key: SETTINGS_KEYS.REPEAT_PENALTY,- label: 'Repeat penalty',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.REPEAT_PENALTY- },- type: SettingsFieldType.INPUT- },- {- defaultValue: undefined,- help: 'Limits tokens based on whether they appear in the output or not.',- key: SETTINGS_KEYS.PRESENCE_PENALTY,- label: 'Presence penalty',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.PRESENCE_PENALTY- },- type: SettingsFieldType.INPUT- },- {- defaultValue: undefined,- help: 'Limits tokens based on how often they appear in the output.',- key: SETTINGS_KEYS.FREQUENCY_PENALTY,- label: 'Frequency penalty',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.FREQUENCY_PENALTY- },- type: SettingsFieldType.INPUT- },- {- defaultValue: undefined,- help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets the DRY sampling multiplier.',- key: SETTINGS_KEYS.DRY_MULTIPLIER,- label: 'DRY multiplier',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.DRY_MULTIPLIER- },- type: SettingsFieldType.INPUT- },- {- defaultValue: undefined,- help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets the DRY sampling base value.',- key: SETTINGS_KEYS.DRY_BASE,- label: 'DRY base',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: { paramType: SyncableParameterType.NUMBER, serverKey: SETTINGS_KEYS.DRY_BASE },+ defaultValue: 10,+ help: 'Maximum number of tool execution cycles before stopping (prevents infinite loops).',+ isPositiveInteger: true,+ key: SETTINGS_KEYS.AGENTIC_MAX_TURNS,+ label: 'Agentic turns',type: SettingsFieldType.INPUT},{- defaultValue: undefined,- help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets the allowed length for DRY sampling.',- key: SETTINGS_KEYS.DRY_ALLOWED_LENGTH,- label: 'DRY allowed length',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.DRY_ALLOWED_LENGTH- },+ defaultValue: DEFAULT_MCP_CONFIG.requestTimeoutSeconds,+ help: 'Timeout for individual MCP tool calls.',+ isPositiveInteger: true,+ key: SETTINGS_KEYS.MCP_REQUEST_TIMEOUT_SECONDS,+ label: 'MCP request timeout (seconds)',type: SettingsFieldType.INPUT},{- defaultValue: undefined,- help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets DRY penalty for the last n tokens.',- key: SETTINGS_KEYS.DRY_PENALTY_LAST_N,- label: 'DRY penalty last N',- section: SETTINGS_SECTION_SLUGS.PENALTIES,- sync: {- paramType: SyncableParameterType.NUMBER,- serverKey: SETTINGS_KEYS.DRY_PENALTY_LAST_N- },+ defaultValue: FILE_GLOB_SEARCH_PICKERS.DEFAULT_SEARCH_DEPTH,+ help: 'How many directory levels below the working directory the @-mention file search descends. Larger values surface deeply nested files but take longer on large trees.',+ isPositiveInteger: true,+ key: SETTINGS_KEYS.MENTION_SEARCH_MAX_DEPTH,+ label: 'Mention search depth',+ max: FILE_GLOB_SEARCH_PICKERS.MAX_SEARCH_DEPTH,+ min: 1,+ placeholder: `${FILE_GLOB_SEARCH_PICKERS.DEFAULT_SEARCH_DEPTH}`,type: SettingsFieldType.INPUT}],- slug: SETTINGS_SECTION_SLUGS.PENALTIES,- title: SETTINGS_SECTION_TITLES.PENALTIES+ slug: SETTINGS_SECTION_SLUGS.AGENTIC,+ title: SETTINGS_SECTION_TITLES.AGENTIC+ },+ // Import/Export+ {+ icon: Database,+ settings: [],+ slug: SETTINGS_SECTION_SLUGS.IMPORT_EXPORT,+ title: SETTINGS_SECTION_TITLES.IMPORT_EXPORT},- [SETTINGS_SECTION_SLUGS.SAMPLING]: {+ // Sampling+ {icon: Funnel,settings: [{@@ -524,7 +361,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Controls the randomness of the generated text by affecting the probability distribution of the output tokens. Higher = more random, lower = more focused.',key: SETTINGS_KEYS.TEMPERATURE,label: 'Temperature',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: {paramType: SyncableParameterType.NUMBER,serverKey: SETTINGS_KEYS.TEMPERATURE@@ -536,7 +372,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Addon for the temperature sampler. The added value to the range of dynamic temperature, which adjusts probabilities by entropy of tokens.',key: SETTINGS_KEYS.DYNATEMP_RANGE,label: 'Dynamic temperature range',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: {paramType: SyncableParameterType.NUMBER,serverKey: SETTINGS_KEYS.DYNATEMP_RANGE@@ -548,7 +383,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Addon for the temperature sampler. Smoothes out the probability redistribution based on the most probable token.',key: SETTINGS_KEYS.DYNATEMP_EXPONENT,label: 'Dynamic temperature exponent',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: {paramType: SyncableParameterType.NUMBER,serverKey: SETTINGS_KEYS.DYNATEMP_EXPONENT@@ -560,7 +394,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Keeps only k top tokens.',key: SETTINGS_KEYS.TOP_K,label: 'Top K',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: { paramType: SyncableParameterType.NUMBER, serverKey: SETTINGS_KEYS.TOP_K },type: SettingsFieldType.INPUT},@@ -569,7 +402,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Limits tokens to those that together have a cumulative probability of at least p',key: SETTINGS_KEYS.TOP_P,label: 'Top P',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: { paramType: SyncableParameterType.NUMBER, serverKey: SETTINGS_KEYS.TOP_P },type: SettingsFieldType.INPUT},@@ -578,7 +410,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Limits tokens based on the minimum probability for a token to be considered, relative to the probability of the most likely token.',key: SETTINGS_KEYS.MIN_P,label: 'Min P',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: { paramType: SyncableParameterType.NUMBER, serverKey: SETTINGS_KEYS.MIN_P },type: SettingsFieldType.INPUT},@@ -587,7 +418,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'XTC sampler cuts out top tokens; this parameter controls the chance of cutting tokens at all. 0 disables XTC.',key: SETTINGS_KEYS.XTC_PROBABILITY,label: 'XTC probability',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: {paramType: SyncableParameterType.NUMBER,serverKey: SETTINGS_KEYS.XTC_PROBABILITY@@ -599,7 +429,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'XTC sampler cuts out top tokens; this parameter controls the token probability that is required to cut that token.',key: SETTINGS_KEYS.XTC_THRESHOLD,label: 'XTC threshold',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: {paramType: SyncableParameterType.NUMBER,serverKey: SETTINGS_KEYS.XTC_THRESHOLD@@ -611,7 +440,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Sorts and limits tokens based on the difference between log-probability and entropy.',key: SETTINGS_KEYS.TYP_P,label: 'Typical P',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: { paramType: SyncableParameterType.NUMBER, serverKey: SETTINGS_KEYS.TYP_P },type: SettingsFieldType.INPUT},@@ -620,7 +448,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'The maximum number of token per output. Use -1 for infinite (no limit).',key: SETTINGS_KEYS.MAX_TOKENS,label: 'Max tokens',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: {paramType: SyncableParameterType.NUMBER,serverKey: SETTINGS_KEYS.MAX_TOKENS@@ -632,7 +459,6 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'The order at which samplers are applied, in simplified way. Default is "top_k;typ_p;top_p;min_p;temperature": top_k->typ_p->top_p->min_p->temperature',key: SETTINGS_KEYS.SAMPLERS,label: 'Samplers',- section: SETTINGS_SECTION_SLUGS.SAMPLING,sync: { paramType: SyncableParameterType.STRING, serverKey: SETTINGS_KEYS.SAMPLERS },type: SettingsFieldType.INPUT},@@ -641,54 +467,170 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {help: 'Enable backend-based samplers. When enabled, supported samplers run on the accelerator backend for faster sampling.',key: SETTINGS_KEYS.BACKEND_SAMPLING,label: 'Backend sampling',- section: SETTINGS_SECTION_SLUGS.SAMPLING,type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: undefined,+ help: 'Last n tokens to consider for penalizing repetition',+ key: SETTINGS_KEYS.REPEAT_LAST_N,+ label: 'Repeat last N',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.REPEAT_LAST_N+ },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'Controls the repetition of token sequences in the generated text',+ key: SETTINGS_KEYS.REPEAT_PENALTY,+ label: 'Repeat penalty',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.REPEAT_PENALTY+ },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'Limits tokens based on whether they appear in the output or not.',+ key: SETTINGS_KEYS.PRESENCE_PENALTY,+ label: 'Presence penalty',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.PRESENCE_PENALTY+ },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'Limits tokens based on how often they appear in the output.',+ key: SETTINGS_KEYS.FREQUENCY_PENALTY,+ label: 'Frequency penalty',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.FREQUENCY_PENALTY+ },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets the DRY sampling multiplier.',+ key: SETTINGS_KEYS.DRY_MULTIPLIER,+ label: 'DRY multiplier',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.DRY_MULTIPLIER+ },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets the DRY sampling base value.',+ key: SETTINGS_KEYS.DRY_BASE,+ label: 'DRY base',+ sync: { paramType: SyncableParameterType.NUMBER, serverKey: SETTINGS_KEYS.DRY_BASE },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets the allowed length for DRY sampling.',+ key: SETTINGS_KEYS.DRY_ALLOWED_LENGTH,+ label: 'DRY allowed length',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.DRY_ALLOWED_LENGTH+ },+ type: SettingsFieldType.INPUT+ },+ {+ defaultValue: undefined,+ help: 'DRY sampling reduces repetition in generated text even across long contexts. This parameter sets DRY penalty for the last n tokens.',+ key: SETTINGS_KEYS.DRY_PENALTY_LAST_N,+ label: 'DRY penalty last N',+ sync: {+ paramType: SyncableParameterType.NUMBER,+ serverKey: SETTINGS_KEYS.DRY_PENALTY_LAST_N+ },+ type: SettingsFieldType.INPUT}],- slug: SETTINGS_SECTION_SLUGS.SAMPLING,- title: SETTINGS_SECTION_TITLES.SAMPLING- }-} as const;-const NON_UI_SETTINGS: SettingsEntry[] = [- {- defaultValue: true,- help: 'Display the system message at the top of each conversation.',- key: SETTINGS_KEYS.SHOW_SYSTEM_MESSAGE,- label: 'Show system message',- type: SettingsFieldType.CHECKBOX- },- {- defaultValue: '[]',- help: 'Configure MCP servers as a JSON list. Use the form in the MCP Client settings section to edit.',- key: SETTINGS_KEYS.MCP_SERVERS,- label: 'MCP servers',- type: SettingsFieldType.INPUT+ slug: SETTINGS_SECTION_SLUGS.SAMPLING_PENALTIES,+ title: SETTINGS_SECTION_TITLES.SAMPLING_PENALTIES},+ // Developer{- defaultValue: false,- help: 'Counterpart of the conversation title radio; stored and synced without a dedicated UI field.',- key: SETTINGS_KEYS.TITLE_GENERATION_USE_LLM,- label: 'Generate title with LLM',- type: SettingsFieldType.CHECKBOX+ icon: Code,+ settings: [+ {+ defaultValue: false,+ help: 'After each response, re-submit the conversation to pre-fill the server KV cache. Makes the next turn faster since the prompt is already encoded while you read the response.',+ key: SETTINGS_KEYS.PRE_ENCODE_CONVERSATION,+ label: 'Pre-fill KV cache after response',+ type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: false,+ help: 'Send reasoning_format=none so the server returns thinking tokens inline instead of extracting them into a separate field.',+ key: SETTINGS_KEYS.DISABLE_REASONING_PARSING,+ label: 'Disable reasoning content parsing',+ type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: false,+ help: 'Strip thinking from previous messages before sending. When off, thinking is sent back via the reasoning_content field so the model sees its own chain-of-thought across turns.',+ key: SETTINGS_KEYS.EXCLUDE_REASONING_FROM_CONTEXT,+ label: 'Exclude reasoning from context',+ type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: false,+ help: 'Show toggle button to display messages as plain text instead of Markdown-formatted content',+ key: SETTINGS_KEYS.SHOW_RAW_OUTPUT_SWITCH,+ label: 'Enable raw output toggle',+ type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: false,+ help: 'Expose a run_javascript tool to the model. Code runs in a Web Worker inside a sandboxed iframe with an opaque origin, isolated from the WebUI and its API, with a hard timeout.',+ key: SETTINGS_KEYS.JS_SANDBOX_ENABLED,+ label: 'JavaScript sandbox tool',+ type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: false,+ dependsOn: SETTINGS_KEYS.JS_SANDBOX_ENABLED,+ help: 'Pre-load nerdamer in the sandbox for symbolic computation: simplify, diff, integrate, solve, and more. Requires "JavaScript sandbox tool" to be enabled.',+ key: SETTINGS_KEYS.SYMBOLIC_MATH_ENABLED,+ label: 'Symbolic math (nerdamer)',+ type: SettingsFieldType.CHECKBOX+ },+ {+ defaultValue: '',+ help: 'Custom JSON parameters to send to the API. Must be valid JSON format.',+ key: SETTINGS_KEYS.CUSTOM_JSON,+ label: 'Custom JSON',+ type: SettingsFieldType.TEXTAREA+ },+ {+ defaultValue: '',+ help: 'CSS injected into the page at runtime. Set it here, or ship it server side via the --ui-config customCss field.',+ key: SETTINGS_KEYS.CUSTOM_CSS,+ label: 'Custom CSS',+ type: SettingsFieldType.TEXTAREA+ }+ ],+ slug: SETTINGS_SECTION_SLUGS.DEVELOPER,+ title: SETTINGS_SECTION_TITLES.DEVELOPER}- // {- // key: SETTINGS_KEYS.PY_INTERPRETER_ENABLED,- // label: 'Python interpreter enabled',- // help: 'Enable Python interpreter using Pyodide. Allows running Python code in markdown code blocks.',- // defaultValue: false,- // type: SettingsFieldType.CHECKBOX,- // isExperimental: true,- //- // }];function getAllSettings(): SettingsEntry[] {const result: SettingsEntry[] = [];- for (const section of Object.values(SETTINGS_REGISTRY)) {+ for (const section of SETTINGS_REGISTRY) {result.push(...section.settings);}- result.push(...NON_UI_SETTINGS);return result;}@@ -703,52 +645,41 @@ export const SETTING_CONFIG_INFO: Record<string, string> = Object.fromEntries(getAllSettings().map((s) => [s.key, s.help])) as Record<string, string>;-/** Theme select options. */-export const SETTINGS_COLOR_MODES_CONFIG = COLOR_MODE_OPTIONS;-/** Sidebar sections + field configs (as consumed by UI). */-export const SETTINGS_CHAT_SECTIONS: SettingsSection[] = [- ...Object.values(SETTINGS_REGISTRY).map((section) => ({- fields: section.settings.map((s) => ({- dependsOn: s.dependsOn,- help: s.help,- isExperimental: s.isExperimental,- isPositiveInteger: s.isPositiveInteger,- isPrivate: s.isPrivate,- key: s.key,- label: s.label,- max: s.max,- min: s.min,- options: s.options,- placeholder: s.placeholder,- radioOptions: s.radioOptions,- type: s.type- })),+function toSettingsSection(section: SettingsSectionEntry): SettingsSection {+ return {+ fields: section.settings+ .filter((s) => s.standaloneField !== false)+ .map((s) => ({+ dependsOn: s.dependsOn,+ help: s.help,+ isExperimental: s.isExperimental,+ isPositiveInteger: s.isPositiveInteger,+ isPrivate: s.isPrivate,+ key: s.key,+ label: s.label,+ max: s.max,+ min: s.min,+ options: s.options as SettingsFieldConfig['options'],+ placeholder: s.placeholder,+ radioOptions: s.radioOptions,+ type: s.type+ })),icon: section.icon,slug: section.slug,title: section.title- })),- ...STANDALONE_SECTIONS-];+ };+}++/** Sidebar sections in custom display order (the registry array order). */+export const SETTINGS_CHAT_SECTIONS: SettingsSection[] = SETTINGS_REGISTRY.map(toSettingsSection);/** INPUT-type settings whose value is a number. */export const NUMERIC_FIELDS = getAllSettings().filter((s) => s.type === SettingsFieldType.INPUT && typeof s.defaultValue !== 'string').map((s) => s.key) as readonly string[];-/** Numeric fields clamped to ≥ 1 and rounded. */+/** Numeric fields clamped to >= 1 and rounded. */export const POSITIVE_INTEGER_FIELDS = getAllSettings().filter((s) => s.isPositiveInteger).map((s) => s.key) as readonly string[];--/** Derived for the parameter sync service. */-export const SYNCABLE_PARAMETERS: SyncableParameter[] = getAllSettings()- .filter((s) => s.sync !== undefined)- .map((s) => ({- canSync: true,- key: s.key,- serverKey: s.sync!.serverKey,- type: s.sync!.paramType- }));--export const SETTINGS_FALLBACK_EXIT_ROUTE = ROUTES.START;diff --git a/tools/ui/src/lib/services/index.ts b/tools/ui/src/lib/services/index.tsindex 7ae9e23d48..88e79446ec 100644--- a/tools/ui/src/lib/services/index.ts+++ b/tools/ui/src/lib/services/index.ts@@ -340,3 +340,13 @@ export { RouterService } from './router.service';* @see migration.service.ts — full implementation (non-destructive)*/export { MigrationService } from './migration.service';++/**+ * **SettingsService** - localStorage persistence layer for settings+ *+ * Stateless read/write of the settings config and user-override keys. Business+ * logic (default merging, mobile defaults, theme migration) stays in the store.+ *+ * @see settingsStore in stores/settings/index.svelte.ts - reactive state + business logic+ */+export { SettingsService } from './settings.service';diff --git a/tools/ui/src/lib/services/parameter-sync.service.ts b/tools/ui/src/lib/services/parameter-sync.service.tsindex 467e7c2dbd..e140874491 100644--- a/tools/ui/src/lib/services/parameter-sync.service.ts+++ b/tools/ui/src/lib/services/parameter-sync.service.ts@@ -6,11 +6,23 @@* No reactive state; consumed by settingsStore.*/-import { SETTINGS_KEYS, SYNCABLE_PARAMETERS } from '$lib/constants';+import { SETTINGS_KEYS, SETTINGS_REGISTRY } from '$lib/constants';import { ParameterSource, SyncableParameterType } from '$lib/enums';-import type { ParameterInfo, ParameterRecord, ParameterValue } from '$lib/types';+import type { ParameterInfo, ParameterRecord, ParameterValue, SyncableParameter } from '$lib/types';import { normalizeFloatingPoint } from '$lib/utils';+/** Mapping of UI setting keys to server parameter keys, derived from the registry. */+export const SYNCABLE_PARAMETERS: SyncableParameter[] = SETTINGS_REGISTRY.flatMap(+ (section) => section.settings+)+ .filter((s) => s.sync !== undefined)+ .map((s) => ({+ canSync: true,+ key: s.key,+ serverKey: s.sync!.serverKey,+ type: s.sync!.paramType+ }));+export class ParameterSyncService {/*** Check if a parameter can be synced from server.diff --git a/tools/ui/src/lib/services/settings.service.ts b/tools/ui/src/lib/services/settings.service.tsnew file mode 100644index 0000000000..639fb063e4--- /dev/null+++ b/tools/ui/src/lib/services/settings.service.ts@@ -0,0 +1,76 @@+import { browser } from '$app/environment';+import { CONFIG_LOCALSTORAGE_KEY, USER_OVERRIDES_LOCALSTORAGE_KEY } from '$lib/constants';++/**+ * SettingsService - localStorage persistence layer for settings+ *+ * Stateless read/write of the settings config and user-override keys. Business+ * logic (default merging, mobile defaults, theme migration) stays in the store.+ *+ * **Architecture & Relationships:**+ * - **settingsStore**: Primary consumer - loads config on init and persists on change+ *+ * @see settingsStore in stores/settings/index.svelte.ts - reactive state + business logic+ */+export class SettingsService {+ /**+ * Read the raw config and user overrides from localStorage.+ * @returns Parsed values, or empty defaults when nothing is stored or parsing fails.+ */+ static loadConfig(): {+ config: Record<string, unknown>;+ userOverrides: string[];+ isFirstVisit: boolean;+ } {+ if (!browser) {+ return { config: {}, isFirstVisit: false, userOverrides: [] };+ }++ try {+ const storedConfigRaw = localStorage.getItem(CONFIG_LOCALSTORAGE_KEY);+ const isFirstVisit = storedConfigRaw === null;+ const config = JSON.parse(storedConfigRaw || '{}') as Record<string, unknown>;+ const userOverrides = JSON.parse(+ localStorage.getItem(USER_OVERRIDES_LOCALSTORAGE_KEY) || '[]'+ ) as string[];++ return { config, isFirstVisit, userOverrides };+ } catch (error) {+ console.warn('Failed to parse config from localStorage, using defaults:', error);++ return { config: {}, isFirstVisit: false, userOverrides: [] };+ }+ }++ /**+ * Migrate the legacy un-namespaced "theme" localStorage key.+ * Returns the legacy theme value (and removes the key) when present, else null.+ */+ static migrateLegacyTheme(): string | null {+ if (!browser) return null;++ const legacyTheme = localStorage.getItem('theme');++ if (legacyTheme) {+ localStorage.removeItem('theme');++ return legacyTheme;+ }++ return null;+ }++ /**+ * Persist the config and user overrides to localStorage.+ */+ static saveConfig(config: Record<string, unknown>, userOverrides: string[]): void {+ if (!browser) return;++ try {+ localStorage.setItem(CONFIG_LOCALSTORAGE_KEY, JSON.stringify(config));+ localStorage.setItem(USER_OVERRIDES_LOCALSTORAGE_KEY, JSON.stringify(userOverrides));+ } catch (error) {+ console.error('Failed to save config to localStorage:', error);+ }+ }+}diff --git a/tools/ui/src/lib/stores/settings/index.svelte.ts b/tools/ui/src/lib/stores/settings/index.svelte.tsindex 0373ade420..a583a1423f 100644--- a/tools/ui/src/lib/stores/settings/index.svelte.ts+++ b/tools/ui/src/lib/stores/settings/index.svelte.ts@@ -8,14 +8,10 @@*/import { browser } from '$app/environment';-import {- CONFIG_LOCALSTORAGE_KEY,- SETTING_CONFIG_DEFAULT,- SETTINGS_KEYS,- USER_OVERRIDES_LOCALSTORAGE_KEY-} from '$lib/constants';+import { SETTING_CONFIG_DEFAULT, SETTINGS_KEYS } from '$lib/constants';import { ColorMode } from '$lib/enums';import { ParameterSyncService } from '$lib/services/parameter-sync.service';+import { SettingsService } from '$lib/services/settings.service';import { deviceStore } from '$lib/stores/device.svelte';// direct imports between stores, not via the barrel, to avoid circular depsimport { serverStore } from '$lib/stores/server.svelte';@@ -428,45 +424,37 @@ class SettingsStore {}/**- * Load configuration from localStorage- * Returns default values for missing keys to prevent breaking changes+ * Load configuration from localStorage via the persistence service.+ * Returns default values for missing keys to prevent breaking changes.*/private loadConfig() {if (!browser) return;- try {- const storedConfigRaw = localStorage.getItem(CONFIG_LOCALSTORAGE_KEY);-- // First visit: no stored config yet. Server ui_settings apply once in- // this state, then the user's config diverges freely.- this.isFirstVisit = storedConfigRaw === null;+ const {+ config: savedVal,+ isFirstVisit,+ userOverrides: savedOverrides+ } = SettingsService.loadConfig();- const savedVal = JSON.parse(storedConfigRaw || '{}');+ // First visit: no stored config yet. Server ui_settings apply once in+ // this state, then the user's config diverges freely.+ this.isFirstVisit = isFirstVisit;- // Merge with defaults to prevent breaking changes- this.config = {- ...SETTING_CONFIG_DEFAULT,- ...savedVal- };+ // Merge with defaults to prevent breaking changes+ this.config = {+ ...SETTING_CONFIG_DEFAULT,+ ...savedVal+ };- // Default sendOnEnter to false on mobile when the user has no saved preference- if (!(SETTINGS_KEYS.SEND_ON_ENTER in savedVal)) {- if (deviceStore.isMobile) {- this.config[SETTINGS_KEYS.SEND_ON_ENTER] = false;- }+ // Default sendOnEnter to false on mobile when the user has no saved preference+ if (!(SETTINGS_KEYS.SEND_ON_ENTER in savedVal)) {+ if (deviceStore.isMobile) {+ this.config[SETTINGS_KEYS.SEND_ON_ENTER] = false;}-- // Load user overrides- const savedOverrides = JSON.parse(- localStorage.getItem(USER_OVERRIDES_LOCALSTORAGE_KEY) || '[]'- );-- this.userOverrides = new Set(savedOverrides);- } catch (error) {- console.warn('Failed to parse config from localStorage, using defaults:', error);- this.config = { ...SETTING_CONFIG_DEFAULT };- this.userOverrides = new Set();}++ // Load user overrides+ this.userOverrides = new Set(savedOverrides);}/**@@ -478,32 +466,22 @@ class SettingsStore {private migrateLegacyTheme() {if (!browser) return;- const legacyTheme = localStorage.getItem('theme');+ const legacyTheme = SettingsService.migrateLegacyTheme();if (legacyTheme) {this.config[SETTINGS_KEYS.THEME] = legacyTheme;- localStorage.removeItem('theme');this.saveConfig();setMode(legacyTheme as ColorMode);}}/**- * Save the current configuration to localStorage+ * Save the current configuration to localStorage via the persistence service.*/private saveConfig() {if (!browser) return;- try {- localStorage.setItem(CONFIG_LOCALSTORAGE_KEY, JSON.stringify(this.config));-- localStorage.setItem(- USER_OVERRIDES_LOCALSTORAGE_KEY,- JSON.stringify(Array.from(this.userOverrides))- );- } catch (error) {- console.error('Failed to save config to localStorage:', error);- }+ SettingsService.saveConfig(this.config, Array.from(this.userOverrides));}}diff --git a/tools/ui/src/lib/stores/settings/referrer.svelte.ts b/tools/ui/src/lib/stores/settings/referrer.svelte.tsindex 9679049df9..d1055cc6e8 100644--- a/tools/ui/src/lib/stores/settings/referrer.svelte.ts+++ b/tools/ui/src/lib/stores/settings/referrer.svelte.ts@@ -5,9 +5,9 @@* there after a fallback exit. Standalone reactive value, no host.*/-import { SETTINGS_FALLBACK_EXIT_ROUTE } from '$lib/constants';+import { ROUTES } from '$lib/constants';-let _url = $state<string>(SETTINGS_FALLBACK_EXIT_ROUTE);+let _url = $state<string>(ROUTES.SETTINGS_EXIT);export const settingsReferrer = {get url() {diff --git a/tools/ui/src/lib/types/settings.d.ts b/tools/ui/src/lib/types/settings.d.tsindex d04837727d..377a570408 100644--- a/tools/ui/src/lib/types/settings.d.ts+++ b/tools/ui/src/lib/types/settings.d.ts@@ -25,13 +25,15 @@ export interface SettingsEntry {help: string;defaultValue: SettingsConfigValue;type: SettingsFieldType;- section?: string;options?: Array<{ value: string; label: string; icon: Component }>;/** Options rendered for RADIO fields. Each entry maps a `value` (the radio's selected value) to the underlying config `key` whose boolean state mirrors it. */radioOptions?: Array<{ value: string; label: string; key: string; isExperimental?: boolean }>;isExperimental?: boolean;isPositiveInteger?: boolean;+ /** When true, the field is rendered as a password input (e.g. API key). */isPrivate?: boolean;+ /** When false, the setting is stored/synced but has no standalone field; it is rendered by a sibling control or a dedicated page. */+ standaloneField?: boolean;placeholder?: string;min?: number;max?: number;diff --git a/tools/ui/src/routes/settings/+layout.svelte b/tools/ui/src/routes/settings/+layout.svelteindex 4e191dce72..993d64d0b6 100644--- a/tools/ui/src/routes/settings/+layout.svelte+++ b/tools/ui/src/routes/settings/+layout.svelte@@ -4,7 +4,7 @@import { goto } from '$app/navigation';import { page } from '$app/state';import { ActionIcon } from '$lib/components/app';- import { SETTINGS_FALLBACK_EXIT_ROUTE } from '$lib/constants';+ import { ROUTES } from '$lib/constants';let { children } = $props();@@ -24,7 +24,7 @@if (browser && window.history.length > 1 && !prevIsSettings) {history.back();} else {- goto(SETTINGS_FALLBACK_EXIT_ROUTE);+ goto(ROUTES.SETTINGS_EXIT);}}</script>