dashboard: hide forge links instead of guessing <hostname>:3000
Adds services.hyperhive.forge.publicUrl (defaults to the gateway vhost URL when behindGateway=true, null otherwise). HIVE_FORGE_PUBLIC_URL is now sourced from it instead of hardcoding https://${forge.domain} whenever behindGateway is on. The 4 frontend call sites that built a forge link from state.forge_public_url now hide the link when that's absent, rather than guessing http://<browser-hostname>:3000 — a guess that's only correct by accident once the operator isn't on plain localhost. Fixes the dashboard H0M3 tile, per-agent-row forge links + agent menu, the approval-queue PR link, and the per-agent page's own meta-nav forge link (found during this pass, same defect, not in the original 3-site inventory). Docs + doc-comments updated to match.
This commit is contained in:
parent
68560215bd
commit
3512e4b019
10 changed files with 96 additions and 42 deletions
|
|
@ -1230,10 +1230,13 @@ window.marked = marked;
|
|||
const metaLinks = $('meta-links');
|
||||
if (metaLinks && Array.isArray(s.links)) {
|
||||
metaLinks.replaceChildren();
|
||||
// Prefer forge_public_url from state (set when the gateway serves
|
||||
// forge at its sub-domain); fall back to :3000 for local-dev.
|
||||
const forgeBase = s.forge_public_url || `http://${window.location.hostname}:3000`;
|
||||
// s.forge_public_url (set from services.hyperhive.forge.publicUrl)
|
||||
// or falsy — never guessed from "<hostname>:3000". A forge-kind
|
||||
// link is skipped entirely below when there's no public URL to
|
||||
// point it at.
|
||||
const forgeBase = s.forge_public_url || null;
|
||||
s.links.forEach((lnk, i) => {
|
||||
if (lnk.kind === 'forge' && !forgeBase) return;
|
||||
const href = lnk.kind === 'forge' ? forgeBase + (lnk.url || '')
|
||||
: lnk.kind === 'external' ? (lnk.url || '')
|
||||
: /* container */ (lnk.url || '');
|
||||
|
|
|
|||
|
|
@ -242,12 +242,10 @@ export function renderApprovals() {
|
|||
}
|
||||
// forge link base — only when the hive-forge container is up.
|
||||
const fs = window.__hyperhive_state;
|
||||
const hostname = (fs && fs.hostname) || window.location.hostname;
|
||||
// Prefer state.forge_public_url (set when forge.behindGateway=true,
|
||||
// e.g. "https://forge.pr1ma.darkest.space") over the direct :3000 port.
|
||||
const forgeBase = (fs && fs.forge_present)
|
||||
? (fs.forge_public_url || `http://${hostname}:3000`)
|
||||
: null;
|
||||
// state.forge_public_url (set from services.hyperhive.forge.publicUrl)
|
||||
// or null — never guessed from "<hostname>:3000". The PR-link builder
|
||||
// below already gates on forgeBase being truthy.
|
||||
const forgeBase = (fs && fs.forge_present && fs.forge_public_url) || null;
|
||||
|
||||
const ul = el('ul', { class: 'approvals' });
|
||||
for (const a of pending) {
|
||||
|
|
|
|||
|
|
@ -30,14 +30,16 @@ async function init() {
|
|||
if (tile) tile.hidden = false;
|
||||
}
|
||||
|
||||
// Forge tile: reveal + point at the live forge only when the
|
||||
// hive-forge container is up. Prefer the gateway-served public URL
|
||||
// (set when forge.behindGateway=true), fall back to the direct :3000
|
||||
// port — same precedence the dashboard uses for forge links.
|
||||
if (state.forge_present) {
|
||||
// Forge tile: reveal only when the hive-forge container is up AND
|
||||
// the operator has stated a public URL for it
|
||||
// (services.hyperhive.forge.publicUrl, surfaced as
|
||||
// state.forge_public_url) — hidden rather than guessed from
|
||||
// `location.hostname` + the direct :3000 port, which is only
|
||||
// correct by accident on deployments that aren't plain localhost.
|
||||
if (state.forge_present && state.forge_public_url) {
|
||||
const tile = $('home-tile-forge');
|
||||
if (tile) {
|
||||
tile.href = state.forge_public_url || `http://${location.hostname}:3000`;
|
||||
tile.href = state.forge_public_url;
|
||||
tile.hidden = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -414,6 +414,9 @@ function buildContainerLi(c, node, opts) {
|
|||
// -- nav strip -----------------------------------------------
|
||||
if (Array.isArray(ds.links)) {
|
||||
for (const lnk of ds.links) {
|
||||
// No public forge URL to link to — hide rather than build
|
||||
// a broken/guessed href (see forgeBase above).
|
||||
if (lnk.kind === 'forge' && !forgeBase) continue;
|
||||
const href = lnk.kind === 'forge' ? forgeBase + (lnk.url || '')
|
||||
: lnk.kind === 'external' ? (lnk.url || '')
|
||||
: /* container */ containerBase + '/' + (lnk.url || '');
|
||||
|
|
@ -637,10 +640,12 @@ export function renderContainers(s) {
|
|||
// loopback port while the socket marker is absent). See
|
||||
// `docs/web-ui.md::Container row` + `docs/gateway.md::Vhost map`.
|
||||
const gatewayLinks = !!(s && s.gateway_enabled);
|
||||
// Forge public URL: prefer state.forge_public_url (set by the NixOS
|
||||
// module when forge.behindGateway=true), fall back to
|
||||
// "<hostname>:3000" for gateway-off / local-dev deploys.
|
||||
const forgeBase = (s && s.forge_public_url) || `http://${hostname}:3000`;
|
||||
// Forge public URL: state.forge_public_url (set by the NixOS module
|
||||
// from services.hyperhive.forge.publicUrl) or null — never guessed
|
||||
// from "<hostname>:3000". `null` propagates down to
|
||||
// buildContainerLi/buildAgentMenu, which already hide forge links
|
||||
// rather than emit a possibly-wrong one.
|
||||
const forgeBase = (s && s.forge_public_url) || null;
|
||||
const ul = existingUl ?? el('ul', { class: 'containers' });
|
||||
const tree = buildAgentTree(containers);
|
||||
// In-flight rebuild / meta-update / destroy ops per agent name —
|
||||
|
|
|
|||
Loading…
Reference in a new issue