1584 lines
40 KiB
Svelte
1584 lines
40 KiB
Svelte
<script lang="ts">
|
||
import { createMutation, createQuery, useQueryClient } from '@tanstack/svelte-query';
|
||
import { fade } from 'svelte/transition';
|
||
import AppShell from '$lib/components/shell/AppShell.svelte';
|
||
import Button from '$lib/components/ui/Button.svelte';
|
||
import ConfirmDialog from '$lib/components/ui/ConfirmDialog.svelte';
|
||
import Icon from '$lib/components/ui/Icon.svelte';
|
||
import EmptyState from '$lib/components/ui/EmptyState.svelte';
|
||
import { settings, type LlmProfile, type Settings } from '$lib/api';
|
||
import { randomId } from '$lib/ids';
|
||
import { toast } from '$lib/toast';
|
||
import { t } from '$lib/i18n.svelte';
|
||
|
||
const client = useQueryClient();
|
||
|
||
const settingsQuery = createQuery({
|
||
queryKey: ['settings'],
|
||
queryFn: settings.get,
|
||
});
|
||
|
||
// A profile while being edited here: `api_key` is the public boolean,
|
||
// except for a freshly typed key waiting to be sent to the server.
|
||
type WorkingProfile = Omit<LlmProfile, 'api_key'> & { api_key: boolean | string };
|
||
|
||
// ------------------------------------------------------------------
|
||
// Local test-state persistence (last result / time / consecutive
|
||
// failures per profile). Purely presentational; connectivity facts
|
||
// always come from the server-side probe.
|
||
// ------------------------------------------------------------------
|
||
type TestRec = { ok: boolean; ms?: number; at: number; fails: number; reason?: string };
|
||
const TESTS_KEY = 'calliope.models.tests';
|
||
let tests = $state<Record<string, TestRec>>({});
|
||
let pendingTests = $state<Record<string, boolean>>({});
|
||
|
||
function loadTests() {
|
||
try {
|
||
const raw = localStorage.getItem(TESTS_KEY);
|
||
if (raw) tests = JSON.parse(raw) as Record<string, TestRec>;
|
||
} catch {
|
||
tests = {};
|
||
}
|
||
}
|
||
function saveTests(map: Record<string, TestRec>) {
|
||
tests = map;
|
||
try {
|
||
localStorage.setItem(TESTS_KEY, JSON.stringify(map));
|
||
} catch {
|
||
/* storage full / disabled — the page still works without persistence */
|
||
}
|
||
}
|
||
function recordTest(id: string, rec: TestRec) {
|
||
saveTests({ ...tests, [id]: rec });
|
||
}
|
||
function pruneTests(ids: string[]) {
|
||
const keep = new Set(ids);
|
||
const next: Record<string, TestRec> = {};
|
||
let changed = false;
|
||
for (const [k, v] of Object.entries(tests)) {
|
||
if (keep.has(k)) next[k] = v;
|
||
else changed = true;
|
||
}
|
||
if (changed) saveTests(next);
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Form state — add / edit custom LLM (spec §9.3)
|
||
// ------------------------------------------------------------------
|
||
type FormMode = 'idle' | 'add' | 'edit';
|
||
let formMode = $state<FormMode>('idle');
|
||
let editingId = $state<string | null>(null);
|
||
let form = $state({ name: '', baseUrl: '', model: '', apiKey: '', timeout: 10 });
|
||
let formTest = $state<{ ok: boolean; ms?: number } | null>(null);
|
||
let formTestFailure = $state<{ text: string; detail: string } | null>(null);
|
||
let formPending = $state(false);
|
||
let showErrors = $state(false);
|
||
|
||
const TIMEOUT_OPTIONS = [5, 10, 15, 30, 60];
|
||
|
||
function resetForm() {
|
||
formMode = 'idle';
|
||
editingId = null;
|
||
form = { name: '', baseUrl: '', model: '', apiKey: '', timeout: 10 };
|
||
formTest = null;
|
||
formTestFailure = null;
|
||
showErrors = false;
|
||
}
|
||
|
||
function startAdd() {
|
||
resetForm();
|
||
formMode = 'add';
|
||
}
|
||
|
||
function startEdit(profile: LlmProfile) {
|
||
resetForm();
|
||
formMode = 'edit';
|
||
editingId = profile.id;
|
||
form = {
|
||
name: profile.name,
|
||
baseUrl: profile.base_url,
|
||
model: profile.model,
|
||
apiKey: '',
|
||
timeout: 10,
|
||
};
|
||
}
|
||
|
||
// A connectivity-relevant edit invalidates the previous passing test.
|
||
function touchFormConnectivity() {
|
||
formTest = null;
|
||
formTestFailure = null;
|
||
}
|
||
|
||
const urlValid = $derived.by(() => {
|
||
try {
|
||
const u = new URL(form.baseUrl.trim());
|
||
return u.protocol === 'http:' || u.protocol === 'https:';
|
||
} catch {
|
||
return false;
|
||
}
|
||
});
|
||
|
||
const formErrors = $derived.by(() => {
|
||
const errs: Record<string, string> = {};
|
||
if (!form.name.trim()) errs.name = t('models.errName');
|
||
if (!urlValid) errs.baseUrl = t('models.errUrl');
|
||
if (!form.model.trim()) errs.model = t('models.errModel');
|
||
// Key is required when creating; on edit an empty field keeps the
|
||
// stored key (masked tail placeholder covers the affordance).
|
||
if (formMode === 'add' && !form.apiKey.trim()) errs.apiKey = t('models.errKey');
|
||
return errs;
|
||
});
|
||
const formValid = $derived(Object.keys(formErrors).length === 0);
|
||
|
||
const editingProfile = $derived.by(() => {
|
||
if (formMode !== 'edit' || !editingId || !$settingsQuery.data) return null;
|
||
return $settingsQuery.data.llm_profiles.find((p) => p.id === editingId) ?? null;
|
||
});
|
||
|
||
// ------------------------------------------------------------------
|
||
// Failure classification → spec §9.6 copy (primary sentence) with the
|
||
// server-provided detail as a mono secondary line where it adds info.
|
||
// ------------------------------------------------------------------
|
||
function classifyFailure(
|
||
res: { error?: string; detail?: string; timeout_sec?: number },
|
||
fallbackSec: number,
|
||
): { text: string; detail: string } {
|
||
const detail = res.detail ?? '';
|
||
switch (res.error) {
|
||
case 'timeout':
|
||
return { text: t('models.failTimeout', { sec: res.timeout_sec ?? fallbackSec }), detail };
|
||
case 'auth':
|
||
return { text: t('models.failAuth'), detail };
|
||
case 'not_found':
|
||
return { text: t('models.failNotFound'), detail };
|
||
case 'http': {
|
||
if (detail.startsWith('HTTP 404')) return { text: t('models.failNotOpenai'), detail };
|
||
const status = detail.split(':')[0].replace('HTTP ', '').trim();
|
||
return { text: t('models.failHttp', { status: status || detail }), detail };
|
||
}
|
||
case 'connect':
|
||
default:
|
||
return { text: t('models.failConnect'), detail };
|
||
}
|
||
}
|
||
|
||
async function runTest() {
|
||
showErrors = true;
|
||
if (!urlValid || !form.model.trim()) return;
|
||
// On add the key is required before anything can be probed.
|
||
if (formMode === 'add' && !form.apiKey.trim()) return;
|
||
formPending = true;
|
||
formTest = null;
|
||
formTestFailure = null;
|
||
try {
|
||
const res = await settings.testLlm({
|
||
...(formMode === 'edit' && editingId ? { profile_id: editingId } : {}),
|
||
base_url: form.baseUrl.trim(),
|
||
model: form.model.trim(),
|
||
...(form.apiKey.trim() ? { api_key: form.apiKey.trim() } : {}),
|
||
timeout_sec: form.timeout,
|
||
});
|
||
if (res.ok) {
|
||
formTest = { ok: true, ms: res.elapsed_ms };
|
||
} else {
|
||
formTest = { ok: false };
|
||
formTestFailure = classifyFailure(res, form.timeout);
|
||
}
|
||
} catch (err) {
|
||
formTest = { ok: false };
|
||
formTestFailure = {
|
||
text: t('models.failConnect'),
|
||
detail: err instanceof Error ? err.message : String(err),
|
||
};
|
||
} finally {
|
||
formPending = false;
|
||
}
|
||
}
|
||
|
||
function llmProfilesFromSettings(s: Settings): WorkingProfile[] {
|
||
if (s.llm_profiles?.length) return s.llm_profiles.map((p) => ({ ...p }));
|
||
return [
|
||
{
|
||
id: s.llm_active_id || 'legacy',
|
||
name: s.llm_model || 'LLM',
|
||
base_url: s.llm_base_url,
|
||
model: s.llm_model,
|
||
api_key: s.llm_api_key,
|
||
},
|
||
];
|
||
}
|
||
|
||
const saveMutation = createMutation({
|
||
mutationFn: async () => {
|
||
const s = $settingsQuery.data;
|
||
if (!s) throw new Error('settings unavailable');
|
||
const base = llmProfilesFromSettings(s);
|
||
const typedKey = form.apiKey.trim();
|
||
let list: WorkingProfile[];
|
||
if (formMode === 'edit' && editingId) {
|
||
list = base.map((p) =>
|
||
p.id === editingId
|
||
? {
|
||
...p,
|
||
name: form.name.trim(),
|
||
base_url: form.baseUrl.trim(),
|
||
model: form.model.trim(),
|
||
...(typedKey ? { api_key: typedKey } : {}),
|
||
}
|
||
: p,
|
||
);
|
||
} else {
|
||
list = [
|
||
...base,
|
||
{
|
||
id: randomId(),
|
||
name: form.name.trim(),
|
||
base_url: form.baseUrl.trim(),
|
||
model: form.model.trim(),
|
||
api_key: typedKey,
|
||
},
|
||
];
|
||
}
|
||
return settings.update({
|
||
llm_profiles: list.map((p) => ({
|
||
id: p.id,
|
||
name: p.name.trim(),
|
||
base_url: p.base_url.trim(),
|
||
model: p.model.trim(),
|
||
...(typeof p.api_key === 'string' && p.api_key.trim()
|
||
? { api_key: p.api_key.trim() }
|
||
: {}),
|
||
})),
|
||
});
|
||
},
|
||
onSuccess: (saved) => {
|
||
client.invalidateQueries({ queryKey: ['settings'] });
|
||
// Carry the passing test over so the new card shows 已连接.
|
||
if (formTest?.ok) {
|
||
const id =
|
||
formMode === 'edit' && editingId ? editingId : (saved.llm_profiles.at(-1)?.id ?? '');
|
||
if (id) recordTest(id, { ok: true, ms: formTest.ms, at: Date.now(), fails: 0 });
|
||
}
|
||
toast.success(t('models.saved'));
|
||
resetForm();
|
||
},
|
||
onError: (err) => {
|
||
toast.error(
|
||
t('models.saveFailed', { detail: err instanceof Error ? err.message : String(err) }),
|
||
);
|
||
},
|
||
});
|
||
|
||
function submitSave() {
|
||
showErrors = true;
|
||
if (!formValid || !formTest?.ok || $saveMutation.isPending) return;
|
||
$saveMutation.mutate();
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Card actions: per-profile test / delete / set default
|
||
// ------------------------------------------------------------------
|
||
async function testProfile(profile: LlmProfile) {
|
||
pendingTests = { ...pendingTests, [profile.id]: true };
|
||
try {
|
||
const res = await settings.testLlm({
|
||
profile_id: profile.id,
|
||
base_url: profile.base_url.trim(),
|
||
model: profile.model.trim(),
|
||
timeout_sec: 10,
|
||
});
|
||
const prev = tests[profile.id];
|
||
if (res.ok) {
|
||
recordTest(profile.id, { ok: true, ms: res.elapsed_ms, at: Date.now(), fails: 0 });
|
||
} else {
|
||
const cls = classifyFailure(res, 10);
|
||
recordTest(profile.id, {
|
||
ok: false,
|
||
at: Date.now(),
|
||
fails: (prev?.fails ?? 0) + 1,
|
||
reason: cls.text + (cls.detail ? `(${cls.detail})` : ''),
|
||
});
|
||
}
|
||
} catch (err) {
|
||
const prev = tests[profile.id];
|
||
recordTest(profile.id, {
|
||
ok: false,
|
||
at: Date.now(),
|
||
fails: (prev?.fails ?? 0) + 1,
|
||
reason: err instanceof Error ? err.message : String(err),
|
||
});
|
||
} finally {
|
||
const next = { ...pendingTests };
|
||
delete next[profile.id];
|
||
pendingTests = next;
|
||
}
|
||
}
|
||
|
||
let deleteOpen = $state(false);
|
||
let deleteTarget = $state<LlmProfile | null>(null);
|
||
|
||
function requestDelete(profile: LlmProfile) {
|
||
deleteTarget = profile;
|
||
deleteOpen = true;
|
||
}
|
||
|
||
function agentsUsing(s: Settings, profileId: string): number {
|
||
return Object.values(s.agent_llm_assignments ?? {}).filter((v) => v === profileId).length;
|
||
}
|
||
|
||
const deleteMessage = $derived.by(() => {
|
||
const s = $settingsQuery.data;
|
||
if (!deleteTarget || !s) return '';
|
||
const n = agentsUsing(s, deleteTarget.id);
|
||
return n > 0 ? t('models.delConfirmUsed', { n }) : t('models.delConfirmFree');
|
||
});
|
||
|
||
const deleteMutation = createMutation({
|
||
mutationFn: async () => {
|
||
const s = $settingsQuery.data;
|
||
const target = deleteTarget;
|
||
if (!s || !target) throw new Error('no target');
|
||
const list = llmProfilesFromSettings(s).filter((p) => p.id !== target.id);
|
||
return settings.update({
|
||
llm_profiles: list.map((p) => ({
|
||
id: p.id,
|
||
name: p.name.trim(),
|
||
base_url: p.base_url.trim(),
|
||
model: p.model.trim(),
|
||
})),
|
||
});
|
||
},
|
||
onSuccess: () => {
|
||
if (deleteTarget) {
|
||
const next = { ...tests };
|
||
delete next[deleteTarget.id];
|
||
saveTests(next);
|
||
if (editingId === deleteTarget.id) resetForm();
|
||
}
|
||
client.invalidateQueries({ queryKey: ['settings'] });
|
||
toast.success(t('models.deleted'));
|
||
},
|
||
onError: (err) => {
|
||
toast.error(
|
||
t('models.saveFailed', { detail: err instanceof Error ? err.message : String(err) }),
|
||
);
|
||
},
|
||
});
|
||
|
||
const defaultMutation = createMutation({
|
||
mutationFn: (id: string) => settings.update({ llm_active_id: id }),
|
||
onSuccess: () => {
|
||
client.invalidateQueries({ queryKey: ['settings'] });
|
||
toast.success(t('models.defaultSetToast'));
|
||
},
|
||
onError: (err) => {
|
||
toast.error(
|
||
t('models.saveFailed', { detail: err instanceof Error ? err.message : String(err) }),
|
||
);
|
||
},
|
||
});
|
||
|
||
// ------------------------------------------------------------------
|
||
// Agent default-model panel (spec §9.4). The five AIGC agents; 视觉设计
|
||
// binds to the `style` role added for the upcoming style agent.
|
||
// ------------------------------------------------------------------
|
||
const AGENTS: {
|
||
role: string;
|
||
labelKey: string;
|
||
color: string;
|
||
char: string;
|
||
dark?: boolean;
|
||
}[] = [
|
||
{
|
||
role: 'story',
|
||
labelKey: 'models.agentStory',
|
||
color: 'var(--avatar-1)',
|
||
char: '剧',
|
||
dark: true,
|
||
},
|
||
{ role: 'style', labelKey: 'models.agentStyle', color: 'var(--avatar-2)', char: '视' },
|
||
{ role: 'script', labelKey: 'models.agentScript', color: 'var(--avatar-3)', char: '分' },
|
||
{ role: 'assets', labelKey: 'models.agentAssets', color: 'var(--avatar-4)', char: '素' },
|
||
{ role: 'video', labelKey: 'models.agentVideo', color: 'var(--avatar-5)', char: '镜' },
|
||
];
|
||
|
||
const assignMutation = createMutation({
|
||
mutationFn: (payload: Record<string, string | null>) =>
|
||
settings.update({ agent_llm_assignments: payload }),
|
||
onSuccess: () => {
|
||
client.invalidateQueries({ queryKey: ['settings'] });
|
||
toast.success(t('models.assignSaved'));
|
||
},
|
||
onError: (err) => {
|
||
client.invalidateQueries({ queryKey: ['settings'] });
|
||
toast.error(
|
||
t('models.saveFailed', { detail: err instanceof Error ? err.message : String(err) }),
|
||
);
|
||
},
|
||
});
|
||
|
||
function setAssignment(s: Settings, role: string, value: string) {
|
||
const merged: Record<string, string | null> = { ...(s.agent_llm_assignments ?? {}) };
|
||
merged[role] = value === '' ? null : value;
|
||
$assignMutation.mutate(merged);
|
||
}
|
||
|
||
// ------------------------------------------------------------------
|
||
// Helpers
|
||
// ------------------------------------------------------------------
|
||
function classifyEndpoint(rawUrl: string): 'local' | 'lan' | 'cloud' {
|
||
try {
|
||
const u = new URL(rawUrl.trim());
|
||
const h = u.hostname.toLowerCase();
|
||
if (h === 'localhost' || h === '::1' || h.startsWith('127.')) return 'local';
|
||
const m = h.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
||
if (m) {
|
||
const a = Number(m[1]);
|
||
const b = Number(m[2]);
|
||
if (a === 10 || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168)) return 'lan';
|
||
if (a === 169 && b === 254) return 'lan';
|
||
return 'cloud';
|
||
}
|
||
if (!h.includes('.') || h.endsWith('.local') || h.endsWith('.lan') || h.endsWith('.internal'))
|
||
return 'lan';
|
||
return 'cloud';
|
||
} catch {
|
||
return 'cloud';
|
||
}
|
||
}
|
||
|
||
function typeLabel(kind: 'local' | 'lan' | 'cloud'): string {
|
||
return kind === 'local'
|
||
? t('models.typeLocal')
|
||
: kind === 'lan'
|
||
? t('models.typeLan')
|
||
: t('models.typeCloud');
|
||
}
|
||
|
||
function formatTime(at: number): string {
|
||
return new Date(at).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
||
}
|
||
|
||
function keyTail(profile: LlmProfile): string {
|
||
const tail = profile.api_key_tail ?? '';
|
||
return tail ? `sk-****${tail}` : '';
|
||
}
|
||
|
||
loadTests();
|
||
// Prune stale test records once the profile list is known.
|
||
$effect(() => {
|
||
const data = $settingsQuery.data;
|
||
if (data) pruneTests(data.llm_profiles.map((p) => p.id));
|
||
});
|
||
</script>
|
||
|
||
<AppShell active="models" title={t('models.title')} subtitle={t('models.subtitle')}>
|
||
{#snippet actions()}
|
||
{#if !$settingsQuery.isLoading && $settingsQuery.data}
|
||
{@const profiles = $settingsQuery.data.llm_profiles}
|
||
{@const availableCount = profiles.filter((p) => tests[p.id]?.ok).length}
|
||
<span class="status-chip">
|
||
{t('models.statusCount', { n: profiles.length, m: availableCount })}
|
||
</span>
|
||
{/if}
|
||
<button
|
||
class="a-btn"
|
||
class:primary={formMode === 'idle'}
|
||
class:secondary={formMode !== 'idle'}
|
||
onclick={startAdd}
|
||
>
|
||
<Icon name="plus" size={14} />
|
||
{t('models.add')}
|
||
</button>
|
||
{/snippet}
|
||
|
||
<div class="page">
|
||
{#if $settingsQuery.isLoading}
|
||
<p class="loading">{t('models.loading')}</p>
|
||
{:else if !$settingsQuery.data}
|
||
<p class="loading error">{t('models.loadFailed')}</p>
|
||
{:else}
|
||
{@const s = $settingsQuery.data}
|
||
{@const profiles = s.llm_profiles}
|
||
{@const activeId = s.llm_active_id ?? profiles[0]?.id ?? ''}
|
||
|
||
<div class="tabs" role="tablist" aria-label={t('models.title')}>
|
||
<span class="tab active" role="tab" aria-selected="true">
|
||
{t('models.tabLlm')}
|
||
<span class="tab-count">{profiles.length}</span>
|
||
</span>
|
||
<span class="tab disabled" aria-disabled="true">
|
||
{t('models.tabImage')}
|
||
<span class="soon-pill">{t('models.comingSoon')}</span>
|
||
</span>
|
||
<span class="tab disabled" aria-disabled="true">
|
||
{t('models.tabVideo')}
|
||
<span class="soon-pill">{t('models.comingSoon')}</span>
|
||
</span>
|
||
</div>
|
||
|
||
<div class="layout" class:form-open={formMode !== 'idle'}>
|
||
<section class="main-col">
|
||
{#if profiles.length === 0}
|
||
<EmptyState title={t('models.empty')} />
|
||
{:else}
|
||
<div class="cards">
|
||
{#each profiles as profile (profile.id)}
|
||
{@const isActive = profile.id === activeId}
|
||
{@const rec = tests[profile.id]}
|
||
{@const kind = classifyEndpoint(profile.base_url)}
|
||
{@const pending = pendingTests[profile.id] === true}
|
||
{@const using = agentsUsing(s, profile.id)}
|
||
<article class="card" class:failed={rec?.ok === false}>
|
||
<div class="card-row">
|
||
<span class="card-icon"><Icon name="sparkle" size={18} /></span>
|
||
<span class="card-name">{profile.name}</span>
|
||
<span class="tag tag-{kind}">{typeLabel(kind)}</span>
|
||
{#if isActive}
|
||
<span class="tag tag-default">{t('models.defaultBadge')}</span>
|
||
{/if}
|
||
<span class="card-actions">
|
||
<Button
|
||
variant="secondary"
|
||
size="sm"
|
||
loading={pending}
|
||
onclick={() => testProfile(profile)}
|
||
>
|
||
{pending ? t('models.testing') : t('models.test')}
|
||
</Button>
|
||
<Button variant="ghost" size="sm" onclick={() => startEdit(profile)}>
|
||
{t('models.edit')}
|
||
</Button>
|
||
{#if isActive}
|
||
<button
|
||
type="button"
|
||
class="link-danger"
|
||
disabled
|
||
title={t('models.delDefaultHint')}
|
||
>
|
||
{t('models.delete')}
|
||
</button>
|
||
{:else}
|
||
<button
|
||
type="button"
|
||
class="link-danger"
|
||
onclick={() => requestDelete(profile)}
|
||
>
|
||
{t('models.delete')}
|
||
</button>
|
||
{/if}
|
||
</span>
|
||
</div>
|
||
<p class="card-meta mono">{profile.base_url} · {profile.model}</p>
|
||
<div class="card-status">
|
||
{#if pending}
|
||
<span class="dot amber breathing"></span>
|
||
<span class="status-text amber">{t('models.testing')}</span>
|
||
{:else if rec?.ok}
|
||
<span class="dot green"></span>
|
||
<span class="status-text green">{t('models.statusConnected')}</span>
|
||
<span class="status-sub mono">
|
||
{t('models.latency', { ms: rec.ms ?? '?' })}{#if using > 0}
|
||
· {t('models.agentsUsing', { n: using })}{/if}
|
||
</span>
|
||
{:else if rec?.ok === false}
|
||
<span class="dot red"></span>
|
||
<span class="status-text red">{t('models.statusFailed')}</span>
|
||
<span class="status-sub mono">
|
||
{t('models.lastTestAt', { time: formatTime(rec.at) })}{#if rec.fails >= 2}
|
||
· {t('models.consecutiveFails', { n: rec.fails })}{/if}
|
||
</span>
|
||
{#if rec.fails >= 3}
|
||
<span class="paused">{t('models.cloudPaused')}</span>
|
||
{/if}
|
||
{:else}
|
||
<span class="dot gray"></span>
|
||
<span class="status-text gray">{t('models.statusUntested')}</span>
|
||
{/if}
|
||
</div>
|
||
{#if rec?.ok === false && rec.reason}
|
||
<div class="error-bar">
|
||
<Icon name="alert" size={14} />
|
||
<p>{rec.reason}</p>
|
||
</div>
|
||
{/if}
|
||
{#if !isActive}
|
||
<div class="card-foot">
|
||
<button
|
||
type="button"
|
||
class="link-accent"
|
||
onclick={() => $defaultMutation.mutate(profile.id)}
|
||
>
|
||
{t('models.setDefault')}
|
||
</button>
|
||
</div>
|
||
{/if}
|
||
</article>
|
||
{/each}
|
||
</div>
|
||
{/if}
|
||
|
||
<div class="notice" role="note">
|
||
<Icon name="info" size={16} />
|
||
<p>
|
||
<strong>{t('models.noticeStrong')}</strong>{t('models.noticeBody')}
|
||
</p>
|
||
</div>
|
||
|
||
<section class="agents-panel">
|
||
<div class="panel-head">
|
||
<h2>{t('models.agentsTitle')}</h2>
|
||
<span class="panel-hint">{t('models.agentsHint')}</span>
|
||
</div>
|
||
<div class="agents-grid">
|
||
{#each AGENTS as agent (agent.role)}
|
||
<label class="agent-cell">
|
||
<span class="avatar" style:background={agent.color} class:dark={agent.dark}>
|
||
{agent.char}
|
||
</span>
|
||
<span class="agent-name">{t(agent.labelKey)}</span>
|
||
<select
|
||
class="a-select"
|
||
value={s.agent_llm_assignments?.[agent.role] ?? ''}
|
||
onchange={(e) => setAssignment(s, agent.role, e.currentTarget.value)}
|
||
>
|
||
<option value="">{t('models.agentDefault')}</option>
|
||
{#each profiles as p (p.id)}
|
||
<option value={p.id} class:unavailable={tests[p.id]?.ok === false}>
|
||
{p.name} — {p.model}{tests[p.id]?.ok === false
|
||
? t('models.unavailable')
|
||
: ''}
|
||
</option>
|
||
{/each}
|
||
</select>
|
||
</label>
|
||
{/each}
|
||
</div>
|
||
</section>
|
||
</section>
|
||
|
||
{#if formMode !== 'idle'}
|
||
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions -->
|
||
<div class="drawer-backdrop" onclick={resetForm} aria-hidden="true"></div>
|
||
{/if}
|
||
<aside
|
||
class="form-col"
|
||
class:open={formMode !== 'idle'}
|
||
aria-label={t('models.formTitleAdd')}
|
||
>
|
||
{#if formMode === 'idle'}
|
||
<div class="form-idle">
|
||
<Icon name="sparkle" size={20} />
|
||
<p>{t('models.idleFormHint')}</p>
|
||
</div>
|
||
{:else}
|
||
<div class="form-head">
|
||
<h2>
|
||
{formMode === 'add' ? t('models.formTitleAdd') : t('models.formTitleEdit')}
|
||
</h2>
|
||
<button
|
||
type="button"
|
||
class="icon-btn"
|
||
aria-label={t('models.formClose')}
|
||
onclick={resetForm}
|
||
>
|
||
<Icon name="close" size={16} />
|
||
</button>
|
||
</div>
|
||
|
||
<label class="f-field">
|
||
<span class="f-label">{t('models.fName')}<em>*</em></span>
|
||
<input
|
||
class="f-input"
|
||
class:invalid={showErrors && formErrors.name}
|
||
value={form.name}
|
||
disabled={formPending}
|
||
oninput={(e) => (form.name = e.currentTarget.value)}
|
||
placeholder={t('models.fNamePh')}
|
||
/>
|
||
{#if showErrors && formErrors.name}<span class="f-error">{formErrors.name}</span>{/if}
|
||
</label>
|
||
|
||
<div class="f-field">
|
||
<span class="f-label">{t('models.fApiType')}</span>
|
||
<div class="seg" role="radiogroup" aria-label={t('models.fApiType')}>
|
||
<span class="seg-item selected" role="radio" aria-checked="true">
|
||
{t('models.apiOpenai')}
|
||
</span>
|
||
<span class="seg-item disabled" aria-disabled="true">
|
||
{t('models.apiAnthropic')}
|
||
</span>
|
||
<span class="seg-item disabled" aria-disabled="true">{t('models.apiOther')}</span>
|
||
</div>
|
||
<span class="f-hint">{t('models.apiTypeHelp')}</span>
|
||
</div>
|
||
|
||
<label class="f-field">
|
||
<span class="f-label">{t('models.fBaseUrl')}<em>*</em></span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && formErrors.baseUrl}
|
||
value={form.baseUrl}
|
||
disabled={formPending}
|
||
spellcheck="false"
|
||
oninput={(e) => {
|
||
form.baseUrl = e.currentTarget.value;
|
||
touchFormConnectivity();
|
||
}}
|
||
placeholder="http://192.168.200.18:11434/v1"
|
||
/>
|
||
{#if showErrors && formErrors.baseUrl}
|
||
<span class="f-error">{formErrors.baseUrl}</span>
|
||
{/if}
|
||
<span class="f-hint">{t('models.baseUrlHelp')}</span>
|
||
</label>
|
||
|
||
<label class="f-field">
|
||
<span class="f-label">{t('models.fModel')}<em>*</em></span>
|
||
<input
|
||
class="f-input mono"
|
||
class:invalid={showErrors && formErrors.model}
|
||
value={form.model}
|
||
disabled={formPending}
|
||
spellcheck="false"
|
||
oninput={(e) => {
|
||
form.model = e.currentTarget.value;
|
||
touchFormConnectivity();
|
||
}}
|
||
placeholder="deepseek-chat"
|
||
/>
|
||
{#if showErrors && formErrors.model}
|
||
<span class="f-error">{formErrors.model}</span>
|
||
{/if}
|
||
<span class="f-hint">{t('models.modelHelp')}</span>
|
||
</label>
|
||
|
||
<label class="f-field">
|
||
<span class="f-label">
|
||
{t('models.fApiKey')}<em>*</em>
|
||
<span class="kh-inline mono">{t('models.keyNoEcho')}</span>
|
||
</span>
|
||
<span class="key-wrap">
|
||
<input
|
||
class="f-input key-input"
|
||
type="password"
|
||
class:invalid={showErrors && formErrors.apiKey}
|
||
value={form.apiKey}
|
||
disabled={formPending}
|
||
autocomplete="off"
|
||
oninput={(e) => {
|
||
form.apiKey = e.currentTarget.value;
|
||
touchFormConnectivity();
|
||
}}
|
||
placeholder={formMode === 'edit' && editingProfile?.api_key
|
||
? t('models.keyKeepHint')
|
||
: 'sk-…'}
|
||
/>
|
||
{#if formMode === 'edit' && editingProfile?.api_key && keyTail(editingProfile)}
|
||
<span class="kh mono">{keyTail(editingProfile)}</span>
|
||
{/if}
|
||
</span>
|
||
{#if showErrors && formErrors.apiKey}
|
||
<span class="f-error">{formErrors.apiKey}</span>
|
||
{/if}
|
||
<span class="f-hint">{t('models.keyHelp')}</span>
|
||
</label>
|
||
|
||
<label class="f-field">
|
||
<span class="f-label">{t('models.fTimeout')}</span>
|
||
<select
|
||
class="f-input"
|
||
value={form.timeout}
|
||
disabled={formPending}
|
||
onchange={(e) => {
|
||
form.timeout = Number(e.currentTarget.value);
|
||
touchFormConnectivity();
|
||
}}
|
||
>
|
||
{#each TIMEOUT_OPTIONS as sec (sec)}
|
||
<option value={sec}>{t('models.timeoutSec', { n: sec })}</option>
|
||
{/each}
|
||
</select>
|
||
</label>
|
||
|
||
{#if formTest?.ok}
|
||
<div class="result-bar ok" transition:fade={{ duration: 250 }}>
|
||
{t('models.testOk', { ms: formTest.ms ?? '?', model: form.model.trim() })}
|
||
</div>
|
||
{:else if formTest?.ok === false && formTestFailure}
|
||
<div class="result-bar err" transition:fade={{ duration: 250 }}>
|
||
<p>{t('models.testFail', { reason: formTestFailure.text })}</p>
|
||
{#if formTestFailure.detail}
|
||
<p class="mono detail">{formTestFailure.detail}</p>
|
||
{/if}
|
||
</div>
|
||
{/if}
|
||
|
||
<div class="form-actions">
|
||
<span class="need-test" class:passed={formTest?.ok}>{t('models.needTest')}</span>
|
||
<Button variant="secondary" size="sm" loading={formPending} onclick={runTest}>
|
||
{formPending ? t('models.testing') : t('models.testBtn')}
|
||
</Button>
|
||
<Button
|
||
variant="primary"
|
||
size="sm"
|
||
disabled={!formValid || !formTest?.ok}
|
||
loading={$saveMutation.isPending}
|
||
onclick={submitSave}
|
||
>
|
||
{t('models.save')}
|
||
</Button>
|
||
</div>
|
||
{/if}
|
||
</aside>
|
||
</div>
|
||
{/if}
|
||
</div>
|
||
</AppShell>
|
||
|
||
<ConfirmDialog
|
||
bind:open={deleteOpen}
|
||
title={t('models.delTitle')}
|
||
message={deleteMessage}
|
||
confirmLabel={t('models.delete')}
|
||
danger
|
||
onconfirm={() => $deleteMutation.mutate()}
|
||
oncancel={() => (deleteTarget = null)}
|
||
/>
|
||
|
||
<style>
|
||
.page {
|
||
padding: 24px 28px 40px;
|
||
max-width: 1560px;
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
margin: 0 auto;
|
||
}
|
||
|
||
.loading {
|
||
padding: 48px;
|
||
color: var(--text-2);
|
||
}
|
||
.loading.error {
|
||
color: var(--error);
|
||
}
|
||
|
||
/* ---------------- topbar chip + button (§9.1, rendered in AppShell) ---------------- */
|
||
.status-chip {
|
||
padding: 5px 12px;
|
||
border-radius: 999px;
|
||
background: var(--surface-3);
|
||
color: var(--text-2);
|
||
font-size: 11.5px;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
/* Amber primary / outline secondary per §5 — only one amber button per
|
||
screen: the header one steps back to outline while the form is open. */
|
||
.a-btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
min-height: 34px;
|
||
padding: 0 16px;
|
||
border-radius: 8px;
|
||
font-family: inherit;
|
||
font-size: 13px;
|
||
font-weight: 600;
|
||
cursor: pointer;
|
||
border: 1px solid transparent;
|
||
transition:
|
||
background-color 150ms cubic-bezier(0.16, 1, 0.3, 1),
|
||
border-color 150ms,
|
||
transform 100ms;
|
||
}
|
||
.a-btn.primary {
|
||
background: var(--accent);
|
||
color: var(--accent-contrast);
|
||
}
|
||
.a-btn.primary:hover {
|
||
background: var(--accent-hover);
|
||
}
|
||
.a-btn.secondary {
|
||
background: var(--surface-2);
|
||
border-color: var(--border-strong);
|
||
color: var(--text);
|
||
}
|
||
.a-btn.secondary:hover {
|
||
border-color: rgba(255, 255, 255, 0.24);
|
||
}
|
||
.a-btn:active {
|
||
transform: scale(0.98);
|
||
}
|
||
|
||
/* ---------------- tabs (§9.1 / §9.8 .tab) ---------------- */
|
||
.tabs {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 22px;
|
||
border-bottom: 1px solid var(--border);
|
||
margin-bottom: 22px;
|
||
}
|
||
.tab {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
padding: 10px 2px 12px;
|
||
font-size: 13.5px;
|
||
position: relative;
|
||
}
|
||
.tab.active {
|
||
color: var(--accent);
|
||
font-weight: 600;
|
||
border-bottom: 2px solid var(--accent);
|
||
margin-bottom: -1px;
|
||
}
|
||
.tab-count {
|
||
padding: 1px 8px;
|
||
border-radius: 999px;
|
||
background: var(--accent-dim);
|
||
color: var(--accent);
|
||
font-size: 10.5px;
|
||
font-weight: 600;
|
||
}
|
||
.tab.disabled {
|
||
color: var(--text-3);
|
||
opacity: 0.55;
|
||
cursor: default;
|
||
user-select: none;
|
||
}
|
||
.soon-pill {
|
||
padding: 1px 8px;
|
||
border-radius: 999px;
|
||
background: var(--surface-3);
|
||
color: var(--text-3);
|
||
font-size: 10.5px;
|
||
}
|
||
|
||
/* ---------------- layout (§9.1) ---------------- */
|
||
.layout {
|
||
display: flex;
|
||
gap: 24px;
|
||
align-items: flex-start;
|
||
}
|
||
.main-col {
|
||
flex: 1;
|
||
min-width: 0;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 22px;
|
||
}
|
||
|
||
/* ---------------- model cards (§9.2) ---------------- */
|
||
.cards {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 14px;
|
||
}
|
||
.card {
|
||
background: var(--surface);
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 16px 18px;
|
||
transition: border-color 150ms cubic-bezier(0.16, 1, 0.3, 1);
|
||
}
|
||
.card.failed {
|
||
border-color: rgba(229, 72, 77, 0.35);
|
||
}
|
||
.card-row {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 10px;
|
||
flex-wrap: wrap;
|
||
}
|
||
.card-icon {
|
||
width: 38px;
|
||
height: 38px;
|
||
border-radius: 9px;
|
||
background: var(--surface-2);
|
||
border: 1px solid var(--border-strong);
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
color: var(--accent);
|
||
flex-shrink: 0;
|
||
}
|
||
.card-name {
|
||
font-size: 14px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.tag {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
padding: 2px 9px;
|
||
border-radius: 999px;
|
||
font-size: 10.5px;
|
||
font-weight: 600;
|
||
}
|
||
.tag-local,
|
||
.tag-lan {
|
||
color: var(--info);
|
||
background: var(--info-dim);
|
||
}
|
||
.tag-cloud {
|
||
color: var(--cloud);
|
||
background: var(--cloud-dim);
|
||
}
|
||
.tag-default {
|
||
color: var(--accent);
|
||
background: var(--accent-dim);
|
||
}
|
||
.card-actions {
|
||
margin-left: auto;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
gap: 6px;
|
||
}
|
||
.card-meta {
|
||
margin: 10px 0 0 48px;
|
||
font-size: 11.5px;
|
||
color: var(--text-3);
|
||
word-break: break-all;
|
||
}
|
||
.card-status {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin: 8px 0 0 48px;
|
||
flex-wrap: wrap;
|
||
}
|
||
.dot {
|
||
width: 7px;
|
||
height: 7px;
|
||
border-radius: 50%;
|
||
flex-shrink: 0;
|
||
}
|
||
.dot.green {
|
||
background: var(--success);
|
||
}
|
||
.dot.red {
|
||
background: var(--error);
|
||
}
|
||
.dot.gray {
|
||
background: var(--text-3);
|
||
}
|
||
.dot.amber {
|
||
background: var(--accent);
|
||
box-shadow: 0 0 10px var(--accent-glow);
|
||
}
|
||
.dot.breathing {
|
||
animation: breathe 2s ease-in-out infinite;
|
||
}
|
||
@keyframes breathe {
|
||
0%,
|
||
100% {
|
||
opacity: 1;
|
||
}
|
||
50% {
|
||
opacity: 0.35;
|
||
}
|
||
}
|
||
.status-text {
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
}
|
||
.status-text.green {
|
||
color: var(--success);
|
||
}
|
||
.status-text.red {
|
||
color: var(--error);
|
||
}
|
||
.status-text.amber {
|
||
color: var(--accent);
|
||
}
|
||
.status-text.gray {
|
||
color: var(--text-3);
|
||
font-weight: 400;
|
||
}
|
||
.status-sub {
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
}
|
||
.paused {
|
||
color: var(--error);
|
||
font-size: 11.5px;
|
||
margin-left: auto;
|
||
}
|
||
.error-bar {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 8px;
|
||
margin: 10px 0 0 48px;
|
||
padding: 9px 12px;
|
||
border-radius: 7px;
|
||
background: var(--error-dim);
|
||
}
|
||
.error-bar p {
|
||
margin: 0;
|
||
font-size: 11.5px;
|
||
line-height: 1.55;
|
||
color: var(--text-2);
|
||
}
|
||
.error-bar :global(.icon) {
|
||
color: var(--error);
|
||
flex-shrink: 0;
|
||
margin-top: 2px;
|
||
}
|
||
.card-foot {
|
||
margin: 8px 0 0 48px;
|
||
}
|
||
|
||
.link-danger {
|
||
background: none;
|
||
border: none;
|
||
padding: 5px 8px;
|
||
font-family: inherit;
|
||
font-size: 12px;
|
||
color: var(--error);
|
||
cursor: pointer;
|
||
border-radius: 6px;
|
||
opacity: 0.85;
|
||
}
|
||
.link-danger:hover:not(:disabled) {
|
||
opacity: 1;
|
||
background: var(--error-dim);
|
||
}
|
||
.link-danger:disabled {
|
||
opacity: 0.35;
|
||
cursor: not-allowed;
|
||
}
|
||
.link-accent {
|
||
background: none;
|
||
border: none;
|
||
padding: 0;
|
||
font-family: inherit;
|
||
font-size: 12px;
|
||
color: var(--accent);
|
||
cursor: pointer;
|
||
}
|
||
.link-accent:hover {
|
||
text-decoration: underline;
|
||
}
|
||
|
||
/* ---------------- notice bar (§9.5) ---------------- */
|
||
.notice {
|
||
display: flex;
|
||
align-items: flex-start;
|
||
gap: 10px;
|
||
padding: 12px 16px;
|
||
border: 1.5px dashed var(--border-strong);
|
||
border-radius: 10px;
|
||
color: var(--text-2);
|
||
}
|
||
.notice :global(.icon) {
|
||
color: var(--text-3);
|
||
flex-shrink: 0;
|
||
margin-top: 2px;
|
||
}
|
||
.notice p {
|
||
margin: 0;
|
||
font-size: 12px;
|
||
line-height: 1.65;
|
||
}
|
||
.notice strong {
|
||
color: var(--text);
|
||
}
|
||
|
||
/* ---------------- agents panel (§9.4) ---------------- */
|
||
.agents-panel {
|
||
background: var(--surface);
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 18px 20px;
|
||
}
|
||
.panel-head {
|
||
display: flex;
|
||
align-items: baseline;
|
||
justify-content: space-between;
|
||
gap: 12px;
|
||
margin-bottom: 16px;
|
||
flex-wrap: wrap;
|
||
}
|
||
.panel-head h2 {
|
||
margin: 0;
|
||
font-size: 14.5px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.panel-hint {
|
||
font-size: 11.5px;
|
||
color: var(--text-3);
|
||
}
|
||
.agents-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(5, 1fr);
|
||
gap: 14px;
|
||
}
|
||
.agent-cell {
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 8px;
|
||
min-width: 0;
|
||
}
|
||
.avatar {
|
||
width: 24px;
|
||
height: 24px;
|
||
border-radius: 6px;
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
font-size: 11px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.avatar.dark {
|
||
color: #16130a;
|
||
}
|
||
.agent-name {
|
||
font-size: 12.5px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.a-select {
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
background: var(--surface-2);
|
||
border: 1px solid var(--border-strong);
|
||
border-radius: 7px;
|
||
padding: 7px 9px;
|
||
color: var(--text);
|
||
font-family: inherit;
|
||
font-size: 12px;
|
||
cursor: pointer;
|
||
}
|
||
.a-select:focus {
|
||
outline: none;
|
||
border-color: rgba(232, 163, 61, 0.6);
|
||
}
|
||
.a-select option.unavailable {
|
||
color: var(--text-3);
|
||
}
|
||
|
||
/* ---------------- form column (§9.3) ---------------- */
|
||
.form-col {
|
||
width: 384px;
|
||
flex-shrink: 0;
|
||
background: var(--surface);
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
padding: 18px 20px 20px;
|
||
position: sticky;
|
||
top: 24px;
|
||
}
|
||
.form-idle {
|
||
display: flex;
|
||
flex-direction: column;
|
||
align-items: center;
|
||
gap: 10px;
|
||
padding: 36px 12px;
|
||
color: var(--text-3);
|
||
text-align: center;
|
||
}
|
||
.form-idle p {
|
||
margin: 0;
|
||
font-size: 12px;
|
||
line-height: 1.6;
|
||
}
|
||
.form-head {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
margin-bottom: 14px;
|
||
}
|
||
.form-head h2 {
|
||
margin: 0;
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
color: var(--text);
|
||
}
|
||
.icon-btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 28px;
|
||
height: 28px;
|
||
border: none;
|
||
border-radius: 7px;
|
||
background: transparent;
|
||
color: var(--text-3);
|
||
cursor: pointer;
|
||
}
|
||
.icon-btn:hover {
|
||
background: var(--surface-3);
|
||
color: var(--text);
|
||
}
|
||
|
||
.f-field {
|
||
display: block;
|
||
margin-bottom: 13px;
|
||
}
|
||
.f-label {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 4px;
|
||
font-size: 12px;
|
||
font-weight: 600;
|
||
color: var(--text-2);
|
||
margin-bottom: 6px;
|
||
}
|
||
.f-label em {
|
||
color: var(--error);
|
||
font-style: normal;
|
||
}
|
||
.kh-inline {
|
||
margin-left: auto;
|
||
font-size: 10.5px;
|
||
font-weight: 400;
|
||
color: var(--text-3);
|
||
}
|
||
.f-input {
|
||
width: 100%;
|
||
box-sizing: border-box;
|
||
background: var(--surface-2);
|
||
border: 1px solid var(--border-strong);
|
||
border-radius: 7px;
|
||
padding: 9px 11px;
|
||
color: var(--text);
|
||
font-family: inherit;
|
||
font-size: 13px;
|
||
}
|
||
.f-input.mono {
|
||
font-size: 12px;
|
||
}
|
||
.f-input:focus {
|
||
outline: none;
|
||
border-color: rgba(232, 163, 61, 0.6);
|
||
}
|
||
.f-input:disabled {
|
||
color: var(--text-3);
|
||
cursor: not-allowed;
|
||
}
|
||
.f-input.invalid {
|
||
border-color: rgba(229, 72, 77, 0.65);
|
||
}
|
||
.f-hint {
|
||
display: block;
|
||
margin-top: 5px;
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
}
|
||
.f-error {
|
||
display: block;
|
||
margin-top: 5px;
|
||
font-size: 11.5px;
|
||
color: var(--error);
|
||
}
|
||
.key-wrap {
|
||
position: relative;
|
||
display: block;
|
||
}
|
||
.key-input {
|
||
padding-right: 92px;
|
||
}
|
||
.kh {
|
||
position: absolute;
|
||
right: 10px;
|
||
top: 50%;
|
||
transform: translateY(-50%);
|
||
font-size: 10.5px;
|
||
color: var(--text-3);
|
||
pointer-events: none;
|
||
}
|
||
|
||
/* segmented control (§9.8 .seg) */
|
||
.seg {
|
||
display: flex;
|
||
gap: 6px;
|
||
}
|
||
.seg-item {
|
||
flex: 1;
|
||
text-align: center;
|
||
padding: 7px 6px;
|
||
border-radius: 7px;
|
||
border: 1px solid var(--border);
|
||
background: var(--surface-2);
|
||
font-size: 12px;
|
||
color: var(--text-2);
|
||
}
|
||
.seg-item.selected {
|
||
border-color: var(--accent);
|
||
color: var(--accent);
|
||
background: var(--accent-dim);
|
||
font-weight: 600;
|
||
}
|
||
.seg-item.disabled {
|
||
opacity: 0.45;
|
||
cursor: default;
|
||
user-select: none;
|
||
}
|
||
|
||
.result-bar {
|
||
margin: 4px 0 12px;
|
||
padding: 10px 12px;
|
||
border-radius: 7px;
|
||
font-size: 12px;
|
||
line-height: 1.55;
|
||
}
|
||
.result-bar.ok {
|
||
background: var(--success-dim);
|
||
color: var(--success);
|
||
}
|
||
.result-bar.err {
|
||
background: var(--error-dim);
|
||
color: var(--error);
|
||
}
|
||
.result-bar p {
|
||
margin: 0;
|
||
}
|
||
.result-bar .detail {
|
||
margin-top: 3px;
|
||
font-size: 10.5px;
|
||
color: var(--text-2);
|
||
word-break: break-all;
|
||
}
|
||
|
||
.form-actions {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 8px;
|
||
margin-top: 4px;
|
||
padding-top: 12px;
|
||
border-top: 1px solid var(--border);
|
||
}
|
||
.need-test {
|
||
margin-right: auto;
|
||
font-size: 11px;
|
||
color: var(--text-3);
|
||
}
|
||
.need-test.passed {
|
||
color: var(--success);
|
||
}
|
||
|
||
/* Reused ui/Button restyled inside the darkroom token scope (§5) */
|
||
.page :global(.btn-secondary) {
|
||
background: var(--surface-2);
|
||
border-color: var(--border-strong);
|
||
color: var(--text);
|
||
}
|
||
.page :global(.btn-secondary:hover:not(:disabled)) {
|
||
background: var(--surface-3);
|
||
border-color: rgba(255, 255, 255, 0.24);
|
||
}
|
||
.page :global(.btn-primary) {
|
||
background: var(--accent);
|
||
color: var(--accent-contrast);
|
||
}
|
||
.page :global(.btn-primary:hover:not(:disabled)) {
|
||
background: var(--accent-hover);
|
||
}
|
||
.page :global(.btn-ghost) {
|
||
color: var(--text-2);
|
||
}
|
||
.page :global(.btn-ghost:hover:not(:disabled)) {
|
||
background: var(--surface-3);
|
||
color: var(--text);
|
||
}
|
||
.page :global(.btn:focus-visible) {
|
||
outline-color: var(--accent);
|
||
}
|
||
|
||
.drawer-backdrop {
|
||
display: none;
|
||
}
|
||
|
||
/* ---------------- responsive (§9.7) ---------------- */
|
||
@media (max-width: 1439px) {
|
||
.page {
|
||
padding: 20px 22px 36px;
|
||
}
|
||
.layout {
|
||
flex-direction: column;
|
||
}
|
||
/* form becomes a right drawer (372px) */
|
||
.form-col {
|
||
position: fixed;
|
||
top: 0;
|
||
right: 0;
|
||
bottom: 0;
|
||
width: 372px;
|
||
max-width: calc(100vw - 24px);
|
||
border-radius: 0;
|
||
border-top: none;
|
||
border-bottom: none;
|
||
border-right: none;
|
||
z-index: 800;
|
||
overflow-y: auto;
|
||
transform: translateX(100%);
|
||
transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
|
||
box-shadow: -24px 0 64px rgba(0, 0, 0, 0.4);
|
||
}
|
||
.form-col.open {
|
||
transform: translateX(0);
|
||
}
|
||
.form-idle {
|
||
display: none;
|
||
}
|
||
.layout:not(.form-open) .form-col {
|
||
display: none;
|
||
}
|
||
.drawer-backdrop {
|
||
display: block;
|
||
position: fixed;
|
||
inset: 0;
|
||
z-index: 790;
|
||
background: rgba(5, 5, 8, 0.5);
|
||
}
|
||
.agents-grid {
|
||
grid-template-columns: repeat(3, 1fr);
|
||
}
|
||
}
|
||
|
||
@media (max-width: 1023px) {
|
||
.page {
|
||
padding: 16px 16px 32px;
|
||
}
|
||
/* single column: cards → form → notice → agents list */
|
||
.form-col {
|
||
position: static;
|
||
width: 100%;
|
||
max-width: none;
|
||
transform: none;
|
||
box-shadow: none;
|
||
border: 1px solid var(--border);
|
||
border-radius: 10px;
|
||
}
|
||
.drawer-backdrop {
|
||
display: none;
|
||
}
|
||
.agents-grid {
|
||
grid-template-columns: 1fr;
|
||
gap: 12px;
|
||
}
|
||
.agent-cell {
|
||
flex-direction: row;
|
||
align-items: center;
|
||
gap: 10px;
|
||
}
|
||
.agent-cell .a-select {
|
||
width: 250px;
|
||
margin-left: auto;
|
||
}
|
||
.card-actions {
|
||
margin-left: 0;
|
||
width: 100%;
|
||
}
|
||
.card-meta,
|
||
.card-status,
|
||
.error-bar,
|
||
.card-foot {
|
||
margin-left: 0;
|
||
}
|
||
}
|
||
</style>
|