@moonsand/dsh-ui-optimize 0.8.4 → 0.9.27

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
@@ -2,7 +2,9 @@
2
2
 
3
3
  English | [中文](README.zh.md)
4
4
 
5
- Two independent features for the DeepSeek Harness web interface: a **theme gallery** of eight minimalist themes (each defining one palette for light and one for dark), and the **desktop Reload/Restart buttons** at the sidebar foot — every feature has its own switch.
5
+ A collection of switches that tune how DeepSeek Harness looks and behaves — the whole interface, not a few named screens. Each switch works on its own, and more arrive as the shell grows.
6
+
7
+ Today: a **theme gallery** of eight minimalist themes (each defining one palette for light and one for dark), and **sidebar panel folding** — the panel rows collapse into a single **Panels** entry that opens a two-column launcher.
6
8
 
7
9
  Colours travel only through `ctx.theme.overrideTokens`, as a single layer of theme variables. No structural CSS is injected and no other plugin's DOM is read, so an upstream redesign can at worst make the colours inert — it cannot break the layout.
8
10
 
@@ -18,25 +20,24 @@ Open **Settings → UI Optimize**.
18
20
 
19
21
  Celadon, Linen, Cream, Graphite, Indigo, Slate, Sage, Rose. Picking a card recolours the whole interface; **Default** restores the stock look. Every theme defines one palette for light and one for dark — switching Appearance between them carries the theme along, so there is no separate version to pick.
20
22
 
21
- ### Desktop actions
22
-
23
- Two switches control the sidebar-foot buttons:
23
+ ### Sidebar
24
24
 
25
- - **Reload UI** — reloads the page and client plugins only; the Host and running tasks keep going
26
- - **Restart app** — restarts the whole app including its Host; interrupts the current conversation. **Desktop app only** — in a browser it degrades to reloading the page
25
+ A switch folds the panel rows in the left rail into a single **Panels** entry. Clicking it opens a two-column launcher with the panel icons, a title and count, a search box once there are more than seven panels, and keyboard control (↑ ↓ to move, Enter to open, Esc to close). Panels that register later — including ones added by other plugins — are picked up on the next open, so nothing silently disappears from the list.
27
26
 
28
- ## Relationship to dsh-desktop-restart
27
+ The entry calls the shell's own panel-selection API instead of synthesising clicks. A watchdog measures the folded row after mount and on every resize: if it cannot be measured, the switch turns itself off and the native sidebar comes back rather than leaving an empty rail.
29
28
 
30
- The desktop actions are ported from [`@moonsand/dsh-desktop-restart`](https://github.com/MoonSand/dsh-desktop-restart) and use their own route prefix, `/ui-optimize/desktop`.
29
+ The **More** row keeps its own line. Folding it in was tried and dropped: the shell's overflow menu only opens from a trusted click, which a plugin cannot produce, and the synthetic pointer events that came close also closed the launcher through the shell's click-outside handler.
31
30
 
32
- Both plugins can be installed at the same time without crashing, but you would get two sets of buttons. When the old plugin is detected, a notice appears at the top of the settings page suggesting you uninstall it.
31
+ The launcher follows the pattern of the community plugin [dsh-sidebar-shelf](https://github.com/wumouren114/dsh-sidebar-shelf): register a real rail row, hide the rest with one scoped CSS rule, enumerate entries through the slot API, and select a panel through the shell's own API rather than by faking clicks.
33
32
 
34
33
  ## Known limitations
35
34
 
36
35
  - The theme choice lives in browser `localStorage`; it is lost with the browser profile or site data
37
- - Restart works only in the desktop app; a browser session can only reload
38
- - Restart logs still go to `%TEMP%\dsh-desktop-restart.log`, inherited from the ported source
39
- - The restart action is a process-level operation that cannot be verified automatically
36
+ - The **More** row is not folded; it stays in the native rail
37
+ - The launcher keeps the shell's own panel order — it does not sort, pin or reorder
38
+ - The **More** row is not folded; it stays in the native rail
39
+ - The launcher keeps the shell's own panel order — it does not sort, pin or reorder
40
+ - Sidebar folding and `dsh-sidebar-shelf` rewrite the same rail; enable one of them, not both
40
41
 
41
42
  ## Development
42
43
 
@@ -44,7 +45,7 @@ Both plugins can be installed at the same time without crashing, but you would g
44
45
  node scripts/smoke.mjs
45
46
  ```
46
47
 
47
- The smoke test covers the assembly contract only: the three runtime files parse, the theme table is complete (8 themes × 10 tokens × 2 schemes), and the published identity plus `engines.dsh` are intact. It does **not** check whether the palettes look right or whether restart actually restarts.
48
+ The smoke test covers the assembly contract only: the three runtime files parse, the theme table is complete (8 themes × 10 tokens × 2 schemes), and the published identity plus `engines.dsh` are intact. It does **not** check whether the palettes look right or whether the sidebar launcher opens.
48
49
 
49
50
  ## License
50
51
 
package/README.zh.md CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  [English](README.md) | 中文
4
4
 
5
- 给 DeepSeek Harness 界面换主题,并把「刷新界面 / 重启应用」两个按钮收进同一个插件——两个功能各自独立开关。
5
+ 一组用来调 DeepSeek Harness 观感与操作的开关——管的是整套界面,不是某几块屏幕。每个开关单独生效,宿主长出新能力时会继续增加。
6
6
 
7
- - **主题画廊**:8 套极简主题,浅色与深色各定义一组配色,点一张卡片整套配色生效
8
- - **桌面操作**:侧栏底部的刷新与重启按钮,可分别关掉
7
+ 目前包含:**主题画廊**(8 套极简主题,浅色与深色各定义一组配色),以及**侧栏收纳**(面板行收成一个「面板」入口,点开是两列启动面板)。
9
8
 
10
9
  配色只通过 `ctx.theme.overrideTokens` 以**单层**覆盖主题变量,不注入任何结构性 CSS、不读写其他插件的 DOM,所以宿主改版最多让颜色不生效,不会把界面layout弄坏。
11
10
 
@@ -36,25 +35,22 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
36
35
 
37
36
  选「默认」恢复原生外观。每套主题为浅色与深色各定义一组配色,切换「外观」里的浅色/深色时自动跟随,不需要为两种模式各选一次。
38
37
 
39
- ### 桌面操作
38
+ ### 侧栏
40
39
 
41
- 两个开关分别控制侧栏底部的「刷新界面」和「重启应用」按钮:
40
+ 一个开关把左侧竖栏里的面板行收成一个「面板」入口。点开是两列启动面板:图标、标题与数量、面板多于 7 个时出现搜索框,并支持键盘操作(↑ ↓ 移动、回车打开、Esc 关闭)。之后才注册的面板——包括其他插件加进来的——在下次打开时自动出现,不会漏。
42
41
 
43
- - **刷新界面**:只重新加载页面与客户端插件,Host 与正在跑的任务不受影响
44
- - **重启应用**:重启整个应用(含 Host),会中断当前对话;**仅桌面端可用**,网页端会降级为刷新页面
42
+ 入口走宿主自己的面板选中接口,不伪造点击。挂载后与每次缩放时都有一个看门狗在量尺寸:量不到就把开关自动关掉、还原原生侧栏,而不是留一根空栏。
45
43
 
46
- ## 与 dsh-desktop-restart 的关系
44
+ 「更多」保持独立一行。把它也收进去试过并放弃了:宿主的溢出菜单只认真实点击,插件造不出来;而伪造的指针事件又会被宿主的「点外部即关闭」吃掉,刚打开的弹层立刻被关掉。
47
45
 
48
- 本插件的桌面操作移植自 [`@moonsand/dsh-desktop-restart`](https://github.com/MoonSand/dsh-desktop-restart),并已改用独立的路由前缀 `/ui-optimize/desktop`。
49
-
50
- 两个插件**可以同时安装而不会崩溃**,但会出现两套刷新/重启按钮。检测到旧插件仍在运行时,设置页顶部会给出提示,建议卸载它。
46
+ 启动面板的做法参考社区插件 [dsh-sidebar-shelf](https://github.com/wumouren114/dsh-sidebar-shelf):注册一根真实的竖栏行、用一条 scoped CSS 规则隐藏其余行、通过槽位 API 枚举条目,并用宿主自己的接口选中面板,而不是伪造点击。
51
47
 
52
48
  ## 已知限制
53
49
 
54
50
  - 主题选择保存在浏览器 `localStorage`,换机器或清站点数据会丢失
55
- - 重启只适用于桌面端;网页端只能刷新
56
- - 重启日志仍写在 `%TEMP%\dsh-desktop-restart.log`(沿用移植来源的路径)
57
- - 重启动作为进程级操作,无法在自动化测试中验证,只能人工点一次确认
51
+ - 「更多」没有收进弹层,仍在原生竖栏里
52
+ - 弹层沿用宿主自己的面板顺序,不排序、不置顶、不重排
53
+ - 侧栏收纳与 `dsh-sidebar-shelf` 改的是同一根竖栏,两个只能开一个
58
54
 
59
55
  ## 开发
60
56
 
@@ -62,7 +58,7 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
62
58
  node scripts/smoke.mjs
63
59
  ```
64
60
 
65
- 冒烟只验证装配契约:三个运行时文件可解析、主题表结构完整(8 套 × 10 个变量 × 浅/深两组)、包身份与 `engines.dsh` 完好。**它不验证配色观感,也不验证重启是否真的重启。**
61
+ 冒烟只验证装配契约:三个运行时文件可解析、主题表结构完整(8 套 × 10 个变量 × 浅/深两组)、包身份与 `engines.dsh` 完好。**它不验证配色观感,也不验证侧栏弹层能否正常打开。**
66
62
 
67
63
  ## 许可
68
64
 
package/client.js CHANGED
@@ -34,8 +34,7 @@ window.__ModuleLoader__.load({
34
34
  const DICT = {
35
35
  en: {
36
36
  title: 'UI Optimize',
37
- subtitle:
38
- 'Pick one theme and the whole interface follows. Each theme defines one palette for light and one for dark; switching Appearance between them carries the theme along — no separate version to pick.',
37
+ subtitle: 'Making the DSH interface pleasant to live in, one switch at a time.',
39
38
  defaultName: 'Default',
40
39
  defaultHint: 'Keep the current look',
41
40
  'section.theme': 'Theme',
@@ -57,6 +56,15 @@ window.__ModuleLoader__.load({
57
56
  'theme.rose.hint': 'Dusty rose — warm without being loud',
58
57
  applyFailed: 'The theme is not reaching the interface.',
59
58
  'section.desktop': 'Desktop actions',
59
+ 'section.sidebar': 'Sidebar',
60
+ 'sidebar.shelf': 'Panels',
61
+ 'sidebar.shelfEmpty': 'No matching panels',
62
+ 'sidebar.count': 'panels',
63
+ 'sidebar.search': 'Search panels…',
64
+ 'sidebar.hint': '↑↓ move · ↵ open · Esc close',
65
+ 'sidebar.more': 'More',
66
+ 'sidebar.switch': 'Fold the sidebar menu into one Panels entry',
67
+ 'sidebar.switchHint': 'The menu rows collapse into a single launcher that lists every panel; panels a future plugin registers show up on their own. Also makes the New Session button shorter',
60
68
  'desktop.label': 'Restart app',
61
69
  'desktop.hint': 'Restart DeepSeek Harness (app and Host)',
62
70
  'desktop.refresh': 'Reload UI',
@@ -82,8 +90,7 @@ window.__ModuleLoader__.load({
82
90
  },
83
91
  zh: {
84
92
  title: '界面优化',
85
- subtitle:
86
- '选一个主题,整个界面跟着换。每套主题为浅色与深色各定义一组配色,切换「外观」时自动跟随,不需要为两种模式各选一次。',
93
+ subtitle: '把 DSH 界面调得顺眼顺手,一个开关一件事。',
87
94
  defaultName: '默认',
88
95
  defaultHint: '保持当前外观',
89
96
  'section.theme': '主题',
@@ -105,6 +112,15 @@ window.__ModuleLoader__.load({
105
112
  'theme.rose.hint': '灰调玫瑰,暖而不吵',
106
113
  applyFailed: '主题未作用到界面。',
107
114
  'section.desktop': '桌面操作',
115
+ 'section.sidebar': '侧栏',
116
+ 'sidebar.shelf': '面板',
117
+ 'sidebar.shelfEmpty': '没有匹配的面板',
118
+ 'sidebar.count': '个面板',
119
+ 'sidebar.search': '搜索面板…',
120
+ 'sidebar.hint': '↑↓ 选择 · ↵ 打开 · Esc 关闭',
121
+ 'sidebar.more': '更多',
122
+ 'sidebar.switch': '把侧栏菜单收进「面板」',
123
+ 'sidebar.switchHint': '菜单行合并成一个入口,点开列出全部面板;新插件注册的面板会自动出现。同时把「新会话」按钮压低一点',
108
124
  'desktop.label': '重启应用',
109
125
  'desktop.hint': '重启 DeepSeek Harness(应用与 Host)',
110
126
  'desktop.refresh': '刷新界面',
@@ -383,7 +399,7 @@ window.__ModuleLoader__.load({
383
399
  * ------------------------------------------------------------------ */
384
400
 
385
401
  function defaultState() {
386
- return { version: 3, theme: null, reload: true, restart: true }
402
+ return { version: 4, theme: null, reload: true, restart: true, sidebar: false }
387
403
  }
388
404
 
389
405
  function normalize(stored) {
@@ -394,6 +410,7 @@ window.__ModuleLoader__.load({
394
410
  }
395
411
  if (typeof stored.reload === 'boolean') out.reload = stored.reload
396
412
  if (typeof stored.restart === 'boolean') out.restart = stored.restart
413
+ if (typeof stored.sidebar === 'boolean') out.sidebar = stored.sidebar
397
414
  return out
398
415
  }
399
416
 
@@ -790,6 +807,29 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
790
807
  }),
791
808
  ),
792
809
  ),
810
+ h(
811
+ 'div',
812
+ { className: 'dsuik-section' },
813
+ h('p', { className: 'dsuik-sectiontitle' }, translate('section.sidebar')),
814
+ h(
815
+ 'div',
816
+ { className: 'dsuik-row' },
817
+ h(
818
+ 'div',
819
+ { className: 'dsuik-rowtext' },
820
+ h('span', { className: 'dsuik-rowname' }, translate('sidebar.switch')),
821
+ h('span', { className: 'dsuik-rowhint' }, translate('sidebar.switchHint')),
822
+ ),
823
+ h(Switch, {
824
+ checked: state.sidebar === true,
825
+ disabled: !slotsCoreApi,
826
+ label: translate('sidebar.switch'),
827
+ onChange: function (next) {
828
+ store.setFlag('sidebar', next)
829
+ },
830
+ }),
831
+ ),
832
+ ),
793
833
  surface.controller && !surface.controller.active()
794
834
  ? h(
795
835
  'p',
@@ -1199,6 +1239,486 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
1199
1239
  )
1200
1240
  }
1201
1241
 
1242
+ /* ------------------------------------------------------------------ *
1243
+ * Sidebar panel shelf (feature 3)
1244
+ *
1245
+ * Modelled on dsh-sidebar-shelf: one native row registered into
1246
+ * `sidebar.panellist` becomes the launcher, one scoped rule hides the other
1247
+ * rows, and the popover lists every registered panel read live from
1248
+ * `entriesOfSlot` — so a panel a future plugin registers shows up on its own.
1249
+ *
1250
+ * Opening a panel goes through the official `ctx.layout.selectPanel(id)`;
1251
+ * no synthetic clicks on the shell's DOM.
1252
+ *
1253
+ * Degradation: the slots helper package is required lazily. If it is not
1254
+ * available, this feature stays off and every other feature is unaffected.
1255
+ * ------------------------------------------------------------------ */
1256
+
1257
+ const SHELF_ID = 'muik-panels'
1258
+ const SHELF_ATTR = 'data-muik-shelf'
1259
+ const SHELF_ROW_ATTR = 'data-muik-shelf-row'
1260
+
1261
+ let slotsCoreApi = null
1262
+ try {
1263
+ slotsCoreApi = require('@deepseek-ai/dsh-client-ui-slots')
1264
+ } catch (err) {
1265
+ slotsCoreApi = null
1266
+ }
1267
+
1268
+ let reactDomApi = null
1269
+ try {
1270
+ reactDomApi = require('react-dom')
1271
+ } catch (err) {
1272
+ reactDomApi = null
1273
+ }
1274
+
1275
+ const SHELF_CSS = `
1276
+ [${SHELF_ATTR}="on"] > nav > *:not([${SHELF_ROW_ATTR}]):not([data-muik-keep]){display:none!important}
1277
+ button.muik-shelf-row{display:flex;align-items:center;gap:10px;box-sizing:border-box;width:100%;height:36px;padding:0 10px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:13px;text-align:left;cursor:pointer}
1278
+ button.muik-shelf-row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1279
+ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4d6bfe);outline-offset:-2px}
1280
+ .muik-shelf-glyph{flex:none;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px}
1281
+ .muik-shelf-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1282
+ .muik-shelf-pop{position:fixed;z-index:2147483000;box-sizing:border-box;min-width:190px;max-height:min(60vh,420px);overflow:auto;padding:6px;border-radius:10px;background:var(--dsw-alias-bg-layer-1,#fff);border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.12));box-shadow:0 10px 28px rgba(0,0,0,.18);color:var(--dsw-alias-label-primary,inherit)}
1283
+ .muik-shelf-grid{display:grid;grid-template-columns:1fr 1fr;gap:2px;max-height:min(58vh,420px);overflow:auto;padding:2px;overscroll-behavior:contain}
1284
+ .muik-shelf-tile{display:flex;align-items:center;gap:8px;min-width:0;height:38px;padding:0 10px;border:0;border-radius:7px;background:transparent;color:inherit;font:inherit;font-size:13px;text-align:left;cursor:pointer}
1285
+ .muik-shelf-tile:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1286
+ .muik-shelf-tile:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4d6bfe);outline-offset:-2px}
1287
+ .muik-shelf-tileglyph{flex:none;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px}
1288
+ .muik-shelf-tile--wide{grid-column:1 / -1;margin-top:2px;border-top:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));border-radius:0 0 7px 7px}
1289
+ .muik-shelf-tilelabel{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1290
+ .muik-shelf-fallback{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:4px;background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.16));font-size:11px;font-weight:600}
1291
+ .muik-shelf-head{display:flex;align-items:baseline;gap:8px;padding:6px 8px 7px}
1292
+ .muik-shelf-title{flex:1;min-width:0;font-size:13px;font-weight:600;letter-spacing:.01em}
1293
+ .muik-shelf-meta{flex:none;font-size:11px;color:var(--dsw-alias-label-tertiary,inherit);font-variant-numeric:tabular-nums}
1294
+ .muik-shelf-search{padding:0 4px 6px}
1295
+ .muik-shelf-search input{box-sizing:border-box;width:100%;height:32px;padding:0 10px;border-radius:7px;border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.14));background:var(--dsw-alias-bg-layer-2,transparent);color:inherit;font:inherit;font-size:13px;outline:none}
1296
+ .muik-shelf-search input::placeholder{color:var(--dsw-alias-label-tertiary,#888)}
1297
+ .muik-shelf-hint{padding:6px 8px 4px;font-size:11px;color:var(--dsw-alias-label-tertiary,#888)}
1298
+ .muik-shelf-tile--focus{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12));outline:2px solid var(--dsw-alias-brand-primary,#4d6bfe);outline-offset:-2px}
1299
+ .muik-shelf-empty{padding:8px 10px;font-size:12px;color:var(--dsw-alias-label-secondary,inherit)}
1300
+ [${SHELF_ATTR}="on"] > button[class*="_newSession"]{height:30px!important;min-height:30px!important;max-height:30px!important}
1301
+ `
1302
+
1303
+ function readPanelEntries(slotsApi) {
1304
+ if (!slotsApi || typeof slotsApi.entriesOfSlot !== 'function') return []
1305
+ let registered = []
1306
+ try {
1307
+ registered = slotsApi.entriesOfSlot('sidebar.panellist') || []
1308
+ } catch (err) {
1309
+ return []
1310
+ }
1311
+ const out = []
1312
+ const seen = new Set()
1313
+ for (let i = 0; i < registered.length; i += 1) {
1314
+ const entry = registered[i]
1315
+ const options = entry && entry.options
1316
+ const id = options && options.id
1317
+ if (typeof id !== 'string' || id === SHELF_ID || seen.has(id)) continue
1318
+ seen.add(id)
1319
+ let label = id
1320
+ try {
1321
+ if (slotsCoreApi && typeof slotsCoreApi.resolveSlotLabel === 'function') {
1322
+ const resolved = slotsCoreApi.resolveSlotLabel(options.label)
1323
+ if (typeof resolved === 'string' && resolved.length > 0) label = resolved
1324
+ } else if (typeof options.label === 'function') {
1325
+ const resolved = options.label()
1326
+ if (typeof resolved === 'string' && resolved.length > 0) label = resolved
1327
+ } else if (typeof options.label === 'string') {
1328
+ label = options.label
1329
+ }
1330
+ } catch (err) {
1331
+ /* a malformed label must never hide a panel */
1332
+ }
1333
+ out.push({
1334
+ id: id,
1335
+ order: typeof options.order === 'number' ? options.order : 0,
1336
+ label: label,
1337
+ icon: entry.component,
1338
+ })
1339
+ }
1340
+ out.sort(function (a, b) {
1341
+ return a.order - b.order
1342
+ })
1343
+ return out
1344
+ }
1345
+
1346
+ /** One glyph from the panel's own slot component, with a safe fallback. */
1347
+ class GlyphBoundary extends React.Component {
1348
+ constructor(props) {
1349
+ super(props)
1350
+ this.state = { failed: false }
1351
+ }
1352
+ static getDerivedStateFromError() {
1353
+ return { failed: true }
1354
+ }
1355
+ componentDidCatch(error) {
1356
+ console.warn('[dsh-ui-optimize] panel icon failed, using fallback', error)
1357
+ }
1358
+ render() {
1359
+ return this.state.failed === true ? this.props.fallback : this.props.children
1360
+ }
1361
+ }
1362
+
1363
+ function PanelGlyph(props) {
1364
+ const panel = props.panel || {}
1365
+ const label = typeof panel.label === 'string' ? panel.label : ''
1366
+ const initial = label.length > 0 ? label.trim().slice(0, 1).toUpperCase() : '?'
1367
+ const fallback = h('span', { className: 'muik-shelf-fallback', 'aria-hidden': 'true' }, initial)
1368
+ const icon = panel.icon
1369
+ if (typeof icon !== 'function' && (typeof icon !== 'object' || icon === null)) return fallback
1370
+ return h(GlyphBoundary, { fallback: fallback }, h(icon, { size: 18, active: false }))
1371
+ }
1372
+
1373
+ function PanelsShelf(props) {
1374
+ const [state, setState] = React.useState(store.state)
1375
+ const [open, setOpen] = React.useState(false)
1376
+ const [panels, setPanels] = React.useState(function () {
1377
+ return readPanelEntries(props.slotsApi)
1378
+ })
1379
+ const [pos, setPos] = React.useState(null)
1380
+ const [query, setQuery] = React.useState('')
1381
+ const [focusIndex, setFocusIndex] = React.useState(-1)
1382
+ const inputRef = React.useRef(null)
1383
+ const tileRefs = React.useRef([])
1384
+ const glyphRef = React.useRef(null)
1385
+ const rowRef = React.useRef(null)
1386
+ const popRef = React.useRef(null)
1387
+ const toggleRef = React.useRef(null)
1388
+ const moreRef = React.useRef(null)
1389
+ const [hasMore, setHasMore] = React.useState(false)
1390
+ const enabled = state.sidebar === true
1391
+
1392
+ const needle = query.trim().toLowerCase()
1393
+ const filtered =
1394
+ needle.length === 0
1395
+ ? panels
1396
+ : panels.filter(function (panel) {
1397
+ return (
1398
+ String(panel.label).toLowerCase().indexOf(needle) !== -1 ||
1399
+ String(panel.id).toLowerCase().indexOf(needle) !== -1
1400
+ )
1401
+ })
1402
+
1403
+ React.useEffect(function () {
1404
+ return store.subscribe(function () {
1405
+ setState(store.state)
1406
+ })
1407
+ }, [])
1408
+
1409
+ React.useEffect(
1410
+ function () {
1411
+ const glyph = glyphRef.current
1412
+ // The shell wraps every panellist entry in its own <button> and draws the
1413
+ // label itself, so the row to mark is that wrapper — not our glyph.
1414
+ const row = glyph && typeof glyph.closest === 'function' ? glyph.closest('button') : null
1415
+ if (!row) return undefined
1416
+ const nav = row.parentElement
1417
+ const root = nav ? nav.parentElement : null
1418
+ if (!root) return undefined
1419
+ rowRef.current = row
1420
+ row.setAttribute(SHELF_ROW_ATTR, '')
1421
+ row.style.display = enabled ? '' : 'none'
1422
+ root.setAttribute(SHELF_ATTR, enabled ? 'on' : 'off')
1423
+
1424
+ // The shell appends its own "More" row after the registered rows, and its
1425
+ // menu holds content that is not a panellist entry. Hiding that row would
1426
+ // strand it, so it is kept visible whenever the actions list has entries.
1427
+ let keepRow = null
1428
+ try {
1429
+ const actions = props.slotsApi.entriesOfSlot('sidebar.panellist.actions') || []
1430
+ if (actions.length > 0) {
1431
+ const kids = nav.children
1432
+ for (let i = kids.length - 1; i >= 0; i -= 1) {
1433
+ if (kids[i] !== row) {
1434
+ keepRow = kids[i]
1435
+ // Kept visible on purpose. The shell's More menu only opens from a
1436
+ // trusted click: synthetic click(), full pointer sequences and a
1437
+ // re-shown row were each tried (0.9.13 / 0.9.23 / 0.9.24 / 0.9.25)
1438
+ // and none opened it, so the row keeps its own place instead of
1439
+ // being folded into the popover.
1440
+ keepRow.setAttribute('data-muik-keep', '')
1441
+ break
1442
+ }
1443
+ }
1444
+ }
1445
+ } catch (err) {
1446
+ keepRow = null
1447
+ }
1448
+ moreRef.current = null
1449
+ setHasMore(false)
1450
+
1451
+ // The row node is ours to keep only while React does not replace it, and a
1452
+ // replaced node silently loses its listener — the shell's own handler then
1453
+ // wins and selects a panel. Hold the latest toggle in a ref so the listener
1454
+ // itself never needs to be re-attached, and swallow the event completely.
1455
+ toggleRef.current = toggle
1456
+
1457
+ function onClick(event) {
1458
+ if (!enabled) return
1459
+ event.preventDefault()
1460
+ event.stopPropagation()
1461
+ if (typeof event.stopImmediatePropagation === 'function') event.stopImmediatePropagation()
1462
+ if (typeof toggleRef.current === 'function') toggleRef.current(row)
1463
+ }
1464
+ row.addEventListener('click', onClick, true)
1465
+
1466
+ /**
1467
+ * Safety net. Hiding rows is the only destructive thing this feature does,
1468
+ * and a bad measurement once left the whole column blank. If the column or
1469
+ * our own row has no measurable box shortly after mounting, put everything
1470
+ * back and leave the native sidebar alone — a degraded feature beats a
1471
+ * missing sidebar, and it recovers without the user touching anything.
1472
+ */
1473
+ function verify() {
1474
+ if (!enabled) return
1475
+ let healthy = true
1476
+ try {
1477
+ const rootRect = root.getBoundingClientRect()
1478
+ const rowRect = row.getBoundingClientRect()
1479
+ healthy = rootRect.width > 0 && rootRect.height > 0 && rowRect.height > 0
1480
+ } catch (err) {
1481
+ healthy = false
1482
+ }
1483
+ if (!healthy) {
1484
+ root.setAttribute(SHELF_ATTR, 'off')
1485
+ row.removeAttribute(SHELF_ROW_ATTR)
1486
+ row.style.display = ''
1487
+ }
1488
+ }
1489
+ const verifyTimer = window.setTimeout(verify, 400)
1490
+ window.addEventListener('resize', verify)
1491
+
1492
+ return function () {
1493
+ row.removeEventListener('click', onClick, true)
1494
+ window.clearTimeout(verifyTimer)
1495
+ window.removeEventListener('resize', verify)
1496
+ row.removeAttribute(SHELF_ROW_ATTR)
1497
+ row.style.display = ''
1498
+ if (keepRow) keepRow.removeAttribute('data-muik-keep')
1499
+ moreRef.current = null
1500
+ if (root.getAttribute(SHELF_ATTR) === 'on') root.setAttribute(SHELF_ATTR, 'off')
1501
+ rowRef.current = null
1502
+ }
1503
+ },
1504
+ [enabled],
1505
+ )
1506
+
1507
+ React.useEffect(
1508
+ function () {
1509
+ if (!open) return undefined
1510
+ function onPointerDown(event) {
1511
+ const inPop = popRef.current && popRef.current.contains(event.target)
1512
+ const inRow = rowRef.current && rowRef.current.contains(event.target)
1513
+ if (!inPop && !inRow) setOpen(false)
1514
+ }
1515
+ function onKeyDown(event) {
1516
+ if (event.key === 'Escape') {
1517
+ setOpen(false)
1518
+ return
1519
+ }
1520
+ if (filtered.length === 0) return
1521
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
1522
+ event.preventDefault()
1523
+ const step = event.key === 'ArrowDown' ? 1 : -1
1524
+ setFocusIndex(function (prev) {
1525
+ const next = prev + step
1526
+ if (next < 0) return filtered.length - 1
1527
+ if (next >= filtered.length) return 0
1528
+ return next
1529
+ })
1530
+ return
1531
+ }
1532
+ if (event.key === 'Enter') {
1533
+ const target = filtered[focusIndex >= 0 ? focusIndex : 0]
1534
+ if (target) {
1535
+ event.preventDefault()
1536
+ pick(target.id)
1537
+ }
1538
+ }
1539
+ }
1540
+ document.addEventListener('mousedown', onPointerDown, true)
1541
+ document.addEventListener('keydown', onKeyDown, true)
1542
+ return function () {
1543
+ document.removeEventListener('mousedown', onPointerDown, true)
1544
+ document.removeEventListener('keydown', onKeyDown, true)
1545
+ }
1546
+ },
1547
+ [open, filtered, focusIndex],
1548
+ )
1549
+
1550
+ function toggle(row) {
1551
+ const next = !open
1552
+ if (next) {
1553
+ setPanels(readPanelEntries(props.slotsApi))
1554
+ setQuery('')
1555
+ setFocusIndex(-1)
1556
+ if (row) {
1557
+ // Drop the card right under the row; alongside the rail when collapsed.
1558
+ const rect = row.getBoundingClientRect()
1559
+ const viewportWidth = window.innerWidth
1560
+ const viewportHeight = window.innerHeight
1561
+ const width = Math.min(300, viewportWidth - 24)
1562
+ const rail = rect.width < 80
1563
+ const preferredLeft = rail ? rect.right + 10 : rect.left
1564
+ const left = Math.min(Math.max(preferredLeft, 12), viewportWidth - width - 12)
1565
+ const top = Math.min(rect.bottom + 6, viewportHeight - 92)
1566
+ setPos({
1567
+ left: Math.round(left),
1568
+ top: Math.round(top),
1569
+ width: Math.round(width),
1570
+ })
1571
+ }
1572
+ }
1573
+ setOpen(next)
1574
+ }
1575
+
1576
+ function pick(id) {
1577
+ setOpen(false)
1578
+ try {
1579
+ props.selectPanel(id)
1580
+ } catch (err) {
1581
+ /* a panel that cannot be selected must not break the row */
1582
+ }
1583
+ }
1584
+
1585
+ /**
1586
+ * Hand a "More" click to the shell's own row button.
1587
+ *
1588
+ * The row is parked by a static stylesheet rule at --muik-more-x/y, so it keeps
1589
+ * a real (tiny) rect to anchor the shell's menu against while taking no space
1590
+ * in the column. Only two custom properties on <html> are written here, then
1591
+ * the button is clicked. No `display`, `position`, size or opacity is touched
1592
+ * at click time: mutating layout properties on a host node the shell is about
1593
+ * to re-render is exactly what collapsed the sidebar before.
1594
+ */
1595
+ function openMore() {
1596
+ const button = moreRef.current
1597
+ if (!button) return
1598
+ const x = pos ? pos.left : 12
1599
+ const y = pos ? pos.top : 120
1600
+ try {
1601
+ const style = document.documentElement.style
1602
+ style.setProperty('--muik-more-x', x + 'px')
1603
+ style.setProperty('--muik-more-y', y + 'px')
1604
+ } catch (err) {
1605
+ /* a missing coordinate only misplaces the menu, it never breaks the row */
1606
+ }
1607
+ // Click only. Replaying pointerdown/mousedown first made the shell open its
1608
+ // menu and immediately dismiss it again (its outside-press handler fires on
1609
+ // the bubbled mousedown). The menu itself is no longer clipped because the
1610
+ // parked row keeps `overflow: visible`.
1611
+ try {
1612
+ button.click()
1613
+ } catch (err) {
1614
+ /* the shell refusing to open its menu must not break the popover */
1615
+ }
1616
+ setOpen(false)
1617
+ }
1618
+
1619
+ const glyph = h(
1620
+ 'span',
1621
+ { ref: glyphRef, className: 'muik-shelf-glyph', 'aria-hidden': 'true' },
1622
+ h(
1623
+ 'svg',
1624
+ { viewBox: '0 0 16 16', width: 18, height: 18, fill: 'currentColor' },
1625
+ h('rect', { x: 1.5, y: 2.5, width: 5, height: 5, rx: 1.2 }),
1626
+ h('rect', { x: 9.5, y: 2.5, width: 5, height: 5, rx: 1.2 }),
1627
+ h('rect', { x: 1.5, y: 9.5, width: 5, height: 5, rx: 1.2 }),
1628
+ h('rect', { x: 9.5, y: 9.5, width: 5, height: 5, rx: 1.2 }),
1629
+ ),
1630
+ )
1631
+
1632
+ if (!open || !pos) return glyph
1633
+
1634
+ const popover = h(
1635
+ 'div',
1636
+ {
1637
+ ref: popRef,
1638
+ className: 'muik-shelf-pop',
1639
+ style: {
1640
+ left: pos.left + 'px',
1641
+ top: pos.top + 'px',
1642
+ width: pos.width ? pos.width + 'px' : undefined,
1643
+ },
1644
+ },
1645
+ h(
1646
+ 'div',
1647
+ { className: 'muik-shelf-head' },
1648
+ h('span', { className: 'muik-shelf-title' }, translate('sidebar.shelf')),
1649
+ h('span', { className: 'muik-shelf-meta' }, filtered.length + ' ' + translate('sidebar.count')),
1650
+ ),
1651
+ panels.length > 7
1652
+ ? h(
1653
+ 'div',
1654
+ { className: 'muik-shelf-search' },
1655
+ h('input', {
1656
+ ref: inputRef,
1657
+ type: 'text',
1658
+ value: query,
1659
+ placeholder: translate('sidebar.search'),
1660
+ autoFocus: true,
1661
+ onChange: function (event) {
1662
+ setQuery(event.target.value)
1663
+ setFocusIndex(-1)
1664
+ },
1665
+ }),
1666
+ )
1667
+ : null,
1668
+ filtered.length === 0
1669
+ ? h('div', { className: 'muik-shelf-empty' }, translate('sidebar.shelfEmpty'))
1670
+ : h(
1671
+ 'div',
1672
+ { className: 'muik-shelf-grid' },
1673
+ filtered.map(function (panel, index) {
1674
+ return h(
1675
+ 'button',
1676
+ {
1677
+ key: panel.id,
1678
+ ref: function (node) {
1679
+ tileRefs.current[index] = node
1680
+ },
1681
+ type: 'button',
1682
+ className:
1683
+ 'muik-shelf-tile' + (index === focusIndex ? ' muik-shelf-tile--focus' : ''),
1684
+ title: panel.label,
1685
+ onMouseEnter: function () {
1686
+ setFocusIndex(index)
1687
+ },
1688
+ onClick: function () {
1689
+ pick(panel.id)
1690
+ },
1691
+ },
1692
+ h('span', { className: 'muik-shelf-tileglyph' }, h(PanelGlyph, { panel: panel })),
1693
+ h('span', { className: 'muik-shelf-tilelabel' }, panel.label),
1694
+ )
1695
+ }),
1696
+ hasMore
1697
+ ? h(
1698
+ 'button',
1699
+ {
1700
+ type: 'button',
1701
+ className: 'muik-shelf-tile muik-shelf-tile--wide',
1702
+ title: translate('sidebar.more'),
1703
+ onClick: function () {
1704
+ openMore()
1705
+ },
1706
+ },
1707
+ h('span', { className: 'muik-shelf-tilelabel' }, translate('sidebar.more')),
1708
+ )
1709
+ : null,
1710
+ ),
1711
+ h('div', { className: 'muik-shelf-hint' }, translate('sidebar.hint')),
1712
+ )
1713
+
1714
+ const portal =
1715
+ reactDomApi && typeof reactDomApi.createPortal === 'function'
1716
+ ? reactDomApi.createPortal(popover, document.body)
1717
+ : popover
1718
+
1719
+ return h(React.Fragment, null, glyph, portal)
1720
+ }
1721
+
1202
1722
  /* ------------------------------------------------------------------ *
1203
1723
  * Plugin
1204
1724
  * ------------------------------------------------------------------ */
@@ -1289,6 +1809,43 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
1289
1809
  }
1290
1810
  }, 'dsh-ui-optimize: theme layer')
1291
1811
 
1812
+ /* Feature 3. Skipped entirely when the slots helper package is unavailable,
1813
+ * so a missing optional dependency can never take the whole plugin down. */
1814
+ if (slotsCoreApi) {
1815
+ ctx.effect(function () {
1816
+ const style = document.createElement('style')
1817
+ style.setAttribute('data-dsh-ui-optimize', 'sidebar-shelf')
1818
+ style.textContent = SHELF_CSS
1819
+ document.head.appendChild(style)
1820
+ return function () {
1821
+ style.remove()
1822
+ }
1823
+ }, 'dsh-ui-optimize: sidebar shelf styles')
1824
+
1825
+ ctx.slots.inject('sidebar.panellist', function () {
1826
+ return ctx.slots.register(
1827
+ {
1828
+ name: 'sidebar.panellist',
1829
+ id: SHELF_ID,
1830
+ order: -1000,
1831
+ label: function () {
1832
+ return translate('sidebar.shelf')
1833
+ },
1834
+ inject: function () {
1835
+ return {
1836
+ slotsApi: ctx.slots,
1837
+ selectPanel: function (id) {
1838
+ const layout = typeof ctx.get === 'function' ? ctx.get('layout') : undefined
1839
+ if (layout && typeof layout.selectPanel === 'function') layout.selectPanel(id)
1840
+ },
1841
+ }
1842
+ },
1843
+ },
1844
+ PanelsShelf,
1845
+ )
1846
+ })
1847
+ }
1848
+
1292
1849
  ctx.slots.inject('settings.section', function () {
1293
1850
  return ctx.slots.register(
1294
1851
  {
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-ui-optimize",
4
- "description": "Minimalist theme gallery for the DSH interface: pick one card in Settings and the whole UI re-colours at once — no per-token tuning. Eight themes — Celadon, Linen, Cream, Graphite, Indigo, Slate, Sage, Rose — each define one palette for light and one for dark and follow the Appearance setting automatically. Choosing Default restores the original look. Colours travel only through the theme token layer, so an upstream redesign cannot break the layout or the plugin."
4
+ "description": "Optimizes how DeepSeek Harness looks and behaves across the whole interface, not just a few screens: the switches are meant to grow with the shell, and every one of them can be turned off on its own. Today it carries a minimalist theme gallery — Celadon, Linen, Cream, Graphite, Indigo, Slate, Sage, Rose — where each theme defines one palette for light and one for dark, follows the Appearance setting, and re-colours the interface through a single theme-token layer so an upstream redesign cannot break the layout; plus folding the sidebar panel rows into one Panels entry that opens a two-column launcher with search and keyboard control. The sidebar launcher follows the pattern of the community plugin dsh-sidebar-shelf (github.com/wumouren114/dsh-sidebar-shelf)."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-ui-optimize",
4
- "description": "给 DSH 界面换主题的极简插件:设置页里只有一排主题卡片,点一下整套界面配色跟着换,不必逐个去调颜色。内置 8 套主题——青瓷、亚麻、奶油、石墨、靛蓝、雾蓝、苔绿、玫瑰,每套为浅色与深色各定义一组配色、切换外观时自动跟随;选「默认」即恢复原生外观。配色只走主题变量层、不注入结构性样式,上游改版不会把界面弄坏。"
4
+ "description": "优化的是 DeepSeek Harness 的整体观感与操作,不局限于某几个界面;开关会随宿主长出的新能力继续增加,每一项都能单独关掉。目前包含:8 套极简主题的画廊——青瓷、亚麻、奶油、石墨、靛蓝、雾蓝、苔绿、玫瑰,每套为浅色与深色各定义一组配色并跟随「外观」设置,配色只走单一主题变量层,上游改版不会把界面弄坏;以及把侧栏面板行收成一个「面板」入口,点开是两列启动面板,带搜索与键盘操作。侧栏启动面板的做法参考社区插件 dsh-sidebar-shelf(github.com/wumouren114/dsh-sidebar-shelf)。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@moonsand/dsh-ui-optimize",
3
- "version": "0.8.4",
3
+ "version": "0.9.27",
4
4
  "type": "module",
5
- "description": "Two features for the DSH web interface, each with its own switch: a minimalist theme gallery (eight themes, one palette for light and one for dark) and the desktop Reload/Restart actions at the sidebar foot. · DSH 界面优化:8 套极简主题(浅色与深色各一组配色)+ 侧栏底部的刷新/重启按钮,两个功能各有独立开关。",
5
+ "description": "Switches that tune how DeepSeek Harness looks and behaves across the whole interface, not just a few screens — each works on its own and more arrive as the shell grows. Sidebar launcher pattern from dsh-sidebar-shelf (github.com/wumouren114/dsh-sidebar-shelf). · 调 DeepSeek Harness 整体观感与操作的开关集合,管的是整套界面而不只是某几块;每个开关独立生效,随宿主能力增长继续增加。侧栏启动面板的做法参考 dsh-sidebar-shelf(github.com/wumouren114/dsh-sidebar-shelf)。",
6
6
  "license": "MIT",
7
7
  "author": "MoonSand",
8
8
  "publishConfig": {