Feat default surface routing (#4)
Some checks failed
CI/CD / detect-changes (push) Successful in 3s
CI/CD / test-frontend (push) Successful in 5s
CI/CD / test-go-pg (push) Failing after 2m17s
CI/CD / test-sqlite (push) Successful in 2m44s
CI/CD / build-and-deploy (push) Has been skipped

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #4.
This commit is contained in:
2026-03-26 19:56:14 +00:00
committed by xcaliber
parent a36be83aaf
commit f4512071db
9 changed files with 169 additions and 40 deletions

View File

@@ -7,21 +7,25 @@ const { useState, useEffect, useCallback } = hooks;
export default function SettingsSection() {
const [cfg, setCfg] = useState({});
const [models, setModels] = useState([]);
const [surfaces, setSurfaces] = useState([]);
const [vault, setVault] = useState(null);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const load = useCallback(async () => {
try {
const [s, m, v] = await Promise.all([
const [s, m, v, surfList] = await Promise.all([
sw.api.admin.settings.get(),
sw.api.admin.models.list().catch(() => []),
sw.api.admin.vault.status().catch(() => null),
sw.api.admin.surfaces.list().catch(() => []),
]);
const raw = s || {};
const pol = raw.policies || {};
const cfg_ = raw.settings || {};
setSurfaces((surfList || []).filter(s => s.enabled));
setCfg({
default_surface: cfg_.default_surface?.id || '',
allow_registration: pol.allow_registration === 'true',
registration_default_state: cfg_.registration_default_state || 'pending',
system_prompt: cfg_.system_prompt || '',
@@ -62,6 +66,9 @@ export default function SettingsSection() {
async function save() {
setSaving(true);
try {
// Default surface
await sw.api.admin.settings.update('default_surface', { value: cfg.default_surface ? { id: cfg.default_surface } : null });
// Policies
await sw.api.admin.settings.update('allow_registration', { value: String(cfg.allow_registration) });
await sw.api.admin.settings.update('registration_default_state', { value: cfg.registration_default_state });
@@ -128,6 +135,16 @@ export default function SettingsSection() {
return html`
<div class="admin-settings-form">
<div class="settings-section"><h3>Default Surface</h3>
<div class="form-group"><label>Landing page for /</label>
<select value=${cfg.default_surface} onChange=${e => set('default_surface', e.target.value)}>
<option value="">-- Auto (first extension surface, then Admin) --</option>
${surfaces.filter(s => s.source !== 'core').map(s => html`<option key=${s.id} value=${s.id}>${s.title || s.id}</option>`)}
</select>
</div>
<span class="text-muted" style="font-size:12px;">Where users land when visiting /. Only extension surfaces are listed.</span>
</div>
<div class="settings-section"><h3>Registration</h3>
<label class="toggle-label"><input type="checkbox" checked=${cfg.allow_registration} onChange=${e => set('allow_registration', e.target.checked)} /><span class="toggle-track"></span><span>Allow new user registration</span></label>
<div class="form-group" style="margin-top:8px;"><label>Default state</label>