# dsh-layout-memory English | [中文](README.md) A DeepSeek Harness (DSH) **web** plugin that remembers the left sidebar and right panel widths across reloads and restarts. ## The problem DSH's layout shell (`@deepseek-ai/dsh-client-ui-layout`) keeps both widths in transient state: - The left sidebar starts at 280px and clamps to 264–420px; a reload, restart, or collapse-expand resets it. - The right panel starts as `null`, opens at 45% of the viewport the first time, and clamps to 300px–70% of the viewport; a reload or restart resets it. - DSH persists the right panel's open state per session (`dsh.sidebar-right.v1.`), so after a restart the panel may still be open while its width has been reset. This plugin restores widths only. It does not change the open state, tabs, or panes. ## Behavior 1. **Record** — listen for `pointerdown`/`pointerup` on both drag handles (`[data-side="sidebar"|"rightbar"]`) and read the settled column widths from the frame's inline `grid-template-columns`. 2. **Restore** — on startup, write the stored widths back through the layout store's `setSidebar()`/`setRightbar()`, the same actions the drag handles use. 3. **Collapse and expand** — watch the frame's `data-sidebar-collapsed` attribute and re-apply the remembered width when the sidebar expands (native behavior returns to 280px). 4. **Resolution** — store absolute pixels and let the layout shell apply its own clamps; no proportional scaling. ## Storage One localStorage key, `dsh.layout-memory.v1`: ```json { "v": 1, "left": 340, "right": 900 } ``` When storage is unavailable (private mode, quota) or the JSON is corrupt, only the memory feature turns off; the page is unaffected. ## Install > Installing changes the profile configuration under `%USERPROFILE%\.dsh`; confirm first. HMR-enabled profiles normally recompose live. Do not automatically restart DSH or interrupt running sessions. Repository: **From the Plugins page**: sidebar **Plugins** → **Add plugin**, and enter the repository address `https://github.com/AkotaP/dsh-layout-memory`. DSH probes the repository with `git ls-remote` before handing it to pnpm; once installed, confirm it shows as enabled. **One command**: ```powershell dsh plugin --profile desktop add https://github.com/AkotaP/dsh-layout-memory ``` **Let an agent install it** (paste this into a DSH agent): > Install `https://github.com/AkotaP/dsh-layout-memory` into the current DSH desktop profile: use the sidebar **Plugins** page's **Add plugin**, or `dsh plugin --profile desktop add https://github.com/AkotaP/dsh-layout-memory`. After installing, confirm `dsh-layout-memory` is present in the profile's `dsh.profile.bundles` and that the Plugins page shows it. Ask before restarting only if the host explicitly requires a restart; do not restart automatically. **Local development** (link a checkout into a profile so source changes apply live): ```powershell $profileDir = $env:DSH_PROFILE_DIR # e.g. ~/.dsh/profiles/desktop $repo = "E:\Data\Project\dsh\dsh-layout-memory" # 1. Add the link to the profile package.json dependencies: # "dsh-layout-memory": "link:E:/Data/Project/dsh/dsh-layout-memory" # 2. Add dsh-layout-memory to dsh.profile.bundles # 3. Create the link New-Item -ItemType Junction -Path "$profileDir\node_modules\dsh-layout-memory" -Target $repo ``` The package's own `cordis.patch.yml` already inserts its loader row; do not add it to the profile patch again. After installing, verify through the host's read-only health route (use the actual DSH web port): ```powershell curl http://127.0.0.1:/dsh-layout-memory/health # {"loaded":true} ``` To uninstall: remove it from the **Plugins** page, or `dsh plugin --profile desktop remove dsh-layout-memory`, and confirm it is gone from `dsh.profile.bundles`. ## Verify 1. Drag both widths to values clearly different from the defaults. 2. Reload the page (F5), or quit and restart DSH. 3. Expected: the left sidebar restores the dragged width; the right panel reopens with its stored width if it was open (the open state itself is DSH's own per-session decision). 4. Collapse the left sidebar and expand it again; the width should be the remembered value, not 280px. 5. Resize the window and restart; the right panel keeps its absolute pixel width and is clamped by the native rule to 70% of the viewport. Offline tests: ```powershell cd E:\Data\Project\dsh\dsh-layout-memory node --test --test-isolation=none ``` ## Limitations - **Non-public field dependency** — the width actions are not part of the public `ctx.layout` face (`ILayout` exposes panel transitions only). The plugin reads `setSidebar`/`setRightbar` from the `LayoutController` instance's private `panels` field with a feature check; if a future layout build drops that field, it degrades to record-only and warns in the console. - **Width preferences are global**, not per session; the right panel's open state is still per session. - **Fullscreen right panel is not recorded** — it is 100vw with no drag handle, and the plugin leaves it alone. - **Multiple windows** share the same localStorage key; the last write wins (DSH desktop is usually single-window). - **No cross-resolution scaling for the right panel** — it keeps absolute pixels and is clamped by the native rule, exactly like a manual drag. - Below a 1024px viewport the left sidebar collapses automatically; the plugin restores a width only when the user expands it manually. ## Rollback Remove `dsh-layout-memory` from `dsh.profile.bundles` and delete the `node_modules` link; delete the `dsh.layout-memory.v1` localStorage key if you also want to clear the remembered widths. ## Compatibility - Node.js `>=20` - DSH `>=0.2.1-rc.2`