dashboard: build same-origin /agent/<name>/ links when gateway is up (closes #842)
When `services.hyperhive.gateway.enable` is on (default), the c0re NixOS module now sets `HIVE_GATEWAY_ENABLED=1` on the service env. `/api/state` exposes the flag as `gateway_enabled`; the SW4RM tab's container-row renderer flips three link sites (primary agent-name link, favicon fetch, `container`-kind nav-strip links) from the legacy `http://<host>:<port>/` direct TCP shape to same-origin `/agent/<name>/` URLs — the gateway proxies them to the per-agent harness via `agent-ports.json` or `agent-sockets.json` (#784 / #815). Gateway-off deploys keep the direct TCP fallback so local-dev / operator opt-out keeps working. `forge`-kind nav-strip links still resolve against `:3000` (separate sub-domain transition, tracked by `forge.behindGateway`); `external`-kind links are already absolute. Mirrors the `HIVE_MATRIX_GUI_ENABLED` env→snapshot-flag pattern. Docs updated: `docs/web-ui.md::Container row` + new `docs/gateway.md::Dashboard link shape` section.
This commit is contained in:
parent
b50f182396
commit
fbc41d42a6
5 changed files with 72 additions and 4 deletions
|
|
@ -236,6 +236,17 @@ struct StateSnapshot {
|
|||
/// chrome so the `M4TR1X →` tab doesn't flash when the GUI is off
|
||||
/// (#607, #634).
|
||||
matrix_gui_enabled: bool,
|
||||
/// Whether `hive-gateway` is in front of this dashboard. Sourced
|
||||
/// from `HIVE_GATEWAY_ENABLED` env var (set by the c0re NixOS
|
||||
/// module when `services.hyperhive.gateway.enable` is on). When
|
||||
/// true the dashboard frontend builds same-origin
|
||||
/// `/agent/<name>/` links to the per-agent web UI (the gateway
|
||||
/// proxies them via `agent-ports.json` + `agent-sockets.json`);
|
||||
/// when false it falls back to direct
|
||||
/// `http://<hostname>:<port>/` TCP links so gateway-off /
|
||||
/// local-dev deploys keep working. See
|
||||
/// `docs/gateway.md::Vhost map`.
|
||||
gateway_enabled: bool,
|
||||
}
|
||||
|
||||
/// `OpQuestion` + computed `question_refs` / `answer_refs`. Built
|
||||
|
|
@ -435,6 +446,13 @@ async fn api_state(headers: HeaderMap, State(state): State<AppState>) -> axum::J
|
|||
let s = v.to_string_lossy().to_ascii_lowercase();
|
||||
matches!(s.as_str(), "1" | "true" | "yes")
|
||||
}),
|
||||
gateway_enabled: std::env::var_os("HIVE_GATEWAY_ENABLED").is_some_and(|v| {
|
||||
// Same truthy-string parse as `matrix_gui_enabled`; the
|
||||
// env var is set by the c0re NixOS module to the literal
|
||||
// "1" when `services.hyperhive.gateway.enable` is on.
|
||||
let s = v.to_string_lossy().to_ascii_lowercase();
|
||||
matches!(s.as_str(), "1" | "true" | "yes")
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue