refactor: extract shared settings stylesheet (pg.css) and clean up inline styles
- 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>
This commit is contained in:
@@ -4,51 +4,15 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Tool Settings — Cortex</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>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
:root {
|
||||
color-scheme: light dark;
|
||||
--pg-bg: #f8fafc; --pg-card: #ffffff; --pg-border: #e2e8f0;
|
||||
--pg-text: #1e293b; --pg-muted: #64748b; --pg-dimmer: #94a3b8;
|
||||
--pg-bright: #cbd5e1; --pg-nav-hover: rgba(255,255,255,0.05);
|
||||
--pg-accent: #7c3aed;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--pg-bg: #0f0a1e; --pg-card: #1a1228; --pg-border: #2d2040;
|
||||
--pg-text: #e2d9f3; --pg-muted: #9d8ec4; --pg-dimmer: #6b5d8a;
|
||||
--pg-bright: #1a1228; --pg-nav-hover: rgba(0,0,0,0.05);
|
||||
}
|
||||
}
|
||||
|
||||
body { font-family: system-ui, sans-serif; background: var(--pg-bg); color: var(--pg-text); min-height: 100vh; }
|
||||
|
||||
.page-nav {
|
||||
display: flex; align-items: center; gap: 0.25rem;
|
||||
padding: 0.5rem 1rem; background: var(--pg-card);
|
||||
border-bottom: 1px solid var(--pg-border); flex-wrap: wrap;
|
||||
}
|
||||
.nav-link {
|
||||
padding: 0.35rem 0.7rem; border-radius: 0.375rem; font-size: 0.875rem;
|
||||
color: var(--pg-muted); text-decoration: none; white-space: nowrap;
|
||||
}
|
||||
.nav-link:hover { color: var(--pg-text); background: var(--pg-nav-hover); }
|
||||
.nav-link.active { color: #a78bfa; }
|
||||
.nav-spacer { flex: 1; min-width: 0.5rem; }
|
||||
.nav-link.nav-logout { color: var(--pg-dimmer); }
|
||||
.nav-link.nav-logout:hover { color: var(--pg-muted); background: none; }
|
||||
|
||||
.page-wrap { max-width: 860px; margin: 0 auto; padding: 2rem 1rem 4rem; }
|
||||
h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
|
||||
.page-lead { color: var(--pg-muted); font-size: 0.9rem; margin-bottom: 2rem; }
|
||||
|
||||
.success { color: #22c55e; font-size: 0.9rem; margin: 0.5rem 0; }
|
||||
.error { color: #f87171; font-size: 0.9rem; margin: 0.5rem 0; }
|
||||
|
||||
/* ── Risk policy card ── */
|
||||
/* ── Policy cards (bordered sections on tools page) ── */
|
||||
.policy-card {
|
||||
background: var(--pg-card); border: 1px solid var(--pg-border);
|
||||
background: var(--pg-surface); border: 1px solid var(--pg-border);
|
||||
border-radius: 0.75rem; padding: 1.25rem 1.5rem; margin-bottom: 1.75rem;
|
||||
}
|
||||
.policy-card h2 { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; }
|
||||
@@ -56,30 +20,37 @@
|
||||
.policy-label { font-size: 0.875rem; font-weight: 500; min-width: 6rem; }
|
||||
.policy-note { font-size: 0.8rem; color: var(--pg-muted); margin-top: 0.35rem; line-height: 1.5; }
|
||||
|
||||
select, input[type="text"] {
|
||||
background: var(--pg-bg); border: 1px solid var(--pg-border);
|
||||
border-radius: 0.375rem; color: var(--pg-text);
|
||||
/* Compact selects and inputs inside policy cards */
|
||||
.policy-card select, .policy-card input[type="text"] {
|
||||
padding: 0.4rem 0.65rem; font-size: 0.875rem;
|
||||
}
|
||||
select:focus, input:focus { outline: 2px solid var(--pg-accent); border-color: transparent; }
|
||||
|
||||
/* Two-column layout for allow/deny textareas */
|
||||
.col-split { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: flex-start; }
|
||||
.col-half { flex: 1; min-width: 200px; }
|
||||
.col-half label { font-size: 0.8rem; font-weight: 600; margin-bottom: 0.35rem; }
|
||||
.col-half textarea {
|
||||
font-size: 0.82rem; border-radius: 0.375rem; padding: 0.45rem 0.65rem;
|
||||
}
|
||||
|
||||
/* Save button (compact, not full-width) */
|
||||
.save-btn {
|
||||
background: var(--pg-accent); color: #fff; border: none;
|
||||
background: var(--pg-action); color: #fff; border: none;
|
||||
border-radius: 0.5rem; padding: 0.5rem 1.4rem;
|
||||
font-size: 0.875rem; font-weight: 600; cursor: pointer;
|
||||
margin-top: 0.5rem;
|
||||
margin-top: 0.5rem; transition: opacity 0.15s;
|
||||
}
|
||||
.save-btn:hover { opacity: 0.88; }
|
||||
|
||||
/* ── Tool table ── */
|
||||
.section-head {
|
||||
.table-section-label {
|
||||
font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
|
||||
text-transform: uppercase; color: var(--pg-dimmer);
|
||||
margin: 1.75rem 0 0.6rem;
|
||||
}
|
||||
.tool-table {
|
||||
width: 100%; border-collapse: collapse;
|
||||
background: var(--pg-card); border: 1px solid var(--pg-border);
|
||||
background: var(--pg-surface); border: 1px solid var(--pg-border);
|
||||
border-radius: 0.75rem; overflow: hidden; margin-bottom: 0.5rem;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
@@ -92,36 +63,31 @@
|
||||
.tool-table td { padding: 0.5rem 0.9rem; border-bottom: 1px solid var(--pg-border); vertical-align: middle; }
|
||||
.tool-table tr:last-child td { border-bottom: none; }
|
||||
.tool-table tr:hover td { background: rgba(124,58,237,0.04); }
|
||||
|
||||
.tool-name { font-family: monospace; font-size: 0.82rem; }
|
||||
|
||||
/* Risk badges */
|
||||
.risk { display: inline-block; font-size: 0.7rem; font-weight: 700;
|
||||
padding: 0.15rem 0.45rem; border-radius: 9999px; letter-spacing: 0.04em; }
|
||||
.risk-low { background: rgba(34,197,94,0.15); color: #16a34a; }
|
||||
.risk-medium { background: rgba(234,179, 8,0.15); color: #ca8a04; }
|
||||
.risk-high { background: rgba(239,68, 68,0.15); color: #dc2626; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.risk-low { background: rgba(34,197,94,0.12); color: #4ade80; }
|
||||
.risk-medium { background: rgba(234,179, 8,0.12); color: #fbbf24; }
|
||||
.risk-high { background: rgba(239,68, 68,0.12); color: #f87171; }
|
||||
}
|
||||
.risk-low { background: rgba(34,197,94,0.12); color: #4ade80; }
|
||||
.risk-medium { background: rgba(234,179,8,0.12); color: #fbbf24; }
|
||||
.risk-high { background: rgba(239,68,68,0.12); color: #f87171; }
|
||||
[data-theme="light"] .risk-low { background: rgba(34,197,94,0.15); color: #16a34a; }
|
||||
[data-theme="light"] .risk-medium { background: rgba(234,179,8,0.15); color: #ca8a04; }
|
||||
[data-theme="light"] .risk-high { background: rgba(239,68,68,0.15); color: #dc2626; }
|
||||
|
||||
/* Auto status pill */
|
||||
.auto-pill {
|
||||
display: inline-block; font-size: 0.68rem; font-weight: 600;
|
||||
padding: 0.12rem 0.4rem; border-radius: 9999px;
|
||||
}
|
||||
.auto-on { background: rgba(124,58,237,0.12); color: #7c3aed; }
|
||||
.auto-on { background: rgba(124,58,237,0.12); color: #a78bfa; }
|
||||
.auto-off { background: rgba(148,163,184,0.12); color: var(--pg-dimmer); }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.auto-on { color: #a78bfa; }
|
||||
}
|
||||
[data-theme="light"] .auto-on { color: #7c3aed; }
|
||||
|
||||
/* Override select */
|
||||
.override-sel {
|
||||
font-size: 0.78rem; padding: 0.25rem 0.5rem;
|
||||
border-radius: 0.3rem; min-width: 7rem;
|
||||
border-radius: 0.3rem; min-width: 7rem; width: auto;
|
||||
}
|
||||
.override-sel.forced-on { border-color: #7c3aed; color: #7c3aed; }
|
||||
.override-sel.forced-off { border-color: #dc2626; color: #dc2626; }
|
||||
@@ -129,7 +95,7 @@
|
||||
/* Legend */
|
||||
.legend { display: flex; gap: 1.25rem; flex-wrap: wrap; margin-bottom: 1.25rem; font-size: 0.8rem; color: var(--pg-muted); }
|
||||
.legend-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 50%; margin-right: 0.3rem; }
|
||||
.legend-dot.on { background: #7c3aed; }
|
||||
.legend-dot.on { background: #a78bfa; }
|
||||
.legend-dot.off { background: var(--pg-dimmer); }
|
||||
</style>
|
||||
</head>
|
||||
@@ -146,8 +112,8 @@
|
||||
</nav>
|
||||
|
||||
<div class="page-wrap">
|
||||
<h1>Tool Settings</h1>
|
||||
<p class="page-lead">
|
||||
<h1 class="page-title">Tool Settings</h1>
|
||||
<p class="page-subtitle">
|
||||
Control which orchestrator tools are available. The risk level sets an automatic threshold;
|
||||
whitelist and blacklist let you fine-tune individual tools beyond that.
|
||||
</p>
|
||||
@@ -157,15 +123,14 @@
|
||||
|
||||
<form method="POST" action="/settings/tools" id="tools-form">
|
||||
|
||||
<!-- ── Risk policy ── -->
|
||||
<!-- Risk policy -->
|
||||
<div class="policy-card">
|
||||
<h2>Risk Policy</h2>
|
||||
|
||||
<div class="policy-row">
|
||||
<span class="policy-label">Max risk level</span>
|
||||
<select name="max_risk" id="max-risk-sel">
|
||||
<option value="" {{ sel_none }}>No filter — use all role-permitted tools</option>
|
||||
<option value="low" {{ sel_low }}>Low — read-only and sandboxed tools only</option>
|
||||
<option value="" {{ sel_none }}>No filter — use all role-permitted tools</option>
|
||||
<option value="low" {{ sel_low }}>Low — read-only and sandboxed tools only</option>
|
||||
<option value="medium" {{ sel_medium }}>Medium — low + medium risk (recommended)</option>
|
||||
<option value="high" {{ sel_high }}>High — all tools including destructive ones</option>
|
||||
</select>
|
||||
@@ -175,53 +140,42 @@
|
||||
<strong>Medium</strong> tools write to local data or send notifications to you (cron jobs, scratch, task management).<br>
|
||||
<strong>High</strong> tools affect external systems or the host (shell exec, email, device control, service restart).
|
||||
</p>
|
||||
|
||||
<p class="policy-note" style="margin-top:0.75rem;">
|
||||
The <em>Auto</em> column below shows each tool's status at your current max risk level.
|
||||
Use the override column to force-include or force-exclude individual tools.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- ── Legend ── -->
|
||||
<!-- Legend -->
|
||||
<div class="legend">
|
||||
<span><span class="legend-dot on"></span>Auto-included by risk level</span>
|
||||
<span><span class="legend-dot off"></span>Auto-excluded by risk level</span>
|
||||
</div>
|
||||
|
||||
<!-- ── Tool table ── -->
|
||||
<!-- Tool table -->
|
||||
{{ tool_table_html }}
|
||||
|
||||
<!-- ── Confirmation gate ── -->
|
||||
<!-- Confirmation gate -->
|
||||
<div class="policy-card" style="margin-top:1.75rem;">
|
||||
<h2>Confirmation Gate</h2>
|
||||
<p class="policy-note" style="margin-bottom:0.85rem;">
|
||||
<p class="policy-note">
|
||||
Some tools require explicit confirmation before executing. Override the defaults here.<br>
|
||||
Tools requiring confirmation by default: <code style="font-size:0.78rem;">{{ confirm_required_tools }}</code>
|
||||
Tools requiring confirmation by default: <code>{{ confirm_required_tools }}</code>
|
||||
</p>
|
||||
<div class="policy-row" style="align-items:flex-start; gap:1.5rem; flex-wrap:wrap;">
|
||||
<div style="flex:1; min-width:200px;">
|
||||
<label style="display:block; font-size:0.8rem; font-weight:600; margin-bottom:0.35rem;">
|
||||
Allow list — bypass confirmation
|
||||
</label>
|
||||
<div class="col-split" style="margin-top:0.85rem;">
|
||||
<div class="col-half">
|
||||
<label>Allow list — bypass confirmation</label>
|
||||
<textarea name="allow_list" rows="4"
|
||||
placeholder="reminders_clear cron_remove"
|
||||
autocomplete="off" spellcheck="false"
|
||||
style="width:100%; background:var(--pg-bg); border:1px solid var(--pg-border);
|
||||
border-radius:0.375rem; color:var(--pg-text); padding:0.45rem 0.65rem;
|
||||
font-size:0.82rem; font-family:monospace; resize:vertical;">{{ tool_allow }}</textarea>
|
||||
<p class="policy-note">One tool name per line. These tools skip the confirmation prompt.</p>
|
||||
autocomplete="off" spellcheck="false">{{ tool_allow }}</textarea>
|
||||
<p class="hint">One tool name per line. These tools skip the confirmation prompt.</p>
|
||||
</div>
|
||||
<div style="flex:1; min-width:200px;">
|
||||
<label style="display:block; font-size:0.8rem; font-weight:600; margin-bottom:0.35rem;">
|
||||
Deny list — always block
|
||||
</label>
|
||||
<div class="col-half">
|
||||
<label>Deny list — always block</label>
|
||||
<textarea name="deny_list" rows="4"
|
||||
placeholder="shell_exec file_write"
|
||||
autocomplete="off" spellcheck="false"
|
||||
style="width:100%; background:var(--pg-bg); border:1px solid var(--pg-border);
|
||||
border-radius:0.375rem; color:var(--pg-text); padding:0.45rem 0.65rem;
|
||||
font-size:0.82rem; font-family:monospace; resize:vertical;">{{ tool_deny }}</textarea>
|
||||
<p class="policy-note">These tools are always blocked regardless of risk policy.</p>
|
||||
autocomplete="off" spellcheck="false">{{ tool_deny }}</textarea>
|
||||
<p class="hint">These tools are always blocked regardless of risk policy.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user