@restregular/dsh-powerup 0.19.17 → 0.19.19

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.
Files changed (2) hide show
  1. package/client.js +381 -34
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -98,7 +98,7 @@
98
98
  const requirementCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
99
99
  /** Fallback bucket when the hero cannot resolve an owning workspace yet. */
100
100
  const UNSCOPED_WORKSPACE = '__unscoped__';
101
- const VERSION = '0.19.17';
101
+ const VERSION = '0.19.19';
102
102
  const MENU_GAP = 8;
103
103
  const MENU_WIDTH = 248;
104
104
  /** Reference scheme understood by the Host's `powerup_step_read` tool. */
@@ -222,6 +222,14 @@
222
222
  'send.interruptHint': '立即打断并发送(Ctrl+Shift+Enter)',
223
223
  'send.empty': '输入为空',
224
224
  'launcher.groupDefault': '分组',
225
+ 'launcher.menuTitle': '启动器操作',
226
+ 'launcher.menuInstall': '安装插件',
227
+ 'launcher.menuInstallHint': '打开插件安装面板',
228
+ 'launcher.menuInstallUnavailable': '插件安装面板尚未加载,请先打开插件页面一次',
229
+ 'launcher.contextMenuLabel': '右键操作菜单',
230
+ 'launcher.contextMenuHint': '右键侧边栏启动器打开操作菜单,默认为空',
231
+ 'launcher.menuInstallLabel': '菜单加「安装插件」入口',
232
+ 'launcher.menuInstallEntryHint': '在操作菜单中加入插件安装面板入口,需先启用右键操作菜单',
225
233
  'launcher.count': '{count} 个面板',
226
234
  'launcher.renameHint': '点击重命名',
227
235
  'launcher.dissolve': '解散分组',
@@ -326,6 +334,11 @@
326
334
  'update.registryCustom': '自定义地址',
327
335
  'update.registryFrom': '版本列表来自 {registry}',
328
336
  'update.start': '开始安装',
337
+ 'update.installNewIntro': '输入要安装的插件包名或安装地址(支持 name@version、npm 包名或 git 链接),安装后插件保持停用,可在插件页手动启用。',
338
+ 'update.installNewSpecLabel': '安装地址',
339
+ 'update.installNewSpecPlaceholder': '例如 @scope/pkg、@scope/pkg@1.2.3 或 git+https://…',
340
+ 'update.installNewStart': '安装',
341
+ 'update.installNewNoSpec': '请输入要安装的插件包名或地址',
329
342
  'update.cancel': '取消',
330
343
  'update.close': '关闭',
331
344
  'update.step.checking': '正在校验版本…',
@@ -657,6 +670,14 @@
657
670
  'send.interruptHint': 'Interrupt and send now (Ctrl+Shift+Enter)',
658
671
  'send.empty': 'Empty input',
659
672
  'launcher.groupDefault': 'Group',
673
+ 'launcher.menuTitle': 'Launcher actions',
674
+ 'launcher.menuInstall': 'Install plugin',
675
+ 'launcher.menuInstallHint': 'Open the plugin install panel',
676
+ 'launcher.menuInstallUnavailable': 'The install panel is not loaded yet; open the Plugins page once first',
677
+ 'launcher.contextMenuLabel': 'Right-click action menu',
678
+ 'launcher.contextMenuHint': 'Right-click the sidebar launcher to open an action menu (empty by default)',
679
+ 'launcher.menuInstallLabel': 'Add an "Install plugin" entry',
680
+ 'launcher.menuInstallEntryHint': 'Adds the plugin install panel to the action menu; requires the right-click action menu',
660
681
  'launcher.count': '{count} panels',
661
682
  'launcher.renameHint': 'Click to rename',
662
683
  'launcher.dissolve': 'Ungroup',
@@ -761,6 +782,11 @@
761
782
  'update.registryCustom': 'Custom address',
762
783
  'update.registryFrom': 'Versions came from {registry}',
763
784
  'update.start': 'Install',
785
+ 'update.installNewIntro': 'Enter the package name or install spec of a plugin to install (name@version, an npm name, or a git URL). The plugin installs disabled; enable it on the Plugins page.',
786
+ 'update.installNewSpecLabel': 'Install spec',
787
+ 'update.installNewSpecPlaceholder': 'e.g. @scope/pkg, @scope/pkg@1.2.3, or git+https://…',
788
+ 'update.installNewStart': 'Install',
789
+ 'update.installNewNoSpec': 'Enter a package name or install spec first',
764
790
  'update.cancel': 'Cancel',
765
791
  'update.close': 'Close',
766
792
  'update.step.checking': 'Checking the version…',
@@ -1022,6 +1048,8 @@
1022
1048
  const DEFAULT_SETTINGS = {
1023
1049
  contextMenu: true,
1024
1050
  launcher: true,
1051
+ launcherContextMenu: false,
1052
+ launcherMenuInstall: false,
1025
1053
  sessionSwitch: true,
1026
1054
  jobStop: true,
1027
1055
  update: true,
@@ -1051,6 +1079,9 @@
1051
1079
  return {
1052
1080
  contextMenu,
1053
1081
  launcher: parsed.launcher !== false,
1082
+ launcherContextMenu: parsed.launcherContextMenu === true,
1083
+ // A stored install entry with the menu off cannot open; normalize it off.
1084
+ launcherMenuInstall: parsed.launcherContextMenu === true && parsed.launcherMenuInstall === true,
1054
1085
  sessionSwitch: parsed.sessionSwitch !== false,
1055
1086
  jobStop: parsed.jobStop !== false,
1056
1087
  update: parsed.update !== false,
@@ -1088,6 +1119,12 @@
1088
1119
 
1089
1120
  function setSettings(patch) {
1090
1121
  settingsValue = { ...settingsValue, ...patch };
1122
+ // Coupled sub-features: disabling the launcher right-click menu also
1123
+ // disables every entry contributed to it (the install entry), since a
1124
+ // menu that never opens cannot host them.
1125
+ if (settingsValue.launcherContextMenu === false && settingsValue.launcherMenuInstall === true) {
1126
+ settingsValue.launcherMenuInstall = false;
1127
+ }
1091
1128
  try {
1092
1129
  localStorage.setItem(SETTINGS_KEY, JSON.stringify(settingsValue));
1093
1130
  } catch {
@@ -1488,6 +1525,20 @@
1488
1525
  const restartPromptBridge = { open: null };
1489
1526
  /** Same bridge for the "close DSH" confirmation. */
1490
1527
  const closePromptBridge = { open: null };
1528
+ /**
1529
+ * Bridge to the PluginUpdateOverlay's install dialog. The launcher is
1530
+ * plain DOM and cannot render React, so the overlay publishes its
1531
+ * "install a new plugin" opener here while it is mounted; the launcher
1532
+ * action menu calls it for its 插件安装 entry.
1533
+ */
1534
+ const launcherInstallBridge = { open: null };
1535
+ /**
1536
+ * Shared action-menu registry: entries contributed by optional
1537
+ * sub-features. Each entry: { id, label, hint, icon (svg string), run }.
1538
+ * The menu is empty until a sub-feature registers an entry, so the
1539
+ * right-click menu ships empty by default.
1540
+ */
1541
+ const launcherMenuEntries = new Map();
1491
1542
 
1492
1543
  /**
1493
1544
  * Last resort for a host where the Plugins overlay (and with it the
@@ -1678,6 +1729,10 @@
1678
1729
  const selectConversation = typeof options.selectConversation === 'function' ? options.selectConversation : () => {};
1679
1730
  const openRestart = typeof options.openRestart === 'function' ? options.openRestart : () => false;
1680
1731
  const openClose = typeof options.openClose === 'function' ? options.openClose : () => false;
1732
+ /** Right-click action menu enabled (the launcherContextMenu sub-feature). */
1733
+ const menuEnabled = typeof options.menuEnabled === 'function' ? options.menuEnabled : () => false;
1734
+ /** Extra entries for the action menu, contributed by optional sub-features. */
1735
+ const menuEntries = typeof options.menuEntries === 'function' ? options.menuEntries : () => [];
1681
1736
 
1682
1737
  let nav = null;
1683
1738
  let docObserver = null;
@@ -2258,6 +2313,105 @@
2258
2313
  closePopup();
2259
2314
  }
2260
2315
 
2316
+ // ----------------------------------------------------------------
2317
+ // Action menu (right-click on the launcher)
2318
+ // ----------------------------------------------------------------
2319
+ let actionMenu = null;
2320
+
2321
+ /** Close and unmount the right-click action menu. */
2322
+ function closeActionMenu() {
2323
+ if (actionMenu === null) return;
2324
+ const element = actionMenu.element;
2325
+ actionMenu = null;
2326
+ document.removeEventListener('pointerdown', onActionMenuOutside, true);
2327
+ document.removeEventListener('keydown', onActionMenuKey, true);
2328
+ if (typeof window !== 'undefined' && window !== null && typeof window.removeEventListener === 'function') {
2329
+ window.removeEventListener('resize', closeActionMenu, true);
2330
+ window.removeEventListener('scroll', closeActionMenu, true);
2331
+ }
2332
+ element.remove();
2333
+ }
2334
+
2335
+ function onActionMenuOutside(event) {
2336
+ if (actionMenu === null) return;
2337
+ const target = event.target;
2338
+ if (target === null || target === undefined) return;
2339
+ if (typeof actionMenu.element.contains === 'function' && actionMenu.element.contains(target)) return;
2340
+ closeActionMenu();
2341
+ }
2342
+
2343
+ function onActionMenuKey(event) {
2344
+ if (actionMenu === null || event.key !== 'Escape') return;
2345
+ closeActionMenu();
2346
+ }
2347
+
2348
+ /** Open the launcher action menu at a pointer position. */
2349
+ function openActionMenu(x, y) {
2350
+ if (!hasDocument()) return;
2351
+ const entries = [...menuEntries()];
2352
+ if (entries.length === 0) return;
2353
+ closeActionMenu();
2354
+ const element = document.createElement('div');
2355
+ element.className = 'dsh-powerup-action-menu';
2356
+ element.setAttribute('role', 'menu');
2357
+ element.setAttribute('aria-label', t('launcher.menuTitle'));
2358
+ for (const entry of entries) {
2359
+ if (entry === null || typeof entry !== 'object' || typeof entry.id !== 'string' || typeof entry.run !== 'function') continue;
2360
+ const item = document.createElement('button');
2361
+ item.type = 'button';
2362
+ item.className = 'dsh-powerup-action-menu-item';
2363
+ item.setAttribute('role', 'menuitem');
2364
+ if (typeof entry.label === 'string' && entry.label !== '') item.textContent = entry.label;
2365
+ if (typeof entry.hint === 'string' && entry.hint !== '') {
2366
+ item.setAttribute('title', entry.hint);
2367
+ item.setAttribute('aria-label', entry.hint);
2368
+ }
2369
+ item.addEventListener('click', (event) => {
2370
+ event.preventDefault();
2371
+ event.stopPropagation();
2372
+ closeActionMenu();
2373
+ try {
2374
+ entry.run();
2375
+ } catch (error) {
2376
+ warn('launcher menu entry failed:', error);
2377
+ }
2378
+ });
2379
+ element.appendChild(item);
2380
+ }
2381
+ if (element.childElementCount === 0) return;
2382
+ document.body.appendChild(element);
2383
+ actionMenu = { element };
2384
+ const width = element.offsetWidth || 200;
2385
+ const height = element.offsetHeight || 80;
2386
+ const viewWidth = (typeof window !== 'undefined' && window !== null && window.innerWidth) || 1280;
2387
+ const viewHeight = (typeof window !== 'undefined' && window !== null && window.innerHeight) || 900;
2388
+ const margin = 10;
2389
+ element.style.left = Math.round(Math.max(margin, Math.min(x, viewWidth - width - margin))) + 'px';
2390
+ element.style.top = Math.round(Math.max(margin, Math.min(y, viewHeight - height - margin))) + 'px';
2391
+ document.addEventListener('pointerdown', onActionMenuOutside, true);
2392
+ document.addEventListener('keydown', onActionMenuKey, true);
2393
+ if (typeof window !== 'undefined' && window !== null && typeof window.addEventListener === 'function') {
2394
+ window.addEventListener('resize', closeActionMenu, true);
2395
+ window.addEventListener('scroll', closeActionMenu, true);
2396
+ }
2397
+ const first = element.querySelector('[role="menuitem"]');
2398
+ if (first !== null && typeof first.focus === 'function') first.focus();
2399
+ }
2400
+
2401
+ /** Capture-phase contextmenu handler: opens the action menu on the launcher nav. */
2402
+ function onNavContextMenu(event) {
2403
+ if (menuEnabled() !== true) return;
2404
+ const target = event.target;
2405
+ if (!(target instanceof Element) && (target === null || typeof target?.closest !== 'function')) return;
2406
+ const inside = typeof target.closest === 'function' && target.closest('nav.dsh-powerup-launcher') !== null;
2407
+ if (!inside) return;
2408
+ // Do not hijack the browser menu inside text fields (launcher rename).
2409
+ if (typeof target.closest === 'function' && target.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]') !== null) return;
2410
+ event.preventDefault();
2411
+ event.stopPropagation();
2412
+ openActionMenu(event.clientX, event.clientY);
2413
+ }
2414
+
2261
2415
  function positionPopup() {
2262
2416
  if (popup === null) return;
2263
2417
  const anchor = popup.anchor;
@@ -2979,6 +3133,7 @@
2979
3133
  if (started || !hasDocument()) return;
2980
3134
  started = true;
2981
3135
  document.addEventListener('pointerdown', onPointerDown, true);
3136
+ document.addEventListener('contextmenu', onNavContextMenu, true);
2982
3137
  const element = queryNav();
2983
3138
  if (element !== null) attachNav(element);
2984
3139
  else observeDocument();
@@ -3023,7 +3178,9 @@
3023
3178
  }
3024
3179
  if (typeof document !== 'undefined' && document !== null && typeof document.removeEventListener === 'function') {
3025
3180
  document.removeEventListener('pointerdown', onPointerDown, true);
3181
+ document.removeEventListener('contextmenu', onNavContextMenu, true);
3026
3182
  }
3183
+ closeActionMenu();
3027
3184
  clearVisuals();
3028
3185
  if (chatButton !== null) {
3029
3186
  chatButton.remove();
@@ -3127,6 +3284,22 @@
3127
3284
  void closeWithoutPrompt();
3128
3285
  return true;
3129
3286
  },
3287
+ menuEnabled: () => getSettings().launcher !== false && getSettings().launcherContextMenu === true,
3288
+ menuEntries: () => {
3289
+ const entries = [];
3290
+ if (getSettings().launcher !== false && getSettings().launcherContextMenu === true && getSettings().launcherMenuInstall === true) {
3291
+ entries.push({
3292
+ id: 'install-plugin',
3293
+ label: translateCurrent('launcher.menuInstall'),
3294
+ hint: translateCurrent('launcher.menuInstallHint'),
3295
+ run: () => {
3296
+ if (launcherInstallBridge.open !== null) launcherInstallBridge.open();
3297
+ else toastMessage(translateCurrent('launcher.menuInstallUnavailable'));
3298
+ },
3299
+ });
3300
+ }
3301
+ return entries;
3302
+ },
3130
3303
  });
3131
3304
  ctx.effect(() => {
3132
3305
  core.start();
@@ -4269,14 +4442,11 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [cl
4269
4442
  .dsh-powerup-card-body{margin-top:12px}
4270
4443
  .dsh-powerup-card-how{margin:0 0 0;padding:10px 12px;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.55;overflow-wrap:anywhere}
4271
4444
  .dsh-powerup-card-detail{margin-top:12px;padding-top:4px}
4272
- .dsh-powerup-card-foot{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-top:12px}
4273
4445
  .dsh-powerup-how-card .dsh-powerup-section-title{margin-bottom:10px}
4274
- .dsh-powerup-fold-btn{flex:none;display:inline-flex;align-items:center;gap:5px;padding:3px 9px 3px 7px;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:18px;cursor:pointer;white-space:nowrap}
4275
- .dsh-powerup-fold-btn:hover{background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-primary)}
4276
- .dsh-powerup-fold-btn.on{color:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}
4277
- .dsh-powerup-fold-btn:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
4278
- .dsh-powerup-fold-chevron{display:inline-block;width:0;height:0;border-left:4px solid transparent;border-right:4px solid transparent;border-top:4.5px solid currentColor;transition:transform .14s ease}
4279
- .dsh-powerup-fold-btn.on .dsh-powerup-fold-chevron{transform:rotate(180deg)}
4446
+ .dsh-powerup-more-link{flex:none;display:inline-flex;align-items:center;gap:3px;padding:0;border:0;background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:12px;line-height:18px;cursor:pointer;white-space:nowrap;text-decoration:underline;text-underline-offset:2px}
4447
+ .dsh-powerup-more-link:hover{color:var(--dsw-alias-brand-primary-hover,var(--dsw-alias-brand-primary));text-decoration-thickness:2px}
4448
+ .dsh-powerup-more-link:focus-visible{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
4449
+ .dsh-powerup-more-link .dsh-powerup-fold-line{display:inline-flex;align-items:center}
4280
4450
  .dsh-powerup-detail-modal{box-sizing:border-box;display:flex;flex-direction:column;width:min(460px,100%);max-height:min(680px,calc(100dvh - 48px));border-radius:var(--dsw-radius-panel,14px);background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;overflow:hidden;animation:dsh-powerup-prompt-rise .18s cubic-bezier(.2,.8,.3,1)}
4281
4451
  .dsh-powerup-detail-modal.is-closing{animation:dsh-powerup-prompt-sink .14s ease-in forwards}
4282
4452
  .dsh-powerup-detail-modal-title{display:flex;align-items:center;gap:10px;font-size:16px;line-height:24px;font-weight:500;min-width:0}
@@ -4904,7 +5074,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4904
5074
  .dsh-powerup-directask-file button{border:0;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;font-size:13px;line-height:1}
4905
5075
  .dsh-powerup-directask-btn.on{box-shadow:0 0 0 2px color-mix(in srgb,var(--dsw-alias-brand-primary) 30%,transparent)}
4906
5076
  `;
4907
-
4908
5077
  /** Max display length of a session option, in Unicode code points. */
4909
5078
  const SESSION_SWITCH_LABEL_MAX = 40;
4910
5079
  /** Separator between the workspace name and the session title. */
@@ -7866,6 +8035,68 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7866
8035
  });
7867
8036
  }, []);
7868
8037
 
8038
+ /**
8039
+ * Open the dialog in "install a new plugin" mode: a spec input first
8040
+ * (name, name@version, or any install spec), then the shared
8041
+ * inspect→install→enable flow. Opened from the launcher action menu.
8042
+ */
8043
+ const openInstallNew = useCallback(() => {
8044
+ const token = {};
8045
+ tokenRef.current = token;
8046
+ try {
8047
+ abortRef.current?.abort?.();
8048
+ } catch {
8049
+ /* ignore */
8050
+ }
8051
+ abortRef.current = null;
8052
+ const remembered = readRememberedRegistry();
8053
+ const powerupDefault = readDefaultRegistry();
8054
+ setView({
8055
+ name: '',
8056
+ title: '',
8057
+ self: false,
8058
+ currentVersion: null,
8059
+ phase: 'install-new',
8060
+ step: null,
8061
+ spec: '',
8062
+ choices: [],
8063
+ registryKey: '',
8064
+ defaultRegistryKey: null,
8065
+ versions: [],
8066
+ versionsState: 'idle',
8067
+ versionsError: null,
8068
+ versionsRegistry: null,
8069
+ version: '',
8070
+ listOpen: false,
8071
+ listPopover: null,
8072
+ registryOpen: false,
8073
+ registryPopover: null,
8074
+ error: null,
8075
+ formError: null,
8076
+ log: '',
8077
+ enabling: false,
8078
+ restarting: false,
8079
+ });
8080
+ // Registry choices load in the background; the spec input works
8081
+ // without them (install falls back to the remembered registry).
8082
+ void (async () => {
8083
+ try {
8084
+ const registries = await manager.registries();
8085
+ if (tokenRef.current !== token) return;
8086
+ const choices = buildRegistryChoices(registries.ok ? registries.value : null, remembered, powerupDefault, tRef.current);
8087
+ const choice = pickRegistryChoice(choices, remembered, powerupDefault);
8088
+ setView((current) => current === null || tokenRef.current !== token ? current : {
8089
+ ...current,
8090
+ choices,
8091
+ registryKey: choice.key,
8092
+ defaultRegistryKey: matchStoredChoice(choices, powerupDefault)?.key ?? null,
8093
+ });
8094
+ } catch {
8095
+ /* The spec input still works; install uses the remembered registry. */
8096
+ }
8097
+ })();
8098
+ }, [manager]);
8099
+
7869
8100
  /** Remember that one updated plugin waits for a whole-app restart. */
7870
8101
  const recordPending = useCallback((entry) => {
7871
8102
  setPending((current) => {
@@ -8140,9 +8371,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8140
8371
  };
8141
8372
  }, [localeTick, pending, settings.update]);
8142
8373
 
8143
- // Keep the selected version input focused when the chooser opens.
8374
+ // Keep the selected version input focused when the chooser opens, and
8375
+ // the spec input focused when the install-new dialog opens.
8144
8376
  useEffect(() => {
8145
- if (view !== null && view.phase === 'choose' && inputRef.current !== null) {
8377
+ if (view !== null && (view.phase === 'choose' || view.phase === 'install-new') && inputRef.current !== null) {
8146
8378
  try {
8147
8379
  inputRef.current.focus();
8148
8380
  } catch {
@@ -8481,6 +8713,72 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8481
8713
  }
8482
8714
  };
8483
8715
 
8716
+ /**
8717
+ * Install a brand-new plugin from the spec the install-new input
8718
+ * holds: inspect first (the Host refuses unresolvable specs and
8719
+ * non-bundles), then install disabled and hand over to the shared
8720
+ * enable question. No removal and no rollback: nothing was installed
8721
+ * before this dialog ran.
8722
+ */
8723
+ const startInstallNew = async () => {
8724
+ const token = tokenRef.current;
8725
+ const current = view;
8726
+ if (token === null || current === null || current.phase !== 'install-new') return;
8727
+ const t = tRef.current;
8728
+ const spec = String(current.spec ?? '').trim();
8729
+ if (spec === '') {
8730
+ setView((state) => state === null ? state : { ...state, formError: t('update.installNewNoSpec') });
8731
+ return;
8732
+ }
8733
+ const choice = current.choices.find((item) => item.key === current.registryKey) ?? current.choices[0];
8734
+ const registry = registryValue(choice);
8735
+ const requestId = newRequestId();
8736
+ patch(token, {
8737
+ phase: 'working',
8738
+ step: 'checking',
8739
+ error: null,
8740
+ formError: null,
8741
+ log: '',
8742
+ logLabel: spec,
8743
+ listOpen: false,
8744
+ listPopover: null,
8745
+ registryOpen: false,
8746
+ registryPopover: null,
8747
+ });
8748
+ try {
8749
+ const checked = await manager.inspect(spec, { registry });
8750
+ if (tokenRef.current !== token) return;
8751
+ if (!checked.ok) throw new Error(checked.error?.message ?? t('update.unknown'));
8752
+ if (checked.value.status !== 'accepted') throw new Error(inspectReason(checked.value, t));
8753
+ if (checked.value.bundle === false) throw new Error(t('update.notBundle'));
8754
+ const installedName = packageNameFromSpec(spec)
8755
+ ?? (checked.value.bundle === true && typeof checked.value.name === 'string' ? checked.value.name : packageNameFromSpec(spec));
8756
+ patch(token, { step: 'installing', name: installedName ?? spec, title: installedName ?? spec });
8757
+ const installed = await manager.installBundle(spec, { enabled: false, requestId, registry });
8758
+ if (tokenRef.current !== token) return;
8759
+ if (!installed.ok) throw new Error(installed.error?.message ?? t('update.unknown'));
8760
+ const value = installed.value;
8761
+ if (value.error !== undefined || value.application === 'failed') throw new Error(operationReason(value, t));
8762
+ if (value.application === 'cancelled') throw new Error(t('update.cancelled'));
8763
+ const restartRequired = value.application === 'restart-required';
8764
+ const finalName = typeof value.bundle === 'string' && value.bundle !== '' ? value.bundle : (installedName ?? spec);
8765
+ if (restartRequired) {
8766
+ recordPending({ name: finalName, version: value.version ?? '', reason: value.restartReason ?? '' });
8767
+ }
8768
+ patch(token, {
8769
+ phase: 'enable',
8770
+ step: null,
8771
+ name: finalName,
8772
+ title: finalName,
8773
+ installedVersion: value.version ?? '',
8774
+ restartRequired,
8775
+ enabling: false,
8776
+ });
8777
+ } catch (error) {
8778
+ patch(token, { phase: 'error', step: null, error: errorText(error) || t('update.unknown') });
8779
+ }
8780
+ };
8781
+
8484
8782
  /** Ask one Host app-control route whether this runtime supports it. */
8485
8783
  const readAppCapability = async (api) => {
8486
8784
  try {
@@ -8558,12 +8856,16 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8558
8856
  // calls these openers for its synthetic restart/close tiles. Keeping
8559
8857
  // them here means the sidebar and the pending-restart bar share one
8560
8858
  // confirmation dialog, one capability read and one set of copy.
8859
+ const openInstallNewRef = useRef(openInstallNew);
8860
+ openInstallNewRef.current = openInstallNew;
8561
8861
  useEffect(() => {
8562
8862
  restartPromptBridge.open = () => openAppActionRef.current('restart');
8563
8863
  closePromptBridge.open = () => openAppActionRef.current('close');
8864
+ launcherInstallBridge.open = () => openInstallNewRef.current();
8564
8865
  return () => {
8565
8866
  if (restartPromptBridge.open !== null) restartPromptBridge.open = null;
8566
8867
  if (closePromptBridge.open !== null) closePromptBridge.open = null;
8868
+ if (launcherInstallBridge.open !== null) launcherInstallBridge.open = null;
8567
8869
  };
8568
8870
  }, []);
8569
8871
 
@@ -8751,6 +9053,19 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8751
9053
  const quickAvailable = view.self !== true && quickVersion !== '';
8752
9054
 
8753
9055
  const footer = (() => {
9056
+ if (view.phase === 'install-new') {
9057
+ const specReady = String(view.spec ?? '').trim() !== '';
9058
+ return [
9059
+ h('button', { key: 'cancel', type: 'button', className: 'dsh-powerup-update-ghost', onClick: close }, t('update.cancel')),
9060
+ h('button', {
9061
+ key: 'start',
9062
+ type: 'button',
9063
+ className: 'dsh-powerup-update-primary',
9064
+ disabled: !specReady,
9065
+ onClick: () => startInstallNew(),
9066
+ }, t('update.installNewStart')),
9067
+ ];
9068
+ }
8754
9069
  if (view.phase === 'choose') {
8755
9070
  return [
8756
9071
  h('button', { key: 'cancel', type: 'button', className: 'dsh-powerup-update-ghost', onClick: close }, t('update.cancel')),
@@ -8871,6 +9186,31 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8871
9186
  if (view.phase === 'blocked') {
8872
9187
  return notice('error', h(WarnIcon, { size: 15 }), t('update.unsupportedTitle'), view.error ?? t('update.notRemovable'));
8873
9188
  }
9189
+ if (view.phase === 'install-new') {
9190
+ return [
9191
+ h('p', { key: 'intro', className: 'dsh-powerup-update-note' }, t('update.installNewIntro')),
9192
+ h('div', { key: 'spec', className: 'dsh-powerup-update-field' },
9193
+ h('label', { className: 'dsh-powerup-update-label', htmlFor: 'dsh-powerup-install-spec' }, t('update.installNewSpecLabel')),
9194
+ h('input', {
9195
+ id: 'dsh-powerup-install-spec',
9196
+ ref: inputRef,
9197
+ className: 'dsh-powerup-update-input',
9198
+ type: 'text',
9199
+ value: view.spec ?? '',
9200
+ placeholder: t('update.installNewSpecPlaceholder'),
9201
+ autoComplete: 'off',
9202
+ spellCheck: false,
9203
+ onChange: (event) => setView((current) => current === null ? current : { ...current, spec: event.target.value, formError: null }),
9204
+ onKeyDown: (event) => {
9205
+ if (event.key === 'Enter') startInstallNew();
9206
+ },
9207
+ }),
9208
+ view.formError === null || view.formError === undefined
9209
+ ? null
9210
+ : notice('error', h(WarnIcon, { size: 14 }), null, view.formError),
9211
+ ),
9212
+ ];
9213
+ }
8874
9214
  if (view.phase === 'choose') {
8875
9215
  return [
8876
9216
  h('div', { key: 'summary', className: 'dsh-powerup-update-summary' },
@@ -11253,9 +11593,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11253
11593
 
11254
11594
  /**
11255
11595
  * One uniform feature card: icon + title + a one-line brief with a
11256
- * Details link and enable switch on its right (aligned with each other),
11257
- * and a right-aligned fold/unfold button on the card-foot row for
11258
- * sub-options (the "More" settings; these never enter the detail modal).
11596
+ * link-styled fold/unfold "More" button (line chevron, no rotation),
11597
+ * then a Details link and the enable switch on its right (all
11598
+ * aligned with each other). Sub-options (the "More" settings) never
11599
+ * enter the detail modal.
11259
11600
  * opts: { descKey, howKey, howParts, detail, modalExtra }
11260
11601
  */
11261
11602
  const featureCard = (key, iconComp, titleKey, briefKey, opts = {}) => {
@@ -11280,6 +11621,17 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11280
11621
  h('h2', null, t(titleKey)),
11281
11622
  h('div', { className: 'dsh-powerup-card-brief-row' },
11282
11623
  h('p', null, t(briefKey)),
11624
+ hasSub
11625
+ ? h('button', {
11626
+ type: 'button',
11627
+ className: 'dsh-powerup-more-link' + (expanded ? ' on' : ''),
11628
+ 'aria-expanded': expanded ? 'true' : 'false',
11629
+ onClick: toggleExpanded,
11630
+ },
11631
+ h('span', { className: 'dsh-powerup-fold-line', 'aria-hidden': 'true' },
11632
+ h(ChevronDownIcon, { size: 12 })),
11633
+ t(expanded ? 'page.collapse' : 'page.more'))
11634
+ : null,
11283
11635
  hasDetail
11284
11636
  ? h('button', {
11285
11637
  type: 'button',
@@ -11291,18 +11643,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11291
11643
  ),
11292
11644
  ),
11293
11645
  ),
11294
- hasSub
11295
- ? h('div', { className: 'dsh-powerup-card-foot' },
11296
- h('button', {
11297
- type: 'button',
11298
- className: 'dsh-powerup-fold-btn' + (expanded ? ' on' : ''),
11299
- 'aria-expanded': expanded ? 'true' : 'false',
11300
- onClick: toggleExpanded,
11301
- },
11302
- h('span', { className: 'dsh-powerup-fold-chevron', 'aria-hidden': 'true' }),
11303
- h('span', null, t(expanded ? 'page.collapse' : 'page.more'))),
11304
- )
11305
- : null,
11306
11646
  hasSub && expanded
11307
11647
  ? h('div', { className: 'dsh-powerup-card-body' }, detail)
11308
11648
  : null,
@@ -11407,6 +11747,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11407
11747
  }),
11408
11748
  featureCard('launcher', LauncherIcon, 'page.launcherTitle', 'page.launcherBrief', {
11409
11749
  descKey: 'page.launcherDesc',
11750
+ detail: h('div', { className: 'dsh-powerup-card-detail' },
11751
+ settingRow('launcherContextMenu', settings.launcherContextMenu === true,
11752
+ t('launcher.contextMenuLabel'), t('launcher.contextMenuHint')),
11753
+ settingRow('launcherMenuInstall', settings.launcherMenuInstall === true,
11754
+ t('launcher.menuInstallLabel'), t('launcher.menuInstallEntryHint')),
11755
+ ),
11410
11756
  }),
11411
11757
  featureCard('sessionSwitch', QuickIcon, 'page.sessionSwitchTitle', 'page.sessionSwitchBrief', { howKey: 'page.sessionSwitchHow', descKey: 'page.sessionSwitchDesc' }),
11412
11758
  featureCard('locateSession', LocateIcon, 'page.locateTitle', 'page.locateBrief', { howKey: 'page.locateHow', descKey: 'page.locateDesc' }),
@@ -11466,7 +11812,6 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
11466
11812
  : null,
11467
11813
  );
11468
11814
  }
11469
-
11470
11815
  // ------------------------------------------------------------------
11471
11816
  // Translator wiring
11472
11817
  // ------------------------------------------------------------------
@@ -12612,13 +12957,13 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12612
12957
  {
12613
12958
  slot: 'main',
12614
12959
  options: { key: 'powerup' },
12615
- component: () => h(PowerUpPage, { ctx }),
12960
+ component: (props, ctx) => h(PowerUpPage, { ctx }),
12616
12961
  label: 'dsh-powerup: main page',
12617
12962
  },
12618
12963
  {
12619
12964
  slot: 'shell.overlay',
12620
12965
  options: { id: 'powerup-context-menu', order: 55 },
12621
- component: () => h(PowerUpOverlay, { ctx }),
12966
+ component: (props, ctx) => h(PowerUpOverlay, { ctx }),
12622
12967
  label: 'dsh-powerup: context menu',
12623
12968
  },
12624
12969
  {
@@ -12656,7 +13001,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12656
13001
  {
12657
13002
  slot: 'conversation.input.right',
12658
13003
  options: { id: 'powerup-dual-send', order: 80 },
12659
- component: (props) => h(DualSendButtons, {
13004
+ component: (props, ctx) => h(DualSendButtons, {
12660
13005
  ...props,
12661
13006
  ctx,
12662
13007
  t: (key, params) => translateCurrent(key, params),
@@ -12666,7 +13011,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12666
13011
  {
12667
13012
  slot: 'conversation.input.right',
12668
13013
  options: { id: 'powerup-direct-ask', order: 82 },
12669
- component: (props) => h(DirectAskButton, {
13014
+ component: (props, ctx) => h(DirectAskButton, {
12670
13015
  ...props,
12671
13016
  ctx,
12672
13017
  t: (key, params) => translateCurrent(key, params),
@@ -12676,7 +13021,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12676
13021
  {
12677
13022
  slot: 'conversation.input.right',
12678
13023
  options: { id: 'powerup-quick-replies', order: 84 },
12679
- component: (props) => h(QuickReplies, {
13024
+ component: (props, ctx) => h(QuickReplies, {
12680
13025
  ...props,
12681
13026
  ctx,
12682
13027
  t: (key, params) => translateCurrent(key, params),
@@ -12697,7 +13042,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12697
13042
  {
12698
13043
  slot: 'conversation.view',
12699
13044
  options: { id: 'powerup-settings', order: 20, label: () => translateCurrent('mask.viewTabLabel') },
12700
- component: (props) => h(WorkspaceSettingsView, { ...props, ctx }),
13045
+ component: (props, ctx) => h(WorkspaceSettingsView, { ...props, ctx }),
12701
13046
  label: 'dsh-powerup: workspace settings view',
12702
13047
  },
12703
13048
  // The update control drives the built-in plugin manager through its
@@ -12740,7 +13085,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12740
13085
  const register = (slot, options, component, label) => {
12741
13086
  try {
12742
13087
  ctx.effect(
12743
- () => slots.inject(slot, () => slots.register({ name: slot, ...options }, component)),
13088
+ () => slots.inject(slot, () => slots.register({ name: slot, ...options }, (props) => component(props, ctx))),
12744
13089
  label,
12745
13090
  );
12746
13091
  } catch (error) {
@@ -12853,6 +13198,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
12853
13198
  dissolveGroupOrder,
12854
13199
  createLauncherCore,
12855
13200
  installLauncher,
13201
+ launcherInstallBridge,
13202
+ launcherMenuEntries,
12856
13203
  PowerUpLineIcon,
12857
13204
  LauncherIcon,
12858
13205
  UpdateIcon,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.19.17",
3
+ "version": "0.19.19",
4
4
  "description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词、旁路模型生成的结构化任务进度;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, workspace prompts, and non-blocking model-generated structured task progress — each toggled independently on the Power-Up page.",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",