summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-hub/src/meshbay_hub/static
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-08-22 18:26:22 +0200
committerChristophe Besson <cbesson@gmail.com>2026-08-22 18:26:22 +0200
commit8dc11dc05a35a5d64ba4d2c892ccc01c7bfae3da (patch)
treee172bb4d596bde53c48ce2ca3ef2d59c98968147 /packages/meshbay-hub/src/meshbay_hub/static
parentb4baa4770d517ea7d1d25bb0ac50fc7c989531d6 (diff)
downloadmeshbay-8dc11dc05a35a5d64ba4d2c892ccc01c7bfae3da.tar.gz
feat(node): systemd service panel on the Node page, and a clean CLI restart
Add a status panel at the top of the Node page — always visible, even before an MNP connection exists — showing the meshbay-node systemd unit's own state (via `systemctl --user show`, main process only) with Start/Stop/Restart controls. This is the piece the rest of the page cannot provide: it has to work while the daemon is stopped or crash- looping, which the MNP-based sections require the daemon to already answer. While touching node lifecycle: `reload` and `restart-daemon` in the CLI shelled out to pgrep + SIGTERM/SIGHUP and respawned the process by hand, logging to a hardcoded /tmp path. That pattern already SIGHUPed a developer's own running node by accident once (see the old test_cli_dispatch.py comment). Both now delegate to `systemctl --user reload|restart meshbay-node`, which the unit already supports correctly (ExecReload=, Restart=on-failure). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016SF6RKNBKg9qejmoMJ9ybA
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/static')
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/app.js90
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/de.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/en.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/es.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/it.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js14
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/platform.js22
-rw-r--r--packages/meshbay-hub/src/meshbay_hub/static/style.css21
13 files changed, 273 insertions, 0 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/app.js b/packages/meshbay-hub/src/meshbay_hub/static/app.js
index b863460..36df0cd 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/app.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/app.js
@@ -5633,6 +5633,90 @@ function BlocklistForm({ onAdd }) {
// ── Node management (D5) ────────────────────────────────────────────────────
+/**
+ * The systemd unit's own state, independent of the MNP connection below it.
+ *
+ * The rest of NodePage talks to the daemon over a signed MNP session, which
+ * requires the daemon to already be up and answering — no use at all for
+ * "the node is stopped, start it" or "it is crash-looping, tell me". This
+ * asks systemd directly (main process → `systemctl --user`), the same way
+ * `node:installed` and the wizard's `node:start` already do, so it works
+ * from every state the connection below can be in.
+ */
+function NodeServicePanel({ onChanged }) {
+ const [info, setInfo] = useState(null);
+ const [busy, setBusy] = useState('');
+ const [err, setErr] = useState('');
+
+ const refresh = useCallback(async () => {
+ try {
+ const r = await platform.node.service.status();
+ setInfo(r);
+ setErr('');
+ } catch (e) {
+ setErr(platform.bridgeMessage(e));
+ }
+ }, []);
+
+ useEffect(() => {
+ if (!platform.node.service.available) return;
+ refresh();
+ const timer = setInterval(refresh, 5000);
+ return () => clearInterval(timer);
+ }, [refresh]);
+
+ const act = useCallback(async (name, fn) => {
+ setBusy(name);
+ setErr('');
+ try {
+ await fn();
+ await refresh();
+ if (onChanged) onChanged();
+ } catch (e) {
+ setErr(platform.bridgeMessage(e));
+ } finally {
+ setBusy('');
+ }
+ }, [refresh, onChanged]);
+
+ if (!platform.node.service.available) return null;
+ if (!info || info.supported === false) {
+ return html`<div class="node-service">
+ <span class="spinner"></span>${' '}${t('node.service_checking')}
+ </div>`;
+ }
+
+ const KNOWN_STATES = ['active', 'inactive', 'failed', 'activating', 'deactivating'];
+ const stateKey = KNOWN_STATES.includes(info.activeState) ? info.activeState : 'unknown';
+ const running = info.activeState === 'active' || info.activeState === 'activating';
+ const dot = info.activeState === 'active' ? 'online'
+ : info.activeState === 'failed' ? 'offline' : 'unknown';
+ const label = info.installed ? t('node.service_state_' + stateKey)
+ : t('node.service_not_installed');
+
+ return html`
+ <div class="node-service">
+ <div class="node-service-status">
+ <span class="presence presence-${dot}" title="${label}" aria-label="${label}"></span>
+ <span>${label}</span>
+ </div>
+ ${err && html`<div class="error-msg">${err}</div>`}
+ <div class="node-service-actions">
+ <button class="btn btn-small btn-secondary" disabled=${!!busy || running}
+ onClick=${() => act('start', () => platform.node.start())}>
+ ${busy === 'start' ? t('node.service_starting') : t('node.service_start')}</button>
+ ${info.installed && html`
+ <button class="btn btn-small btn-secondary" disabled=${!!busy || !running}
+ onClick=${() => act('stop', () => platform.node.service.stop())}>
+ ${busy === 'stop' ? t('node.service_stopping') : t('node.service_stop')}</button>
+ <button class="btn btn-small btn-secondary" disabled=${!!busy}
+ onClick=${() => act('restart', () => platform.node.service.restart())}>
+ ${busy === 'restart' ? t('node.service_restarting') : t('node.service_restart')}</button>
+ `}
+ </div>
+ </div>`;
+}
+
function NodePage({ token, username, userId, groups }) {
const [status, setStatus] = useState('idle');
const [error, setError] = useState('');
@@ -5918,17 +6002,22 @@ function NodePage({ token, username, userId, groups }) {
if (status === 'idle' || status === 'connecting') {
return html`<div class="page-content">
+ <h2>${t('node.title')}</h2>
+ <${NodeServicePanel} onChanged=${connectAndFetch} />
<p class="page-message"><span class="spinner"></span>${' '}${t('status.connecting')}</p>
</div>`;
}
if (status === 'no_groups') {
return html`<div class="page-content">
+ <h2>${t('node.title')}</h2>
+ <${NodeServicePanel} onChanged=${connectAndFetch} />
<p class="page-message">${t('node.no_groups')}</p>
</div>`;
}
if (status === 'error') {
return html`<div class="page-content">
<h2>${t('node.title')}</h2>
+ <${NodeServicePanel} onChanged=${connectAndFetch} />
<p class="error-msg">${error}</p>
<button class="btn btn-primary" onClick=${connectAndFetch}>
${t('node.retry')}</button>
@@ -5943,6 +6032,7 @@ function NodePage({ token, username, userId, groups }) {
onClick=${reloadConfig}>
${t('node.reload')}</button>
</div>
+ <${NodeServicePanel} onChanged=${connectAndFetch} />
${actionMsg && html`<div class="node-message">${actionMsg}</div>`}
${(() => {
const hubIds = new Set((groups || []).map(g => g.id));
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
index 4df7781..1a151e2 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/de.js
@@ -490,6 +490,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Node-Dienst wird überprüft…',
+ 'node.service_not_installed': 'Nicht als Dienst installiert',
+ 'node.service_state_active': 'Wird ausgeführt',
+ 'node.service_state_inactive': 'Angehalten',
+ 'node.service_state_failed': 'Fehlgeschlagen',
+ 'node.service_state_activating': 'Wird gestartet…',
+ 'node.service_state_deactivating': 'Wird angehalten…',
+ 'node.service_state_unknown': 'Unbekannt',
+ 'node.service_start': 'Starten',
+ 'node.service_starting': 'Wird gestartet…',
+ 'node.service_stop': 'Anhalten',
+ 'node.service_stopping': 'Wird angehalten…',
+ 'node.service_restart': 'Neu starten',
+ 'node.service_restarting': 'Wird neu gestartet…',
'node.not_operator': 'Ihr Node konnte nicht erreicht werden. Stellen Sie sicher, dass er läuft.',
'node.offline': 'Node ist offline',
'node.retry': 'Erneut versuchen',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
index 3ddd7f1..dfd400b 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js
@@ -501,6 +501,20 @@ export default {
// Node management (D5)
'sidebar.node': 'Node',
'node.title': 'Node',
+ 'node.service_checking': 'Checking node service…',
+ 'node.service_not_installed': 'Not installed as a service',
+ 'node.service_state_active': 'Running',
+ 'node.service_state_inactive': 'Stopped',
+ 'node.service_state_failed': 'Failed',
+ 'node.service_state_activating': 'Starting…',
+ 'node.service_state_deactivating': 'Stopping…',
+ 'node.service_state_unknown': 'Unknown',
+ 'node.service_start': 'Start',
+ 'node.service_starting': 'Starting…',
+ 'node.service_stop': 'Stop',
+ 'node.service_stopping': 'Stopping…',
+ 'node.service_restart': 'Restart',
+ 'node.service_restarting': 'Restarting…',
'node.offline': 'Node is offline',
'node.no_groups': 'No groups configured on this node.',
'node.retry': 'Retry',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
index 093b1e7..498fc38 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/es.js
@@ -485,6 +485,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Comprobando el servicio del nodo…',
+ 'node.service_not_installed': 'No instalado como servicio',
+ 'node.service_state_active': 'En ejecución',
+ 'node.service_state_inactive': 'Detenido',
+ 'node.service_state_failed': 'Fallido',
+ 'node.service_state_activating': 'Iniciando…',
+ 'node.service_state_deactivating': 'Deteniendo…',
+ 'node.service_state_unknown': 'Desconocido',
+ 'node.service_start': 'Iniciar',
+ 'node.service_starting': 'Iniciando…',
+ 'node.service_stop': 'Detener',
+ 'node.service_stopping': 'Deteniendo…',
+ 'node.service_restart': 'Reiniciar',
+ 'node.service_restarting': 'Reiniciando…',
'node.not_operator': 'No se pudo contactar con su node. Asegúrese de que esté en ejecución.',
'node.offline': 'Node sin conexión',
'node.retry': 'Reintentar',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
index 43036dd..9e21135 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js
@@ -489,6 +489,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Vérification du service du nœud…',
+ 'node.service_not_installed': 'Non installé en tant que service',
+ 'node.service_state_active': 'En cours d’exécution',
+ 'node.service_state_inactive': 'Arrêté',
+ 'node.service_state_failed': 'Échec',
+ 'node.service_state_activating': 'Démarrage…',
+ 'node.service_state_deactivating': 'Arrêt en cours…',
+ 'node.service_state_unknown': 'Inconnu',
+ 'node.service_start': 'Démarrer',
+ 'node.service_starting': 'Démarrage…',
+ 'node.service_stop': 'Arrêter',
+ 'node.service_stopping': 'Arrêt…',
+ 'node.service_restart': 'Redémarrer',
+ 'node.service_restarting': 'Redémarrage…',
'node.not_operator': 'Impossible de joindre votre node. Vérifiez qu\'il est en cours d\'exécution.',
'node.offline': 'Node hors ligne',
'node.retry': 'Réessayer',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
index af22add..7e2b100 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/it.js
@@ -487,6 +487,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Verifica del servizio del nodo…',
+ 'node.service_not_installed': 'Non installato come servizio',
+ 'node.service_state_active': 'In esecuzione',
+ 'node.service_state_inactive': 'Arrestato',
+ 'node.service_state_failed': 'Non riuscito',
+ 'node.service_state_activating': 'Avvio…',
+ 'node.service_state_deactivating': 'Arresto…',
+ 'node.service_state_unknown': 'Sconosciuto',
+ 'node.service_start': 'Avvia',
+ 'node.service_starting': 'Avvio…',
+ 'node.service_stop': 'Arresta',
+ 'node.service_stopping': 'Arresto…',
+ 'node.service_restart': 'Riavvia',
+ 'node.service_restarting': 'Riavvio…',
'node.not_operator': 'Impossibile raggiungere il suo node. Si assicuri che sia in esecuzione.',
'node.offline': 'Node non in linea',
'node.retry': 'Riprova',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
index 2aa2ab5..ee55fc2 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/ja.js
@@ -475,6 +475,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'ノードサービスを確認中…',
+ 'node.service_not_installed': 'サービスとしてインストールされていません',
+ 'node.service_state_active': '実行中',
+ 'node.service_state_inactive': '停止',
+ 'node.service_state_failed': '失敗',
+ 'node.service_state_activating': '起動中…',
+ 'node.service_state_deactivating': '停止中…',
+ 'node.service_state_unknown': '不明',
+ 'node.service_start': '開始',
+ 'node.service_starting': '起動中…',
+ 'node.service_stop': '停止',
+ 'node.service_stopping': '停止中…',
+ 'node.service_restart': '再起動',
+ 'node.service_restarting': '再起動中…',
'node.not_operator': 'node に接続できませんでした。node が実行中であることをご確認ください。',
'node.offline': 'Node はオフラインです',
'node.retry': '再試行',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
index 5a9a303..986d653 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/nl.js
@@ -489,6 +489,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Node-service controleren…',
+ 'node.service_not_installed': 'Niet als service geïnstalleerd',
+ 'node.service_state_active': 'Actief',
+ 'node.service_state_inactive': 'Gestopt',
+ 'node.service_state_failed': 'Mislukt',
+ 'node.service_state_activating': 'Starten…',
+ 'node.service_state_deactivating': 'Stoppen…',
+ 'node.service_state_unknown': 'Onbekend',
+ 'node.service_start': 'Starten',
+ 'node.service_starting': 'Starten…',
+ 'node.service_stop': 'Stoppen',
+ 'node.service_stopping': 'Stoppen…',
+ 'node.service_restart': 'Herstarten',
+ 'node.service_restarting': 'Herstarten…',
'node.not_operator': 'Uw node is niet bereikbaar. Controleer of hij draait.',
'node.offline': 'Node is offline',
'node.retry': 'Opnieuw proberen',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
index c8c0315..ca3f60c 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pl.js
@@ -502,6 +502,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Sprawdzanie usługi węzła…',
+ 'node.service_not_installed': 'Nie zainstalowano jako usługi',
+ 'node.service_state_active': 'Uruchomiona',
+ 'node.service_state_inactive': 'Zatrzymana',
+ 'node.service_state_failed': 'Niepowodzenie',
+ 'node.service_state_activating': 'Uruchamianie…',
+ 'node.service_state_deactivating': 'Zatrzymywanie…',
+ 'node.service_state_unknown': 'Nieznany',
+ 'node.service_start': 'Uruchom',
+ 'node.service_starting': 'Uruchamianie…',
+ 'node.service_stop': 'Zatrzymaj',
+ 'node.service_stopping': 'Zatrzymywanie…',
+ 'node.service_restart': 'Uruchom ponownie',
+ 'node.service_restarting': 'Ponowne uruchamianie…',
'node.not_operator': 'Nie udało się połączyć z Pana/Pani node. Upewnij się, że działa.',
'node.offline': 'Node jest niedostępny',
'node.retry': 'Ponów',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
index 1f7bee2..8231daa 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/pt-BR.js
@@ -486,6 +486,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': 'Verificando o serviço do nó…',
+ 'node.service_not_installed': 'Não instalado como serviço',
+ 'node.service_state_active': 'Em execução',
+ 'node.service_state_inactive': 'Parado',
+ 'node.service_state_failed': 'Falhou',
+ 'node.service_state_activating': 'Iniciando…',
+ 'node.service_state_deactivating': 'Parando…',
+ 'node.service_state_unknown': 'Desconhecido',
+ 'node.service_start': 'Iniciar',
+ 'node.service_starting': 'Iniciando…',
+ 'node.service_stop': 'Parar',
+ 'node.service_stopping': 'Parando…',
+ 'node.service_restart': 'Reiniciar',
+ 'node.service_restarting': 'Reiniciando…',
'node.not_operator': 'Não foi possível alcançar seu node. Verifique se ele está em execução.',
'node.offline': 'Node está off-line',
'node.retry': 'Tentar novamente',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
index 162fadb..48122d3 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/zh-CN.js
@@ -461,6 +461,20 @@ export default {
// Node admin
'node.title': 'Node',
+ 'node.service_checking': '正在检查节点服务…',
+ 'node.service_not_installed': '未安装为服务',
+ 'node.service_state_active': '运行中',
+ 'node.service_state_inactive': '已停止',
+ 'node.service_state_failed': '失败',
+ 'node.service_state_activating': '正在启动…',
+ 'node.service_state_deactivating': '正在停止…',
+ 'node.service_state_unknown': '未知',
+ 'node.service_start': '启动',
+ 'node.service_starting': '正在启动…',
+ 'node.service_stop': '停止',
+ 'node.service_stopping': '正在停止…',
+ 'node.service_restart': '重启',
+ 'node.service_restarting': '正在重启…',
'node.not_operator': '无法连接到您的 node。请确保它正在运行。',
'node.offline': 'Node 已离线',
'node.retry': '重试',
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
index a8e17bf..30df80e 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js
+++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js
@@ -241,6 +241,28 @@ export const node = {
async setPairingCode(code) {
return bridge && bridge.node ? bridge.node.setPairingCode(code) : false;
},
+ /**
+ * The systemd unit's own state — start, stop and restart the node as a
+ * service, independent of whether the daemon itself is answering. Absent
+ * in a browser, same as the rest of `node`.
+ */
+ service: {
+ available: Boolean(bridge && bridge.node && bridge.node.service),
+ async status() {
+ if (!bridge || !bridge.node || !bridge.node.service) return { supported: false };
+ return bridge.node.service.status();
+ },
+ async stop() {
+ if (!bridge || !bridge.node || !bridge.node.service)
+ throw new Error('Node bridge not available');
+ return bridge.node.service.stop();
+ },
+ async restart() {
+ if (!bridge || !bridge.node || !bridge.node.service)
+ throw new Error('Node bridge not available');
+ return bridge.node.service.restart();
+ },
+ },
};
/**
diff --git a/packages/meshbay-hub/src/meshbay_hub/static/style.css b/packages/meshbay-hub/src/meshbay_hub/static/style.css
index ee51a8a..20b9f8c 100644
--- a/packages/meshbay-hub/src/meshbay_hub/static/style.css
+++ b/packages/meshbay-hub/src/meshbay_hub/static/style.css
@@ -2181,6 +2181,27 @@ a.transfer-name {
}
.node-header h2 { margin-bottom: 0; }
+.node-service {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ flex-wrap: wrap;
+ gap: 10px;
+ padding: 10px 12px;
+ margin-bottom: 16px;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ background: var(--bg-raised);
+}
+.node-service-status {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ font-size: 0.9em;
+}
+.node-service-actions { display: flex; gap: 8px; }
+.node-service .error-msg { flex-basis: 100%; margin: 0; }
+
.node-section { margin-top: 16px; }
.node-section-header {
display: flex;