feat: ops & UX batch — jobs survive restarts, logs/system in the console, media queue, gallery, chat, exact stream tokens
Fifteen changes aimed at the first day of real use: - Import and media jobs persist to <data>/jobs-*.json and reload on start (running ones settle as errors); the Register button no longer vanishes because the gateway restarted. - Docker ships the cortiq binary (built in the builder stage) — local .cmf chat models and image/video generation now work in containers, where auto-install never could (no cargo in the runtime image). libvulkan1 added for optional GPU offload. - Open admin console on 0.0.0.0 without a token now warns in the log and shows a dismissible banner — the VPS footgun is at least labeled. - "Restart gateway" button in Settings: stops managed model servers, spawns a fresh copy (bind retried while the port frees), Docker relies on the container restart policy instead. - Dashboard "System" panel: CPU sparkline + load, RAM (with the gateway's own RSS), free disk at the models dir — sampled by sysinfo every 2 s. - Featured model cards warn "not enough disk" / "may not fit in RAM" before the download, from the same live snapshot. - Log viewer in the sidebar: a 500-line in-memory ring fed by a second ANSI-free tracing layer; filter, level, pause, copy. - Update check: crates.io polled twice a day, the console shows an "update available" notice. - Media generations queue up (with position shown) instead of being rejected; progress gained an honest ETA from measured throughput. - Generation gallery under the image/video tabs: lazy PPM thumbnails, click to reopen with seed/steps, delete. - Playground chat is a real dialogue now: history is resent, bubbles, Clear, Cmd/Ctrl+Enter. - "Connect your app" snippets (curl / Python / JS) on the keys page, with the real key inlined right after creation. - One-click benchmark on the Models page via `cortiq bench --json`. - Config export now downloads the actual gateway.toml (comments intact); import accepts TOML (validated, hot-reloaded) and the legacy JSON. - Streaming token counts are exact when the model server provides usage (cortiq-server patch, shipped separately); the gateway fallback now counts content chunks (1/token on cortiq) instead of chars/4. Wizard's Finish lands on the Playground. 37 new strings in all 7 languages.
This commit is contained in:
@@ -73,6 +73,15 @@ pub struct AppState {
|
||||
pub imports: Arc<crate::import::JobStore>,
|
||||
/// Image/video generation jobs (cortiq imagine / animate).
|
||||
pub media: Arc<crate::media::MediaStore>,
|
||||
/// One-click local model benchmarks (cortiq bench --json).
|
||||
pub bench: Arc<crate::bench::BenchStore>,
|
||||
/// Host metrics sampler (CPU / RAM / disk) for the dashboard.
|
||||
pub sysmon: Arc<crate::sysmon::SysMon>,
|
||||
/// Newest cortiq-gateway version on crates.io, when newer than ours.
|
||||
pub gateway_update: Arc<std::sync::Mutex<Option<String>>>,
|
||||
/// Admin console reachable from other machines without a token — the
|
||||
/// footgun banner flag (set at startup, shown by the SPA).
|
||||
pub admin_open_public: std::sync::atomic::AtomicBool,
|
||||
/// Managed local CMF model server (install/update/spawn lifecycle + status).
|
||||
pub cmf: Arc<crate::cmf_runtime::CmfRuntime>,
|
||||
pub cache: Arc<SemanticCache>,
|
||||
@@ -116,6 +125,29 @@ impl SharedState {
|
||||
let promotion = crate::promotion::Promotion::new(promotion_cfg(&cfg.shadow));
|
||||
let imports = crate::import::JobStore::new();
|
||||
let media = crate::media::MediaStore::new();
|
||||
let bench = crate::bench::BenchStore::new();
|
||||
// jobs survive restarts: files under <data>/, reconciled on load
|
||||
let data = crate::config::data_dir();
|
||||
let _ = std::fs::create_dir_all(&data);
|
||||
imports.attach_persistence(data.join("jobs-import.json"));
|
||||
media.attach_persistence(data.join("jobs-media.json"));
|
||||
let sysmon = crate::sysmon::spawn(cfg.cmf.models_dir.clone());
|
||||
let gateway_update: Arc<std::sync::Mutex<Option<String>>> =
|
||||
Arc::new(std::sync::Mutex::new(None));
|
||||
{
|
||||
// check crates.io for a newer gateway once at start and twice a day
|
||||
let slot = gateway_update.clone();
|
||||
tokio::spawn(async move {
|
||||
loop {
|
||||
if let Some(latest) = crate::cmf_runtime::latest_gateway_version().await {
|
||||
let newer =
|
||||
crate::cmf_runtime::version_lt(env!("CARGO_PKG_VERSION"), &latest);
|
||||
*slot.lock().unwrap() = newer.then_some(latest);
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_secs(12 * 3600)).await;
|
||||
}
|
||||
});
|
||||
}
|
||||
let cmf = crate::cmf_runtime::CmfRuntime::new();
|
||||
let cache = SemanticCache::new(&cfg.cache);
|
||||
let router_status = RouterLastStatus::default();
|
||||
@@ -126,6 +158,10 @@ impl SharedState {
|
||||
promotion,
|
||||
imports,
|
||||
media,
|
||||
bench,
|
||||
sysmon,
|
||||
gateway_update,
|
||||
admin_open_public: std::sync::atomic::AtomicBool::new(false),
|
||||
cmf,
|
||||
cache,
|
||||
secrets,
|
||||
|
||||
Reference in New Issue
Block a user