phase 8 step 3: needs-login partial-run mode + dashboard badge
This commit is contained in:
parent
c59fa8541c
commit
78fae44ee5
7 changed files with 191 additions and 11 deletions
|
|
@ -4,17 +4,26 @@
|
|||
//! `hive-c0re`'s generated per-agent flake (deterministic from agent name).
|
||||
|
||||
use std::net::SocketAddr;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use anyhow::{Context, Result};
|
||||
use axum::{Router, extract::State, response::Html, routing::get};
|
||||
|
||||
use crate::login::LoginState;
|
||||
|
||||
/// Live login state for the web UI. The harness updates this in place as it
|
||||
/// transitions between `NeedsLogin` and `Online`; the UI reads on each
|
||||
/// render.
|
||||
pub type LoginStateCell = Arc<Mutex<LoginState>>;
|
||||
|
||||
#[derive(Clone)]
|
||||
struct AppState {
|
||||
label: String,
|
||||
login: LoginStateCell,
|
||||
}
|
||||
|
||||
pub async fn serve(label: String, port: u16) -> Result<()> {
|
||||
let state = AppState { label };
|
||||
pub async fn serve(label: String, port: u16, login: LoginStateCell) -> Result<()> {
|
||||
let state = AppState { label, login };
|
||||
let app = Router::new().route("/", get(index)).with_state(state);
|
||||
let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
let listener = tokio::net::TcpListener::bind(addr)
|
||||
|
|
@ -26,8 +35,21 @@ pub async fn serve(label: String, port: u16) -> Result<()> {
|
|||
}
|
||||
|
||||
async fn index(State(state): State<AppState>) -> Html<String> {
|
||||
let login = *state.login.lock().unwrap();
|
||||
let (status_label, status_class, body_extra) = match login {
|
||||
LoginState::Online => (
|
||||
"▓█▓▒░ harness alive — turn loop running ▓█▓▒░",
|
||||
"status-online",
|
||||
"<p class=\"meta\">phase 6a placeholder — turn-loop status / inbox / xterm.js coming in 6b+</p>",
|
||||
),
|
||||
LoginState::NeedsLogin => (
|
||||
"▓█▓▒░ NEEDS L0G1N ▓█▓▒░",
|
||||
"status-needs-login",
|
||||
"<p>No Claude session in <code>~/.claude/</code>. The harness is up and reachable on this UI, but the turn loop is paused until you log in.</p>\n<p class=\"meta\">Phase 8 step 4 will wire a login form here that drives <code>claude /login</code> over plain stdio pipes. Until then: <code>nixos-container root-login</code> the container and run <code>claude</code> interactively, then restart the harness.</p>",
|
||||
),
|
||||
};
|
||||
Html(format!(
|
||||
"<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>{label} // hyperhive</title>\n{STYLE}\n</head>\n<body>\n<pre class=\"banner\">░▒▓█▓▒░ {label} ░▒▓█▓▒░ hyperhive ag3nt ░▒▓█▓▒░</pre>\n<h2>◆ {label} ◆</h2>\n<div class=\"divider\">══════════════════════════════════════════════════════════════</div>\n<p>▓█▓▒░ harness alive ▓█▓▒░</p>\n<p class=\"meta\">phase 6a placeholder — turn-loop status / inbox / xterm.js coming in 6b+</p>\n</body>\n</html>\n",
|
||||
"<!doctype html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<meta http-equiv=\"refresh\" content=\"5\">\n<title>{label} // hyperhive</title>\n{STYLE}\n</head>\n<body>\n<pre class=\"banner\">░▒▓█▓▒░ {label} ░▒▓█▓▒░ hyperhive ag3nt ░▒▓█▓▒░</pre>\n<h2>◆ {label} ◆</h2>\n<div class=\"divider\">══════════════════════════════════════════════════════════════</div>\n<p class=\"{status_class}\">{status_label}</p>\n{body_extra}\n</body>\n</html>\n",
|
||||
label = state.label,
|
||||
))
|
||||
}
|
||||
|
|
@ -71,5 +93,8 @@ const STYLE: &str = r#"
|
|||
margin-bottom: 0.5em;
|
||||
}
|
||||
.meta { color: var(--muted); font-size: 0.85em; }
|
||||
.status-online { color: #66ff99; text-shadow: 0 0 6px rgba(102, 255, 153, 0.5); }
|
||||
.status-needs-login { color: #ffb84d; text-shadow: 0 0 6px rgba(255, 184, 77, 0.6); }
|
||||
code { background: rgba(204, 102, 255, 0.1); padding: 0.05em 0.3em; border-radius: 2px; }
|
||||
</style>
|
||||
"#;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue