- Create cortex/static/pg.css with shared variables, nav, containers, form elements, button classes, text utilities, and feedback messages - All four settings pages (settings, notifications, tools, help) now link to pg.css and have page-specific-only <style> blocks - Style block line counts reduced: settings 244→70, notifications 189→42, tools 126→88, help 122→75 - Inline style= attributes reduced: settings 45→4, notifications 7→3, tools 12→4, help 0 - Introduced shared CSS classes: .btn-submit, .btn-save, .btn-cancel, .btn-secondary, .action-link, .hint, .section-note, .page-title, .page-subtitle, .page-wrap, .usage-table, .tool-cat-row - Fix tools_settings.py: replace server-generated inline styles on category header rows with .tool-cat-row CSS class - Fix settings.py: add btn-save/btn-cancel/persona-rename-cancel classes to server-rendered persona rename form buttons Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
407 lines
16 KiB
HTML
407 lines
16 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Cortex — Account Settings</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="/static/pg.css">
|
|
<script>(function(){var t=localStorage.getItem('theme')||(window.matchMedia('(prefers-color-scheme: dark)').matches?'dark':'light');document.documentElement.setAttribute('data-theme',t);})();</script>
|
|
<style>
|
|
/* ── Persona list ── */
|
|
.persona-list {
|
|
list-style: none; display: flex; flex-direction: column;
|
|
gap: 0.5rem; margin-top: 0.5rem;
|
|
}
|
|
.persona-list li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
|
|
.persona-link {
|
|
display: inline-block; padding: 0.3rem 0.75rem;
|
|
background: var(--pg-bg); border: 1px solid var(--pg-border);
|
|
border-radius: 20px; color: var(--pg-accent); font-size: 0.85rem;
|
|
text-decoration: none; transition: border-color 0.15s;
|
|
}
|
|
.persona-link:hover { border-color: var(--pg-action); }
|
|
.persona-list li em { color: var(--pg-muted); font-size: 0.85rem; }
|
|
.persona-rename-toggle {
|
|
background: none; border: 1px solid var(--pg-border);
|
|
border-radius: 6px; color: var(--pg-muted); font-size: 0.8rem;
|
|
padding: 0.3rem 0.6rem; margin-top: 0.25rem;
|
|
cursor: pointer; opacity: 0.7; transition: opacity 0.15s, color 0.15s;
|
|
}
|
|
.persona-rename-toggle:hover { opacity: 1; color: var(--pg-accent); }
|
|
.persona-rename-form { display: flex; align-items: center; gap: 0.4rem; }
|
|
.persona-rename-form input[type="text"] {
|
|
width: 12rem; padding: 0.3rem 0.6rem;
|
|
border-color: var(--pg-action); font-size: 0.9rem;
|
|
}
|
|
.persona-rename-form .btn-save { padding: 0.3rem 0.75rem; font-size: 0.85rem; }
|
|
.add-persona {
|
|
display: inline-block; margin-top: 0.75rem;
|
|
font-size: 0.8rem; color: var(--pg-muted); text-decoration: none;
|
|
}
|
|
.add-persona:hover { color: var(--pg-accent); }
|
|
|
|
/* ── Role badge ── */
|
|
.role-badge {
|
|
display: inline-block; padding: 0.25rem 0.75rem;
|
|
border-radius: 20px; font-size: 0.78rem; font-weight: 600;
|
|
text-transform: uppercase; letter-spacing: 0.06em;
|
|
}
|
|
.role-badge.role-admin {
|
|
background: rgba(124,58,237,0.15); color: var(--pg-accent);
|
|
border: 1px solid rgba(124,58,237,0.4);
|
|
}
|
|
.role-badge.role-user {
|
|
background: rgba(100,116,139,0.12); color: var(--pg-muted);
|
|
border: 1px solid var(--pg-border);
|
|
}
|
|
|
|
/* ── OpenRouter quickstart warning card ── */
|
|
#openrouter-quickstart {
|
|
display: none; background: #1c1a0a; border: 1px solid #78350f;
|
|
border-radius: 8px; padding: 1rem; margin-bottom: 1rem;
|
|
}
|
|
#openrouter-quickstart .qs-title {
|
|
font-size: 0.82rem; color: #fbbf24; font-weight: 600; margin-bottom: 0.4rem;
|
|
}
|
|
#openrouter-quickstart .qs-body {
|
|
font-size: 0.8rem; color: #d97706; margin-bottom: 0.75rem; line-height: 1.5;
|
|
}
|
|
.action-link.action-link-amber {
|
|
background: #92400e; color: #fef3c7; font-size: 0.85rem; padding: 0.5rem 0.9rem;
|
|
}
|
|
.action-link.action-link-amber:hover { opacity: 0.9; background: #78350f; }
|
|
|
|
/* ── Inline result feedback spans ── */
|
|
.result-ok { display: none; margin-left: 0.75rem; font-size: 0.8rem; color: #4ade80; }
|
|
|
|
/* ── Usage table wrapper ── */
|
|
.usage-wrap { overflow-x: auto; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<nav class="page-nav">
|
|
<a href="{{ back_href }}" class="nav-link">← Chat</a>
|
|
<a href="{{ help_href }}" class="nav-link">Help</a>
|
|
<a href="/settings" class="nav-link active">Settings</a>
|
|
<a href="/settings/notifications" class="nav-link">Notifications</a>
|
|
<a href="/settings/tools" class="nav-link">Tools</a>
|
|
<span class="nav-spacer"></span>
|
|
<a href="/logout" class="nav-link nav-logout">Sign out</a>
|
|
</nav>
|
|
<div class="page-wrap">
|
|
<h1 class="page-title">Account Settings</h1>
|
|
<p class="page-subtitle">Manage your account and personas.</p>
|
|
|
|
<!-- SUCCESS -->
|
|
<!-- ERROR -->
|
|
|
|
<!-- Account info -->
|
|
<div class="section">
|
|
<h2>Account</h2>
|
|
<div class="field">
|
|
<label>Username</label>
|
|
<input type="text" value="{{ username }}" readonly>
|
|
</div>
|
|
<div class="field">
|
|
<label>Role</label>
|
|
<span class="role-badge role-{{ user_role }}">{{ user_role }}</span>
|
|
</div>
|
|
<button type="button" id="show-rename-user" class="persona-rename-toggle">
|
|
✏ Change username
|
|
</button>
|
|
<form id="rename-user-form" method="POST" action="/settings/username" style="display:none; margin-top:0.75rem;">
|
|
<div class="field">
|
|
<label for="new_username">New username</label>
|
|
<input type="text" id="new_username" name="new_username"
|
|
value="{{ username }}"
|
|
pattern="[a-z_][a-z0-9_\-]{0,31}" required autofocus
|
|
autocomplete="off" data-form-type="other">
|
|
<p class="hint">Lowercase letters, digits, _ or - only. You will be logged out after renaming.</p>
|
|
</div>
|
|
<div class="btn-row">
|
|
<button type="submit" class="btn-save">Save</button>
|
|
<button type="button" id="cancel-rename-user" class="btn-cancel">Cancel</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Connected accounts -->
|
|
<div class="section">
|
|
<h2>Connected Accounts</h2>
|
|
<div class="field">
|
|
<label>Google Account</label>
|
|
<input type="text" value="{{ google_email }}" readonly
|
|
placeholder="No Google account linked"
|
|
style="{{ google_email == '' and 'color:var(--pg-dimmer)' or '' }}">
|
|
</div>
|
|
<p class="hint" style="margin-top:-0.5rem;">To link or change your Google account, contact Scott.</p>
|
|
</div>
|
|
|
|
<!-- Email Allowlist -->
|
|
<div class="section">
|
|
<h2>Email Allowlist</h2>
|
|
<p class="section-note">
|
|
One regex pattern per line. The <code>email_send</code> tool will only send to addresses
|
|
that match at least one pattern. Leave blank to block all outbound email.
|
|
</p>
|
|
<form method="POST" action="/settings/email-allowlist">
|
|
<div class="field">
|
|
<label for="email_allowlist_ta">Allowed patterns</label>
|
|
<textarea id="email_allowlist_ta" name="patterns" rows="6"
|
|
placeholder=".*@example\.com alice@example\.com"
|
|
spellcheck="false">{{ email_allowlist }}</textarea>
|
|
</div>
|
|
<button type="submit" class="btn-submit">Save allowlist</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- HTTP POST Allowlist -->
|
|
<div class="section">
|
|
<h2>HTTP POST Allowlist</h2>
|
|
<p class="section-note">
|
|
One URL prefix per line. The <code>http_post</code> tool will only POST to URLs that
|
|
start with a listed prefix. Leave blank to block all outbound POST requests.
|
|
</p>
|
|
<form method="POST" action="/settings/http-allowlist">
|
|
<div class="field">
|
|
<label for="http_allowlist_ta">Allowed URL prefixes</label>
|
|
<textarea id="http_allowlist_ta" name="prefixes" rows="5"
|
|
placeholder="https://ha.dgrzone.com/api/webhook/ https://n8n.dgrzone.com/webhook/"
|
|
spellcheck="false">{{ http_allowlist }}</textarea>
|
|
</div>
|
|
<button type="submit" class="btn-submit">Save allowlist</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Notifications -->
|
|
<div class="section">
|
|
<h2>Notifications</h2>
|
|
<p class="section-note">
|
|
Configure how Inara reaches out proactively — reminders, cron jobs, and memory digests.
|
|
</p>
|
|
<a href="/settings/notifications" class="action-link">Notification settings →</a>
|
|
</div>
|
|
|
|
<!-- Tool Permissions → /settings/tools -->
|
|
<div class="section">
|
|
<h2>Tool Permissions</h2>
|
|
<p class="section-note">
|
|
Configure tool access, risk policy, and confirmation gate overrides on the Tools page.
|
|
</p>
|
|
<a href="/settings/tools" class="action-link">Tool settings →</a>
|
|
</div>
|
|
|
|
<!-- Usage summary -->
|
|
<div class="section" id="usage-section">
|
|
<h2>Usage</h2>
|
|
<p class="section-note">
|
|
Token consumption tracked for API-backed models (Gemini API, local OpenAI-compatible).
|
|
Claude CLI calls are not metered.
|
|
</p>
|
|
<div id="usage-table-wrap" class="usage-wrap">
|
|
<p class="section-note">Loading…</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Browser Cache -->
|
|
<div class="section">
|
|
<h2>Browser Cache</h2>
|
|
<p class="section-note">
|
|
Clears UI preferences stored in this browser: active mode, session ID, memory toggles,
|
|
theme, font size, and context tier. Does not sign you out.
|
|
</p>
|
|
<button type="button" id="clear-ls-btn" class="btn-secondary">Clear browser cache</button>
|
|
<span id="clear-ls-ok" class="result-ok">Cleared.</span>
|
|
</div>
|
|
|
|
<!-- Model Registry -->
|
|
<div class="section">
|
|
<h2>Model Registry</h2>
|
|
|
|
<div id="openrouter-quickstart">
|
|
<p class="qs-title">⚡ You're on the server default model</p>
|
|
<p class="qs-body">
|
|
You can chat now, but adding your own model gives you more choices, lets you pick
|
|
role-specific models, and tracks your usage separately.
|
|
OpenRouter is the easiest way to get started — one key, many models.
|
|
</p>
|
|
<a href="/setup/model" class="action-link action-link-amber">Set up OpenRouter →</a>
|
|
</div>
|
|
|
|
<p class="section-note">
|
|
Configure AI providers (Anthropic, Google), local hosts (Open WebUI, Ollama, OpenRouter, etc.),
|
|
and assign models to roles — chat, orchestrator, distill, and more.
|
|
</p>
|
|
<a href="/settings/models" class="action-link">Manage models →</a>
|
|
</div>
|
|
|
|
<!-- Change Password -->
|
|
<div class="section">
|
|
<h2>Change Password</h2>
|
|
<form method="POST" action="/settings/password" id="password-form">
|
|
<div class="field">
|
|
<label for="current_password">Current password</label>
|
|
<input type="password" id="current_password" name="current_password"
|
|
autocomplete="current-password" required>
|
|
</div>
|
|
<div class="field">
|
|
<label for="new_password">New password</label>
|
|
<input type="password" id="new_password" name="new_password"
|
|
autocomplete="new-password" required minlength="8">
|
|
</div>
|
|
<div class="field">
|
|
<label for="confirm_password">Confirm new password</label>
|
|
<input type="password" id="confirm_password" name="confirm_password"
|
|
autocomplete="new-password" required>
|
|
</div>
|
|
<button type="submit" class="btn-submit">Update password</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Sessions -->
|
|
<div class="section">
|
|
<h2>Sessions</h2>
|
|
<p class="section-note">
|
|
Auto-name any sessions that still show a random ID, using their first message as the name.
|
|
Only unnamed sessions are affected — existing names are left alone.
|
|
</p>
|
|
<button type="button" id="backfill-names-btn" class="btn-secondary">Auto-name old sessions</button>
|
|
<span id="backfill-names-ok" class="result-ok"></span>
|
|
</div>
|
|
|
|
<!-- Personas -->
|
|
<div class="section">
|
|
<h2>Personas</h2>
|
|
<ul class="persona-list">
|
|
{{ persona_items }}
|
|
</ul>
|
|
<a href="/setup/persona" class="add-persona">+ Add new persona</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Password confirmation check
|
|
document.getElementById('password-form').addEventListener('submit', e => {
|
|
const np = document.getElementById('new_password').value;
|
|
const cfm = document.getElementById('confirm_password').value;
|
|
if (np !== cfm) {
|
|
e.preventDefault();
|
|
alert('New passwords do not match.');
|
|
}
|
|
});
|
|
|
|
// Username rename toggle
|
|
document.getElementById('show-rename-user').addEventListener('click', () => {
|
|
document.getElementById('show-rename-user').style.display = 'none';
|
|
document.getElementById('rename-user-form').style.display = 'block';
|
|
document.getElementById('new_username').focus();
|
|
});
|
|
document.getElementById('cancel-rename-user').addEventListener('click', () => {
|
|
document.getElementById('rename-user-form').style.display = 'none';
|
|
document.getElementById('show-rename-user').style.display = '';
|
|
});
|
|
|
|
// Clear localStorage (keeps JWT cookie — no sign-out)
|
|
document.getElementById('clear-ls-btn').addEventListener('click', () => {
|
|
localStorage.clear();
|
|
document.getElementById('clear-ls-ok').style.display = 'inline';
|
|
});
|
|
|
|
// Show OpenRouter quick-start card if no model is configured
|
|
(async () => {
|
|
try {
|
|
const d = await fetch('/backend').then(r => r.json());
|
|
if ((d.available_roles || []).length === 0) {
|
|
document.getElementById('openrouter-quickstart').style.display = 'block';
|
|
}
|
|
} catch (_) {}
|
|
})();
|
|
|
|
// Usage summary table
|
|
(async () => {
|
|
const wrap = document.getElementById('usage-table-wrap');
|
|
try {
|
|
const resp = await fetch('/api/usage/summary');
|
|
if (!resp.ok) throw new Error(resp.statusText);
|
|
const rows_data = await resp.json();
|
|
if (!rows_data.length) {
|
|
wrap.innerHTML = '<p class="section-note">No usage recorded yet.</p>';
|
|
return;
|
|
}
|
|
const fmt = n => n >= 1000 ? (n / 1000).toFixed(1) + 'k' : String(n);
|
|
const rows = rows_data.map(d => {
|
|
const labelCell = d.label !== d.key
|
|
? `<span title="${d.key}">${d.label}</span>`
|
|
: `<span>${d.key}</span>`;
|
|
return `<tr>
|
|
<td>${labelCell}</td>
|
|
<td>${d.calls}</td>
|
|
<td>${fmt(d.prompt_tokens)}</td>
|
|
<td>${fmt(d.completion_tokens)}</td>
|
|
<td>${fmt(d.total_tokens)}</td>
|
|
</tr>`;
|
|
}).join('');
|
|
wrap.innerHTML = `<table class="usage-table">
|
|
<thead><tr>
|
|
<th style="text-align:left">Model</th>
|
|
<th>Calls</th><th>Prompt</th><th>Output</th><th>Total</th>
|
|
</tr></thead>
|
|
<tbody>${rows}</tbody>
|
|
</table>`;
|
|
} catch (e) {
|
|
wrap.innerHTML = '<p class="section-note">Could not load usage data.</p>';
|
|
}
|
|
})();
|
|
|
|
// Auto-name old sessions backfill
|
|
document.getElementById('backfill-names-btn').addEventListener('click', async () => {
|
|
const btn = document.getElementById('backfill-names-btn');
|
|
const ok = document.getElementById('backfill-names-ok');
|
|
btn.disabled = true;
|
|
btn.textContent = 'Working…';
|
|
try {
|
|
const params = new URLSearchParams(window.location.search);
|
|
const user = params.get('user') || document.querySelector('input[value]')?.value || '';
|
|
const persona = params.get('persona') || '';
|
|
const qs = user ? `?user=${encodeURIComponent(user)}&persona=${encodeURIComponent(persona)}` : '';
|
|
const res = await fetch(`/api/sessions/backfill-names${qs}`, { method: 'POST' });
|
|
const data = await res.json();
|
|
if (!res.ok) throw new Error(data.detail || res.statusText);
|
|
const n = data.named ?? 0;
|
|
ok.textContent = `Named ${n} session${n !== 1 ? 's' : ''}.`;
|
|
ok.style.display = 'inline';
|
|
} catch (e) {
|
|
ok.textContent = 'Error — check console.';
|
|
ok.style.color = '#f87171';
|
|
ok.style.display = 'inline';
|
|
}
|
|
btn.textContent = 'Auto-name old sessions';
|
|
btn.disabled = false;
|
|
});
|
|
|
|
// Persona rename toggle
|
|
document.querySelectorAll('.persona-rename-toggle').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
const p = btn.dataset.persona;
|
|
const form = document.querySelector(`.persona-rename-form[data-persona="${p}"]`);
|
|
btn.style.display = 'none';
|
|
form.style.display = 'flex';
|
|
form.querySelector('input[type="text"]').focus();
|
|
});
|
|
});
|
|
document.querySelectorAll('.persona-rename-cancel').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
const form = btn.closest('.persona-rename-form');
|
|
const p = form.dataset.persona;
|
|
const toggle = document.querySelector(`.persona-rename-toggle[data-persona="${p}"]`);
|
|
form.style.display = 'none';
|
|
toggle.style.display = '';
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|