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).
This commit is contained in:
adm committed 2026-11-24 20:38:24 +01:00
1 parent 9e6d44fa1a
commit 1e13caa4ed
15 files changed
+1922 -23

No files matched your search

+24
View File
@@ -96,6 +96,11 @@ pub struct Config {
#[serde(default)]
pub allowed_hosts: Option<Vec<String>>,
/// Path to the GUI session database (SQLite). Defaults to
/// `~/.config/strata-ctl/sessions.db`.
#[serde(default)]
pub db_path: Option<String>,
/// Keys we understand but don't act on yet are NOT listed above, so they
/// arrive here untouched — the "ignore what isn't ours" guarantee.
#[serde(flatten)]
@@ -192,6 +197,15 @@ impl Config {
Duration::from_secs(self.silence_timeout_secs.unwrap_or(600))
}
/// Effective GUI database path: config > `~/.config/strata-ctl/sessions.db`.
pub fn gui_db_path(&self) -> PathBuf {
if let Some(p) = &self.db_path {
return PathBuf::from(p);
}
let home = std::env::var("HOME").unwrap_or_default();
PathBuf::from(home).join(".config/strata-ctl/sessions.db")
}
/// The top-level keys present in the file that we are not acting on —
/// reported by `--check` so the shared-file contract stays visible.
pub fn ignored_keys(&self) -> Vec<&str> {
@@ -337,4 +351,14 @@ mod tests {
assert_eq!(cfg2.startup_timeout(), Duration::from_secs(30));
assert_eq!(cfg2.silence_timeout(), Duration::from_secs(120));
}
#[test]
fn gui_db_path_default_and_override() {
let cfg = Config::parse(REAL, "test").unwrap();
assert!(cfg
.gui_db_path()
.ends_with(".config/strata-ctl/sessions.db"));
let cfg2 = Config::parse(r#"{"exe":"/x/e","db_path":"/tmp/x.db"}"#, "test").unwrap();
assert_eq!(cfg2.gui_db_path(), PathBuf::from("/tmp/x.db"));
}
}