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.
This commit is contained in:
1 parent
7c945890f4
commit
0ce84581a4
20 files changed
+1412
-118
No files matched your search
+20
-1
@@ -121,6 +121,16 @@ body.resizing { cursor: col-resize; user-select: none; }
|
||||
}
|
||||
.empty { color: var(--muted); text-align: center; margin: auto; max-width: 28ch; }
|
||||
|
||||
/* Sliding-window banner: the browser shows the same recent window the model
|
||||
sees; older turns are preserved server-side. Sticky so it stays visible. */
|
||||
.window-note {
|
||||
position: sticky; top: 0; z-index: 1;
|
||||
max-width: 860px; width: 100%; margin: 0 auto;
|
||||
padding: 6px 12px; font-size: 0.75rem; color: var(--muted);
|
||||
background: var(--panel-2); border: 1px solid var(--border);
|
||||
border-radius: 8px; text-align: center;
|
||||
}
|
||||
|
||||
/* ---- Message bubbles ---- */
|
||||
.msg { max-width: 860px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; }
|
||||
.msg .role { font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
|
||||
@@ -260,7 +270,7 @@ details.thinking .reasoning {
|
||||
.msg-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
|
||||
|
||||
/* ---- Stats modal ---- */
|
||||
#stats-modal, #dialog, #settings-modal {
|
||||
#stats-modal, #dialog, #settings-modal, #notepad-modal {
|
||||
position: fixed; inset: 0; z-index: 40;
|
||||
background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center;
|
||||
padding: 20px;
|
||||
@@ -380,6 +390,15 @@ details.thinking .reasoning {
|
||||
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
|
||||
.sess-btn:disabled { opacity: 0.35; cursor: default; }
|
||||
|
||||
/* ---- Notepad (read-only pinned entries, agent-managed) ---- */
|
||||
.notepad-card { width: min(560px, 100%); max-width: 560px; max-height: 85dvh; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
|
||||
.notepad-card .stats-head h2 { flex: 1; }
|
||||
.notepad-hint { margin: 0; padding: 10px 18px 0; }
|
||||
.notepad-content { padding: 14px 18px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
|
||||
.notepad-entry { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); }
|
||||
.notepad-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; color: var(--accent); flex: 0 0 auto; max-width: 42%; overflow-wrap: anywhere; }
|
||||
.notepad-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
|
||||
|
||||
/* ---- Wide screens: persistent sidebar ---- */
|
||||
@media (min-width: 900px) {
|
||||
#drawer { position: static; transform: none; width: var(--sidebar-w); flex-shrink: 0; }
|
||||
|
||||
Reference in new issue
Block a user