@restregular/dsh-powerup 0.4.1 → 0.5.1

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
@@ -30,16 +30,22 @@ Right-click empty space in the ledger:
30
30
  - **Open the Power-Up page** — the sidebar control panel.
31
31
 
32
32
  The sidebar **Power-Up** page turns the menu on or off and lists the available
33
- actions. The setting is stored in the browser.
33
+ actions. The setting is stored in the browser. It also holds the defaults for
34
+ **one-click update** (auto-enable and auto-restart), which the plugin updater
35
+ uses.
34
36
 
35
37
  ### Stop a background job with a reason
36
38
 
37
39
  The session header's background jobs panel keeps the host's list, live output,
38
- and stop button. Clicking a running job's stop button opens a small Power-Up
39
- dialog instead of the host's two-press stop:
40
+ and stop button. Clicking a running job's stop button opens a themed Power-Up
41
+ dialog instead of the host's two-press stop. The dialog is portaled to the
42
+ document body, so it renders above the jobs menu (which is itself a body portal)
43
+ and is not clipped by any slot's stacking context; its colors come only from
44
+ `--dsw-alias-*` tokens, so light and dark themes both work.
40
45
 
41
46
  - The reason field is optional; an empty field keeps the host's default
42
- `cancelled by the user` reason.
47
+ `cancelled by the user` reason. A live character counter shows the 200-character
48
+ limit, and `Enter` confirms while `Esc` cancels.
43
49
  - Confirming stops the job through the Host route, which records
44
50
  `cancelled by the user: <reason>`. The completion notice injected into the
45
51
  session and the shell tool's result therefore carry the reason.
@@ -64,18 +70,25 @@ update dialog:
64
70
  2. Type a version or pick one from the floating version list. The current
65
71
  installed version is tagged **Current**; the newest is tagged **latest**, and
66
72
  a version that is both uses one **Current · latest** tag.
67
- 3. Confirming removes the installed copy, checks the new spec the way **Add
68
- plugin** does, and installs the selected version without enabling it.
69
- Because the old copy is already gone at that point, a refused check or a
73
+ 3. **One-click update** installs the newest version and skips both questions:
74
+ by default the new copy is enabled and DSH restarts automatically. The
75
+ Power-Up page can turn either default off. With auto-enable off, the new
76
+ version is left disabled and nothing restarts. With auto-restart off (or when
77
+ the current runtime cannot restart itself), the completion panel closes
78
+ itself after a few seconds instead of staying on screen. Power-Up's own
79
+ update keeps its background handoff and does not offer one-click.
80
+ 4. Otherwise, confirming removes the installed copy, checks the new spec the
81
+ way **Add plugin** does, and installs the selected version without enabling
82
+ it. Because the old copy is already gone at that point, a refused check or a
70
83
  failed install automatically re-installs the removed version with its
71
84
  previous enabled state; the dialog reports both the failure and the rollback
72
85
  result.
73
- 4. The dialog then asks whether to enable the new version.
74
- 5. After enabling, it asks whether to restart DSH. On the desktop app the
86
+ 5. The dialog then asks whether to enable the new version.
87
+ 6. After enabling, it asks whether to restart DSH. On the desktop app the
75
88
  `lib/restart-helper.cjs` helper relaunches the exact executable after the old
76
89
  Host exits; under `dsh web` the dialog explains that the terminal owns the
77
90
  process.
78
- 6. A management call that reports `restart-required` keeps a **Restart needed**
91
+ 7. A management call that reports `restart-required` keeps a **Restart needed**
79
92
  tag on the card and adds the plugin to the count beside the **Installed
80
93
  plugins** heading. The heading bar is always present — with **No plugins need
81
94
  a restart** and the restart button when nothing is pending — and a **Restart
@@ -84,11 +97,11 @@ update dialog:
84
97
  the built-in **Add plugin** / **Update** UI, or before this page loaded, are
85
98
  marked too.
86
99
 
87
- Power-Up updates itself through the same dialog. Because removing the plugin
88
- unloads this panel, the Host answers first and then hands `removeBundle` →
89
- `inspect` → `installBundle(enabled: true)` to the built-in manager service,
90
- which keeps running after the Power-Up Host fiber is unloaded. The panel closes;
91
- refresh the page when the install finishes.
100
+ Power-Up updates itself through the same dialog (the one-click action is hidden
101
+ for itself). Because removing the plugin unloads this panel, the Host answers
102
+ first and then hands `removeBundle` → `inspect` → `installBundle(enabled: true)`
103
+ to the built-in manager service, which keeps running after the Power-Up Host
104
+ fiber is unloaded. The panel closes; refresh the page when the install finishes.
92
105
 
93
106
  ## Design notes
94
107
 
@@ -131,6 +144,21 @@ refresh the page when the install finishes.
131
144
  `~/.dsh/powerup/self-update.log`. The Host captures the version it was loaded
132
145
  from before removal and re-installs that version if the check or install
133
146
  fails, so a failed self-update does not leave Power-Up missing.
147
+ - **One-click update is a client-side decision.** The newest version and both
148
+ defaults live in the shared settings store (`dsh-powerup:settings:v1`), so the
149
+ Power-Up page and an open dialog agree without a reload. A one-click run
150
+ installs disabled — the same shape as **Add plugin** — then enables through
151
+ `setBundleEnabled`, and posts the restart only when the defaults allow it. With
152
+ auto-enable off the new copy stays disabled and nothing restarts. When no
153
+ restart happens the completion panel closes on a timer; install, enable, and
154
+ restart failures stay on screen with their reason instead.
155
+ - **The stop dialog is a body portal.** `shell.overlay` is an absolute layer at
156
+ `z-index: 20`, and the host jobs menu is a `document.body` portal at
157
+ `z-index: 100`; a high z-index inside the overlay layer therefore still loses.
158
+ The reason popover is rendered through `react-dom`'s `createPortal` into
159
+ `document.body`, uses `z-index: 1400`, and draws its icon chip, input, error
160
+ strip, and solid confirm button from host tokens, so it stays readable in both
161
+ themes. Without `react-dom` it falls back to in-place rendering.
134
162
  - **Restart status lives in this browser session.** A management result that
135
163
  says `restart-required` is written to `sessionStorage`; the card gets a
136
164
  **Restart needed** tag and the group heading gets a count plus a restart
package/client.js CHANGED
@@ -41,12 +41,39 @@
41
41
  const React = require('react');
42
42
  const h = React.createElement;
43
43
  const { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } = React;
44
+ // react-dom is a seed module in the host's ModuleLoader (the built-in
45
+ // Client packages require it too). Fall back to in-place rendering when
46
+ // it is missing, so an older host loses layering but keeps working.
47
+ const createPortal = (() => {
48
+ try {
49
+ const dom = require('react-dom');
50
+ return dom !== null && dom !== undefined && typeof dom.createPortal === 'function' ? dom.createPortal : null;
51
+ } catch {
52
+ return null;
53
+ }
54
+ })();
55
+
56
+ /**
57
+ * Render a floating panel at the document root. Slot containers own
58
+ * stacking contexts (`position:fixed; z-index:…`), so a high z-index
59
+ * inside a slot still loses to a body-level popover such as the jobs menu.
60
+ * Portaling escapes that context; without react-dom the node stays in
61
+ * place rather than failing.
62
+ * @param {object} node
63
+ * @returns {object}
64
+ */
65
+ function renderInBody(node) {
66
+ const body = typeof document === 'undefined' || document === null ? null : document.body;
67
+ return createPortal !== null && body !== null ? createPortal(node, body) : node;
68
+ }
44
69
 
45
70
  const NS = 'dsh-powerup';
46
71
  const SETTINGS_KEY = 'dsh-powerup:settings:v1';
47
- const VERSION = '0.4.1';
72
+ const VERSION = '0.5.1';
48
73
  const MENU_GAP = 8;
49
74
  const MENU_WIDTH = 248;
75
+ /** How long a one-click update's completion panel stays open when nothing restarts. */
76
+ const ONE_CLICK_AUTO_CLOSE_MS = 4000;
50
77
 
51
78
  // ------------------------------------------------------------------
52
79
  // Dictionaries
@@ -66,8 +93,14 @@
66
93
  'page.how2': '在记录行上右键;在空白处右键可执行会话级操作。',
67
94
  'page.how3': '菜单支持 ↑ / ↓ 选择、Enter 执行、Esc 关闭。',
68
95
  'page.updateTitle': '插件自更新',
69
- 'page.updateDesc': '在插件页为每个第三方已安装插件提供更新入口:从安装源选版本、卸载旧版、按「添加插件」流程重装,并可立即启用与重启 DSH。',
70
- 'page.updateHow': '打开侧边栏的「插件」页,在「已安装插件」分组中点击卡片右侧的更新图标。',
96
+ 'page.updateDesc': '在插件页为每个第三方已安装插件提供更新入口:从安装源选版本、卸载旧版、按「添加插件」流程重装,并可立即启用与重启 DSH;也可以一键更新到最新版。',
97
+ 'page.updateHow': '打开侧边栏的「插件」页,在「已安装插件」分组中点击卡片右侧的更新图标;在更新面板里点「一键更新」即可安装最新版,并按下面的默认行为处理。',
98
+ 'page.oneClickTitle': '一键更新',
99
+ 'page.oneClickDesc': '在更新面板里点「一键更新」时,直接安装最新版本,跳过「是否启用」和「是否重启」的询问。',
100
+ 'page.oneClickEnable': '自动启用新版本',
101
+ 'page.oneClickEnableHint': '关闭后,一键更新只安装新版本,保持停用,也不自动重启。',
102
+ 'page.oneClickRestart': '自动重启 DSH',
103
+ 'page.oneClickRestartHint': '关闭后,更新完成的提示会自动关闭。',
71
104
  'page.jobStopTitle': '后台任务停止原因',
72
105
  'page.jobStopDesc': '在会话顶部的后台任务面板里点停止按钮时,可以顺手填写停止原因;原因会附加在任务结束后注入会话的提示里。',
73
106
  'page.jobStopHow': '打开任意会话,点顶部的「后台任务」面板,在运行中的任务右侧点停止,填写原因(可留空)后确认。',
@@ -116,6 +149,9 @@
116
149
  'toast.forkUnavailable': '当前宿主没有提供 Fork 接口',
117
150
  'toast.noSession': '还没有打开会话',
118
151
  'jobStop.title': '停止后台任务',
152
+ 'jobStop.subtitle': '停止后无法恢复,正在运行的工作会中断。',
153
+ 'jobStop.close': '关闭',
154
+ 'jobStop.hint': 'Enter 确认 · Esc 取消',
119
155
  'jobStop.reasonLabel': '停止原因(可选)',
120
156
  'jobStop.reasonPlaceholder': '例如:已经不需要这个结果了',
121
157
  'jobStop.reasonNote': '原因会附加在任务结束后注入会话的提示里。',
@@ -186,7 +222,18 @@
186
222
  'update.doneDisabled': '{name} 已安装 {version},尚未启用。',
187
223
  'update.doneEnabled': '新版本已启用。',
188
224
  'update.doneRestart': '部分更改需要重启 DSH 后生效。',
225
+ 'update.doneAutoClose': '完成面板将在 {seconds} 秒后自动关闭。',
189
226
  'update.doneButton': '完成',
227
+ 'update.oneClick': '一键更新',
228
+ 'update.oneClickTitle': '一键更新',
229
+ 'update.oneClickHint': '安装最新版本 {version},跳过「是否启用」和「是否重启」的询问。',
230
+ 'update.oneClickDefaults': '自动启用:{enable} · 自动重启:{restart}。可在侧边栏 Power-Up 页面修改。',
231
+ 'update.on': '开',
232
+ 'update.off': '关',
233
+ 'update.oneClickNoLatest': '暂时读不到最新版本,请重试或手动选择版本。',
234
+ 'update.oneClickUpToDate': '已经是最新版本,无需更新。',
235
+ 'update.oneClickEnableFailed': '新版本已安装,但自动启用失败。请到「插件」页手动启用。',
236
+ 'update.oneClickSkippedEnable': '已按设置保持停用;需要时到「插件」页启用。',
190
237
  'update.errorTitle': '更新失败',
191
238
  'update.rollbackOkTitle': '已恢复旧版本',
192
239
  'update.rollbackOkDesc': '更新失败,{name} 已自动回滚到 {version},仍可继续使用。',
@@ -220,8 +267,14 @@
220
267
  'page.how2': 'Right-click a record row; right-click empty space for session actions.',
221
268
  'page.how3': 'Use ↑ / ↓ to move, Enter to run, Esc to close.',
222
269
  'page.updateTitle': 'Update plugins',
223
- 'page.updateDesc': 'Every third-party plugin on the Plugins page gains an update entry: pick a version from a registry, remove the old copy, reinstall through the Add plugin path, then enable and restart DSH.',
224
- 'page.updateHow': 'Open Plugins in the sidebar and click the update icon at the right of a card under Installed plugins.',
270
+ 'page.updateDesc': 'Every third-party plugin on the Plugins page gains an update entry: pick a version from a registry, remove the old copy, reinstall through the Add plugin path, then enable and restart DSH — or update to the newest version in one click.',
271
+ 'page.updateHow': 'Open Plugins in the sidebar and click the update icon at the right of a card under Installed plugins; in the update panel, One-click update installs the newest version using the defaults below.',
272
+ 'page.oneClickTitle': 'One-click update',
273
+ 'page.oneClickDesc': 'One-click update installs the newest version and skips both the enable and the restart questions.',
274
+ 'page.oneClickEnable': 'Enable the new version automatically',
275
+ 'page.oneClickEnableHint': 'When off, one-click update only installs it, leaves it disabled, and does not restart.',
276
+ 'page.oneClickRestart': 'Restart DSH automatically',
277
+ 'page.oneClickRestartHint': 'When off, the completion panel closes itself.',
225
278
  'page.jobStopTitle': 'Background job stop reason',
226
279
  'page.jobStopDesc': 'When you stop a running job from the background jobs panel in the session header, you can leave a reason; the reason is appended to the notice injected into the session when the job settles.',
227
280
  'page.jobStopHow': 'Open a session, expand the background jobs panel, press stop on a running job, type a reason (optional), then confirm.',
@@ -270,6 +323,9 @@
270
323
  'toast.forkUnavailable': 'This host does not expose the fork API',
271
324
  'toast.noSession': 'No session is open',
272
325
  'jobStop.title': 'Stop background job',
326
+ 'jobStop.subtitle': 'This cannot be undone; running work will be interrupted.',
327
+ 'jobStop.close': 'Close',
328
+ 'jobStop.hint': 'Enter to confirm · Esc to cancel',
273
329
  'jobStop.reasonLabel': 'Stop reason (optional)',
274
330
  'jobStop.reasonPlaceholder': 'e.g. the result is no longer needed',
275
331
  'jobStop.reasonNote': 'The reason is appended to the notice injected into the session when the job settles.',
@@ -340,7 +396,18 @@
340
396
  'update.doneDisabled': '{name} {version} is installed but not enabled.',
341
397
  'update.doneEnabled': 'The new version is enabled.',
342
398
  'update.doneRestart': 'Some changes apply only after DSH restarts.',
399
+ 'update.doneAutoClose': 'This panel closes itself in {seconds} seconds.',
343
400
  'update.doneButton': 'Done',
401
+ 'update.oneClick': 'One-click update',
402
+ 'update.oneClickTitle': 'One-click update',
403
+ 'update.oneClickHint': 'Installs the newest version ({version}) and skips the enable and restart questions.',
404
+ 'update.oneClickDefaults': 'Auto-enable: {enable} · Auto-restart: {restart}. Change these on the Power-Up page.',
405
+ 'update.on': 'on',
406
+ 'update.off': 'off',
407
+ 'update.oneClickNoLatest': 'The newest version is not available yet. Retry or pick a version manually.',
408
+ 'update.oneClickUpToDate': 'Already up to date.',
409
+ 'update.oneClickEnableFailed': 'The new version is installed but could not be enabled. Enable it on the Plugins page.',
410
+ 'update.oneClickSkippedEnable': 'Left disabled as configured; enable it on the Plugins page when ready.',
344
411
  'update.errorTitle': 'Update failed',
345
412
  'update.rollbackOkTitle': 'Previous version restored',
346
413
  'update.rollbackOkDesc': 'The update failed, so {name} was rolled back to {version} and is ready to use.',
@@ -388,16 +455,23 @@
388
455
  // ------------------------------------------------------------------
389
456
  // Settings store (localStorage, per browser)
390
457
  // ------------------------------------------------------------------
458
+ /** One-click update defaults: enable and restart unless the user turned one off. */
459
+ const DEFAULT_SETTINGS = { enabled: true, oneClickEnable: true, oneClickRestart: true };
460
+
391
461
  function readSettings() {
392
462
  try {
393
463
  const parsed = JSON.parse(localStorage.getItem(SETTINGS_KEY) || 'null');
394
464
  if (parsed !== null && typeof parsed === 'object') {
395
- return { enabled: parsed.enabled !== false };
465
+ return {
466
+ enabled: parsed.enabled !== false,
467
+ oneClickEnable: parsed.oneClickEnable !== false,
468
+ oneClickRestart: parsed.oneClickRestart !== false,
469
+ };
396
470
  }
397
471
  } catch {
398
472
  /* Private mode or a corrupted value: use the default. */
399
473
  }
400
- return { enabled: true };
474
+ return { ...DEFAULT_SETTINGS };
401
475
  }
402
476
 
403
477
  let settingsValue = readSettings();
@@ -641,6 +715,16 @@
641
715
  );
642
716
  }
643
717
 
718
+ /** A lightning bolt: the one-click update action. */
719
+ function QuickIcon({ size = 16 }) {
720
+ return h(Icon, { size },
721
+ h('path', {
722
+ d: 'M9.1 1.9 3.9 8.7h3.1L6.9 14l5.2-6.8H9L9.1 1.9Z',
723
+ fill: 'currentColor',
724
+ }),
725
+ );
726
+ }
727
+
644
728
  function StopIcon({ size = 16 }) {
645
729
  return h(Icon, { size },
646
730
  h('rect', {
@@ -719,6 +803,13 @@
719
803
  .dsh-powerup-switch[aria-checked=true] .dsh-powerup-switch-track{background:var(--dsw-alias-brand-primary)}
720
804
  .dsh-powerup-switch[aria-checked=true] .dsh-powerup-switch-thumb{background:var(--dsw-alias-label-primary-foreground,var(--dsw-alias-bg-layer-1));transform:translateX(15px)}
721
805
  .dsh-powerup-section-title{margin:0 0 10px;color:var(--dsw-alias-label-tertiary);font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase}
806
+ .dsh-powerup-settings{display:flex;flex-direction:column;gap:0;margin-top:12px}
807
+ .dsh-powerup-setting{display:flex;align-items:center;gap:14px;padding:9px 0;border-top:.5px solid var(--dsw-alias-border-l1)}
808
+ .dsh-powerup-setting:first-child{border-top:0;padding-top:4px}
809
+ .dsh-powerup-setting-copy{display:flex;flex:1 1 auto;flex-direction:column;gap:1px;min-width:0}
810
+ .dsh-powerup-setting-label{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
811
+ .dsh-powerup-setting-hint{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:15px}
812
+ .dsh-powerup-setting .dsh-powerup-switch{margin-left:auto}
722
813
  .dsh-powerup-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin:0;padding:0;list-style:none}
723
814
  .dsh-powerup-action{display:flex;align-items:flex-start;gap:8px;min-width:0;padding:7px 8px;border-radius:8px}
724
815
  .dsh-powerup-action-icon{flex:none;display:flex;align-items:center;justify-content:center;width:20px;height:20px;margin-top:1px;color:var(--dsw-alias-label-tertiary)}
@@ -747,26 +838,36 @@
747
838
  .dsh-powerup-menu-foot-id{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace)}
748
839
  .dsh-powerup-toast{position:fixed;left:50%;bottom:30px;transform:translateX(-50%);z-index:1001;max-width:min(440px,calc(100vw - 32px));padding:7px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));color:var(--dsw-alias-label-primary);box-shadow:var(--dsw-elevation-lv2,0 8px 24px rgba(15,23,42,.18));font-size:12px;line-height:1.45;pointer-events:none;animation:dsh-powerup-toast-in .14s ease-out}
749
840
  @keyframes dsh-powerup-toast-in{from{opacity:0;transform:translate(-50%,5px)}to{opacity:1;transform:translate(-50%,0)}}
750
- .dsh-powerup-jobstop{position:fixed;z-index:1002;box-sizing:border-box;display:flex;flex-direction:column;gap:10px;padding:12px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));box-shadow:var(--dsw-elevation-prominent,0 16px 40px rgba(15,23,42,.24),0 2px 8px rgba(15,23,42,.1));color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:1.45;pointer-events:auto;animation:dsh-powerup-jobstop-in .14s ease-out}
751
- @keyframes dsh-powerup-jobstop-in{from{opacity:0;transform:translateY(3px)}to{opacity:1;transform:none}}
752
- .dsh-powerup-jobstop-head{display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:600;letter-spacing:.03em}
753
- .dsh-powerup-jobstop-head svg{flex:none;color:var(--dsw-alias-state-error-primary)}
754
- .dsh-powerup-jobstop-label{display:flex;align-items:center;gap:6px;min-width:0;color:var(--dsw-alias-label-secondary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px}
755
- .dsh-powerup-jobstop-label span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
756
- .dsh-powerup-jobstop-field{display:flex;flex-direction:column;gap:4px;min-width:0}
841
+ .dsh-powerup-jobstop{position:fixed;z-index:1400;box-sizing:border-box;display:flex;flex-direction:column;gap:12px;padding:14px;border:.5px solid var(--dsw-alias-border-l2);border-radius:14px;background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));box-shadow:var(--dsw-elevation-prominent,0 18px 44px rgba(15,23,42,.26),0 2px 8px rgba(15,23,42,.12));color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;pointer-events:auto;overflow-y:auto;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);animation:dsh-powerup-jobstop-in .16s cubic-bezier(.2,.8,.3,1)}
842
+ @keyframes dsh-powerup-jobstop-in{from{opacity:0;transform:translateY(4px) scale(.99)}to{opacity:1;transform:none}}
843
+ .dsh-powerup-jobstop-head{display:flex;align-items:flex-start;gap:10px}
844
+ .dsh-powerup-jobstop-icon{flex:none;display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:9px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent);color:var(--dsw-alias-state-error-primary)}
845
+ .dsh-powerup-jobstop-heading{display:flex;flex:1 1 auto;flex-direction:column;gap:1px;min-width:0}
846
+ .dsh-powerup-jobstop-title{color:var(--dsw-alias-label-primary);font-size:13.5px;line-height:19px;font-weight:600}
847
+ .dsh-powerup-jobstop-subtitle{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
848
+ .dsh-powerup-jobstop-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin:-3px -3px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:16px;line-height:1;cursor:pointer}
849
+ .dsh-powerup-jobstop-close:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-primary)}
850
+ .dsh-powerup-jobstop-label{display:flex;align-items:center;gap:8px;min-width:0;margin:0;padding:7px 10px;border:.5px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px;line-height:17px}
851
+ .dsh-powerup-jobstop-dot{flex:none;width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-success-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-state-success-primary) 14%,transparent)}
852
+ .dsh-powerup-jobstop-label-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
853
+ .dsh-powerup-jobstop-field{display:flex;flex-direction:column;gap:6px;min-width:0}
854
+ .dsh-powerup-jobstop-field-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
757
855
  .dsh-powerup-jobstop-field-label{color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:17px}
758
- .dsh-powerup-jobstop-input{box-sizing:border-box;width:100%;height:32px;padding:0 9px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;line-height:18px;outline:none;transition:border-color .14s ease,box-shadow .14s ease}
856
+ .dsh-powerup-jobstop-count{color:var(--dsw-alias-label-caption);font-size:10.5px;line-height:16px;font-variant-numeric:tabular-nums}
857
+ .dsh-powerup-jobstop-input{box-sizing:border-box;width:100%;height:36px;padding:0 11px;border:.5px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;outline:none;transition:border-color .14s ease,box-shadow .14s ease}
759
858
  .dsh-powerup-jobstop-input::placeholder{color:var(--dsw-alias-label-caption)}
760
859
  .dsh-powerup-jobstop-input:focus{border-color:var(--dsw-alias-state-business-primary);box-shadow:inset 0 0 0 .5px var(--dsw-alias-state-business-primary)}
761
- .dsh-powerup-jobstop-note{margin:0;color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:15px}
762
- .dsh-powerup-jobstop-error{margin:0;color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:16px;overflow-wrap:anywhere}
860
+ .dsh-powerup-jobstop-note{margin:0;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
861
+ .dsh-powerup-jobstop-error{margin:0;padding:7px 9px;border:.5px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 32%,transparent);border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent);color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:17px;overflow-wrap:anywhere}
862
+ .dsh-powerup-jobstop-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;padding-top:2px}
863
+ .dsh-powerup-jobstop-hint{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:16px;white-space:nowrap}
763
864
  .dsh-powerup-jobstop-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px}
764
- .dsh-powerup-jobstop-cancel{height:28px;padding:0 10px;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:18px;cursor:pointer}
865
+ .dsh-powerup-jobstop-cancel{height:32px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12.5px;line-height:18px;cursor:pointer}
765
866
  .dsh-powerup-jobstop-cancel:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-primary)}
766
- .dsh-powerup-jobstop-confirm{height:28px;padding:0 11px;border:0;border-radius:var(--dsw-radius-sm,6px);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent);color:var(--dsw-alias-state-error-primary);font:inherit;font-size:12px;line-height:18px;cursor:pointer;transition:background .14s ease}
767
- .dsh-powerup-jobstop-confirm:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 20%,transparent)}
768
- .dsh-powerup-jobstop-confirm:disabled,.dsh-powerup-jobstop-cancel:disabled{opacity:.55;cursor:default}
769
- .dsh-powerup-jobstop-cancel:focus-visible,.dsh-powerup-jobstop-confirm:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
867
+ .dsh-powerup-jobstop-confirm{height:32px;padding:0 13px;border:0;border-radius:8px;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground);font:inherit;font-size:12.5px;line-height:18px;font-weight:500;cursor:pointer;transition:background .14s ease,opacity .14s ease}
868
+ .dsh-powerup-jobstop-confirm:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 86%,var(--dsw-alias-label-primary))}
869
+ .dsh-powerup-jobstop-confirm:disabled,.dsh-powerup-jobstop-cancel:disabled,.dsh-powerup-jobstop-close:disabled{opacity:.55;cursor:default}
870
+ .dsh-powerup-jobstop-cancel:focus-visible,.dsh-powerup-jobstop-confirm:focus-visible,.dsh-powerup-jobstop-close:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
770
871
  @media (prefers-reduced-motion:reduce){.dsh-powerup-jobstop{animation:none}}
771
872
  .dsh-powerup-update-button{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-caption);cursor:pointer}
772
873
  .dsh-powerup-update-button:hover{background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-secondary)}
@@ -859,14 +960,20 @@
859
960
  .dsh-powerup-update-option-title{color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:18px}
860
961
  .dsh-powerup-update-option-host{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px;overflow-wrap:anywhere}
861
962
  .dsh-powerup-update-option .dsh-powerup-update-check{flex:none;margin-top:2px}
862
- .dsh-powerup-update-foot{display:flex;align-items:center;justify-content:flex-end;gap:8px;padding:16px 24px 22px;border-top:.5px solid var(--dsw-alias-border-l1)}
963
+ .dsh-powerup-update-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;gap:8px;padding:16px 24px 22px;border-top:.5px solid var(--dsw-alias-border-l1)}
863
964
  .dsh-powerup-update-primary{height:36px;padding:0 14px;border:0;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-brand-primary));color:var(--dsw-alias-label-primary-foreground);font:inherit;font-size:14px;line-height:22px;cursor:pointer;transition:background .14s ease}
864
965
  .dsh-powerup-update-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover,var(--dsw-alias-brand-primary))}
865
966
  .dsh-powerup-update-primary:disabled{opacity:.4;cursor:not-allowed}
866
967
  .dsh-powerup-update-ghost{height:36px;padding:0 14px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:14px;line-height:22px;cursor:pointer}
867
968
  .dsh-powerup-update-ghost:hover{background:var(--dsw-alias-interactive-bg-hover)}
868
969
  .dsh-powerup-update-ghost:active{background:var(--dsw-alias-interactive-bg-active)}
869
- .dsh-powerup-update-close:focus-visible,.dsh-powerup-update-toggle:focus-visible,.dsh-powerup-update-version:focus-visible,.dsh-powerup-update-select-trigger:focus-visible,.dsh-powerup-update-option:focus-visible,.dsh-powerup-update-primary:focus-visible,.dsh-powerup-update-ghost:focus-visible,.dsh-powerup-update-button:focus-visible,.dsh-powerup-restart-action:focus-visible,.dsh-powerup-update-default:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
970
+ .dsh-powerup-update-quick{display:inline-flex;align-items:center;gap:6px;height:36px;padding:0 13px;border:.5px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary) 38%,transparent);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-state-warn-tertiary);color:var(--dsw-alias-state-warn-label);font:inherit;font-size:13.5px;line-height:20px;white-space:nowrap;cursor:pointer;transition:background .14s ease,border-color .14s ease}
971
+ .dsh-powerup-update-quick:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 16%,transparent)}
972
+ .dsh-powerup-update-quick:disabled{opacity:.45;cursor:not-allowed}
973
+ .dsh-powerup-update-quick-note{display:flex;flex-direction:column;gap:4px;padding:10px 12px;border:.5px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary) 26%,transparent);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-state-warn-tertiary)}
974
+ .dsh-powerup-update-quick-note-title{display:flex;align-items:center;gap:6px;color:var(--dsw-alias-state-warn-label);font-size:12px;line-height:17px;font-weight:500}
975
+ .dsh-powerup-update-quick-note .dsh-powerup-update-note{color:var(--dsw-alias-label-secondary)}
976
+ .dsh-powerup-update-close:focus-visible,.dsh-powerup-update-toggle:focus-visible,.dsh-powerup-update-version:focus-visible,.dsh-powerup-update-select-trigger:focus-visible,.dsh-powerup-update-option:focus-visible,.dsh-powerup-update-primary:focus-visible,.dsh-powerup-update-ghost:focus-visible,.dsh-powerup-update-quick:focus-visible,.dsh-powerup-update-button:focus-visible,.dsh-powerup-restart-action:focus-visible,.dsh-powerup-update-default:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
870
977
  @media (max-width:680px){.dsh-powerup-page{padding:20px 16px 42px}.dsh-powerup-actions{grid-template-columns:minmax(0,1fr)}.dsh-powerup-hero-art{width:54px;height:54px}.dsh-powerup-hero h1{font-size:19px}.dsh-powerup-card-head{flex-wrap:wrap}.dsh-powerup-switch{margin-left:auto}.dsh-powerup-update-mask{padding:12px}.dsh-powerup-update-dialog{max-height:calc(100dvh - 24px)}.dsh-powerup-update-head{padding:18px 12px 10px 18px}.dsh-powerup-update-body{padding:0 18px 4px}.dsh-powerup-update-foot{padding:14px 18px 18px}}
871
978
  `;
872
979
 
@@ -1626,6 +1733,33 @@
1626
1733
  return /^\d+(?:\.\d+)*(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.test(text) ? text : '';
1627
1734
  }
1628
1735
 
1736
+ /**
1737
+ * The version a one-click update targets: the registry's `latest` tag,
1738
+ * falling back to the first row of the already sorted version list.
1739
+ * @param {{ latest?: unknown, versions?: unknown }} view
1740
+ * @returns {string} a concrete version, or '' when none is known yet.
1741
+ */
1742
+ function oneClickVersion(view) {
1743
+ const declared = normalizeVersionInput(view?.latest);
1744
+ if (declared !== '') return declared;
1745
+ const first = Array.isArray(view?.versions) ? view.versions[0] : null;
1746
+ return normalizeVersionInput(first);
1747
+ }
1748
+
1749
+ /**
1750
+ * Whether a target version is strictly newer than the installed one.
1751
+ * @param {unknown} target
1752
+ * @param {unknown} current
1753
+ * @returns {boolean}
1754
+ */
1755
+ function isUpdateAvailable(target, current) {
1756
+ const version = normalizeVersionInput(target);
1757
+ if (version === '') return false;
1758
+ const installed = normalizeVersionInput(current);
1759
+ if (installed === '') return true;
1760
+ return compareVersionsDesc(version, installed) < 0;
1761
+ }
1762
+
1629
1763
  /** A display title for a bundle, following the page's locale fallback. */
1630
1764
  function packageDisplayTitle(pkg) {
1631
1765
  const title = pkg?.meta?.title;
@@ -1702,6 +1836,105 @@
1702
1836
  };
1703
1837
  }
1704
1838
 
1839
+ /**
1840
+ * Apply a one-click update's post-install defaults: enable the new copy,
1841
+ * then restart, without asking. A skipped restart (setting off or an
1842
+ * unsupported runtime) ends in `done` with `autoClose`, so the dialog can
1843
+ * dismiss itself; enable/restart failures end in `done` without
1844
+ * `autoClose` and carry their reason.
1845
+ * @param {{
1846
+ * manager: { setBundleEnabled: Function },
1847
+ * name: string,
1848
+ * installedVersion: string,
1849
+ * restartRequired: boolean,
1850
+ * settings: { oneClickEnable?: boolean, oneClickRestart?: boolean },
1851
+ * apply: (patch: object) => void,
1852
+ * isCurrent: () => boolean,
1853
+ * recordPending: (entry: { name: string, version: string, reason: string }) => void,
1854
+ * readRestartCapability: () => Promise<{ supported: boolean, reason: string }>,
1855
+ * requestRestart: () => Promise<void>,
1856
+ * t: (key: string, params?: object) => string,
1857
+ * }} input
1858
+ * @returns {Promise<void>}
1859
+ */
1860
+ async function runOneClickUpdate(input) {
1861
+ const {
1862
+ manager, name, installedVersion, restartRequired, settings,
1863
+ apply, isCurrent, recordPending, readRestartCapability, requestRestart, t,
1864
+ } = input;
1865
+ if (settings.oneClickEnable === false) {
1866
+ apply({
1867
+ phase: 'done',
1868
+ step: null,
1869
+ installedVersion,
1870
+ enabled: false,
1871
+ restartRequired,
1872
+ restartSkipped: true,
1873
+ skippedEnable: true,
1874
+ autoClose: true,
1875
+ });
1876
+ return;
1877
+ }
1878
+ apply({ phase: 'working', step: 'enabling', installedVersion, restartRequired });
1879
+ let enabledValue;
1880
+ try {
1881
+ const enabled = await manager.setBundleEnabled(name, true);
1882
+ if (!isCurrent()) return;
1883
+ if (!enabled.ok) throw new Error(enabled.error?.message ?? t('update.unknown'));
1884
+ enabledValue = enabled.value ?? {};
1885
+ if (enabledValue.error !== undefined || enabledValue.application === 'failed') throw new Error(operationReason(enabledValue, t));
1886
+ if (enabledValue.application === 'cancelled') throw new Error(t('update.cancelled'));
1887
+ } catch (error) {
1888
+ apply({
1889
+ phase: 'done',
1890
+ step: null,
1891
+ installedVersion,
1892
+ enabled: false,
1893
+ enableError: errorText(error) || t('update.unknown'),
1894
+ autoClose: false,
1895
+ });
1896
+ return;
1897
+ }
1898
+ if (restartRequired || enabledValue.application === 'restart-required') {
1899
+ recordPending({
1900
+ name,
1901
+ version: installedVersion,
1902
+ reason: enabledValue.restartReason ?? '',
1903
+ });
1904
+ }
1905
+ if (settings.oneClickRestart === false) {
1906
+ apply({ phase: 'done', step: null, installedVersion, enabled: true, restartSkipped: true, autoClose: true });
1907
+ return;
1908
+ }
1909
+ const restart = await readRestartCapability();
1910
+ if (!isCurrent()) return;
1911
+ if (restart.supported !== true) {
1912
+ apply({
1913
+ phase: 'done',
1914
+ step: null,
1915
+ installedVersion,
1916
+ enabled: true,
1917
+ restartSkipped: true,
1918
+ restartUnsupported: restart.reason,
1919
+ autoClose: true,
1920
+ });
1921
+ return;
1922
+ }
1923
+ apply({ phase: 'restarting', step: null, installedVersion, enabled: true, restarting: true });
1924
+ try {
1925
+ await requestRestart();
1926
+ } catch (error) {
1927
+ apply({
1928
+ phase: 'done',
1929
+ step: null,
1930
+ installedVersion,
1931
+ enabled: true,
1932
+ restartError: errorText(error) || t('update.unknown'),
1933
+ autoClose: false,
1934
+ });
1935
+ }
1936
+ }
1937
+
1705
1938
  /**
1706
1939
  * The package name of a registry install spec. Git, tarball, and local
1707
1940
  * paths return null; their installed name comes from the Host result.
@@ -2075,8 +2308,10 @@
2075
2308
  };
2076
2309
 
2077
2310
  if (target === null) return null;
2078
- const placement = popoverPlacement({ getBoundingClientRect: () => target.rect }, 300, 180);
2079
- return h('div', {
2311
+ const placement = popoverPlacement({ getBoundingClientRect: () => target.rect }, 340, 260);
2312
+ // The body portal escapes every slot's stacking context, so the same
2313
+ // panel is above the host jobs menu (z-index 100) in both themes.
2314
+ return renderInBody(h('div', {
2080
2315
  ref: panelRef,
2081
2316
  className: 'dsh-powerup-jobstop',
2082
2317
  role: 'dialog',
@@ -2103,10 +2338,30 @@
2103
2338
  void submit();
2104
2339
  },
2105
2340
  },
2106
- h('div', { className: 'dsh-powerup-jobstop-head' }, h(StopIcon, { size: 12 }), t('jobStop.title')),
2107
- h('div', { className: 'dsh-powerup-jobstop-label', title: target.job.label }, h('span', null, target.job.label)),
2341
+ h('div', { className: 'dsh-powerup-jobstop-head' },
2342
+ h('div', { className: 'dsh-powerup-jobstop-icon' }, h(StopIcon, { size: 14 })),
2343
+ h('div', { className: 'dsh-powerup-jobstop-heading' },
2344
+ h('span', { className: 'dsh-powerup-jobstop-title' }, t('jobStop.title')),
2345
+ h('span', { className: 'dsh-powerup-jobstop-subtitle' }, t('jobStop.subtitle')),
2346
+ ),
2347
+ h('button', {
2348
+ type: 'button',
2349
+ className: 'dsh-powerup-jobstop-close',
2350
+ 'aria-label': t('jobStop.close'),
2351
+ title: t('jobStop.close'),
2352
+ disabled: pending,
2353
+ onClick: close,
2354
+ }, '×'),
2355
+ ),
2356
+ h('div', { className: 'dsh-powerup-jobstop-label', title: target.job.label },
2357
+ h('span', { className: 'dsh-powerup-jobstop-dot', 'aria-hidden': 'true' }),
2358
+ h('span', { className: 'dsh-powerup-jobstop-label-text' }, target.job.label),
2359
+ ),
2108
2360
  h('label', { className: 'dsh-powerup-jobstop-field' },
2109
- h('span', { className: 'dsh-powerup-jobstop-field-label' }, t('jobStop.reasonLabel')),
2361
+ h('span', { className: 'dsh-powerup-jobstop-field-head' },
2362
+ h('span', { className: 'dsh-powerup-jobstop-field-label' }, t('jobStop.reasonLabel')),
2363
+ h('span', { className: 'dsh-powerup-jobstop-count' }, `${reason.length}/${JOB_STOP_REASON_MAX}`),
2364
+ ),
2110
2365
  h('input', {
2111
2366
  ref: inputRef,
2112
2367
  className: 'dsh-powerup-jobstop-input',
@@ -2120,20 +2375,23 @@
2120
2375
  ),
2121
2376
  h('p', { className: 'dsh-powerup-jobstop-note' }, t('jobStop.reasonNote')),
2122
2377
  error === null ? null : h('p', { className: 'dsh-powerup-jobstop-error', role: 'alert' }, error),
2123
- h('div', { className: 'dsh-powerup-jobstop-actions' },
2124
- h('button', {
2125
- type: 'button',
2126
- className: 'dsh-powerup-jobstop-cancel',
2127
- disabled: pending,
2128
- onClick: close,
2129
- }, t('jobStop.cancel')),
2130
- h('button', {
2131
- type: 'button',
2132
- className: 'dsh-powerup-jobstop-confirm',
2133
- disabled: pending,
2134
- onClick: () => { void submit(); },
2135
- }, pending ? t('jobStop.stopping') : t('jobStop.confirm')),
2136
- ));
2378
+ h('div', { className: 'dsh-powerup-jobstop-foot' },
2379
+ h('span', { className: 'dsh-powerup-jobstop-hint' }, t('jobStop.hint')),
2380
+ h('div', { className: 'dsh-powerup-jobstop-actions' },
2381
+ h('button', {
2382
+ type: 'button',
2383
+ className: 'dsh-powerup-jobstop-cancel',
2384
+ disabled: pending,
2385
+ onClick: close,
2386
+ }, t('jobStop.cancel')),
2387
+ h('button', {
2388
+ type: 'button',
2389
+ className: 'dsh-powerup-jobstop-confirm',
2390
+ disabled: pending,
2391
+ onClick: () => { void submit(); },
2392
+ }, pending ? t('jobStop.stopping') : t('jobStop.confirm')),
2393
+ ),
2394
+ )));
2137
2395
  }
2138
2396
 
2139
2397
  /**
@@ -2331,7 +2589,7 @@
2331
2589
  const seq = versionSeq.current + 1;
2332
2590
  versionSeq.current = seq;
2333
2591
  const current = () => versionSeq.current === seq && tokenRef.current === token;
2334
- patch(token, { versionsState: 'loading', versionsError: null, versionsRegistry: null, ...(resetVersion === true ? { versions: [], version: '' } : {}) });
2592
+ patch(token, { versionsState: 'loading', versionsError: null, versionsRegistry: null, ...(resetVersion === true ? { versions: [], version: '', latest: null } : {}) });
2335
2593
  let lastError = null;
2336
2594
  for (const candidate of lookupRegistries(choices, choice)) {
2337
2595
  if (!current()) return;
@@ -2575,6 +2833,26 @@
2575
2833
  return () => document.removeEventListener('keydown', onKeyDown, true);
2576
2834
  }, [restartAsk, restartBusy]);
2577
2835
 
2836
+ // A one-click update that does not restart leaves a completion panel;
2837
+ // close it on its own so it never lingers over the Plugins page.
2838
+ useEffect(() => {
2839
+ if (view === null || view.phase !== 'done' || view.autoClose !== true) return undefined;
2840
+ const timer = window.setTimeout(() => {
2841
+ setView((current) => {
2842
+ if (current === null || current.phase !== 'done' || current.autoClose !== true) return current;
2843
+ tokenRef.current = null;
2844
+ try {
2845
+ abortRef.current?.abort?.();
2846
+ } catch {
2847
+ /* ignore */
2848
+ }
2849
+ abortRef.current = null;
2850
+ return null;
2851
+ });
2852
+ }, ONE_CLICK_AUTO_CLOSE_MS);
2853
+ return () => window.clearTimeout(timer);
2854
+ }, [view === null ? null : view.phase, view === null ? null : view.autoClose]);
2855
+
2578
2856
  const chooseVersion = (version) => {
2579
2857
  if (tokenRef.current === null) return;
2580
2858
  setView((current) => current === null ? current : { ...current, version, listOpen: false, listPopover: null, formError: null });
@@ -2642,14 +2920,24 @@
2642
2920
  });
2643
2921
  };
2644
2922
 
2645
- const startUpdate = async () => {
2923
+ const startUpdate = async (options = {}) => {
2646
2924
  const token = tokenRef.current;
2647
2925
  const current = view;
2648
2926
  if (token === null || current === null || current.phase !== 'choose') return;
2649
2927
  const t = tRef.current;
2650
- const version = normalizeVersionInput(current.version);
2928
+ const oneClick = options?.oneClick === true;
2929
+ // One-click installs the registry's newest version; the manual path
2930
+ // uses what the user typed or picked.
2931
+ const version = oneClick ? oneClickVersion(current) : normalizeVersionInput(current.version);
2651
2932
  if (version === '') {
2652
- setView((state) => state === null ? state : { ...state, formError: t('update.invalidVersion') });
2933
+ setView((state) => state === null ? state : {
2934
+ ...state,
2935
+ formError: t(oneClick ? 'update.oneClickNoLatest' : 'update.invalidVersion'),
2936
+ });
2937
+ return;
2938
+ }
2939
+ if (oneClick && isUpdateAvailable(version, current.currentVersion) !== true) {
2940
+ setView((state) => state === null ? state : { ...state, formError: t('update.oneClickUpToDate') });
2653
2941
  return;
2654
2942
  }
2655
2943
  const choice = current.choices.find((item) => item.key === current.registryKey) ?? current.choices[0];
@@ -2659,7 +2947,19 @@
2659
2947
  const previousVersion = typeof current.currentVersion === 'string' && current.currentVersion !== '' ? current.currentVersion : null;
2660
2948
  const previousEnabled = current.enabled !== false;
2661
2949
  let removedOld = false;
2662
- patch(token, { phase: 'working', step: current.self === true ? 'installing' : 'removing', error: null, formError: null, log: '', logLabel: spec });
2950
+ patch(token, {
2951
+ phase: 'working',
2952
+ step: current.self === true ? 'installing' : 'removing',
2953
+ error: null,
2954
+ formError: null,
2955
+ log: '',
2956
+ logLabel: spec,
2957
+ oneClick,
2958
+ listOpen: false,
2959
+ listPopover: null,
2960
+ registryOpen: false,
2961
+ registryPopover: null,
2962
+ });
2663
2963
  if (current.self === true) {
2664
2964
  // Power-Up cannot reinstall itself from its own client: removing
2665
2965
  // the bundle unloads this dialog. The Host route receives the
@@ -2714,6 +3014,23 @@
2714
3014
  reason: value.restartReason ?? '',
2715
3015
  });
2716
3016
  }
3017
+ if (oneClick) {
3018
+ // No enable/restart questions: apply the stored defaults.
3019
+ await runOneClickUpdate({
3020
+ manager,
3021
+ name: current.name,
3022
+ installedVersion: value.version ?? version,
3023
+ restartRequired,
3024
+ settings: getSettings(),
3025
+ apply: (delta) => patch(token, delta),
3026
+ isCurrent: () => tokenRef.current === token,
3027
+ recordPending,
3028
+ readRestartCapability,
3029
+ requestRestart: requestAppRestart,
3030
+ t,
3031
+ });
3032
+ return;
3033
+ }
2717
3034
  patch(token, {
2718
3035
  phase: 'enable',
2719
3036
  step: null,
@@ -2773,6 +3090,17 @@
2773
3090
  }
2774
3091
  };
2775
3092
 
3093
+ /** POST the restart command; throws when the Host refuses. */
3094
+ const requestAppRestart = async () => {
3095
+ const response = await fetch(UPDATE_API, {
3096
+ method: 'POST',
3097
+ headers: { 'content-type': 'application/json' },
3098
+ body: JSON.stringify({ action: 'restart' }),
3099
+ });
3100
+ const data = await response.json().catch(() => null);
3101
+ if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? `HTTP ${response.status}`);
3102
+ };
3103
+
2776
3104
  /** Open the list-header restart confirmation and read the capability. */
2777
3105
  const openRestart = () => {
2778
3106
  setRestartAsk(true);
@@ -2789,13 +3117,7 @@
2789
3117
  setRestartBusy(true);
2790
3118
  setRestartError(null);
2791
3119
  try {
2792
- const response = await fetch(UPDATE_API, {
2793
- method: 'POST',
2794
- headers: { 'content-type': 'application/json' },
2795
- body: JSON.stringify({ action: 'restart' }),
2796
- });
2797
- const data = await response.json().catch(() => null);
2798
- if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? `HTTP ${response.status}`);
3120
+ await requestAppRestart();
2799
3121
  } catch (error) {
2800
3122
  setRestartBusy(false);
2801
3123
  setRestartError(errorText(error) || tRef.current('update.unknown'));
@@ -2845,13 +3167,7 @@
2845
3167
  const t = tRef.current;
2846
3168
  patch(token, { restarting: true, restartError: null });
2847
3169
  try {
2848
- const response = await fetch(UPDATE_API, {
2849
- method: 'POST',
2850
- headers: { 'content-type': 'application/json' },
2851
- body: JSON.stringify({ action: 'restart' }),
2852
- });
2853
- const data = await response.json().catch(() => null);
2854
- if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? `HTTP ${response.status}`);
3170
+ await requestAppRestart();
2855
3171
  patch(token, { phase: 'restarting', restarting: true });
2856
3172
  } catch (error) {
2857
3173
  patch(token, { restarting: false, restartError: errorText(error) || t('update.unknown') });
@@ -2919,19 +3235,39 @@
2919
3235
  const canClose = !busy;
2920
3236
  const title = view.title === undefined || view.title === '' ? view.name : view.title;
2921
3237
  const showVersions = view.phase === 'choose' && view.listOpen === true;
3238
+ // The newest version a one-click update would install right now.
3239
+ const quickVersion = oneClickVersion(view);
3240
+ const quickAvailable = view.self !== true
3241
+ && view.versionsState === 'ready'
3242
+ && quickVersion !== ''
3243
+ && isUpdateAvailable(quickVersion, view.currentVersion);
2922
3244
 
2923
3245
  const footer = (() => {
2924
3246
  if (view.phase === 'choose') {
2925
3247
  return [
2926
3248
  h('button', { key: 'cancel', type: 'button', className: 'dsh-powerup-update-ghost', onClick: close }, t('update.cancel')),
3249
+ view.self === true
3250
+ ? null
3251
+ : h('button', {
3252
+ key: 'quick',
3253
+ type: 'button',
3254
+ className: 'dsh-powerup-update-quick',
3255
+ disabled: !quickAvailable,
3256
+ title: quickAvailable
3257
+ ? t('update.oneClickHint', { version: quickVersion })
3258
+ : quickVersion === ''
3259
+ ? t('update.oneClickNoLatest')
3260
+ : t('update.oneClickUpToDate'),
3261
+ onClick: () => startUpdate({ oneClick: true }),
3262
+ }, h(QuickIcon, { size: 13 }), t('update.oneClick')),
2927
3263
  h('button', {
2928
3264
  key: 'start',
2929
3265
  type: 'button',
2930
3266
  className: 'dsh-powerup-update-primary',
2931
3267
  disabled: view.versionsState === 'loading' || String(view.version ?? '').trim() === '',
2932
- onClick: startUpdate,
3268
+ onClick: () => startUpdate(),
2933
3269
  }, t('update.start')),
2934
- ];
3270
+ ].filter(Boolean);
2935
3271
  }
2936
3272
  if (view.phase === 'enable') {
2937
3273
  return [
@@ -3093,6 +3429,25 @@
3093
3429
  ? null
3094
3430
  : h('span', { className: 'dsh-powerup-update-note' }, t('update.registryFrom', { registry: view.versionsRegistry.hint })),
3095
3431
  ),
3432
+ view.self === true
3433
+ ? null
3434
+ : h('div', { key: 'quick', className: 'dsh-powerup-update-quick-note' },
3435
+ h('div', { className: 'dsh-powerup-update-quick-note-title' },
3436
+ h(QuickIcon, { size: 13 }),
3437
+ t('update.oneClickTitle'),
3438
+ ),
3439
+ h('p', { className: 'dsh-powerup-update-note' }, quickAvailable
3440
+ ? t('update.oneClickHint', { version: quickVersion })
3441
+ : quickVersion === ''
3442
+ ? t('update.oneClickNoLatest')
3443
+ : t('update.oneClickUpToDate')),
3444
+ quickAvailable
3445
+ ? h('p', { className: 'dsh-powerup-update-note' }, t('update.oneClickDefaults', {
3446
+ enable: getSettings().oneClickEnable === false ? t('update.off') : t('update.on'),
3447
+ restart: getSettings().oneClickRestart === false ? t('update.off') : t('update.on'),
3448
+ }))
3449
+ : null,
3450
+ ),
3096
3451
  ];
3097
3452
  }
3098
3453
  if (view.phase === 'working') {
@@ -3102,7 +3457,9 @@
3102
3457
  ? t('update.step.installing', { version: view.logLabel ?? '' })
3103
3458
  : view.step === 'rollback'
3104
3459
  ? t('update.step.rollback', { version: view.rollbackVersion ?? view.currentVersion ?? '' })
3105
- : t('update.step.checking');
3460
+ : view.step === 'enabling'
3461
+ ? t('update.step.enabling')
3462
+ : t('update.step.checking');
3106
3463
  return [
3107
3464
  h('div', { key: 'status', className: 'dsh-powerup-update-status' },
3108
3465
  h('span', { className: 'dsh-powerup-update-spinner', 'aria-hidden': 'true' }),
@@ -3161,6 +3518,22 @@
3161
3518
  ? t('update.doneDisabled', { name: view.name, version: view.installedVersion ?? '' })
3162
3519
  : t('update.doneInstalled', { name: view.name, version: view.installedVersion ?? '' })),
3163
3520
  view.restartSkipped === true ? h('p', { key: 'restart', className: 'dsh-powerup-update-note' }, t('update.doneRestart')) : null,
3521
+ view.skippedEnable === true ? h('p', { key: 'skipped-enable', className: 'dsh-powerup-update-note' }, t('update.oneClickSkippedEnable')) : null,
3522
+ view.enableError === null || view.enableError === undefined
3523
+ ? null
3524
+ : notice('error', h(WarnIcon, { size: 14 }), t('update.errorTitle'), t('update.enableFailed', { message: view.enableError })),
3525
+ view.enableError === null || view.enableError === undefined
3526
+ ? null
3527
+ : h('p', { key: 'enable-failed', className: 'dsh-powerup-update-note' }, t('update.oneClickEnableFailed')),
3528
+ view.restartUnsupported === null || view.restartUnsupported === undefined
3529
+ ? null
3530
+ : notice('warn', h(WarnIcon, { size: 14 }), null, t('update.restartUnsupported', { reason: view.restartUnsupported })),
3531
+ view.restartError === null || view.restartError === undefined
3532
+ ? null
3533
+ : notice('error', h(WarnIcon, { size: 14 }), t('update.errorTitle'), t('update.restartFailed', { message: view.restartError })),
3534
+ view.autoClose === true
3535
+ ? h('p', { key: 'auto-close', className: 'dsh-powerup-update-note' }, t('update.doneAutoClose', { seconds: Math.round(ONE_CLICK_AUTO_CLOSE_MS / 1000) }))
3536
+ : null,
3164
3537
  ];
3165
3538
  }
3166
3539
  if (view.phase === 'error') {
@@ -3453,6 +3826,26 @@
3453
3826
  { id: 'fork', icon: ForkIcon, name: t('action.fork'), hint: t('action.forkHint') },
3454
3827
  { id: 'export', icon: ExportIcon, name: t('action.export'), hint: t('action.exportHint') },
3455
3828
  ];
3829
+ /** One label/description row with a host-styled switch. */
3830
+ const settingRow = (key, checked, label, hint) => h('div', { key, className: 'dsh-powerup-setting' },
3831
+ h('div', { className: 'dsh-powerup-setting-copy' },
3832
+ h('span', { className: 'dsh-powerup-setting-label' }, label),
3833
+ h('span', { className: 'dsh-powerup-setting-hint' }, hint),
3834
+ ),
3835
+ h('button', {
3836
+ type: 'button',
3837
+ role: 'switch',
3838
+ 'aria-checked': checked ? 'true' : 'false',
3839
+ 'aria-label': label,
3840
+ className: 'dsh-powerup-switch',
3841
+ onClick: () => setSettings({ [key]: !checked }),
3842
+ },
3843
+ h('span', { className: 'dsh-powerup-switch-track' },
3844
+ h('span', { className: 'dsh-powerup-switch-thumb' }),
3845
+ ),
3846
+ h('span', null, checked ? t('page.enabled') : t('page.disabled')),
3847
+ ),
3848
+ );
3456
3849
  return h('div', { className: 'dsh-powerup-page' },
3457
3850
  h('div', { className: 'dsh-powerup-shell' },
3458
3851
  h('header', { className: 'dsh-powerup-hero' },
@@ -3496,6 +3889,19 @@
3496
3889
  ),
3497
3890
  ),
3498
3891
  ),
3892
+ h('section', { className: 'dsh-powerup-card' },
3893
+ h('div', { className: 'dsh-powerup-card-head' },
3894
+ h('div', { className: 'dsh-powerup-card-icon' }, h(QuickIcon, { size: 18 })),
3895
+ h('div', { className: 'dsh-powerup-card-copy' },
3896
+ h('h2', null, t('page.oneClickTitle')),
3897
+ h('p', null, t('page.oneClickDesc')),
3898
+ ),
3899
+ ),
3900
+ h('div', { className: 'dsh-powerup-settings' },
3901
+ settingRow('oneClickEnable', settings.oneClickEnable !== false, t('page.oneClickEnable'), t('page.oneClickEnableHint')),
3902
+ settingRow('oneClickRestart', settings.oneClickRestart !== false, t('page.oneClickRestart'), t('page.oneClickRestartHint')),
3903
+ ),
3904
+ ),
3499
3905
  h('section', { className: 'dsh-powerup-card' },
3500
3906
  h('div', { className: 'dsh-powerup-card-head' },
3501
3907
  h('div', { className: 'dsh-powerup-card-icon' }, h(UpdateIcon, { size: 18 })),
@@ -3665,11 +4071,13 @@
3665
4071
  CSS,
3666
4072
  PowerUpLineIcon,
3667
4073
  UpdateIcon,
4074
+ QuickIcon,
3668
4075
  PowerUpBridge,
3669
4076
  PowerUpPage,
3670
4077
  PowerUpOverlay,
3671
4078
  PluginUpdateOverlay,
3672
4079
  JobStopOverlay,
4080
+ renderInBody,
3673
4081
  stopButtonLabel,
3674
4082
  resolveStopTarget,
3675
4083
  ensureUpdateButtons,
@@ -3698,9 +4106,15 @@
3698
4106
  readRememberedRegistry,
3699
4107
  packageDisplayTitle,
3700
4108
  normalizeVersionInput,
4109
+ oneClickVersion,
4110
+ isUpdateAvailable,
4111
+ readSettings,
4112
+ getSettings,
4113
+ setSettings,
3701
4114
  inspectReason,
3702
4115
  operationReason,
3703
4116
  restorePreviousBundle,
4117
+ runOneClickUpdate,
3704
4118
  },
3705
4119
  };
3706
4120
  },
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Power-Up",
4
- "description": "Adds a right-click action menu to the Trajectory ledger: copy a record, copy a Markdown quote, quote it into the composer, open the record inspector, fork the session at that record, export the trajectory snapshot, and copy the session ID. The session header's background jobs panel gains an optional stop reason when a job is stopped by hand; the reason is appended to the completion notice injected into the session. The Plugins page gains an update control on every third-party installed plugin: choose a version from the registry, uninstall the old copy, reinstall through the Add plugin path, then enable and optionally restart DSH."
4
+ "description": "Adds a right-click action menu to the Trajectory ledger: copy a record, copy a Markdown quote, quote it into the composer, open the record inspector, fork the session at that record, export the trajectory snapshot, and copy the session ID. The session header's background jobs panel gains an optional stop reason when a job is stopped by hand; the reason is appended to the completion notice injected into the session. The Plugins page gains an update control on every third-party installed plugin: choose a version from the registry, uninstall the old copy, reinstall through the Add plugin path, then enable and optionally restart DSH. The update panel also offers a one-click update that installs the newest version without the enable and restart questions, enabling and restarting automatically by default; both defaults are configurable on the Power-Up page."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Power-Up",
4
- "description": "在轨迹页面为记录增加右键操作菜单:复制内容、复制 Markdown 引用、引用到输入框、查看记录详情、从该记录 Fork 会话、导出轨迹快照、复制会话 ID。在会话顶部的后台任务面板手动停止任务时可以填写停止原因,原因会附加在任务结束后注入会话的提示里。插件页为每个第三方已安装插件增加更新按钮:从安装源选择版本,先卸载旧版再按「添加插件」流程安装,完成后可立即启用并选择是否重启 DSH。"
4
+ "description": "在轨迹页面为记录增加右键操作菜单:复制内容、复制 Markdown 引用、引用到输入框、查看记录详情、从该记录 Fork 会话、导出轨迹快照、复制会话 ID。在会话顶部的后台任务面板手动停止任务时可以填写停止原因,原因会附加在任务结束后注入会话的提示里。插件页为每个第三方已安装插件增加更新按钮:从安装源选择版本,先卸载旧版再按「添加插件」流程安装,完成后可立即启用并选择是否重启 DSH。插件更新面板还提供「一键更新」:安装最新版本并跳过启用与重启的询问,默认自动启用并重启,可在 Power-Up 页面调整默认行为。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.4.1",
4
- "description": "Power-Up — small, opt-in upgrades for DeepSeek Harness. Adds a right-click action menu to the Trajectory ledger, an optional stop reason in the session header's background jobs panel (appended to the injected completion notice), and an update control for third-party plugins installed from the Plugins page, with version lookup from the configured registries, a starred default source, uninstall-and-reinstall through the Add plugin path, restart-needed markers, a background self-update, and an optional DSH restart. · 为 DeepSeek Harness 提供小型增强:在轨迹页面右键记录即可复制、引用、查看详情或从该记录 Fork;在会话顶部的后台任务面板手动停止任务时可填写停止原因,原因会附加到任务结束后的会话提示;并在插件页为已安装插件提供带版本查询的更新按钮,安装源可设默认,沿用「添加插件」的安装流程,支持待重启标记、后台自更新与一键重启。",
3
+ "version": "0.5.1",
4
+ "description": "Power-Up — small, opt-in upgrades for DeepSeek Harness. Adds a right-click action menu to the Trajectory ledger, an optional stop reason in the session header's background jobs panel (appended to the injected completion notice), and an update control for third-party plugins installed from the Plugins page, with version lookup from the configured registries, a starred default source, uninstall-and-reinstall through the Add plugin path, restart-needed markers, a background self-update, and an optional DSH restart, plus a one-click update that installs the newest version and can enable and restart automatically. · 为 DeepSeek Harness 提供小型增强:在轨迹页面右键记录即可复制、引用、查看详情或从该记录 Fork;在会话顶部的后台任务面板手动停止任务时可填写停止原因,原因会附加到任务结束后的会话提示;并在插件页为已安装插件提供带版本查询的更新按钮,安装源可设默认,沿用「添加插件」的安装流程,支持待重启标记、后台自更新与一键重启;插件更新面板提供「一键更新」,默认安装最新版后自动启用并重启,可在 Power-Up 页面调整默认行为。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",
7
7
  "main": "index.js",