dsh-restart-center: Restart Center

Preface

When restarting a desktop app window, it’s easy to accidentally trigger a restart while a session is actively running or a plugin is being installed, which can interrupt conversations or fail installations. This plugin places a restart button to the right of “App / Edit” in the title bar. A single click initiates a two-stage confirmation: first it checks the current state, then it asks for final confirmation, preventing accidental termination of in-progress tasks when the app is in an unsafe state.

What It Is

dsh-restart-center is a client-side plugin that provides restart control for the DeepSeek Desktop window chrome. It places a restart button at the same level as “App / Edit” in the title bar, supporting two-stage confirmation, running-session warnings, and blocking restarts while a plugin installation is in progress or queued. Maintained by wsl1602291891-stack, categorized under Client.

Core Features

Positioning & Rendering

The “App / Edit” menu in the title bar lives inside an Electron preload shadow DOM (installWindowsMenu in lib/preload-app.cjs), styled with position: fixed; z-index: 1100, and has no plugin slot. This plugin registers into shell.overlay and positions the button using the live getBoundingClientRect().right + 2px of [data-windows-menu]. It re-measures on window resize or sidebar collapse. On browsers and non-Windows platforms where this menu bar doesn’t exist, the button simply doesn’t render.

Two-Stage Confirmation

Stage 1: State the Current Situation

  • No session running → green: “No sessions are currently running. You can restart safely.”
  • Session(s) running → yellow: “N session(s) are running (acc52b2f, 226c114f). Restarting will interrupt replies currently being generated.”
  • Plugin installing → red: “A plugin is being installed (source 2/2 · registry.npmmirror.com). Restarting now will interrupt the installation…”
  • Installation queued → red: “A plugin installation task is queued or preparing. Restarting now will cancel it.”
  • State unreadable → yellow: “Could not read the current runtime state. Please manually verify no tasks are running before restarting.”

Focus defaults to the “Cancel” button. Esc closes the dialog, and clicking the overlay backdrop also dismisses it.

Stage 2: Final Confirmation

“Clicking ‘Restart Now’ will close the window, which will automatically reopen in about 10 seconds. Port, model, and plugin settings will be preserved.” If a session is running, an additional warning appears: “Interruption of in-progress generation will not resume automatically.”

Only after confirmation is POST /dsh-restart-center/api/restart {"force":true} called.

Status Pill Indicator

A small pill sits to the right of the button, refreshing every 5 seconds. A breathing dot appears during plugin installation. Statuses and labels:

  • Installation in progress → Plugin Installing
  • Installation queued → Install Queued
  • Session(s) running → N Session(s) Running

This lets you know “now is not the time to restart” even without clicking the button.

Installation Awareness: Two Independent Signals

Running dsh plugin install in a terminal doesn’t emit a request ID, so relying on events alone is insufficient. The plugin uses two independent signals to determine state:

  1. Plugin manager events (install from the plugin page / marketplace)
    - plugin-manager/install-state: stage and source attempt for each request ID
    - plugin-manager/install-log: pnpm output stream; the last frame of a run carries exitCode
    - plugin-manager/changed: end of an operation, clears the entire table

  2. Profile disk state (also covers terminal installs)
    - package.json.lock exists = a package operation holds the profile write lock → treated as queued
    - .plugin-manager/run.json exists = manager is running pnpm (written before start, deleted in finally) → treated as installing

A run.json older than 30 minutes is considered an orphan left behind by a dead writer and is automatically excluded from the count.

API

Method Path Description
GET /dsh-restart-center/api/status Returns {ok, running, runningSessions, install{active,queued,lockHeld,source,count,cancelling,registry,attempt}}
POST /dsh-restart-center/api/restart Requires body {"force":true} to allow restart while busy

Only loopback addresses (127.0.0.1 / ::1) are accessible; all other sources receive 403. status accepts GET only, restart accepts POST only (405 otherwise), and unknown routes return 404.

When busy, a request without force always returns 409 — hitting the API directly will never kill an in-progress conversation or interrupt an installation.

Why Restart Uses a Scheduled Task

In practice on Windows, child processes spawned by the Host (detached, created via WMI Win32_Process.Create, or spawned directly by the Host) get killed along with the app’s process tree, resulting in the app closing while the new instance never starts. A Windows scheduled task is the only mechanism that survives to relaunch the app.

Implementation: The Host writes a launch script to %TEMP%\dsh-restart-center-launch.ps1, creates a one-shot task via schtasks /Create, and triggers it with schtasks /Run. The script first calls Unregister-ScheduledTask to remove itself, then kills processes by install root directory (not by process name), and finally runs Start-Process $exe --updated. The --updated flag is an existing branch in the Electron main process (raiseAfterUpdate) that brings the new window to the front and steals focus. The task name is fixed as DshRestartCenter; repeated clicks overwrite it, and the script deletes itself on execution, leaving no residue.

Installation & Activation

Run the following in a terminal:

dsh plugin --profile desktop add wsl1602291891-stack/dsh-restart-center

After installation, the Host module does not hot-swap; the new Host code takes effect after one app restart. Client-side code takes effect immediately upon page load.

Typical Usage

  1. See the “Restart” button to the right of “App / Edit” in the title bar.
  2. Click “Restart” — the first-stage confirmation dialog appears, showing a green/yellow/red indicator based on the current state.
  3. If everything is clear, click “Restart Now.” The window closes and automatically reopens in about 10 seconds. Port, model, and plugin settings are preserved.
  4. If a session is running or a plugin is installing/queued, you will see a warning and the restart will not proceed.

Use Cases & Notes

Ideal for developers who frequently need to restart the desktop app and want to avoid accidental interruptions during active tasks or installations. The plugin runs with the current dsh process permissions. It is recommended to review the source code and license before installing.

In Brief

dsh-restart-center provides a restart button alongside “App / Edit” in the title bar. Through two-stage confirmation and status indicators, it prevents accidental termination of running sessions or in-progress plugin installations. The restart mechanism uses a Windows scheduled task to ensure the new window launches reliably. For more details, see the directory page and GitHub.

Directory Page

https://www.skillhub.cn/plugins/wsl1602291891-stack/dsh-restart-center

GitHub

https://github.com/wsl1602291891-stack/dsh-restart-center

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye