dsh-sidebar-fold 0.1.5 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,137 +1,164 @@
1
- # dsh-sidebar-fold
2
-
3
- [![npm version](https://img.shields.io/npm/v/dsh-sidebar-fold?color=4d6bfe)](https://www.npmjs.com/package/dsh-sidebar-fold)
4
- [![license](https://img.shields.io/npm/l/dsh-sidebar-fold)](https://github.com/drscrewdriver/dsh-sidebar-fold/blob/main/LICENSE)
5
-
6
- Collapse the DSH sidebar's add-on entries into the shipped **“More”** row.
7
-
8
- The left column's *Global panels* list grows with every installed plugin: schedules,
9
- agent teams, the plugin market, context pages, … `dsh-sidebar-fold` puts a
10
- **28×28 square arrow toggle** on the right end of the host's “More” row. One click
11
- folds those add-on rows away so only the “More” line remains; the arrow flips from
12
- ▲ (can collapse) to ▼ (can expand) and a second click brings the rows back.
13
-
14
- - **Non-invasive** — a client plugin that only adds DOM. The host bundle is never
15
- patched, nothing in `app.asar` is touched, and uninstalling restores the sidebar
16
- exactly as shipped (own `<style>` tag and `data-dshsf-*` marks removed).
17
- - **Structural header detection** — the header row is the `panelRow` carrying
18
- `aria-haspopup="menu"` inside the “Global panels” nav, which is locale-independent
19
- and independent of plugin registration order.
20
- - **State per window** — the folded/open choice persists in `localStorage`, so a
21
- reload keeps it.
22
- - **Alignment switch** — the managed rows (the “More” row included) can put their
23
- icon + label pair **left / centred / right**. At `right` the toggle mirrors to the
24
- row's left end so it never covers the text; the override is a single
25
- `justify-content` longhand and leaves the row's `display`/`gap`/height alone.
26
- - **Configurable** — default state, the kept-visible rows and the row alignment live
27
- in the plugin's settings card (host `Config`, `.volatile()`, applied without a
28
- restart).
29
- - **Rail-safe** — when the sidebar is collapsed to the 36 px icon rail the toggle is
30
- removed and every row is shown again: no squeezing, no half-hidden state.
31
- - **Quiet degradation** — if the host DOM drifts and the anchors are not found, the
32
- plugin stays out of the way instead of breaking the sidebar (`dsh-sidebar-fold:
33
- fold installed { mounted: false }` in the console tells you it happened).
34
-
35
- ## Screenshots
36
-
37
- Expanded, rows centred — the toggle sits on the More row and the add-on rows are listed:
38
-
39
- ![expanded and centre-aligned](assets/middle.png)
40
-
41
- Folded — only the plugin row and the More row remain:
42
-
43
- ![folded](assets/fold.png)
44
-
45
- ## Install
46
-
47
- ```sh
48
- # npm channel (after release)
49
- dsh plugin --profile <profile> add dsh-sidebar-fold
50
-
51
- # local build
52
- npm run build && npm run verify
53
- npm pack --pack-destination .
54
- dsh plugin --profile <profile> add ./dsh-sidebar-fold-0.1.2.tgz
55
- ```
56
-
57
- Then add `dsh-sidebar-fold` to the profile's `dsh.profile.bundles` list (or
58
- enable the bundle in the app) and restart. On the desktop profile, quit the Electron
59
- app before editing its `package.json` — the running app rewrites that file and rolls
60
- external edits back.
61
-
62
- ## Settings
63
-
64
- Open **Plugins → dsh-sidebar-fold** (the card is registered on the
65
- `plugins.bundle.config` seat, keyed by the package name):
66
-
67
- | Field | Meaning | Default |
68
- |---|---|---|
69
- | Folded by default | State a window starts in when it has no local record | off |
70
- | Row alignment | Three-way segmented control (left / centre / right) for the managed rows; the “More” row follows the same setting | left |
71
- | Entries kept visible | **One switch per row read from the live sidebar** — switch a row on to keep it visible while the rest fold | only `插件` / `Plugins` |
72
-
73
- The row list is read from the DOM at open time, so a panel installed later shows up
74
- without editing anything. When every row is switched on the toggle dims itself and
75
- reports `aria-disabled="true"` instead of flipping an arrow over an unchanged list.
76
-
77
- ## Development
78
-
79
- ```sh
80
- npm run build # scripts/build-client.mjs -> lib/client.js (module-loader bundle)
81
- npm run verify # gate: loader id === package name, dual-manifest same string,
82
- # no module request, no host primitives, 9 locales, no
83
- # machine-absolute paths
84
- npm test # node --test on the pure seams (header split, nav fallback chain)
85
- npm run hosts:check # enumeration drift vs scripts/hosts.mjs (--write to repair)
86
- ```
87
-
88
- `prepack` runs build + verify, so a stale `lib/client.js` cannot be published.
89
-
90
- ## Supported hosts
91
-
92
- **DSH 0.2.1-rc.3 only.** Single source of truth: `scripts/hosts.mjs` (the three
93
- declarations — `engines.dsh`, `peerDependencies`, `dsh.plugin.json` — are generated
94
- from it and must not be edited by hand).
95
-
96
- Why not wider: mounting needs the sidebar's panel list **and** the shipped "More"
97
- row. Measured on every published `dsh-client-ui-sidebar` rc:
98
-
99
- | host line | panel list | "More" row |
100
- |---|---|---|
101
- | 0.1.0-rc.8 / 0.1.1-rc.2 / 0.1.2-rc.1 | no | no |
102
- | 0.1.5-rc.3 / 0.1.7-rc.2 / 0.2.0-rc.2 | yes | no |
103
- | 0.2.1-rc.1 / 0.2.1-rc.2 | yes | no |
104
- | **0.2.1-rc.3** | yes | **yes** |
105
-
106
- On a line without the More row the plugin degrades quietly — it injects nothing and
107
- leaves the sidebar as shipped. Declaring such a host would only install a plugin
108
- that does nothing.
109
-
110
- After a host upgrade, re-run the browser smoke test before widening this list:
111
- CSS-module hashes drift every build (rc.2 emitted `wtg9ga_`, rc.3 emits `hHd-Xa_`),
112
- so only the fragment selectors (`_panelList`, `_panelRow`, `_moreAnchor`,
113
- `_collapsed`) are stable.
114
-
115
- ## Upgrade guardrail
116
-
117
- Host CSS-module hashes drift per build (`wtg9ga_` on rc.2 → `hHd-Xa_` on the rc.3
118
- runtime), which is why every selector matches a *fragment* (`_panelList`, `_panelRow`,
119
- `_moreAnchor`, `_collapsed`). **After any host upgrade, re-run the browser smoke**
120
- before assuming the fold still mounts; the plugin degrades silently by design, so a
121
- regression shows up as “nothing happened”, not as an error.
122
-
123
- ## Layout
124
-
125
- ```
126
- src/index.js host half: Config schema + no-op apply (no build step)
127
- src/client/constants.ts measured anchors, attribute marks, injected stylesheet
128
- src/client/locales.ts 9 runtime dictionaries (zh = key-set source of truth)
129
- src/client/fold.ts nav location, header/group split, toggle mount, fold state
130
- src/client/settings-card.ts the bundle-page configuration card (plain DOM)
131
- src/client/index.ts apply: fold first, then the guarded settings waists
132
- scripts/ build-client / verify / sync-hosts / hosts / gen-locale-meta
133
- ```
134
-
135
- ## License
136
-
137
- MIT
1
+ # dsh-sidebar-fold
2
+
3
+ [![npm version](https://img.shields.io/npm/v/dsh-sidebar-fold?color=4d6bfe)](https://www.npmjs.com/package/dsh-sidebar-fold)
4
+ [![license](https://img.shields.io/npm/l/dsh-sidebar-fold)](https://github.com/drscrewdriver/dsh-sidebar-fold/blob/main/LICENSE)
5
+
6
+ Collapse the DSH sidebar's add-on entries into the shipped **“More”** row.
7
+
8
+ The left column's *Global panels* list grows with every installed plugin: schedules,
9
+ agent teams, the plugin market, context pages, … `dsh-sidebar-fold` puts a
10
+ **28×28 square arrow toggle** on the right end of the host's “More” row. One click
11
+ folds those add-on rows away so only the “More” line remains; the arrow flips from
12
+ ▲ (can collapse) to ▼ (can expand) and a second click brings the rows back.
13
+
14
+ - **Non-invasive** — a client plugin that only adds DOM. The host bundle is never
15
+ patched, nothing in `app.asar` is touched, and uninstalling restores the sidebar
16
+ exactly as shipped (own `<style>` tag and `data-dshsf-*` marks removed).
17
+ - **Structural header detection** — the header row is the `panelRow` carrying
18
+ `aria-haspopup="menu"` inside the “Global panels” nav, which is locale-independent
19
+ and independent of plugin registration order.
20
+ - **State per window** — the folded/open choice persists in `localStorage`, so a
21
+ reload keeps it.
22
+ - **Alignment switch** — the managed rows (the “More” row included) can put their
23
+ icon + label pair **left / centred / right**. At `right` the toggle mirrors to the
24
+ row's left end so it never covers the text; the override is a single
25
+ `justify-content` longhand and leaves the row's `display`/`gap`/height alone.
26
+ - **Three states per row (host 0.2.2 on)** — every row in the settings card picks one of
27
+ **Show** (always visible), **Fold** (may be folded) or **Hide in More** (hand the row to the
28
+ host's own “More” list, i.e. its unpin action). A hidden row leaves the column and appears
29
+ in the “More” menu, from where the host's own pin control brings it back; the plugin
30
+ reconciles both sides on boot, on a config write and on every sidebar repaint — including
31
+ after a reload, where the host's in-memory pin table comes back empty.
32
+ - **Configurable** — default state, the three-state row controls and the row alignment live
33
+ in the plugin's settings card (host `Config`, `.volatile()`, applied without a restart).
34
+ - **Rail-safe** — when the sidebar is collapsed to the 36 px icon rail the toggle is
35
+ removed and every row is shown again: no squeezing, no half-hidden state.
36
+ - **Quiet degradation** — if the host DOM drifts and the anchors are not found, the
37
+ plugin stays out of the way instead of breaking the sidebar (`dsh-sidebar-fold:
38
+ fold installed { mounted: false }` in the console tells you it happened).
39
+
40
+ ## Screenshots
41
+
42
+ Expanded, rows centred — the toggle sits on the More row and the add-on rows are listed:
43
+
44
+ ![expanded and centre-aligned](assets/middle.png)
45
+
46
+ Folded — only the plugin row and the More row remain:
47
+
48
+ ![folded](assets/fold.png)
49
+
50
+ ## Install
51
+
52
+ ```sh
53
+ # npm channel (after release)
54
+ dsh plugin --profile <profile> add dsh-sidebar-fold
55
+
56
+ # local build
57
+ npm run build && npm run verify
58
+ npm pack --pack-destination .
59
+ dsh plugin --profile <profile> add ./dsh-sidebar-fold-0.1.2.tgz
60
+ ```
61
+
62
+ Then add `dsh-sidebar-fold` to the profile's `dsh.profile.bundles` list (or
63
+ enable the bundle in the app) and restart. On the desktop profile, quit the Electron
64
+ app before editing its `package.json` — the running app rewrites that file and rolls
65
+ external edits back.
66
+
67
+ ## Settings
68
+
69
+ Open **Plugins → dsh-sidebar-fold** (the card is registered on the
70
+ `plugins.bundle.config` seat, keyed by the package name), or click
71
+ **“Sidebar fold settings” at the bottom of the sidebar's “More” menu**: that row sits in
72
+ the `sidebar.panellist.actions` seat and jumps with the host's own
73
+ `pluginNavigation.openBundle(package)`, so it shares the menu's keyboard walk and dismiss
74
+ path; a host without that service falls back to selecting the Plugins panel.
75
+
76
+ | Field | Meaning | Default |
77
+ |---|---|---|
78
+ | Folded by default | State a window starts in when it has no local record | off |
79
+ | Row alignment | Three-way segmented control (left / centre / right) for the managed rows; the “More” row follows the same setting | left |
80
+ | Entries (one per row) | **Show** = always visible; **Fold** = may be folded (default); **Hide in More** = move it into the host's “More” menu | Fold |
81
+
82
+ The row list is read from the DOM at open time, so a panel installed later shows up
83
+ without editing anything. When every row is set to Show the toggle dims itself and
84
+ reports `aria-disabled="true"` instead of flipping an arrow over an unchanged list.
85
+
86
+ “Hide in More” needs the 0.2.2 row structure (`div._panelEntry` plus the in-row pin
87
+ control): on the 0.2.1 line that one segment is disabled in the card while the other two
88
+ keep working. The host's pin table is **in memory only** (a reload starts empty), so the
89
+ plugin reconciles on every scan: a row that should be hidden but is still in the column
90
+ gets its unpin control clicked, and a hidden label whose row came back is dropped from
91
+ the hide list.
92
+
93
+ ## Development
94
+
95
+ ```sh
96
+ npm run build # scripts/build-client.mjs -> lib/client.js (module-loader bundle)
97
+ npm run verify # gate: loader id === package name, dual-manifest same string,
98
+ # no module request, no host primitives, 9 locales, no
99
+ # machine-absolute paths
100
+ npm test # node --test on the pure seams (header split, nav fallback chain)
101
+ npm run hosts:check # enumeration drift vs scripts/hosts.mjs (--write to repair)
102
+ ```
103
+
104
+ `prepack` runs build + verify, so a stale `lib/client.js` cannot be published.
105
+
106
+ ## Supported hosts
107
+
108
+ **DSH hosts `>=0.2.1-rc.3 <0.3.0`** (the "More" row first ships in 0.2.1-rc.3; newer 0.2.x rcs stay installable without a republish). Single source of truth: `scripts/hosts.mjs` — `engines.dsh` carries that bounded range, `peerDependencies` keep the per-rc enumeration (npm resolution never assumes `includePrerelease`), and `dsh.plugin.json` mirrors the range; all generated, never hand-edited.
109
+
110
+ Why the floor is 0.2.1-rc.3: mounting needs the sidebar's panel list **and** the shipped "More"
111
+ row. Measured on every published `dsh-client-ui-sidebar` rc:
112
+
113
+ | host line | panel list | "More" row | row wrapper / in-row pin control |
114
+ |---|---|---|---|
115
+ | 0.1.0-rc.8 / 0.1.1-rc.2 / 0.1.2-rc.1 | no | no | — |
116
+ | 0.1.5-rc.3 / 0.1.7-rc.2 / 0.2.0-rc.2 | yes | no | — |
117
+ | 0.2.1-rc.1 / 0.2.1-rc.2 | yes | no | — |
118
+ | 0.2.1-rc.3 | yes | yes | no |
119
+ | 0.2.2-rc.3 (DOM-verified 2026-11-14) | yes | yes | **yes** (`div._panelEntry` + `button._panelUnpin`, `button._pinButton` inside the menu) |
120
+
121
+ On a line without the More row the plugin degrades quietly — it injects nothing and
122
+ leaves the sidebar as shipped. Declaring such a host would only install a plugin
123
+ that does nothing.
124
+
125
+ **Two measured differences on the 0.2.2 line** (both verified on 0.2.2-rc.3):
126
+
127
+ 1. A row is wrapped in `div._panelEntry` and carries the host's own unpin control. The fold
128
+ mark therefore has to land on the **wrapper**: hiding only the inner `button._panelRow`
129
+ left a 32 px empty slot (plus a pin that appears on hover) behind — the real regression
130
+ v0.1.6 showed on newer hosts.
131
+ 2. The host's unpin action *is* “hide in More”: an unpinned row is filtered out of the nav
132
+ and rendered by `sidebar.panellist.actions` into the “More” menu (each row with a
133
+ pin-back control). That pin table is in-memory and never persisted, so the plugin keeps
134
+ two label lists (`keepLabels` / `hideLabels`) as the source of truth and reconciles.
135
+
136
+ After a host upgrade, re-run the browser smoke test before widening this list:
137
+ CSS-module hashes drift every build (rc.2 emitted `wtg9ga_`, the 0.2.1/0.2.2 rc.3 runtimes
138
+ emit `hHd-Xa_`), so only the fragment selectors (`_panelList`, `_panelRow`, `_moreAnchor`,
139
+ `_collapsed`, `_panelEntry`, `_panelUnpin`, `_pinButton`) are stable.
140
+
141
+ ## Upgrade guardrail
142
+
143
+ Host CSS-module hashes drift per build (`wtg9ga_` on rc.2 → `hHd-Xa_` on the 0.2.1/0.2.2
144
+ rc.3 runtimes), which is why every selector matches a *fragment* (`_panelList`, `_panelRow`,
145
+ `_moreAnchor`, `_collapsed`, `_panelEntry`, `_panelUnpin`, `_pinButton`). **After any host
146
+ upgrade, re-run the browser smoke** before assuming the three paths still hold: the fold
147
+ mount, the three-state write, and hide/pin-back. The plugin degrades quietly (or disables
148
+ one segment) by design, so a regression shows up as “nothing happened”, not as an error.
149
+
150
+ ## Layout
151
+
152
+ ```
153
+ src/index.js host half: Config schema + no-op apply (no build step)
154
+ src/client/constants.ts measured anchors, attribute marks, injected stylesheet
155
+ src/client/locales.ts 9 runtime dictionaries (zh = key-set source of truth)
156
+ src/client/fold.ts nav location, header/group split, toggle mount, fold state
157
+ src/client/settings-card.ts the bundle-page configuration card (plain DOM)
158
+ src/client/index.ts apply: fold first, then the guarded settings waists
159
+ scripts/ build-client / verify / sync-hosts / hosts / gen-locale-meta
160
+ ```
161
+
162
+ ## License
163
+
164
+ MIT
package/README.zh.md CHANGED
@@ -1,121 +1,141 @@
1
- # dsh-sidebar-fold
2
-
3
- [![npm version](https://img.shields.io/npm/v/dsh-sidebar-fold?color=4d6bfe)](https://www.npmjs.com/package/dsh-sidebar-fold)
4
- [![license](https://img.shields.io/npm/l/dsh-sidebar-fold)](https://github.com/drscrewdriver/dsh-sidebar-fold/blob/main/LICENSE)
5
-
6
- 把 DSH 左侧栏的「加项入口」收进宿主的 **「更多」行**。
7
-
8
- 左侧栏的「全局面板」列表会随安装变长:自动化任务、agent 团队、插件市场、上下文页……
9
- 本插件在宿主「更多」行右端挂一个 **28×28 的方形箭头按钮**。点一下把这些加项行整体收纳,
10
- 只剩「更多」一行;箭头由 ▲(可收起)翻成 ▼(可展开),再点复原。
11
-
12
- - **非侵入** —— 纯 client 插件,只新增 DOM。不打宿主补丁、不碰 `app.asar`;卸载后侧边栏
13
- 与原版逐行一致(自持的 `<style>` 标签与 `data-dshsf-*` 标记一并清除)。
14
- - **结构化定位头行** —— 头行 = 「全局面板」nav 内带 `aria-haspopup="menu"` 的 `panelRow`。
15
- 不依赖任何文案,也不依赖插件注册顺序。
16
- - **状态按窗口持久化** —— 折叠/展开记录在 `localStorage`,刷新后保持。
17
- - **对齐可切换** —— 被管理的入口行(含「更多」行)的文字与图标可整体**左对齐 / 居中 / 右对齐**;
18
- 右对齐时折叠钮自动镜像到行左端,不压文字。覆盖层只用宿主的 `justify-content` 长属性,
19
- 不动行的 `display`/`gap`/高度。
20
- - **可配置** —— 默认态、保持可见的行、行对齐都在插件设置卡里改(宿主 `Config` + `.volatile()`,
21
- 保存即生效,不用重启)。
22
- - **窄栏友好** —— 侧边栏收成 36px 图标栏时自动摘掉按钮并显示全部行:不挤压、不留半隐藏态。
23
- - **静默降级** —— 宿主 DOM 漂移导致锚点找不到时,插件不注入、不改坏侧边栏;控制台会出现
24
- `dsh-sidebar-fold: fold installed { mounted: false }` 告知未挂载。
25
-
26
- ## 截图
27
-
28
- 展开态(各行居中)—— 折叠钮挂在「更多」行,加项行正常列出:
29
-
30
- ![展开且居中](assets/middle.png)
31
-
32
- 折叠态 —— 只剩「插件」行与「更多」行:
33
-
34
- ![折叠](assets/fold.png)
35
-
36
- ## 安装
37
-
38
- ```sh
39
- # npm 通道(发版后)
40
- dsh plugin --profile <profile> add dsh-sidebar-fold
41
-
42
- # 本地构建
43
- npm run build && npm run verify
44
- npm pack --pack-destination .
45
- dsh plugin --profile <profile> add ./dsh-sidebar-fold-0.1.2.tgz
46
- ```
47
-
48
- 装完把 `dsh-sidebar-fold` 补进 profile 的 `dsh.profile.bundles`(或在应用内启用该
49
- bundle)再重启。**desktop profile 必须先关停 Electron 应用**再改它的 `package.json`——
50
- 运行中的桌面端会按自身内存态重写该文件并回滚外部修改。
51
-
52
- ## 设置
53
-
54
- 打开 **插件 → dsh-sidebar-fold**(配置卡注册在 `plugins.bundle.config` 席位,
55
- key 为包名):
56
-
57
- | 字段 | 含义 | 默认 |
58
- |---|---|---|
59
- | 默认折叠 | 窗口在没有本地记录时采用的初始状态 | 关 |
60
- | 文字与图标对齐 | 三档分段控件(左 / 居中 / 右);作用于被折叠管理的入口行,「更多」行跟随同一档 | 左 |
61
- | 保持可见的入口 | **按当前侧边栏实时读出的行逐个开关**;打开的行在折叠时保留可见 | 仅 `插件` / `Plugins` |
62
-
63
- 行清单在打开卡片时从 DOM 读取,所以之后新装的入口会自动出现在列表里;如果全部都打开了,
64
- 折叠钮会自动置灰并报 `aria-disabled="true"`,不会出现“箭头动了但什么都没变”。
65
-
66
- ## 开发
67
-
68
- ```sh
69
- npm run build # scripts/build-client.mjs -> lib/client.js(模块加载器 bundle)
70
- npm run verify # 门禁:loader id === 包名、双清单同串、无模块请求、
71
- # 不引宿主 primitives、9 语词典、无机器绝对路径
72
- npm test # node --test,覆盖纯逻辑面(头行/分组划分、nav 回退链)
73
- npm run hosts:check # 与 scripts/hosts.mjs 的枚举漂移检查(--write 修复)
74
- ```
75
-
76
- `prepack` 会串起 build + verify,过期的 `lib/client.js` 发不出去。
77
-
78
- ## 支持宿主
79
-
80
- **仅 DSH 0.2.1-rc.3。** 唯一事实源 `scripts/hosts.mjs`(三处声明 —— `engines.dsh`、
81
- `peerDependencies`、`dsh.plugin.json` —— 都由它生成,禁止手改)。
82
-
83
- 为什么不放宽:挂载同时需要侧边栏的**面板列表**与宿主**「更多」行**。逐版本实测
84
- 所有已发布的 `dsh-client-ui-sidebar` rc:
85
-
86
- | 宿主线 | 面板列表 | 「更多」行 |
87
- |---|---|---|
88
- | 0.1.0-rc.8 / 0.1.1-rc.2 / 0.1.2-rc.1 | 无 | 无 |
89
- | 0.1.5-rc.3 / 0.1.7-rc.2 / 0.2.0-rc.2 | 有 | 无 |
90
- | 0.2.1-rc.1 / 0.2.1-rc.2 | 有 | 无 |
91
- | **0.2.1-rc.3** | 有 | **有** |
92
-
93
- 没有「更多」行的宿主上,插件按设计静默降级——不注入、不改坏侧边栏;声明这类宿主
94
- 只会让用户装上一个什么都不做的插件。
95
-
96
- 宿主换代后先跑浏览器冒烟再扩表:CSS-module hash 每次构建都漂移(rc.2 是
97
- `wtg9ga_`,rc.3 是 `hHd-Xa_`),只有片段选择器(`_panelList`、`_panelRow`、
98
- `_moreAnchor`、`_collapsed`)是稳的。
99
-
100
- ## 升级护栏
101
-
102
- 宿主 CSS-module hash 每次构建都会漂移(rc.2 是 `wtg9ga_`,rc.3 运行时是 `hHd-Xa_`),
103
- 所以所有选择器只匹配**片段**(`_panelList`、`_panelRow`、`_moreAnchor`、`_collapsed`)。
104
- **宿主换代后必须重跑浏览器冒烟**再认定折叠仍在挂载:插件按设计静默降级,回归表现为
105
- “什么都没发生”,不是报错。
106
-
107
- ## 目录
108
-
109
- ```
110
- src/index.js 宿主半:Config schema + 空 apply(无需构建)
111
- src/client/constants.ts 实测锚点、属性标记、注入的样式表
112
- src/client/locales.ts 9 部运行时词典(zh 键集为真理源)
113
- src/client/fold.ts nav 定位、头行/分组划分、按钮挂载、折叠状态
114
- src/client/settings-card.ts bundle 详情页配置卡(纯 DOM)
115
- src/client/index.ts apply:先装折叠,再各自带守卫地接设置腰
116
- scripts/ build-client / verify / sync-hosts / hosts / gen-locale-meta
117
- ```
118
-
119
- ## 许可
120
-
121
- MIT
1
+ # dsh-sidebar-fold
2
+
3
+ [![npm version](https://img.shields.io/npm/v/dsh-sidebar-fold?color=4d6bfe)](https://www.npmjs.com/package/dsh-sidebar-fold)
4
+ [![license](https://img.shields.io/npm/l/dsh-sidebar-fold)](https://github.com/drscrewdriver/dsh-sidebar-fold/blob/main/LICENSE)
5
+
6
+ 把 DSH 左侧栏的「加项入口」收进宿主的 **「更多」行**。
7
+
8
+ 左侧栏的「全局面板」列表会随安装变长:自动化任务、agent 团队、插件市场、上下文页……
9
+ 本插件在宿主「更多」行右端挂一个 **28×28 的方形箭头按钮**。点一下把这些加项行整体收纳,
10
+ 只剩「更多」一行;箭头由 ▲(可收起)翻成 ▼(可展开),再点复原。
11
+
12
+ - **非侵入** —— 纯 client 插件,只新增 DOM。不打宿主补丁、不碰 `app.asar`;卸载后侧边栏
13
+ 与原版逐行一致(自持的 `<style>` 标签与 `data-dshsf-*` 标记一并清除)。
14
+ - **结构化定位头行** —— 头行 = 「全局面板」nav 内带 `aria-haspopup="menu"` 的 `panelRow`。
15
+ 不依赖任何文案,也不依赖插件注册顺序。
16
+ - **状态按窗口持久化** —— 折叠/展开记录在 `localStorage`,刷新后保持。
17
+ - **对齐可切换** —— 被管理的入口行(含「更多」行)的文字与图标可整体**左对齐 / 居中 / 右对齐**;
18
+ 右对齐时折叠钮自动镜像到行左端,不压文字。覆盖层只用宿主的 `justify-content` 长属性,
19
+ 不动行的 `display`/`gap`/高度。
20
+ - **三档逐行控制(宿主 0.2.2 起)** —— 设置卡每一行三选一:**显示(一直显示)/ 折叠(允许折叠)/ 隐藏到更多**。
21
+ 「隐藏到更多」= 把该行交给宿主自己的「更多」菜单(等价于点宿主的“取消固定”),
22
+ 行从侧边栏消失、出现在「更多」列表里,可在里面一键固定回来;插件负责在启动、改配置与
23
+ 侧边栏重绘时**反向校准**两边状态,宿主内存态的固定表丢了也能恢复。
24
+ - **可配置** —— 默认态、每行三档、行对齐都在插件设置卡里改(宿主 `Config` + `.volatile()`,
25
+ 保存即生效,不用重启)。
26
+ - **窄栏友好** —— 侧边栏收成 36px 图标栏时自动摘掉按钮并显示全部行:不挤压、不留半隐藏态。
27
+ - **静默降级** —— 宿主 DOM 漂移导致锚点找不到时,插件不注入、不改坏侧边栏;控制台会出现
28
+ `dsh-sidebar-fold: fold installed { mounted: false }` 告知未挂载。
29
+
30
+ ## 截图
31
+
32
+ 展开态(各行居中)—— 折叠钮挂在「更多」行,加项行正常列出:
33
+
34
+ ![展开且居中](assets/middle.png)
35
+
36
+ 折叠态 —— 只剩「插件」行与「更多」行:
37
+
38
+ ![折叠](assets/fold.png)
39
+
40
+ ## 安装
41
+
42
+ ```sh
43
+ # npm 通道(发版后)
44
+ dsh plugin --profile <profile> add dsh-sidebar-fold
45
+
46
+ # 本地构建
47
+ npm run build && npm run verify
48
+ npm pack --pack-destination .
49
+ dsh plugin --profile <profile> add ./dsh-sidebar-fold-0.1.2.tgz
50
+ ```
51
+
52
+ 装完把 `dsh-sidebar-fold` 补进 profile 的 `dsh.profile.bundles`(或在应用内启用该
53
+ bundle)再重启。**desktop profile 必须先关停 Electron 应用**再改它的 `package.json`——
54
+ 运行中的桌面端会按自身内存态重写该文件并回滚外部修改。
55
+
56
+ ## 设置
57
+
58
+ 打开 **插件 → dsh-sidebar-fold**(配置卡注册在 `plugins.bundle.config` 席位,
59
+ key 为包名);或点侧栏 **「更多」菜单最下面的「侧栏折叠设置」** 直达——
60
+ 那一行注册在 `sidebar.panellist.actions` 席位,用宿主的 `pluginNavigation.openBundle(包名)` 跳转,
61
+ 所以它和菜单自带的键盘走位、关闭行为一致;宿主没提供该服务时退回「选插件面板」。
62
+
63
+ | 字段 | 含义 | 默认 |
64
+ |---|---|---|
65
+ | 默认折叠 | 窗口在没有本地记录时采用的初始状态 | 关 |
66
+ | 文字与图标对齐 | 三档分段控件(左 / 居中 / 右);作用于被折叠管理的入口行,「更多」行跟随同一档 | 左 |
67
+ | 入口行(逐行) | 每行三选一:**显示**=一直显示(不折叠);**折叠**=允许折叠(默认);**隐藏到更多**=移进宿主「更多」菜单 | 折叠 |
68
+
69
+ 行清单在打开卡片时从 DOM 读取,所以之后新装的入口会自动出现在列表里;如果全部都开了「显示」,
70
+ 折叠钮会自动置灰并报 `aria-disabled="true"`,不会出现“箭头动了但什么都没变”。
71
+
72
+ 「隐藏到更多」依赖宿主 0.2.2 起的行结构(`div._panelEntry` + 行内固定控件):0.2.1 线上该档
73
+ 会在卡片里置灰,其余两档照常可用。宿主自己的固定表是**内存态**(重载即空),所以插件在每次
74
+ 扫瞄时反向校准:该藏的行还在就点“取消固定”,已拉回的行被记住了就把它从隐藏清单里清掉。
75
+
76
+ ## 开发
77
+
78
+ ```sh
79
+ npm run build # scripts/build-client.mjs -> lib/client.js(模块加载器 bundle)
80
+ npm run verify # 门禁:loader id === 包名、双清单同串、无模块请求、
81
+ # 不引宿主 primitives、9 语词典、无机器绝对路径
82
+ npm test # node --test,覆盖纯逻辑面(头行/分组划分、nav 回退链)
83
+ npm run hosts:check # 与 scripts/hosts.mjs 的枚举漂移检查(--write 修复)
84
+ ```
85
+
86
+ `prepack` 会串起 build + verify,过期的 `lib/client.js` 发不出去。
87
+
88
+ ## 支持宿主
89
+
90
+ **支持 DSH 宿主 `>=0.2.1-rc.3 <0.3.0`**(「更多」行自 0.2.1-rc.3 才出现;0.2.x 线上后续 rc 无需重发版即可安装)。唯一事实源 `scripts/hosts.mjs`:`engines.dsh` 发该有界区间,`peerDependencies` 保持逐 rc 枚举(npm 解析不默认带 `includePrerelease`),`dsh.plugin.json` 镜像区间——全部由它生成,禁止手改。
91
+
92
+ 为什么下限是 0.2.1-rc.3:挂载同时需要侧边栏的**面板列表**与宿主**「更多」行**。逐版本实测
93
+ 所有已发布的 `dsh-client-ui-sidebar` rc:
94
+
95
+ | 宿主线 | 面板列表 | 「更多」行 | 行容器 / 行内固定控件 |
96
+ |---|---|---|---|
97
+ | 0.1.0-rc.8 / 0.1.1-rc.2 / 0.1.2-rc.1 | 无 | 无 | —— |
98
+ | 0.1.5-rc.3 / 0.1.7-rc.2 / 0.2.0-rc.2 | 有 | 无 | —— |
99
+ | 0.2.1-rc.1 / 0.2.1-rc.2 | 有 | 无 | —— |
100
+ | 0.2.1-rc.3 | 有 | **有** | 无 |
101
+ | 0.2.2-rc.3(2026-11-14 DOM 实测) | 有 | 有 | **有**(`div._panelEntry` + `button._panelUnpin`,菜单内 `button._pinButton`) |
102
+
103
+ 没有「更多」行的宿主上,插件按设计静默降级——不注入、不改坏侧边栏;声明这类宿主
104
+ 只会让用户装上一个什么都不做的插件。
105
+
106
+ **0.2.2 线的两个实测差异(都已在 0.2.2-rc.3 上验证过)**:
107
+
108
+ 1. 行被 `div._panelEntry` 包裹,行内另有宿主自己的「取消固定」图钉控件。所以折叠标记必须
109
+ 打在**外层 entry** 上:只隐藏内层 `button._panelRow` 的话,折叠后会留一排 32px 空槽 + 悬停
110
+ 就冒出来的图钉(v0.1.6 在高版本上的真实回归)。
111
+ 2. 宿主的“取消固定”就是「隐藏到更多」:未固定行从 nav 被过滤掉,改由 `sidebar.panellist.actions`
112
+ 渲染进「更多」菜单(每行带一个“固定到侧边栏”控件)。宿主这份固定表是内存态、不落盘,
113
+ 所以插件以两份 label 清单为真理源(`keepLabels` / `hideLabels`),每次扫瞄反向校准。
114
+
115
+ 宿主换代后先跑浏览器冒烟再扩表:CSS-module hash 每次构建都漂移(rc.2 是
116
+ `wtg9ga_`,0.2.1-rc.3 / 0.2.2-rc.3 是 `hHd-Xa_`),只有片段选择器(`_panelList`、`_panelRow`、
117
+ `_moreAnchor`、`_collapsed`、`_panelEntry`、`_panelUnpin`、`_pinButton`)是稳的。
118
+
119
+ ## 升级护栏
120
+
121
+ 宿主 CSS-module hash 每次构建都会漂移(rc.2 是 `wtg9ga_`,0.2.1-rc.3 / 0.2.2-rc.3 是 `hHd-Xa_`),
122
+ 所以所有选择器只匹配**片段**(`_panelList`、`_panelRow`、`_moreAnchor`、`_collapsed`、
123
+ `_panelEntry`、`_panelUnpin`、`_pinButton`)。
124
+ **宿主换代后必须重跑浏览器冒烟**再认定这三条通路仍在:折叠挂载、三档写入、隐藏/拉回。
125
+ 插件按设计静默降级或降档,回归表现为“什么都没发生”或“第三档置灰”,不是报错。
126
+
127
+ ## 目录
128
+
129
+ ```
130
+ src/index.js 宿主半:Config schema + 空 apply(无需构建)
131
+ src/client/constants.ts 实测锚点、属性标记、注入的样式表
132
+ src/client/locales.ts 9 部运行时词典(zh 键集为真理源)
133
+ src/client/fold.ts nav 定位、头行/分组划分、按钮挂载、折叠状态
134
+ src/client/settings-card.ts bundle 详情页配置卡(纯 DOM)
135
+ src/client/index.ts apply:先装折叠,再各自带守卫地接设置腰
136
+ scripts/ build-client / verify / sync-hosts / hosts / gen-locale-meta
137
+ ```
138
+
139
+ ## 许可
140
+
141
+ MIT
package/dsh.plugin.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-sidebar-fold",
3
- "version": "0.1.5",
3
+ "version": "0.1.12",
4
4
  "main": "./src/index.js",
5
- "description": "折叠左侧栏加项入口:在宿主「更多」行挂一个 28×28 方形箭头按钮,把自动化任务、agent 团队、插件市场、上下文页等加项面板行收纳成一行,再点展开;折叠状态按窗口持久化。插件设置页可调默认态、保持可见的入口行(按当前侧边栏实时枚举),以及被管理行的文字与图标对齐(左/居中/右)。",
5
+ "description": "折叠左侧栏加项入口:在宿主「更多」行挂一个 28×28 方形箭头按钮,把自动化任务、agent 团队、插件市场、上下文页等加项面板行收纳成一行;设置卡每行三档:显示(一直显示)/ 折叠(允许折叠)/ 隐藏到更多(移进宿主「更多」菜单,宿主 0.2.2 起)。还可调默认态与行内文字图标对齐(左/居中/右)。",
6
6
  "engines": {
7
- "dsh": "0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1"
7
+ "dsh": ">=0.2.1-rc.3 <0.3.0"
8
8
  },
9
9
  "contributes": {
10
10
  "tools": [],