This commit is contained in:
Timothy Jaeryang Baek committed 2026-07-31 21:15:11 -04:00
1 parent 0bbf9a44c9
commit 1b7bea00a4
17 files changed
+816 -238

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ export type MemorySettings = {
enabled: boolean;
tool_enabled: boolean;
background_review_enabled: boolean;
'background_review.model'?: string | null;
review_interval_turns: number;
user_char_limit: number;
workspace_char_limit: number;
@@ -0,0 +1,192 @@
<script lang="ts">
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
import { getAdminConfig, updateConfig } from '$lib/apis/admin';
import { t } from '$lib/i18n';
import Spinner from '$lib/components/common/Spinner.svelte';
import ToggleSwitch from '$lib/components/common/ToggleSwitch.svelte';
import ModelSelector from '$lib/components/common/ModelSelector.svelte';
let loading = $state(true);
let saving = $state(false);
let titleGenerationEnabled = $state(true);
let titleGenerationModel = $state<string | null>(null);
let contextCompactionModel = $state<string | null>(null);
let toolApprovalReviewModel = $state<string | null>(null);
let compactTokenThreshold = $state(80000);
onMount(async () => {
try {
const config = await getAdminConfig();
titleGenerationEnabled =
config['chat.title_generation.enabled'] !== false &&
config['chat.title_generation.enabled'] !== 'false';
titleGenerationModel =
typeof config['chat.title_generation.model'] === 'string'
? config['chat.title_generation.model']
: null;
contextCompactionModel =
typeof config['chat.context_compaction.model'] === 'string'
? config['chat.context_compaction.model']
: null;
toolApprovalReviewModel =
typeof config['tool_approval.review.model'] === 'string'
? config['tool_approval.review.model']
: null;
compactTokenThreshold = Number(config['chat.compact_token_threshold']) || 80000;
} catch {
toast.error($t('admin.failedToLoadConfig'));
} finally {
loading = false;
}
});
async function save() {
saving = true;
try {
await updateConfig({
'chat.title_generation.enabled': titleGenerationEnabled,
'chat.title_generation.model': titleGenerationModel,
'chat.context_compaction.model': contextCompactionModel,
'tool_approval.review.model': toolApprovalReviewModel,
'chat.compact_token_threshold': Math.max(10000, Number(compactTokenThreshold) || 80000)
});
toast.success($t('settings.saved'));
} catch {
toast.error($t('admin.failedToSave'));
} finally {
saving = false;
}
}
</script>
<div class="flex flex-col h-full">
{#if loading}
<div class="flex justify-center py-8"><Spinner size={16} /></div>
{:else}
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5 -mr-1.5">
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$t('admin.chat')}</h2>
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">
{$t('admin.chatTitles')}
</h3>
<div class="flex flex-col gap-2.5">
<label class="flex items-center justify-between gap-3 cursor-pointer">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('admin.chatTitleGeneration')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.chatTitleGenerationHint')}
</div>
</div>
<ToggleSwitch
value={titleGenerationEnabled}
onchange={(value) => {
titleGenerationEnabled = value;
}}
/>
</label>
{#if titleGenerationEnabled}
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('admin.chatTitleModel')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.chatTitleModelHint')}
</div>
</div>
<div class="shrink-0">
<ModelSelector
bind:selectedModel={titleGenerationModel}
nullable
nullLabel={$t('modelSelector.currentModel')}
preferAbove={false}
/>
</div>
</div>
{/if}
</div>
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
{$t('admin.contextCompaction')}
</h3>
<div class="flex flex-col gap-2.5">
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('admin.contextSummaryModel')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.contextSummaryModelHint')}
</div>
</div>
<div class="shrink-0">
<ModelSelector
bind:selectedModel={contextCompactionModel}
nullable
nullLabel={$t('modelSelector.currentModel')}
preferAbove={false}
/>
</div>
</div>
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="compact-threshold">
{$t('admin.compactTokenThreshold')}
</label>
<div class="flex items-center gap-1.5 mt-1">
<input
id="compact-threshold"
type="number"
bind:value={compactTokenThreshold}
min="10000"
max="1000000"
step="10000"
class="w-24 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
<span class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.compactTokenThresholdUnit')}
</span>
</div>
<p class="text-[0.6875rem] text-gray-400 dark:text-gray-600 mt-0.5">
{$t('admin.compactTokenThresholdHint')}
</p>
</div>
</div>
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2 mt-5">
{$t('admin.toolApproval')}
</h3>
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('admin.toolApprovalReviewModel')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.toolApprovalReviewModelHint')}
</div>
</div>
<div class="shrink-0">
<ModelSelector
bind:selectedModel={toolApprovalReviewModel}
nullable
nullLabel={$t('modelSelector.currentModel')}
preferAbove={false}
/>
</div>
</div>
</div>
<div class="shrink-0 pt-3 flex justify-end">
<button
class="text-[0.8125rem] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100 disabled:opacity-50"
disabled={saving}
onclick={save}
>
{saving ? $t('settings.saving') : $t('settings.save')}
</button>
</div>
{/if}
</div>
@@ -0,0 +1,77 @@
<script lang="ts">
import { onMount } from 'svelte';
import { toast } from 'svelte-sonner';
import { getAdminConfig, updateConfig } from '$lib/apis/admin';
import { t } from '$lib/i18n';
import Spinner from '$lib/components/common/Spinner.svelte';
import ModelSelector from '$lib/components/common/ModelSelector.svelte';
let loading = $state(true);
let saving = $state(false);
let commitMessageModel = $state<string | null>(null);
onMount(async () => {
try {
const config = await getAdminConfig();
commitMessageModel =
typeof config['git.commit_message_generation.model'] === 'string'
? config['git.commit_message_generation.model']
: null;
} catch {
toast.error($t('admin.failedToLoadConfig'));
} finally {
loading = false;
}
});
async function save() {
saving = true;
try {
await updateConfig({ 'git.commit_message_generation.model': commitMessageModel });
toast.success($t('settings.saved'));
} catch {
toast.error($t('admin.failedToSave'));
} finally {
saving = false;
}
}
</script>
<div class="flex flex-col h-full">
{#if loading}
<div class="flex justify-center py-8"><Spinner size={16} /></div>
{:else}
<div class="flex-1 min-h-0 overflow-y-auto scrollbar-hover pr-1.5 -mr-1.5">
<h2 class="text-sm font-medium text-gray-900 dark:text-white mb-4">{$t('admin.git')}</h2>
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('admin.gitCommitMessageModel')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.gitCommitMessageModelHint')}
</div>
</div>
<div class="shrink-0">
<ModelSelector
bind:selectedModel={commitMessageModel}
nullable
nullLabel={$t('modelSelector.defaultModel')}
preferAbove={false}
/>
</div>
</div>
</div>
<div class="shrink-0 pt-3 flex justify-end">
<button
class="text-[0.8125rem] text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors duration-100 disabled:opacity-50"
disabled={saving}
onclick={save}
>
{saving ? $t('settings.saving') : $t('settings.save')}
</button>
</div>
{/if}
</div>
@@ -48,10 +48,6 @@
// Default model
let defaultModelId = $state('');
// Context compaction
let compactTokenThreshold = $state(80000);
let compactDirty = $state(false);
const TEMPLATE_VARIABLES = [
{ name: 'CPTR_CONTEXT', desc: 'Runtime, machine, workspace, and tool context' },
{ name: 'RUNTIME_ENV', desc: 'Runtime environment (host or container)' },
@@ -117,7 +113,7 @@ Workspace: {{WORKSPACE_NAME}}
Files:
{{FILE_TREE}}`;
let hasDirty = $derived(globalDirty || compactDirty || models.some((m) => m.dirty));
let hasDirty = $derived(globalDirty || models.some((m) => m.dirty));
function parseRows(config: ModelConfigEntry | undefined): ParamRow[] {
const rp = config?.params?.request_params;
@@ -256,10 +252,9 @@ Files:
onMount(async () => {
await loadModelConfig();
// Load admin config (default model, context compaction)
// Load default model
try {
const adminCfg = await getAdminConfig();
compactTokenThreshold = Number(adminCfg['chat.compact_token_threshold']) || 80000;
defaultModelId =
typeof adminCfg['chat.default_model'] === 'string' ? adminCfg['chat.default_model'] : '';
} catch {}
@@ -349,12 +344,7 @@ Files:
globalDirty = false;
models.forEach((m) => (m.dirty = false));
// Save default model
await updateConfig({
'chat.compact_token_threshold': compactTokenThreshold,
'chat.default_model': defaultModelId
});
compactDirty = false;
await updateConfig({ 'chat.default_model': defaultModelId });
toast.success($t('settings.saved'));
} catch {
@@ -552,43 +542,17 @@ Files:
</button>
</div>
<!-- Default model -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">
{$t('models.defaultModel')}
</h3>
<div class="mb-1">
<ModelSelector bind:selectedModel={defaultModelId} preferAbove={false} align="start" />
</div>
<p class="text-[0.6875rem] text-gray-400 dark:text-gray-600 mb-5">
{$t('models.defaultModelHint')}
</p>
<!-- Context compaction -->
<h3 class="text-xs text-gray-400 dark:text-gray-600 mb-2">{$t('admin.contextCompaction')}</h3>
<div class="flex flex-col gap-2.5 mb-5">
<div>
<label class="text-xs text-gray-600 dark:text-gray-400" for="compact-threshold"
>{$t('admin.compactTokenThreshold')}</label
>
<div class="flex items-center gap-1.5 mt-1">
<input
id="compact-threshold"
type="number"
bind:value={compactTokenThreshold}
oninput={() => (compactDirty = true)}
min="10000"
max="1000000"
step="10000"
class="w-24 h-7 px-2 rounded-lg text-xs bg-gray-100 dark:bg-white/6 text-gray-700 dark:text-gray-300 border border-gray-200 dark:border-white/8 outline-none focus:border-blue-400 dark:focus:border-blue-500 transition-colors"
/>
<span class="text-[0.6875rem] text-gray-400 dark:text-gray-600"
>{$t('admin.compactTokenThresholdUnit')}</span
>
<div class="flex items-center justify-between gap-3 mb-1">
<div class="min-w-0">
<h3 class="text-xs text-gray-600 dark:text-gray-400">
{$t('models.defaultModel')}
</h3>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('models.defaultModelHint')}
</div>
<p class="text-[0.6875rem] text-gray-400 dark:text-gray-600 mt-0.5">
{$t('admin.compactTokenThresholdHint')}
</p>
</div>
<div class="shrink-0">
<ModelSelector bind:selectedModel={defaultModelId} preferAbove={false} />
</div>
</div>
@@ -5,12 +5,14 @@
import { t } from '$lib/i18n';
import ToggleSwitch from '$lib/components/common/ToggleSwitch.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
import ModelSelector from '$lib/components/common/ModelSelector.svelte';
let loading = $state(true);
let saving = $state(false);
let enabled = $state(true);
let toolEnabled = $state(true);
let backgroundReview = $state(true);
let backgroundReviewModel = $state<string | null>(null);
let reviewInterval = $state(10);
onMount(async () => {
@@ -22,6 +24,10 @@
backgroundReview =
config['skills.background_review_enabled'] !== false &&
config['skills.background_review_enabled'] !== 'false';
backgroundReviewModel =
typeof config['skills.background_review.model'] === 'string'
? config['skills.background_review.model']
: null;
reviewInterval = Number(config['skills.review_interval_turns']) || 10;
} catch {
toast.error($t('admin.failedToLoadConfig'));
@@ -36,6 +42,7 @@
'skills.enabled': enabled,
'skills.tool_enabled': toolEnabled,
'skills.background_review_enabled': backgroundReview,
'skills.background_review.model': backgroundReviewModel,
'skills.review_interval_turns': Math.max(1, Number(reviewInterval) || 10)
});
toast.success($t('settings.saved'));
@@ -94,6 +101,25 @@
}}
/>
</label>
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('admin.skillsBackgroundReviewModel')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('admin.skillsBackgroundReviewModelHint')}
</div>
</div>
<div class="shrink-0">
<ModelSelector
bind:selectedModel={backgroundReviewModel}
nullable
nullLabel={$t('modelSelector.currentModel')}
preferAbove={false}
/>
</div>
</div>
{/if}
</div>
@@ -1,7 +1,6 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { activeWorkspace, addWorkspace, openFileTab } from '$lib/stores';
import { defaultModel } from '$lib/stores/chat';
import {
getGitLog,
getGitDiff,
@@ -383,7 +382,7 @@
if (!stagedFiles.length || generatingCommitMessage) return;
generatingCommitMessage = true;
try {
const message = await generateGitCommitMessage(workspacePath, $defaultModel || undefined);
const message = await generateGitCommitMessage(workspacePath);
commitSummary = message.summary;
commitDescription = message.description;
} catch (e) {
@@ -1499,8 +1498,8 @@
{#each fileDiff as df}
{#if fileDiff.length > 1}
<div
class="px-2 py-1 text-[0.625rem] text-gray-500 dark:text-gray-400 border-b border-gray-100 dark:border-white/4 sticky top-0 z-10 font-medium"
style="background: var(--app-bg); border-color: var(--app-border);"
class="px-2 py-1 text-[0.625rem] text-gray-500 dark:text-gray-400 border-b border-gray-100 dark:border-white/4 sticky top-0 z-10 font-medium"
style="background: var(--app-bg); border-color: var(--app-border);"
>
{df.path}
</div>
@@ -3,6 +3,7 @@
import { toast } from 'svelte-sonner';
import ToggleSwitch from '$lib/components/common/ToggleSwitch.svelte';
import Spinner from '$lib/components/common/Spinner.svelte';
import ModelSelector from '$lib/components/common/ModelSelector.svelte';
import { t } from '$lib/i18n';
import { currentWorkspace } from '$lib/stores';
import {
@@ -101,6 +102,27 @@
onchange={(v) => (settings = { ...settings!, background_review_enabled: v })}
/>
</label>
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<div class="text-xs text-gray-600 dark:text-gray-400">
{$t('memory.backgroundReviewModel')}
</div>
<div class="text-[0.6875rem] text-gray-400 dark:text-gray-600">
{$t('memory.backgroundReviewModelHint')}
</div>
</div>
<div class="shrink-0">
<ModelSelector
selectedModel={settings['background_review.model'] ?? null}
nullable
nullLabel={$t('modelSelector.currentModel')}
preferAbove={false}
onchange={(model) =>
(settings = { ...settings!, 'background_review.model': model })}
/>
</div>
</div>
{/if}
</div>
@@ -13,6 +13,8 @@
import Connections from './Admin/Connections.svelte';
import Agents from './Admin/Agents.svelte';
import Models from './Admin/Models.svelte';
import Chat from './Admin/Chat.svelte';
import Git from './Admin/Git.svelte';
import Skills from './Admin/Skills.svelte';
import Messaging from './Admin/Messaging.svelte';
import Gateway from './Admin/Gateway.svelte';
@@ -37,6 +39,8 @@
| 'connections'
| 'agents'
| 'models'
| 'chat'
| 'git'
| 'skills'
| 'messaging'
| 'gateway'
@@ -66,6 +70,8 @@
'connections',
'agents',
'models',
'chat',
'git',
'messaging',
'gateway',
'audio',
@@ -95,6 +101,8 @@
{ id: 'connections', label: $t('admin.connections'), icon: 'plug' },
{ id: 'agents', label: $t('admin.agents'), icon: 'terminal' },
{ id: 'models', label: $t('admin.models'), icon: 'cube' },
{ id: 'chat', label: $t('admin.chat'), icon: 'chat-bubble' },
{ id: 'git', label: $t('admin.git'), icon: 'git-branch' },
{ id: 'messaging', label: $t('admin.messaging'), icon: 'chat-bubble' },
{ id: 'gateway', label: $t('admin.gateway.tab'), icon: 'gateway' },
{ id: 'audio', label: $t('admin.audio.title'), icon: 'microphone' },
@@ -206,6 +214,10 @@
<Agents />
{:else if activeTab === 'models'}
<Models />
{:else if activeTab === 'chat'}
<Chat />
{:else if activeTab === 'git'}
<Git />
{:else if activeTab === 'skills'}
<Skills />
{:else if activeTab === 'messaging'}
@@ -5,15 +5,19 @@
import { t } from '$lib/i18n';
interface Props {
selectedModel: string;
selectedModel: string | null;
preferAbove?: boolean;
align?: 'start' | 'end';
onchange?: (model: string) => void;
nullable?: boolean;
nullLabel?: string;
onchange?: (model: string | null) => void;
}
let {
selectedModel = $bindable(),
preferAbove = true,
align = 'end',
nullable = false,
nullLabel = 'Current model',
onchange
}: Props = $props();
@@ -31,8 +35,22 @@
: $chatModels
);
const menuItems = $derived(
filtered.map((m) => ({
const menuItems = $derived([
...(nullable
? [
{
label: nullLabel,
tooltip: nullLabel,
active: selectedModel === null || selectedModel === '',
check: true,
onclick: () => {
selectedModel = null;
onchange?.(null);
}
}
]
: []),
...filtered.map((m) => ({
label: m.name,
tooltip: m.name,
active: m.id === selectedModel,
@@ -42,7 +60,7 @@
onchange?.(m.id);
}
}))
);
]);
function updateViewportSize() {
isSmallViewport = (window.visualViewport?.width ?? window.innerWidth) < 640;
@@ -59,7 +77,7 @@
});
async function toggle() {
if ($chatModels.length === 0) return;
if ($chatModels.length === 0 && !nullable) return;
if (open) {
open = false;
return;
@@ -80,12 +98,14 @@
onclick={toggle}
>
<span class="truncate max-w-[10rem]"
>{$chatModels.length === 0
? $t('modelSelector.noModels')
: $chatModels.find((m) => m.id === selectedModel)?.name ||
$t('modelSelector.selectModel')}</span
>{selectedModel === null || selectedModel === ''
? nullLabel
: $chatModels.length === 0
? $t('modelSelector.noModels')
: $chatModels.find((m) => m.id === selectedModel)?.name ||
$t('modelSelector.selectModel')}</span
>
{#if $chatModels.length > 0}
{#if $chatModels.length > 0 || nullable}
<svg
class="w-3 h-3 opacity-50"
viewBox="0 0 24 24"
@@ -100,7 +120,7 @@
{/if}
</button>
{#if open && btnEl && $chatModels.length > 0}
{#if open && btnEl && ($chatModels.length > 0 || nullable)}
<DropdownMenu
items={menuItems}
anchor={btnEl}
@@ -159,6 +159,8 @@
"memory.enable": "Enable memory",
"memory.assistantCanSave": "Assistant can save memories",
"memory.backgroundReview": "Background review",
"memory.backgroundReviewModel": "Background review model",
"memory.backgroundReviewModelHint": "Uses the current chat model when unset.",
"memory.limits": "Limits",
"memory.reviewEvery": "Review every",
"memory.userLimit": "User limit",
@@ -463,6 +465,20 @@
"admin.browserBaseUrl": "Base URL",
"admin.browserFirecrawlBaseUrlHint": "Change for self-hosted Firecrawl instances",
"admin.models": "Models",
"admin.chat": "Chat",
"admin.chatTitles": "Titles",
"admin.chatTitleGeneration": "Chat title generation",
"admin.chatTitleGenerationHint": "Name new chats after the first response.",
"admin.chatTitleModel": "Chat title model",
"admin.chatTitleModelHint": "Uses the current chat model when unset.",
"admin.contextSummaryModel": "Context summary model",
"admin.contextSummaryModelHint": "Summarizes older messages during compaction.",
"admin.toolApproval": "Tool approval",
"admin.toolApprovalReviewModel": "Review model",
"admin.toolApprovalReviewModelHint": "Reviews pending tool calls in Auto mode.",
"admin.git": "Git",
"admin.gitCommitMessageModel": "Commit message model",
"admin.gitCommitMessageModelHint": "Drafts messages from staged changes.",
"models.defaultModel": "Default model",
"models.defaultModelNone": "None (use first available)",
"models.defaultModelHint": "Pre-selected model for new chats and gateway requests.",
@@ -555,6 +571,8 @@
"changelog.done": "Done",
"modelSelector.noModels": "No models available",
"modelSelector.selectModel": "Select model",
"modelSelector.currentModel": "Current model",
"modelSelector.defaultModel": "Default model",
"modelSelector.noMatches": "No matches",
"modelSelector.search": "Search...",
"about.licenseName": "Open Use License",
@@ -1199,6 +1217,8 @@
"admin.skillsEnable": "Enable skills",
"admin.skillsAssistantCanManage": "Assistant can manage skills",
"admin.skillsBackgroundReview": "Background review",
"admin.skillsBackgroundReviewModel": "Background review model",
"admin.skillsBackgroundReviewModelHint": "Uses the current chat model when unset.",
"admin.skillsLimits": "Limits",
"admin.skillsReviewEvery": "Review every",
"admin.chars": "chars",