diff options
5 files changed, 46 insertions, 2 deletions
diff --git a/packages/meshbay-client/src/main.js b/packages/meshbay-client/src/main.js index 6c92531..b0505a9 100644 --- a/packages/meshbay-client/src/main.js +++ b/packages/meshbay-client/src/main.js @@ -898,10 +898,17 @@ function registerBridge() { ipcMain.handle('node:service-status', async () => { if (process.platform === 'win32') { // No Task Scheduler to ask "is it running" — probe the daemon itself. - const p = await probeNode(); + // `installed` used to be winAutostartInstalled(), which is wrong: it + // answers "does the Startup launcher exist", not "is there a daemon to + // manage". The Node page's Stop/Restart buttons are gated on + // `installed`, so with no autostart configured they silently vanished + // — the daemon was perfectly manageable, just not launchable at + // sign-in. `autostart` carries that state as its own field instead. + const [p, bin] = await Promise.all([probeNode(), findNodeBinary()]); return { supported: true, - installed: winAutostartInstalled(), + installed: Boolean(bin), + autostart: winAutostartInstalled(), activeState: p ? 'active' : 'inactive', subState: p ? 'running' : '', }; 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 898f7f4..09feaf5 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/en.js @@ -734,6 +734,8 @@ export default { 'node.service_stopping': 'Stopping…', 'node.service_restart': 'Restart', 'node.service_restarting': 'Restarting…', + 'node.autostart_label': 'Start automatically at sign-in', + 'node.autostart_updating': 'Updating…', '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/fr.js b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js index 1999e7e..88e27f8 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/locales/fr.js @@ -677,6 +677,8 @@ export default { 'node.service_stopping': 'Arrêt…', 'node.service_restart': 'Redémarrer', 'node.service_restarting': 'Redémarrage…', + 'node.autostart_label': 'Démarrer automatiquement à l\'ouverture de session', + 'node.autostart_updating': 'Mise à jour…', '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/node-page.js b/packages/meshbay-hub/src/meshbay_hub/static/node-page.js index a2d3e49..c619f6e 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/node-page.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/node-page.js @@ -47,6 +47,12 @@ function NodeServicePanel({ onChanged }) { } }, [refresh, onChanged]); + const toggleAutostart = useCallback(() => { + act('autostart', () => (info && info.autostart + ? platform.node.autostart.remove() + : platform.node.autostart.install())); + }, [act, info]); + if (!platform.node.service.available) return null; if (!info || info.supported === false) { return html`<div class="node-service"> @@ -82,6 +88,14 @@ function NodeServicePanel({ onChanged }) { ${busy === 'restart' ? t('node.service_restarting') : t('node.service_restart')}</button> `} </div> + ${platform.node.autostart.available && typeof info.autostart === 'boolean' && html` + <label class="toggle-switch ${busy ? 'toggle-switch-disabled' : ''}"> + <input type="checkbox" checked=${info.autostart} disabled=${!!busy} + onChange=${toggleAutostart} /> + <span class="toggle-switch-track"><span class="toggle-switch-thumb"></span></span> + ${' '}${busy === 'autostart' ? t('node.autostart_updating') : t('node.autostart_label')} + </label> + `} </div>`; } diff --git a/packages/meshbay-hub/src/meshbay_hub/static/platform.js b/packages/meshbay-hub/src/meshbay_hub/static/platform.js index 78e27eb..b1025c5 100644 --- a/packages/meshbay-hub/src/meshbay_hub/static/platform.js +++ b/packages/meshbay-hub/src/meshbay_hub/static/platform.js @@ -263,6 +263,25 @@ export const node = { return bridge.node.service.restart(); }, }, + /** + * Windows only: run the daemon at sign-in. `service.status()` already + * reports the current state as `autostart`; these two just flip it. + * `available` gates nothing platform-specific by itself — main.js answers + * `{ supported: false }` off Windows, same shape as `service`. + */ + autostart: { + available: Boolean(bridge && bridge.node && bridge.node.autostart), + async install() { + if (!bridge || !bridge.node || !bridge.node.autostart) + throw new Error('Node bridge not available'); + return bridge.node.autostart('install'); + }, + async remove() { + if (!bridge || !bridge.node || !bridge.node.autostart) + throw new Error('Node bridge not available'); + return bridge.node.autostart('remove'); + }, + }, }; /** |