Files
strata-ctl/web/index.html
T
adm 0ce84581a4 Add context management: notepad, sliding window, cache reuse, windowed GUI
Per-session notepad: agent-curated labelled entries via the notepad tool
(set/remove/clear), injected as a pinned <NOTEPAD> section above DIALOG,
char-budgeted with a consolidate ceiling, exposed in a read-only GUI panel.

Sliding DIALOG window (src/window.rs): retains recent messages by count in
two tiers (MAIN_AREA=40 + BUFFER=10), append-only while the buffer fills so
the prompt prefix stays byte-stable for KV reuse, then stepped hysteresis
eviction snapping to user-turn boundaries (never splits a tool exchange).
window_start persisted per session; full history never deleted.

Engine prefix-cache reuse: leave DIALOG open (a moving </DIALOG> closer broke
the engine prompt_ckpt_prefix every user turn, forcing full re-prefill);
surface usage.cached_tokens as a GUI badge; fix the PerfMeter prefill gauge to
gauge over non-cached tokens; add a static sliding-window marker after the
opener so the model knows older turns are omitted.

Stats clarity: distinguish the current inference context (last_prompt_tokens,
new "Contesto attuale" card) from the cumulative lifetime token total
(relabeled "Token cumulativi ... su tutti i turni"); /api/stats carries both.

Windowed browser transcript: GET /api/sessions/{id}/messages returns only the
retained window (SQL-filtered by window_start, never loads the full history)
plus the total count, wrapped as {messages, window_start, total}; the GUI shows
a banner noting older turns are preserved server-side. Full-chat export deferred.

Settings: the session scope re-reads the persisted instance fresh from the store
(like the general scope already did), fixing a stale-cache display that looked
like the session System Prompt was not being kept.

Docs (README) refreshed; 158 tests + 3 ignored green, clippy and fmt clean.
2026-11-26 03:12:23 +01:00

127 lines
6.0 KiB
HTML

<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="color-scheme" content="dark light" />
<title>strata-ctl</title>
<link rel="icon" href="data:," />
<link rel="stylesheet" href="/assets/app.css" />
</head>
<body>
<div id="app">
<!-- Session drawer (off-canvas on mobile, sidebar on wide screens) -->
<aside id="drawer" aria-label="Sessioni">
<div class="drawer-head">
<span class="brand">strata&#8209;ctl</span>
<button id="new-session" class="btn primary" title="Nuova conversazione">+ Nuova</button>
</div>
<ul id="session-list"></ul>
<div class="drawer-foot">
<button id="show-stats" class="btn ghost" data-i18n="stats.title">Statistiche</button>
</div>
</aside>
<div id="splitter" role="separator" aria-orientation="vertical" aria-label="Ridimensiona l'elenco delle discussioni" aria-valuemin="200" aria-valuemax="480" aria-valuenow="280" tabindex="0"></div>
<div id="scrim" hidden></div>
<!-- Main column -->
<main id="main">
<header id="topbar">
<button id="menu" class="btn icon" aria-label="Apri sessioni">&#9776;</button>
<div class="title-wrap">
<span id="session-title">Conversazione</span>
<span id="model-name" class="muted"></span>
</div>
<button id="show-notepad" class="btn icon" aria-label="Notepad">&#128221;</button>
<button id="show-settings" class="btn icon" aria-label="Impostazioni">&#9881;&#65039;</button>
</header>
<section id="transcript" aria-live="polite"></section>
<div id="attachments" class="attachments" hidden></div>
<footer id="composer">
<textarea id="input" rows="1" placeholder="Scrivi un messaggio…" autocomplete="off"></textarea>
<button id="attach" class="btn ghost" aria-label="Allega file o immagini" title="Allega file o immagini">&#128206;</button>
<button id="send" class="btn primary" aria-label="Invia">&#10148;</button>
<input id="file-input" type="file" multiple hidden />
</footer>
</main>
</div>
<!-- Stats dashboard -->
<div id="stats-modal" hidden>
<div class="modal-card stats-card">
<div class="stats-head">
<h2 data-i18n="stats.title">Statistiche</h2>
<span id="stats-live" class="stats-live muted"></span>
<button id="close-stats" class="btn icon" aria-label="Chiudi">&#10005;</button>
</div>
<div id="stats-content" class="stats-content"></div>
</div>
</div>
<!-- Notepad (read-only): the session's pinned entries, managed by the agent -->
<div id="notepad-modal" hidden>
<div class="modal-card notepad-card">
<div class="stats-head">
<h2 data-i18n="notepad.title">Notepad</h2>
<button id="refresh-notepad" class="btn icon" aria-label="Aggiorna">&#8635;</button>
<button id="close-notepad" class="btn icon" aria-label="Chiudi">&#10005;</button>
</div>
<p class="muted small notepad-hint" data-i18n="notepad.hint">Appunti persistenti della sessione, gestiti dall'agente. Sola lettura.</p>
<div id="notepad-content" class="notepad-content"></div>
</div>
</div>
<!-- Generic dialog (rename input / delete confirm); replaces native prompt/confirm -->
<div id="dialog" hidden>
<div class="modal-card">
<h2 id="dialog-title"></h2>
<p id="dialog-msg" class="muted"></p>
<input id="dialog-input" type="text" autocomplete="off" hidden />
<div class="dialog-actions">
<button id="dialog-cancel" class="btn">Annulla</button>
<button id="dialog-ok" class="btn primary">OK</button>
</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" data-i18n="settings.scope.session">Sessione</button>
<button id="set-scope-general" class="btn ghost" data-i18n="settings.scope.general">Generali</button>
</div>
<p id="set-hint" class="muted"></p>
<label class="field" id="set-username-field"><span data-i18n="settings.username">Nome utente</span>
<input id="set-username" type="text" autocomplete="off" data-i18n-ph="settings.username.ph" />
</label>
<label class="field" id="set-name-field"><span data-i18n="settings.name">Nome</span>
<input id="set-name" type="text" autocomplete="off" />
</label>
<p id="set-name-hint" class="muted small"></p>
<label class="field"><span data-i18n="settings.notes">Note (scopo della chat)</span>
<textarea id="set-notes" rows="2"></textarea>
</label>
<label class="field"><span data-i18n="settings.sp">System Prompt</span>
<textarea id="set-sp" rows="4"></textarea>
</label>
<div class="field-grid">
<label class="field"><span data-i18n="settings.temp">Temperature</span><input id="set-temp" type="number" step="0.1" min="0" /></label>
<label class="field"><span data-i18n="settings.topp">Top-p</span><input id="set-topp" type="number" step="0.05" min="0" max="1" /></label>
<label class="field"><span data-i18n="settings.topk">Top-k</span><input id="set-topk" type="number" step="1" min="0" /></label>
<label class="field"><span data-i18n="settings.minp">Min-p</span><input id="set-minp" type="number" step="0.05" min="0" max="1" /></label>
<label class="field"><span data-i18n="settings.maxtokens">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" data-i18n="settings.cancel">Annulla</button>
<button id="set-save" class="btn primary" data-i18n="settings.save">Salva</button>
</div>
</div>
</div>
<script type="module" src="/assets/app.js"></script>
</body>
</html>