Watch
0
0
Fork
You've already forked hyperhive
0

hive dashboard: an agent's name links to its terminal in the swarm UI

This commit is contained in:
iris 2026-11-16 22:55:58 +01:00 • committed by mara
commit 8ca6317356

View file

@ -0,0 +1,26 @@
// Where an agent's name in the container list leads: its terminal in the swarm
// UI. The agent has no page of its own to open, so a hive without a swarm
// domain (`swarm_public_url` unset in the dashboard state) has no link to give.
/**
* @param {{ swarm_public_url?: string | null } | null | undefined} state the dashboard state
* @param {string} name the agent's name
* @returns {string | null} the swarm UI URL of the agent's terminal, or null
*/
export function agentPageUrl(state, name) {
const base = state && state.swarm_public_url;
if (!base) return null;
return `${base.replace(/\/+$/, "")}/agents/${encodeURIComponent(name)}/terminal`;
}
/**
* Where "needs login" leads: the swarm UI's agent list, where an agent is logged
* in again. Null with no swarm domain.
*
* @param {{ swarm_public_url?: string | null } | null | undefined} state
* @returns {string | null}
*/
export function loginPageUrl(state) {
const base = state && state.swarm_public_url;
return base ? `${base.replace(/\/+$/, "")}/agents` : null;
}