perspt-dashboard¶
Real-time web dashboard for Perspt agent monitoring, built with Axum + Askama + HTMX.
Core Types¶
pub struct AppState {
pub store: Arc<SessionStore>, // read-only DuckDB
pub password: Option<String>, // optional auth password
pub session_token: Arc<Mutex<Option<String>>>,
pub working_dir: PathBuf,
pub is_localhost: bool, // controls Secure cookie flag
}
pub enum DashboardError {
Store(anyhow::Error), // 503 — DB unavailable
Template(askama::Error), // 500 — render failure
Internal(String), // 500 — generic
}
DashboardError implements IntoResponse and renders a styled HTML
error page. Store errors return 503 Service Unavailable.
Router¶
build_router(state: AppState) -> Router constructs the full Axum router:
Method |
Route |
Handler |
|---|---|---|
GET |
|
|
POST |
|
|
GET |
|
|
GET |
|
|
GET |
|
|
GET |
|
|
GET |
|
|
GET |
|
|
GET |
|
|
All routes except /login are behind auth::auth_middleware.
If no password is configured, all requests pass through.
Auth Middleware¶
Cookie-based authentication with random session tokens:
On successful login, generates a 32-character alphanumeric token
Stores token in
AppState::session_tokenSets
perspt_sessioncookie:HttpOnly,SameSite=Lax,Path=/,Secure(when not localhost)Middleware checks cookie value against stored token
No password configured → open access mode
SSE Stream¶
The SSE endpoint pushes named events every 2 seconds:
node-stats— live summary of node states (total, done, running, failed)
Each event contains an HTML fragment suitable for HTMX sse-swap.
Templates¶
Askama templates live in crates/perspt-dashboard/templates/:
base.html— layout with navigation, HTMX, and DaisyUI themelogin.html— login formpages/overview.html— session list tablepages/dag.html— node cards and edge tablepages/energy.html— energy component tablepages/llm.html— stats bar and request tablepages/sandbox.html— provisional branch tablepages/decisions.html— collapsible sections for escalations, sheaf validations, rewrites, plan revisions, repair footprints, and verification results
View Models¶
Each page has a corresponding view model in src/views/:
OverviewViewModel— sessions, node counts, budgetsDagViewModel— nodes with state/energy, edgesEnergyViewModel— per-node energy componentsLlmViewModel— requests with token counts, latency, previewsSandboxViewModel— provisional branches with sandbox directoriesDecisionsViewModel— all six decision categories