Commit Graph
11 Commits
Author SHA1 Message Date
adm 7dd66ea138 Render assistant Markdown and LaTeX as sanitized HTML with native MathML
Server-side rendering keeps the browser free of any Markdown/MathJax toolchain (single-binary). New src/render.rs: pulldown-cmark (tables/strikethrough/math) + pulldown-latex -> MathML Core. Safety: raw HTML events are escaped to text (pulldown-cmark 0.13 has no ENABLE_HTML opt-out) and link/image URLs pass a scheme allowlist (javascript:/data:/vbscript: stripped, control chars removed). content_html is added to get_messages (assistant only) and to the agent Final SSE event; the GUI injects it via innerHTML for assistant bubbles (history + live) while user text stays textContent. CSS styles Markdown and native MathML; block math must not override display (UA block math layout) or it collapses to vertical stacks. 10 render unit tests incl. XSS; 136 tests green, clippy/fmt clean; verified live + visually.
2026-11-25 20:58:20 +01:00
adm 0754262b37 GUI refinements: drop redundant general-settings drawer entry and topbar delete; per-turn decode speed + first-token lag in the answer badge; compact date+time on message bubbles 2026-11-25 19:59:42 +01:00
adm f4f209d650 Remove the tool toggle: tools are always on, the agent turn is the only GUI path 2026-11-25 18:47:56 +01:00
adm 22967ef60e Make general settings discoverable (drawer entry + segmented scope switch); suspend vector memory as important TODO 2026-11-25 18:40:36 +01:00
adm 765c197b95 Add a live statistics dashboard over persistent history
Replace the four-row stats modal with a real dashboard — our own angle on
the reference's ephemeral request monitor: because our context lives in
SQLite we can aggregate over ALL history, not just the last N requests.

Backend:
- Usage carries the engine's prompt_ms/decode_ms (from DONE); a token-
  weighted in-memory PerfMeter in ChatService records every served
  request (complete + stream) and exposes decode/prefill tok/s.
- store::Stats grows total_tokens, tool_calls (json_array_length over
  assistant tool_calls_json), a per-session breakdown (busiest first)
  and a per-UTC-day token series; all over existing columns, no schema
  change, still behind the Store trait.
- GET /api/stats returns the store aggregates flattened plus a live
  engine status (model, max_context, busy) and the perf gauge.

Frontend (mobile-first, vanilla, i18n catalog):
- Overview cards: engine state dot + model + context, decode speed
  (run average) + prefill, total/prompt/completion tokens, sessions +
  messages, tool calls, requests served.
- Daily stacked prompt/completion bar chart (continuous zero-filled
  UTC window, last 30 days) and per-session token-share bars.
- Polls every 2s while open, re-renders only on change; closes via
  button, backdrop or Escape.

Tests: new store breakdown test + extended stats integration assertions
(124 passed, 2 ignored). Verified live on the real engine: decode/prefill
gauge populated from DONE timings; dashboard renders on desktop.
2026-11-25 17:52:38 +01:00
adm 65f8111ba2 feat: file/image upload + separated framework root (sessions/data/uploads)
- POST /api/uploads: base64 -> shared ~/.strata-ctl/uploads store (uuid+ext),
  content-sniffed kind (image/text/binary), text token-counted via the model
  tokenizer; metadata persisted in a new uploads table.
- Chat attachments routed by kind: images -> Vision bridge (multipart image_url),
  small text (<=2000 tokens) inlined, large text/binary -> path + shell_exec
  reminder; binaries never inlined. Attachment context persisted with the turn.
- GUI: attach button + file picker, removable chips, attachments sent with the
  turn and shown on the user bubble; cleared on session switch.
- Framework root ~/.strata-ctl separated by type: sessions/<name>/, data/ (SQLite,
  moved from ~/.config/strata-ctl), uploads/. Legacy DB copied once on first run.
- count_tokens seam on Formatter (real tokenizer override) + ChatService.
- i18n: upload errors + attachment markers (backend) and attach.* (GUI), it+en.
- 121 tests + 2 ignored; clippy/fmt clean; validated live (upload routing, real
  tokenizer count, image->Vision answered "Rosso", new layout).
2026-11-25 16:25:55 +01:00
adm 73b665d1a7 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).
2026-11-25 15:51:43 +01:00
adm 0123f41d99 Refine chat management: auto-titles, per-chat rename/delete, custom modal
- Auto-title a session from its first user message (chat_title) so chats are distinguishable in the sidebar instead of all 'Nuova chat'.

- Per-chat rename (✏️) and delete (🗑️) buttons with aria-labels; stopPropagation so they don't switch the conversation. deleteSessionById selects a fallback or creates a fresh session.

- Replace native prompt()/confirm() with a styled custom modal (showDialog): mobile-friendly and inspectable by automation (native dialogs hung the browser subagent).

Verified via direct HTTP (auto-title/rename/delete) + 108 tests; browser subagent avoided after repeated hangs.
2026-11-25 02:41:51 +01:00
adm 8979201139 Add GUI agent mode: the model acts via a universal shell_exec tool
- agent:🐚 native shell_exec (bash -lc, cwd, timeout, 64 KiB output cap)
  behind a ShellRunner seam — base/host mode now; an isolated Docker-MCP runner
  plugs in later without touching the loop. OpenAI function declaration included.
- agent::run_loop: bounded model<->tool orchestration, generic over the model
  step so it is unit-testable without the engine. Persists the full trajectory
  (assistant tool-call turns + role:tool results + final answer) and emits
  tool_call / tool_result / final / error progress events.
- api::sessions: POST .../chat with agent:true drives the loop and streams the
  events as SSE; the GUI shows commands + output inline (observability, no gate).
- store: messages gains tool_call_id; an idempotent migration adds the column to
  pre-existing databases (CREATE TABLE IF NOT EXISTS does not alter them).
- web: robot agent toggle, tool-call/output blocks, history rendering of tool
  turns; inline favicon to silence the favicon 404.

Validated LIVE on engine 0.1.67: the model called shell_exec('uname -a'), the
host executed it, and the model reported the output; trajectory persisted; GUI
verified by browser (toggle, tool block, output, final answer). 106 tests +
2 ignored green, clippy/fmt clean. Isolated mode (user-provided Docker container)
is the next step.
2026-11-25 02:06:45 +01:00
adm e29878bb3d Add drag-resizable sidebar/chat separator to the web GUI
Desktop-only (>=900px) pointer-drag splitter between the session list and the chat; width clamped (200px..min(480, 50% viewport)) and persisted in localStorage; keyboard arrows + ARIA separator role; hover/focus highlight. README updated. Web assets only; suite unchanged (94 green + 2 ignored), clippy/fmt clean.
2026-11-24 20:57:59 +01:00
adm 1e13caa4ed Add mobile-first web GUI with a server-side session store (SQLite)
- store: a swappable Store trait + bundled-SQLite implementation (WAL,
  sessions/messages with per-turn token usage, cascade delete). The standard
  /v1 API stays stateless; conversation context lives server-side so
  multi-session, statistics and advanced settings can grow on top. DB path
  configurable (db_path, default ~/.config/strata-ctl/sessions.db).
- api::sessions: session-aware GUI API — session CRUD, history, POST .../chat
  (loads stored context, reuses the completion service, persists new turns with
  usage; streaming accumulates the assistant turn and persists before [DONE]),
  and /api/stats.
- api::web + web/: a mobile-first chat GUI (vanilla ES modules, no build step),
  embedded via rust-embed and served at GET / (same-origin, offline, single
  binary). Off-canvas session drawer on phones, persistent sidebar on wide
  screens; live streaming with a collapsible thinking panel; model output is
  inserted via textContent only.
- router_with_store mounts the GUI + session API only when a store is configured;
  router()/router_with_auth() are unchanged (API-only).
- Fix: a global [hidden]{display:none!important} reset so an author display rule
  (the stats modal's display:flex) cannot defeat the hidden attribute.

7 new tests (2 store unit + 4 session HTTP end-to-end + 1 config); 94 green +
2 ignored; clippy/fmt clean. Validated live on engine 0.1.67 (context retention,
streaming, stats) and via a browser check (modal, send/render, stats open/close).
Future: the Store backend is intended to move to ArangoDB (multi-model).
2026-11-24 20:38:24 +01:00