GUI settings panel: per-session instance + global defaults, notes, name lock

- ⚙️ settings modal with a Sessione/Generali scope toggle: per-session edits PATCH only that session; Generali edits PUT the defaults template (future sessions only). Fields: name, notes (chat purpose), system prompt, temperature/top_p/top_k/min_p/max_tokens.

- Name field disabled once locked; the sidebar ✏️ rename is disabled after the first interaction. Unexposed settings fields preserved on save. README documents the settings/identity model; 114 tests. Verified via node --check + HTTP (assets + settings flow).
This commit is contained in:
adm committed 2026-11-25 15:51:43 +01:00
1 parent c199953927
commit 73b665d1a7
4 files changed
+165 -5

No files matched your search

+19 -3
View File
@@ -101,6 +101,21 @@ offline, same-origin so no CORS). It is a thin client over a **session-aware API
context, runs inference (streaming SSE or not) and persists the new turns with context, runs inference (streaming SSE or not) and persists the new turns with
their token usage. their token usage.
- `GET /api/stats` — aggregate counters (sessions, messages, prompt/completion tokens). - `GET /api/stats` — aggregate counters (sessions, messages, prompt/completion tokens).
- `GET/PUT /api/settings/defaults` — the global default settings template.
- `PATCH /api/sessions/{id}` — rename (only before the first interaction) and/or
replace the session's own settings instance.
**Settings & identity.** Each session owns a *settings instance* (system prompt,
notes, sampling) snapshotted from the global defaults at creation
(**copy-on-create**): editing a session affects only it, editing the defaults
affects only *future* sessions — no retroactive surprises. The user jots the
chat's purpose in **notes**. The framework assigns an evocative name (a curated
word list); it is editable only before the first interaction, then **immutable**.
At that first interaction a personal workspace folder is created
(`~/.strata-ctl/<name>/`, configurable via `workspace_root`) and a structural
identity reminder ("your name is …, your personal folder is …") is prepended to
the model's context — not an editable setting. The GUI exposes all of this in a
⚙️ settings panel (per-session or general).
The standard `/v1` API stays **stateless**; conversation context lives server-side The standard `/v1` API stays **stateless**; conversation context lives server-side
in an embedded **SQLite** database (default `~/.config/strata-ctl/sessions.db`, in an embedded **SQLite** database (default `~/.config/strata-ctl/sessions.db`,
@@ -180,7 +195,7 @@ unknown keys never break startup.
## Status ## Status
Working and tested (106 tests, plus 2 real-file tests run on demand). Text, images, Working and tested (114 tests, plus 2 real-file tests run on demand). Text, images,
the full client-side tool loop, the Anthropic endpoint, the web GUI (session the full client-side tool loop, the Anthropic endpoint, the web GUI (session
context, streaming, stats) and **agent mode** (the model using `shell_exec` on the context, streaming, stats) and **agent mode** (the model using `shell_exec` on the
host) have been validated live against the real Inkling engine. host) have been validated live against the real Inkling engine.
@@ -191,8 +206,9 @@ engine restart after a crash, a full SSRF guard against DNS rebinding, and the
OpenAI Responses native endpoint. The Anthropic adapter covers the core cases but OpenAI Responses native endpoint. The Anthropic adapter covers the core cases but
not yet the `defer_loading` / `tool_addition` / `tool_reference` tool machinery, the not yet the `defer_loading` / `tool_addition` / `tool_reference` tool machinery, the
thinking `budget_tokens` mapping, or prompt-cache token accounting. The GUI agent's thinking `budget_tokens` mapping, or prompt-cache token accounting. The GUI agent's
**isolated mode** (Docker-container runner) and GUI images / advanced settings are **isolated mode** (Docker-container runner) and GUI file/image upload are still to
still to come; base/host agent mode works. come; base/host agent mode, per-session settings (copy-on-create), session notes,
immutable names and personal workspace folders work.
## License and credits ## License and credits
+20 -1
View File
@@ -179,7 +179,7 @@ details.thinking .reasoning {
#send { min-width: 52px; font-size: 1.3rem; } #send { min-width: 52px; font-size: 1.3rem; }
/* ---- Stats modal ---- */ /* ---- Stats modal ---- */
#stats-modal, #dialog { #stats-modal, #dialog, #settings-modal {
position: fixed; inset: 0; z-index: 40; position: fixed; inset: 0; z-index: 40;
background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
padding: 20px; padding: 20px;
@@ -201,6 +201,25 @@ details.thinking .reasoning {
#dialog-input:focus { outline: none; border-color: var(--accent); } #dialog-input:focus { outline: none; border-color: var(--accent); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; } .dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }
/* ---- Settings modal ---- */
.settings-card { width: min(560px, 100%); max-height: 85vh; overflow-y: auto; }
.scope-toggle { display: flex; gap: 8px; margin: 0 0 12px; }
.scope-toggle .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
#set-hint { margin: 0 0 12px; }
#set-name-hint { margin: -8px 0 12px; }
.small { font-size: 0.8rem; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; }
.field > span { font-size: 0.85rem; color: var(--muted); }
.field input, .field textarea {
width: 100%; background: var(--panel-2); color: var(--text);
border: 1px solid var(--border); border-radius: 8px;
padding: 8px 10px; font-size: 16px; font-family: inherit;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field input:disabled { opacity: 0.6; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.sess-btn:disabled { opacity: 0.35; cursor: default; }
/* ---- Wide screens: persistent sidebar ---- */ /* ---- Wide screens: persistent sidebar ---- */
@media (min-width: 900px) { @media (min-width: 900px) {
#drawer { position: static; transform: none; width: var(--sidebar-w); flex-shrink: 0; } #drawer { position: static; transform: none; width: var(--sidebar-w); flex-shrink: 0; }
+92 -1
View File
@@ -121,7 +121,8 @@ function renderSessions() {
li.appendChild(el("span", "session-title", s.title)); li.appendChild(el("span", "session-title", s.title));
const actions = el("span", "session-actions"); const actions = el("span", "session-actions");
const ren = el("button", "sess-btn", "\u{270F}\u{FE0F}"); const ren = el("button", "sess-btn", "\u{270F}\u{FE0F}");
ren.title = "Rinomina"; ren.title = s.name_locked ? "Nome bloccato dopo la prima interazione" : "Rinomina";
ren.disabled = s.name_locked;
ren.setAttribute("aria-label", "Rinomina chat"); ren.setAttribute("aria-label", "Rinomina chat");
ren.addEventListener("click", (e) => { e.stopPropagation(); renameSessionById(s.id, s.title); }); ren.addEventListener("click", (e) => { e.stopPropagation(); renameSessionById(s.id, s.title); });
const del = el("button", "sess-btn danger", "\u{1F5D1}\u{FE0F}"); const del = el("button", "sess-btn danger", "\u{1F5D1}\u{FE0F}");
@@ -363,6 +364,91 @@ async function showStats() {
$("#stats-modal").hidden = false; $("#stats-modal").hidden = false;
} }
// ---- Settings (per-session instance or global defaults) -------------------
let settingsScope = "session";
let settingsBase = {};
function currentSession() {
return state.sessions.find((s) => s.id === state.current);
}
function fillSettingsForm(data, scope) {
const isSession = scope === "session";
$("#set-name-field").hidden = !isSession;
$("#set-name-hint").hidden = !isSession;
if (isSession) {
const sess = currentSession();
$("#set-name").value = sess ? sess.title : "";
const locked = sess ? sess.name_locked : false;
$("#set-name").disabled = locked;
$("#set-name-hint").textContent = locked
? "Il nome è bloccato dopo la prima interazione."
: "Puoi rinominare finché non invii il primo messaggio.";
$("#set-hint").textContent = "Modifiche valide solo per questa sessione.";
} else {
$("#set-hint").textContent = "Default generali: si applicano solo alle sessioni future.";
}
$("#set-notes").value = data.notes || "";
$("#set-sp").value = data.system_prompt || "";
$("#set-temp").value = data.temperature ?? "";
$("#set-topp").value = data.top_p ?? "";
$("#set-topk").value = data.top_k ?? "";
$("#set-minp").value = data.min_p ?? "";
$("#set-maxtokens").value = data.max_tokens ?? "";
}
function readSettingsForm() {
const num = (v) => (v === "" ? null : Number(v));
const txt = (v) => (v.trim() === "" ? null : v);
return {
notes: txt($("#set-notes").value),
system_prompt: txt($("#set-sp").value),
temperature: num($("#set-temp").value),
top_p: num($("#set-topp").value),
top_k: num($("#set-topk").value),
min_p: num($("#set-minp").value),
max_tokens: num($("#set-maxtokens").value),
};
}
async function openSettings(scope) {
settingsScope = scope;
$("#set-scope-session").classList.toggle("active", scope === "session");
$("#set-scope-general").classList.toggle("active", scope === "general");
$("#settings-title").textContent =
scope === "session" ? "Impostazioni sessione" : "Impostazioni generali";
settingsBase =
scope === "session"
? { ...(currentSession()?.settings || {}) }
: await getJSON("/api/settings/defaults");
fillSettingsForm(settingsBase, scope);
$("#settings-modal").hidden = false;
}
async function saveSettings() {
// Preserve unexposed fields (seed, penalties) from the loaded instance.
const settings = { ...settingsBase, ...readSettingsForm() };
try {
if (settingsScope === "session") {
const sess = currentSession();
if (!sess) return;
const body = { settings };
const newName = $("#set-name").value.trim();
if (!sess.name_locked && newName && newName !== sess.title) body.title = newName;
await sendJSON(`/api/sessions/${sess.id}`, "PATCH", body);
state.sessions = await getJSON("/api/sessions");
renderSessions();
const updated = currentSession();
if (updated) $("#session-title").textContent = updated.title;
} else {
await sendJSON("/api/settings/defaults", "PUT", settings);
}
$("#settings-modal").hidden = true;
} catch (e) {
$("#set-hint").textContent = `Errore: ${e.message}`;
}
}
// A custom modal dialog (replaces native prompt/confirm: styled, mobile-friendly, // A custom modal dialog (replaces native prompt/confirm: styled, mobile-friendly,
// and inspectable by automation). Resolves with the input string (or null on // and inspectable by automation). Resolves with the input string (or null on
// cancel) when `input` is given, otherwise true/false. // cancel) when `input` is given, otherwise true/false.
@@ -469,6 +555,11 @@ function wire() {
}); });
$("#show-stats").addEventListener("click", showStats); $("#show-stats").addEventListener("click", showStats);
$("#close-stats").addEventListener("click", () => { $("#stats-modal").hidden = true; }); $("#close-stats").addEventListener("click", () => { $("#stats-modal").hidden = true; });
$("#show-settings").addEventListener("click", () => openSettings("session"));
$("#set-scope-session").addEventListener("click", () => openSettings("session"));
$("#set-scope-general").addEventListener("click", () => openSettings("general"));
$("#set-save").addEventListener("click", saveSettings);
$("#set-cancel").addEventListener("click", () => { $("#settings-modal").hidden = true; });
const input = $("#input"); const input = $("#input");
input.addEventListener("input", () => autoGrow(input)); input.addEventListener("input", () => autoGrow(input));
input.addEventListener("keydown", (e) => { input.addEventListener("keydown", (e) => {
+34
View File
@@ -32,6 +32,7 @@
<span id="session-title">Conversazione</span> <span id="session-title">Conversazione</span>
<span id="model-name" class="muted"></span> <span id="model-name" class="muted"></span>
</div> </div>
<button id="show-settings" class="btn icon" aria-label="Impostazioni">&#9881;&#65039;</button>
<button id="delete-session" class="btn icon danger" aria-label="Elimina sessione">&#128465;</button> <button id="delete-session" class="btn icon danger" aria-label="Elimina sessione">&#128465;</button>
</header> </header>
@@ -67,6 +68,39 @@
</div> </div>
</div> </div>
<!-- Settings modal: per-session instance or global defaults template -->
<div id="settings-modal" hidden>
<div class="modal-card settings-card">
<h2 id="settings-title">Impostazioni</h2>
<div class="scope-toggle">
<button id="set-scope-session" class="btn ghost active">Sessione</button>
<button id="set-scope-general" class="btn ghost">Generali</button>
</div>
<p id="set-hint" class="muted"></p>
<label class="field" id="set-name-field"><span>Nome</span>
<input id="set-name" type="text" autocomplete="off" />
</label>
<p id="set-name-hint" class="muted small"></p>
<label class="field"><span>Note (scopo della chat)</span>
<textarea id="set-notes" rows="2"></textarea>
</label>
<label class="field"><span>System Prompt</span>
<textarea id="set-sp" rows="4"></textarea>
</label>
<div class="field-grid">
<label class="field"><span>Temperature</span><input id="set-temp" type="number" step="0.1" min="0" /></label>
<label class="field"><span>Top-p</span><input id="set-topp" type="number" step="0.05" min="0" max="1" /></label>
<label class="field"><span>Top-k</span><input id="set-topk" type="number" step="1" min="0" /></label>
<label class="field"><span>Min-p</span><input id="set-minp" type="number" step="0.05" min="0" max="1" /></label>
<label class="field"><span>Max token</span><input id="set-maxtokens" type="number" step="1" min="1" /></label>
</div>
<div class="dialog-actions">
<button id="set-cancel" class="btn">Annulla</button>
<button id="set-save" class="btn primary">Salva</button>
</div>
</div>
</div>
<script type="module" src="/assets/app.js"></script> <script type="module" src="/assets/app.js"></script>
</body> </body>
</html> </html>