@moonsand/dsh-ui-optimize 0.9.27 → 0.9.28

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
@@ -4,7 +4,7 @@ English | [中文](README.zh.md)
4
4
 
5
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
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.
7
+ Today: a **theme gallery** of eight minimalist themes (each defining one palette for light and one for dark), **sidebar panel folding** — the panel rows collapse into a single **Panels** entry that opens a two-column launcher — and the **desktop Reload/Restart buttons** at the sidebar foot.
8
8
 
9
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.
10
10
 
@@ -20,6 +20,13 @@ Open **Settings → UI Optimize**.
20
20
 
21
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.
22
22
 
23
+ ### Desktop actions
24
+
25
+ Two switches control the sidebar-foot buttons:
26
+
27
+ - **Reload UI** — reloads the page and client plugins only; the Host and running tasks keep going
28
+ - **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
29
+
23
30
  ### Sidebar
24
31
 
25
32
  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.
@@ -33,6 +40,8 @@ The launcher follows the pattern of the community plugin [dsh-sidebar-shelf](htt
33
40
  ## Known limitations
34
41
 
35
42
  - The theme choice lives in browser `localStorage`; it is lost with the browser profile or site data
43
+ - Restart works only in the desktop app; a browser session can only reload
44
+ - The restart action is a process-level operation that cannot be verified automatically
36
45
  - The **More** row is not folded; it stays in the native rail
37
46
  - The launcher keeps the shell's own panel order — it does not sort, pin or reorder
38
47
  - The **More** row is not folded; it stays in the native rail
package/README.zh.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  一组用来调 DeepSeek Harness 观感与操作的开关——管的是整套界面,不是某几块屏幕。每个开关单独生效,宿主长出新能力时会继续增加。
6
6
 
7
- 目前包含:**主题画廊**(8 套极简主题,浅色与深色各定义一组配色),以及**侧栏收纳**(面板行收成一个「面板」入口,点开是两列启动面板)。
7
+ 目前包含:**主题画廊**(8 套极简主题,浅色与深色各定义一组配色)、**侧栏收纳**(面板行收成一个「面板」入口,点开是两列启动面板),以及侧栏底部的**桌面刷新/重启按钮**。
8
8
 
9
9
  配色只通过 `ctx.theme.overrideTokens` 以**单层**覆盖主题变量,不注入任何结构性 CSS、不读写其他插件的 DOM,所以宿主改版最多让颜色不生效,不会把界面layout弄坏。
10
10
 
@@ -35,6 +35,13 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
35
35
 
36
36
  选「默认」恢复原生外观。每套主题为浅色与深色各定义一组配色,切换「外观」里的浅色/深色时自动跟随,不需要为两种模式各选一次。
37
37
 
38
+ ### 桌面操作
39
+
40
+ 两个开关分别控制侧栏底部的「刷新界面」与「重启应用」按钮:
41
+
42
+ - **刷新界面**:只重新加载页面与客户端插件,Host 与正在跑的任务不受影响
43
+ - **重启应用**:重启整个应用(含 Host),会中断当前对话;**仅桌面端可用**,网页端降级为刷新页面
44
+
38
45
  ### 侧栏
39
46
 
40
47
  一个开关把左侧竖栏里的面板行收成一个「面板」入口。点开是两列启动面板:图标、标题与数量、面板多于 7 个时出现搜索框,并支持键盘操作(↑ ↓ 移动、回车打开、Esc 关闭)。之后才注册的面板——包括其他插件加进来的——在下次打开时自动出现,不会漏。
@@ -48,6 +55,8 @@ dsh plugin 或 GUI 插件管理:安装 @moonsand/dsh-ui-optimize
48
55
  ## 已知限制
49
56
 
50
57
  - 主题选择保存在浏览器 `localStorage`,换机器或清站点数据会丢失
58
+ - 重启只适用于桌面端;网页端只能刷新
59
+ - 重启动作为进程级操作,无法在自动化测试中验证,只能人工点一次确认
51
60
  - 「更多」没有收进弹层,仍在原生竖栏里
52
61
  - 弹层沿用宿主自己的面板顺序,不排序、不置顶、不重排
53
62
  - 侧栏收纳与 `dsh-sidebar-shelf` 改的是同一根竖栏,两个只能开一个
package/client.js CHANGED
@@ -65,6 +65,7 @@ window.__ModuleLoader__.load({
65
65
  'sidebar.more': 'More',
66
66
  'sidebar.switch': 'Fold the sidebar menu into one Panels entry',
67
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',
68
+ 'sidebar.unavailable': 'This build does not expose the slot API the launcher needs, so folding stays off.',
68
69
  'desktop.label': 'Restart app',
69
70
  'desktop.hint': 'Restart DeepSeek Harness (app and Host)',
70
71
  'desktop.refresh': 'Reload UI',
@@ -121,6 +122,7 @@ window.__ModuleLoader__.load({
121
122
  'sidebar.more': '更多',
122
123
  'sidebar.switch': '把侧栏菜单收进「面板」',
123
124
  'sidebar.switchHint': '菜单行合并成一个入口,点开列出全部面板;新插件注册的面板会自动出现。同时把「新会话」按钮压低一点',
125
+ 'sidebar.unavailable': '当前版本取不到槽位接口,收纳功能用不了,所以保持关闭。',
124
126
  'desktop.label': '重启应用',
125
127
  'desktop.hint': '重启 DeepSeek Harness(应用与 Host)',
126
128
  'desktop.refresh': '刷新界面',
@@ -448,8 +450,39 @@ window.__ModuleLoader__.load({
448
450
  }
449
451
  }
450
452
 
453
+ /* Which shell this page is running in, and therefore what it can actually do.
454
+ *
455
+ * A feature is only offered when the current environment can honour it: the
456
+ * desktop app can restart its own process, a browser session cannot. The rule
457
+ * lives in one table so a new feature declares its requirement instead of
458
+ * each switch inventing its own check. */
459
+ const FEATURES = {
460
+ theme: { envs: ['desktop', 'web'] },
461
+ reload: { envs: ['desktop', 'web'] },
462
+ restart: { envs: ['desktop'], reason: 'desktop.restartNotDesktop' },
463
+ sidebar: { envs: ['desktop', 'web'], reason: 'sidebar.unavailable' },
464
+ }
465
+
466
+ /* The single answer to "can this shell run this feature". Callers render the
467
+ * switch greyed out and print `reason` when `available` is false.
468
+ *
469
+ * `unknown` means the probe has not answered yet (or its route is missing);
470
+ * features stay usable then, because a transient network failure must not
471
+ * disable a working feature. */
472
+ function featureGate(name, env) {
473
+ const spec = FEATURES[name]
474
+ if (!spec) return { available: true, reason: '' }
475
+ if (env !== 'desktop' && env !== 'web') return { available: true, reason: '' }
476
+ if (spec.envs.indexOf(env) === -1) {
477
+ return { available: false, reason: translate(spec.reason) }
478
+ }
479
+ return { available: true, reason: '' }
480
+ }
481
+
451
482
  const store = {
452
483
  state: normalize(readStored()),
484
+ /* Describes the running process, not a preference — never persisted. */
485
+ env: 'unknown',
453
486
  listeners: new Set(),
454
487
  subscribe(listener) {
455
488
  store.listeners.add(listener)
@@ -457,6 +490,24 @@ window.__ModuleLoader__.load({
457
490
  store.listeners.delete(listener)
458
491
  }
459
492
  },
493
+ notify() {
494
+ /* Fresh identity so subscribers that store the state object re-render. */
495
+ store.state = Object.assign({}, store.state)
496
+ const snapshot = Array.from(store.listeners)
497
+ for (let i = 0; i < snapshot.length; i += 1) {
498
+ try {
499
+ snapshot[i]()
500
+ } catch (err) {
501
+ /* a broken subscriber must not block the others */
502
+ }
503
+ }
504
+ },
505
+ setEnv(value) {
506
+ if (value !== 'desktop' && value !== 'web') return
507
+ if (store.env === value) return
508
+ store.env = value
509
+ store.notify()
510
+ },
460
511
  setTheme(key) {
461
512
  publish(
462
513
  Object.assign({}, store.state, {
@@ -466,6 +517,9 @@ window.__ModuleLoader__.load({
466
517
  )
467
518
  },
468
519
  setFlag(name, value) {
520
+ /* Hard gate: a feature this shell cannot run never turns on, even when
521
+ * something other than the switch calls this directly. */
522
+ if (value === true && !featureGate(name, store.env).available) return
469
523
  const next = Object.assign({}, store.state, { version: 3 })
470
524
  next[name] = value === true
471
525
  publish(next)
@@ -625,6 +679,8 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
625
679
  role: 'switch',
626
680
  'aria-checked': props.checked ? 'true' : 'false',
627
681
  'aria-label': props.label,
682
+ 'aria-disabled': disabled ? 'true' : 'false',
683
+ title: disabled && props.title ? props.title : props.hint || props.label,
628
684
  disabled: disabled,
629
685
  className:
630
686
  'dsuik-switch' + (props.checked ? ' is-on' : '') + (disabled ? ' is-disabled' : ''),
@@ -664,8 +720,14 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
664
720
 
665
721
  function SettingsPage() {
666
722
  const [state, setState] = React.useState(store.state)
667
- const [restartUnavailable, setRestartUnavailable] = React.useState(false)
668
723
  const [legacyPresent, setLegacyPresent] = React.useState(false)
724
+ const env = store.env
725
+ const restartGate = featureGate('restart', env)
726
+ /* The shelf also needs the slot API: without it the switch stays off and
727
+ * says why, instead of offering something that cannot work. */
728
+ const sidebarGate = slotsCoreApi
729
+ ? featureGate('sidebar', env)
730
+ : { available: false, reason: translate('sidebar.unavailable') }
669
731
 
670
732
  React.useEffect(function () {
671
733
  return store.subscribe(function () {
@@ -673,21 +735,22 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
673
735
  })
674
736
  }, [])
675
737
 
676
- /* Ask the Host once whether this page is the desktop shell. A browser session
677
- * cannot restart anything, so the switch should say so up front instead of
678
- * leaving the user to discover it on the first click. */
738
+ /* The probe runs at plugin start; if it failed there (a transient network
739
+ * error), retry once when the settings page opens — but never override a
740
+ * known answer. */
679
741
  React.useEffect(function () {
742
+ if (env !== 'unknown') return undefined
680
743
  let alive = true
681
744
  void readStatus().then(function (status) {
682
745
  if (!alive) return
683
746
  if (status && typeof status.desktop === 'boolean') {
684
- setRestartUnavailable(status.desktop !== true)
747
+ store.setEnv(status.desktop === true ? 'desktop' : 'web')
685
748
  }
686
749
  })
687
750
  return function () {
688
751
  alive = false
689
752
  }
690
- }, [])
753
+ }, [env])
691
754
 
692
755
  /* The standalone plugin owns the original route prefix. If it is still
693
756
  * loaded, both plugins draw footer buttons — say so instead of leaving the
@@ -791,15 +854,16 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
791
854
  h('span', { className: 'dsuik-rowname' }, translate('desktop.restartSwitch')),
792
855
  h(
793
856
  'span',
794
- { className: 'dsuik-rowhint' + (restartUnavailable ? ' is-warn' : '') },
795
- restartUnavailable
796
- ? translate('desktop.restartNotDesktop')
797
- : translate('desktop.restartSwitchHint'),
857
+ { className: 'dsuik-rowhint' + (restartGate.available ? '' : ' is-warn') },
858
+ restartGate.available
859
+ ? translate('desktop.restartSwitchHint')
860
+ : restartGate.reason,
798
861
  ),
799
862
  ),
800
863
  h(Switch, {
801
864
  checked: state.restart === true,
802
- disabled: restartUnavailable,
865
+ disabled: !restartGate.available,
866
+ title: restartGate.reason,
803
867
  label: translate('desktop.restartSwitch'),
804
868
  onChange: function (next) {
805
869
  store.setFlag('restart', next)
@@ -818,11 +882,18 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
818
882
  'div',
819
883
  { className: 'dsuik-rowtext' },
820
884
  h('span', { className: 'dsuik-rowname' }, translate('sidebar.switch')),
821
- h('span', { className: 'dsuik-rowhint' }, translate('sidebar.switchHint')),
885
+ h(
886
+ 'span',
887
+ { className: 'dsuik-rowhint' + (sidebarGate.available ? '' : ' is-warn') },
888
+ sidebarGate.available
889
+ ? translate('sidebar.switchHint')
890
+ : sidebarGate.reason,
891
+ ),
822
892
  ),
823
893
  h(Switch, {
824
894
  checked: state.sidebar === true,
825
- disabled: !slotsCoreApi,
895
+ disabled: !sidebarGate.available,
896
+ title: sidebarGate.reason,
826
897
  label: translate('sidebar.switch'),
827
898
  onChange: function (next) {
828
899
  store.setFlag('sidebar', next)
@@ -1151,6 +1222,7 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
1151
1222
  }
1152
1223
 
1153
1224
  function onClick() {
1225
+ if (props.unavailable === true) return
1154
1226
  if (phase === 'restarting') return
1155
1227
  if (phase === 'confirm') {
1156
1228
  void restart()
@@ -1183,9 +1255,14 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
1183
1255
  type: 'button',
1184
1256
  className: 'dsuik-dsr-btn',
1185
1257
  'data-phase': phase,
1186
- disabled: phase === 'restarting',
1258
+ disabled: phase === 'restarting' || props.unavailable === true,
1187
1259
  'aria-label': translate('desktop.label'),
1188
- title: note === '' ? translate('desktop.hint') : note,
1260
+ title:
1261
+ props.unavailable === true
1262
+ ? props.reason || translate('desktop.restartNotDesktop')
1263
+ : note === ''
1264
+ ? translate('desktop.hint')
1265
+ : note,
1189
1266
  onClick: onClick,
1190
1267
  onKeyDown: onKeyDown,
1191
1268
  },
@@ -1230,12 +1307,19 @@ body:not([data-ds-dark-theme]) .dsuik-mc > .dsuik-mc-b{display:none;}
1230
1307
  const wide = props.wide !== false
1231
1308
  const showReload = state.reload === true
1232
1309
  const showRestart = state.restart === true
1310
+ const restartGate = featureGate('restart', store.env)
1233
1311
  if (!showReload && !showRestart) return null
1234
1312
  return h(
1235
1313
  'div',
1236
1314
  { className: 'dsuik-dsr-group' },
1237
1315
  showReload ? h(RefreshButton, { wide: wide }) : null,
1238
- showRestart ? h(RestartButton, { wide: wide }) : null,
1316
+ showRestart
1317
+ ? h(RestartButton, {
1318
+ wide: wide,
1319
+ unavailable: !restartGate.available,
1320
+ reason: restartGate.reason,
1321
+ })
1322
+ : null,
1239
1323
  )
1240
1324
  }
1241
1325
 
@@ -1746,6 +1830,23 @@ button.muik-shelf-row:focus-visible{outline:2px solid var(--dsw-alias-brand-prim
1746
1830
  /* keep the built-in dictionary */
1747
1831
  }
1748
1832
 
1833
+ /* Detect the shell once, before anything is drawn: a desktop app can
1834
+ * restart its own process, a browser session cannot. Switches read this
1835
+ * from the store, so the first render already greys out what this
1836
+ * environment cannot do and prints the reason next to it. */
1837
+ ctx.effect(function () {
1838
+ let alive = true
1839
+ void readStatus().then(function (status) {
1840
+ if (!alive) return
1841
+ if (status && typeof status.desktop === 'boolean') {
1842
+ store.setEnv(status.desktop === true ? 'desktop' : 'web')
1843
+ }
1844
+ })
1845
+ return function () {
1846
+ alive = false
1847
+ }
1848
+ })
1849
+
1749
1850
  /* The client tree may still be composing when this plugin mounts, so the
1750
1851
  * theme service can be unreachable on the first attempt. Retry briefly
1751
1852
  * instead of staying silently unapplied for the whole page session, and
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-ui-optimize",
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)."
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."
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": "优化的是 DeepSeek Harness 的整体观感与操作,不局限于某几个界面;开关会随宿主长出的新能力继续增加,每一项都能单独关掉。目前包含:8 套极简主题的画廊——青瓷、亚麻、奶油、石墨、靛蓝、雾蓝、苔绿、玫瑰,每套为浅色与深色各定义一组配色并跟随「外观」设置,配色只走单一主题变量层,上游改版不会把界面弄坏;以及把侧栏面板行收成一个「面板」入口,点开是两列启动面板,带搜索与键盘操作。侧栏启动面板的做法参考社区插件 dsh-sidebar-shelf(github.com/wumouren114/dsh-sidebar-shelf)。"
4
+ "description": "优化的是 DeepSeek Harness 的整体观感与操作,不局限于某几个界面;开关会随宿主长出的新能力继续增加,每一项都能单独关掉。目前包含:8 套极简主题的画廊——青瓷、亚麻、奶油、石墨、靛蓝、雾蓝、苔绿、玫瑰,每套为浅色与深色各定义一组配色并跟随「外观」设置,配色只走单一主题变量层,上游改版不会把界面弄坏;以及把侧栏面板行收成一个「面板」入口,点开是两列启动面板,带搜索与键盘操作。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@moonsand/dsh-ui-optimize",
3
- "version": "0.9.27",
3
+ "version": "0.9.28",
4
4
  "type": "module",
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)。",
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. · 调 DeepSeek Harness 整体观感与操作的开关集合,管的是整套界面而不只是某几块;每个开关独立生效,随宿主能力增长继续增加。",
6
6
  "license": "MIT",
7
7
  "author": "MoonSand",
8
8
  "publishConfig": {