READMESource: main@7d2449a5
App Restart (@local/dsh-app-restart)
Adds a restart button to the Windows title bar of the DSH desktop app, right where the native window controls start — one click opens a confirmation popover, and confirming restarts the whole application (Electron main + Host).
Why a bundle plugin
The desktop shell has no renderer-visible restart action: app.relaunch() lives only
in the Electron main process (development menu, fatal recovery dialog), the preload
dshDesktop API has no restart method, and the desktop IPC channel list has no
restart message. This plugin therefore has two halves:
- host half (
index.js): registers same-origin routes under/dsh-app-restart/*on the Host web server and, onPOST /dsh-app-restart/restart, starts a hidden helper (launch-helper.vbs->restart.ps1) that terminates the Electron main process (the Host's parent) and starts the app executable again. The Host itself shuts down gracefully when its IPC channel disconnects, so no Host-specific handling is needed. The launcher is started throughwscript.exe: the host is a console-lessELECTRON_RUN_AS_NODEprocess, and spawningpowershell.exedirectly withDETACHED_PROCESScreates a process that exits before running a single statement.wscript.exeis a GUI-subsystem process, so it starts detached reliably and its helper survives the host exit; the VBScript starts PowerShell with a hidden window and does not wait for it. - client half (
client.js): mounts in theshell.overlayslot, renders a 28×28 icon button only when the desktop preload marks the page withhtml[data-windows-titlebar](and not in fullscreen), positions it withposition: fixedto the left of the native caption buttons usingnavigator.windowControlsOverlay.getTitlebarAreaRect(), and hands the restart request to the host half with a same-origin fetch.
Layout
index.js host half: routes + helper spawn
client.js client half: title-bar button + confirmation popover
launch-helper.vbs hidden wscript launcher for the restart helper
restart.ps1 restart helper: kill Electron main, wait, relaunch
cordis.patch.yml bundle mount
locale/en.json display metadata (title / description)
locale/zh.json display metadata (Chinese)
icon.svg bundle icon (64×64)
Notes
- Windows only. On other platforms the restart route answers
501. - The button is invisible in a plain browser tab (the desktop preload attributes are absent), so the web GUI is unchanged.
- The helper waits (up to 45 s) for both the old Electron main and the old Host to exit before starting the new instance, so the single-instance lock is free. If the Host somehow lingers it is terminated after the timeout.
- The Host runs as a plain Node process (
ELECTRON_RUN_AS_NODE=1), so the helper strips inheritedELECTRON_*,NODE_*andDSH_*variables before launching the app again; otherwise the relaunched Electron would immediately fall back to Node mode. This was verified with a marker executable that reports its environment. - Restarting interrupts running agent tasks; the confirmation popover says so.
- Debug logs:
%TEMP%\dsh-app-restart\plugin.logandhelper.log; aGET /dsh-app-restart/logroute returns their tails, and the helper log records the relaunched process id. GET /dsh-app-restart/healthreportselectronPid(the Host's parent),hostPid,helperExistsandlauncherExistsfor quick diagnostics.
No comments yet. Be the first to write one.