ui : rework the settings registry into ordered raw-data sections

SETTINGS_REGISTRY becomes an ordered SettingsSectionEntry[] array; the
array order is the sidebar display order. Section titles, color mode
options and title radio options are declared inline in their section or
entry. Entries gain showInUi; MCP servers, the system-message toggle and
the title LLM flag become hidden entries of their own section.

Derived values (config defaults, help info, chat sections, numeric field
lists, syncable parameters) are still derived here; they move to their
actual consumers in follow-up commits.
This commit is contained in:
Aleksander Grygier
2026-08-20 19:02:09 +02:00
parent 521a64cd01
commit de40f3e81b
5 changed files with 422 additions and 417 deletions
@@ -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';
@@ -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" />
+1 -1
View File
@@ -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';
@@ -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',
@@ -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,8 +11,9 @@ import {
Monitor,
Moon,
PencilRuler,
Sliders,
Sun
SlidersVertical,
Sun,
TriangleAlert
} from '@lucide/svelte';
import { SyncableParameterType } from '$lib/enums';
import { SettingsFieldType } from '$lib/enums/settings.enums';
@@ -22,174 +21,192 @@ import { ColorMode } from '$lib/enums/ui.enums';
import type {
SettingsConfigValue,
SettingsEntry,
SettingsFieldConfig,
SettingsSection,
SettingsSectionEntry,
SettingsSectionTitle,
SyncableParameter
} 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' },
PENALTIES: { slug: 'penalties', title: 'Penalties' },
SAMPLING: { slug: 'sampling', title: 'Sampling' },
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,
PENALTIES: SETTINGS_SECTIONS.PENALTIES.slug,
SAMPLING: SETTINGS_SECTIONS.SAMPLING.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,
PENALTIES: SETTINGS_SECTIONS.PENALTIES.title,
SAMPLING: SETTINGS_SECTIONS.SAMPLING.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 },
export const SETTINGS_REGISTRY: SettingsSectionEntry[] = [
// General
{
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'
},
{
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: 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,
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: 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,
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,
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,
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,
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',
section: SETTINGS_SECTION_SLUGS.DEVELOPER,
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,
type: SettingsFieldType.CHECKBOX
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 }
],
section: SETTINGS_SECTION_SLUGS.GENERAL,
type: SettingsFieldType.SELECT
},
{
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
help: `Set the API Key if you are using <code> ${CLI_FLAGS.API_KEY} </code> option for the server.`,
key: SETTINGS_KEYS.API_KEY,
label: 'API Key',
section: SETTINGS_SECTION_SLUGS.GENERAL,
type: SettingsFieldType.INPUT
},
{
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,
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: true,
help: 'Display the system message at the top of each conversation.',
key: SETTINGS_KEYS.SHOW_SYSTEM_MESSAGE,
label: 'Show system message',
section: SETTINGS_SECTION_SLUGS.GENERAL,
standaloneField: false,
type: SettingsFieldType.CHECKBOX
},
{
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
},
{
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'
}
],
section: SETTINGS_SECTION_SLUGS.GENERAL,
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',
section: SETTINGS_SECTION_SLUGS.GENERAL,
type: SettingsFieldType.TEXTAREA
},
{
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',
section: SETTINGS_SECTION_SLUGS.GENERAL,
standaloneField: false,
type: SettingsFieldType.CHECKBOX
},
{
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,
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: [
{
@@ -309,214 +326,70 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {
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',
section: SETTINGS_SECTION_SLUGS.TOOLS,
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
},
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: 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
},
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,
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 },
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
},
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}`,
section: SETTINGS_SECTION_SLUGS.AGENTIC,
type: SettingsFieldType.INPUT
}
],
slug: SETTINGS_SECTION_SLUGS.PENALTIES,
title: SETTINGS_SECTION_TITLES.PENALTIES
slug: SETTINGS_SECTION_SLUGS.AGENTIC,
title: SETTINGS_SECTION_TITLES.AGENTIC
},
[SETTINGS_SECTION_SLUGS.SAMPLING]: {
// Import/Export
{
icon: Database,
settings: [],
slug: SETTINGS_SECTION_SLUGS.IMPORT_EXPORT,
title: SETTINGS_SECTION_TITLES.IMPORT_EXPORT
},
// Sampling
{
icon: Funnel,
settings: [
{
@@ -647,48 +520,189 @@ const SETTINGS_REGISTRY: Record<string, SettingsSectionEntry> = {
],
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
},
// Penalties
{
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
icon: TriangleAlert,
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 },
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
},
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
},
type: SettingsFieldType.INPUT
}
],
slug: SETTINGS_SECTION_SLUGS.PENALTIES,
title: SETTINGS_SECTION_TITLES.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',
section: SETTINGS_SECTION_SLUGS.DEVELOPER,
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,
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,
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,
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',
section: SETTINGS_SECTION_SLUGS.DEVELOPER,
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,
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: '',
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
}
],
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,46 +717,51 @@ 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;
/** Exit destination for the settings view (fallback when no referrer). */
export const SETTINGS_FALLBACK_EXIT_ROUTE = ROUTES.START;
/** 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,
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()
/** Mapping of UI setting keys to server parameter keys, for the sync service. */
export const SYNCABLE_PARAMETERS: SyncableParameter[] = SETTINGS_REGISTRY.flatMap(
(section) => section.settings
)
.filter((s) => s.sync !== undefined)
.map((s) => ({
canSync: true,
@@ -750,5 +769,3 @@ export const SYNCABLE_PARAMETERS: SyncableParameter[] = getAllSettings()
serverKey: s.sync!.serverKey,
type: s.sync!.paramType
}));
export const SETTINGS_FALLBACK_EXIT_ROUTE = ROUTES.START;
+2 -2
View File
@@ -31,7 +31,8 @@ export interface SettingsEntry {
radioOptions?: Array<{ value: string; label: string; key: string; isExperimental?: boolean }>;
isExperimental?: boolean;
isPositiveInteger?: boolean;
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;
@@ -56,7 +57,6 @@ export interface SettingsFieldConfig {
type: SettingsFieldType;
isExperimental?: boolean;
isPositiveInteger?: boolean;
isPrivate?: boolean;
placeholder?: string;
min?: number;
max?: number;