dsh-window-size: Save and restore DSH Desktop window size on restart

Introduction

When using the DeepSeek Harness Desktop version for daily development, you often have to manually drag the window borders to adjust the size repeatedly. This is because the desktop application hardcodes the main window dimensions to 1280 × 820 upon creation and does not persist the window state. Furthermore, calling window.resizeTo() within the Electron renderer does not actually resize the BrowserWindow, so the startup dimensions cannot be modified solely from the frontend.

The following introduces the community plugin dsh-window-size (Maintainer: home-i, Category: Client). It utilizes Win32 APIs within the Host process to set the window size and position before the window is displayed. It records user adjustments to the harness home directory and automatically restores them upon restart. By default, the window is centered horizontally and vertically, and this can be manually adjusted in the settings page.

What is this?

dsh-window-size is a Host plugin designed for the DeepSeek Harness Desktop version (Windows). Its features include: remembering window dimensions and restoring them after a restart; using a default size of 1440 × 900 and centering the window if there is no previous record; automatically recording every manual adjustment; and ignoring maximized, minimized, or hidden states to prevent the window from opening with incorrect dimensions next time.

While it can still be loaded on non-desktop Hosts (such as the dsh command line or server), the settings page will indicate that window management features are unavailable.

  • Directory Page: https://www.skillhub.cn/plugins/home-i/dsh-window-size
  • Source Code & Documentation: https://github.com/home-i/dsh-window-size
  • License: MIT

Core Features

Startup and Persistence

  1. First Launch: If there is no history, the size 1440 × 900 is used (configurable via Loader), and the window is centered.
  2. Manual Adjustments: Every manual adjustment is automatically recorded and restored on the next startup.
  3. Default Centering: On every startup, the window can be placed in the center of the current monitor’s work area. The “Center on startup” option can be disabled in the settings page to retain the last used position instead.
  4. State Filtering: Maximized, minimized, and hidden states are never recorded. During restoration, the window is shrunk to fit the current monitor’s work area, ensuring compatibility even if monitors are changed.

Settings Page

Path: Settings → Window Size. The page displays the current window size, the recorded size, and the last action (including timestamp). The settings page does not manipulate the window directly; instead, it communicates with the Host via the package-private RPC /dsh-window-size, sharing the same controller used for startup restoration.

Control Function
Width / Height + Apply & Remember Immediately changes the window size and saves it
Remember Current Size Saves the current manually dragged size
Re-apply Applies the recorded values again (incorporating current centering settings)
Restore Defaults Resets to the configured default of 1440 × 900
Center on startup toggle Determines whether to center the window upon restoration
Center now Only centers the window without changing dimensions
Enable size memory toggle When off, neither restoration nor recording occurs

Technical Highlights (Why it must be a Host plugin)

The desktop version’s main window size is hardcoded at creation and not persisted; the renderer cannot change the actual window size. The plugin uses koffi within the Host to call FindWindowExW, GetWindowRect, GetDpiForWindow, and SetWindowPos. These settings are applied before the window is displayed, minimizing the flicker of the old size appearing first.

Installation and Activation

Fill in the GitHub source in the plugin manager (Original installation method):

github:home-i/dsh-window-size#v1.1.2

You can also install from a local directory via the desktop version’s Plugins page. For local development, you can link the package into the desktop profile:

// ~/.dsh/profiles/desktop/package.json
{
  "dependencies": {
    "dsh-window-size": "link:/path/to/dsh-window-size"
  },
  "dsh": {
    "profile": {
      "bundles": ["...", "dsh-window-size"]
    }
  }
}

Changes take effect on the next startup; no reinstallation is needed after modifying the source code. Note: Do not use a manually created Windows junction to replace the link: method described above and then run pnpm install, as this may clear the source code directory.

Configuration and State Files

The first-time default values can be configured in the Loader line of cordis.patch.yml:

# cordis.patch.yml
- insert:
    - id: dsh-window-size
      name: dsh-window-size
      config:
        width: 1440        # Width for first launch, in CSS pixels
        height: 900        # Height for first launch, in CSS pixels
        center: true       # Center on every restoration
        enabled: true      # Whether to enable restoration and recording

Dimensions are in CSS pixels; the minimum width and height are 520 × 600, and restoration is also constrained by the current monitor’s work area.

The record file is located in the harness home (following the profile, not Electron’s userData):

~/.dsh/dsh-window-size/window-size.json

Deleting this file restores the configured defaults. The last field records the most recent action along with the actual dimensions, DPI, and window title, which helps troubleshoot issues like “wrong size after restoration.”

Typical Usage

  1. After installation and restarting the desktop version, drag the window to your preferred size once. Subsequent startups will automatically restore the size, with centering determined by the “Center on startup” toggle.
  2. To fix a specific resolution: Open Settings → Window Size, enter the width and height, and click Apply & Remember.
  3. To temporarily disable memory: Turn off Enable size memory in the settings page. To return to the default size, click Restore Defaults (1440 × 900, or the value specified in your YAML).

Use Cases and Notes

Who it is for: Users on Windows 10/11 (x64 or arm64) using the DSH desktop version who want persistent window sizing, centering, and UI-based control without relying on manual dragging every time.

Environment: Only Win32 Window APIs are effective; it will not function on other platforms.

Security & Permissions: The plugin runs with the permissions of the current DSH process. Please read the source code and MIT License before installation. Confirm the source is https://github.com/home-i/dsh-window-size.

FAQ:

  • If the package manager reports dsh: cannot resolve profile bundle "dsh-window-size": The manifest lists the bundle, but node_modules/dsh-window-size is missing or the link is invalid. You need to restore the link or reinstall.
  • Settings page unavailable: The current Host is not the desktop version, or koffi / user32 failed to load (the page will provide the reason).

Conclusion

dsh-window-size decouples “window dimensions” from the desktop version’s hardcoded 1280 × 820: it offers Host-side Win32 configuration, restart restoration, optional centering, and explicit controls within Settings → Window Size. For the community directory page, see https://www.skillhub.cn/plugins/home-i/dsh-window-size. For implementation details and RPC conventions, see the GitHub README.

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

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

Xiaoye