@restregular/dsh-powerup 0.8.8 → 0.8.10
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 +46 -28
- package/client.js +331 -116
- package/index.js +20 -14
- package/lib/restart.js +49 -11
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ The upgrades include a **right-click action menu in the Trajectory view**, a
|
|
|
6
6
|
data, an optional **stop reason for background jobs**, an in-place
|
|
7
7
|
**plugin installer**, and a **sidebar launcher** that turns the left sidebar's
|
|
8
8
|
panel list into an adaptive icon grid with drag sorting, folders, a
|
|
9
|
-
back-to-conversation tile and
|
|
9
|
+
back-to-conversation tile, and restart/close tiles.
|
|
10
10
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
@@ -98,7 +98,8 @@ entries other plugins add) become an icon grid instead of a one-per-row list:
|
|
|
98
98
|
`minmax(58px, 1fr)` cells, so widening the sidebar adds columns and narrowing
|
|
99
99
|
it removes them — there is no fixed column count to break.
|
|
100
100
|
- **Icons above labels.** Each tile stacks a 20px icon over an 11px caption, one
|
|
101
|
-
line with an ellipsis when the label is long.
|
|
101
|
+
line with an ellipsis when the label is long. The host's per-row unpin button
|
|
102
|
+
is hidden inside the grid, so a tile is one click target.
|
|
102
103
|
- **Drag to sort.** Press and drag a tile; a ghost follows the pointer and a
|
|
103
104
|
thin accent line marks the insertion point. Order is stored per browser.
|
|
104
105
|
- **Drop onto a tile's middle to build a folder.** Dropping on the middle of
|
|
@@ -108,24 +109,38 @@ entries other plugins add) become an icon grid instead of a one-per-row list:
|
|
|
108
109
|
anchored to the tile, scaling in from its edge. Inside the flyout: click an
|
|
109
110
|
entry to open that panel, `×` removes it from the folder, click the title to
|
|
110
111
|
rename the folder, and **Ungroup** returns every member to the grid.
|
|
111
|
-
- **
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
112
|
+
- **A host row may be a wrapper, not a bare button.** DSH 0.2.2 wraps each
|
|
113
|
+
panel row in a cell element (`div.panelEntry` holding `button.panelRow` plus
|
|
114
|
+
its `panelUnpin` overlay) and the extra-panels menu in a `span.moreAnchor`.
|
|
115
|
+
The launcher treats any direct child that owns a direct button as one tile:
|
|
116
|
+
the wrapper becomes the grid cell and its row button the click target, so the
|
|
117
|
+
unpin overlay can be hidden without losing the row. The host's "More" entry is
|
|
118
|
+
recognised by `aria-haspopup` / `aria-expanded` (or the `moreAnchor` wrapper),
|
|
119
|
+
never by "not a button", so every panel row keeps its own slot id.
|
|
120
|
+
- **The host's "More" entry is a tile too.** It gets the same stacked
|
|
121
|
+
icon/label tile and can be dragged like any other panel, including into a
|
|
122
|
+
folder.
|
|
116
123
|
- **A synthetic "Back to conversation" tile.** Power-Up adds one extra tile of
|
|
117
124
|
its own (chat glyph + label) that calls `layout.selectPanel(null)` to return
|
|
118
|
-
to the Conversation; it highlights when no global panel is selected
|
|
119
|
-
placed anywhere by dragging,
|
|
125
|
+
to the Conversation; it highlights when no global panel is selected and can be
|
|
126
|
+
placed anywhere by dragging, including into a folder.
|
|
120
127
|
- **A synthetic "Restart DSH" tile.** A second Power-Up tile (a ring with the
|
|
121
128
|
arrowhead tangent to the top, i.e. the arrow lines up with the arc) plus
|
|
122
129
|
`重启` / `Restart` opens the same restart confirmation the pending-restart
|
|
123
130
|
bar uses: the tile only calls into that React prompt, so there is one dialog,
|
|
124
131
|
one capability read (`GET /dsh-powerup/api/restart`) and one set of copy. The
|
|
125
132
|
confirmation explains that running tasks are interrupted; only a runtime that
|
|
126
|
-
can relaunch itself (the desktop app) enables the confirm button.
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
can relaunch itself (the desktop app) enables the confirm button.
|
|
134
|
+
- **A synthetic "Close DSH" tile.** A power-symbol tile plus `关闭` / `Close`
|
|
135
|
+
opens a close confirmation (same dialog and copy conventions as restart) and
|
|
136
|
+
posts to `GET/POST /dsh-powerup/api/close`, which ends the Electron app without
|
|
137
|
+
relaunching it. Like the other synthetic tiles it drags anywhere, including
|
|
138
|
+
into a folder.
|
|
139
|
+
- **Folders take every tile.** Host panels, the host's "More" entry and
|
|
140
|
+
Power-Up's own tiles all merge the same way: drop one onto the middle of
|
|
141
|
+
another, or onto a folder, and it becomes a member; drag it out of the flyout
|
|
142
|
+
to put it back on the grid. The three synthetic tiles are hidden with the rest
|
|
143
|
+
of the grid in the collapsed rail.
|
|
129
144
|
- **Ungroup expands in place.** Dissolving a folder puts its icons back on the
|
|
130
145
|
grid exactly where the folder sat, in the folder's own order — nothing jumps
|
|
131
146
|
to the end of the grid.
|
|
@@ -228,24 +243,27 @@ fiber is unloaded. The panel closes; refresh the page when the install finishes.
|
|
|
228
243
|
synthetic folder tiles, hides the rows that moved into a folder with an
|
|
229
244
|
inline `display` (React rewrites `className` when the active panel changes and
|
|
230
245
|
would drop an added class), and sorts with the grid's `order` property. Host
|
|
231
|
-
rows are resolved by shape — a direct `<button>`, or a wrapper
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
246
|
+
rows are resolved by shape — a direct `<button>`, or a cell wrapper
|
|
247
|
+
(`div.panelEntry` since 0.2.2, the More `Menu` root `<span>`) whose direct
|
|
248
|
+
child is that button — so one code path covers both the panel rows and the
|
|
249
|
+
more menu, and only `aria-haspopup` / `aria-expanded` / `moreAnchor` marks a
|
|
250
|
+
row as More.
|
|
251
|
+
- **The DOM launcher borrows the React app-action prompts.** The launcher is
|
|
252
|
+
plain DOM and cannot render React, so the Plugins overlay publishes
|
|
253
|
+
`openRestart` and `openClose` in module-level bridges while it is mounted; the
|
|
254
|
+
synthetic restart/close tiles call them, and get the exact confirmations,
|
|
255
|
+
capability checks and localized copy the pending-restart bar uses — nothing is
|
|
256
|
+
duplicated. If the overlay is not mounted at all (a host without
|
|
257
|
+
`remote.pluginManager`), each tile falls back to a browser confirm over the
|
|
258
|
+
same Host route.
|
|
241
259
|
- **Every sync write is idempotent.** The launcher observes its own `<nav>`
|
|
242
260
|
with a `MutationObserver`, so a write that changes a watched subtree on every
|
|
243
261
|
sync turns into an infinite loop — and a loop rebuilds the folder flyout
|
|
244
262
|
continuously, which makes normal clicks miss (the node under the pointer is
|
|
245
263
|
replaced between `pointerdown` and `click`). Setting `textContent` to the same
|
|
246
|
-
string still emits a `childList` mutation, so the synthetic chat/restart
|
|
247
|
-
only write their labels when they actually changed, folder tiles rebuild
|
|
248
|
-
when
|
|
264
|
+
string still emits a `childList` mutation, so the synthetic chat/restart/close
|
|
265
|
+
tiles only write their labels when they actually changed, folder tiles rebuild
|
|
266
|
+
only when
|
|
249
267
|
their signature changed, and the flyout re-renders only when its roster or
|
|
250
268
|
name changed. A
|
|
251
269
|
`MutationObserver` re-applies that after every host render, and the module
|
|
@@ -260,9 +278,9 @@ fiber is unloaded. The panel closes; refresh the page when the install finishes.
|
|
|
260
278
|
`[data-plugin-group="bundles"] [data-plugin-package]` card and re-asserts it
|
|
261
279
|
after React renders. Version listing is a plain registry `GET`; removal and
|
|
262
280
|
installation use the same `remote.pluginManager` calls as **Add plugin**. The
|
|
263
|
-
Host adds
|
|
264
|
-
process restart,
|
|
265
|
-
handoff.
|
|
281
|
+
Host adds three loopback-only routes: `/dsh-powerup/api/restart` for the
|
|
282
|
+
process restart, `/dsh-powerup/api/close` for closing the app without a
|
|
283
|
+
relaunch, and `/dsh-powerup/api/self-update` for the self-install handoff.
|
|
266
284
|
- **Power-Up's own install outlives its unload.** The Host route sends its
|
|
267
285
|
answer, then a timer starts `removeBundle` → `inspect` →
|
|
268
286
|
`installBundle(enabled: true)` through the built-in manager service. Removing
|
package/client.js
CHANGED
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
|
|
70
70
|
const NS = 'dsh-powerup';
|
|
71
71
|
const SETTINGS_KEY = 'dsh-powerup:settings:v1';
|
|
72
|
-
const VERSION = '0.8.
|
|
72
|
+
const VERSION = '0.8.9';
|
|
73
73
|
const MENU_GAP = 8;
|
|
74
74
|
const MENU_WIDTH = 248;
|
|
75
75
|
/** Reference scheme understood by the Host's `powerup_step_read` tool. */
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
'page.jobStopDesc': '在会话顶部的后台任务面板里点停止按钮时,可以顺手填写停止原因;原因会附加在任务结束后注入会话的提示里。',
|
|
108
108
|
'page.jobStopHow': '打开任意会话,点顶部的「后台任务」面板,在运行中的任务右侧点停止,填写原因(可留空)后确认。',
|
|
109
109
|
'page.launcherTitle': '侧边栏启动器',
|
|
110
|
-
'page.launcherDesc': '把左侧边栏的面板按钮变成自适应图标网格:列数跟着侧边栏宽度走,图标在上、文字在下;拖动图标可以排序,把一个图标拖到另一个图标的中间就会合成一个分组(像 Windows
|
|
110
|
+
'page.launcherDesc': '把左侧边栏的面板按钮变成自适应图标网格:列数跟着侧边栏宽度走,图标在上、文字在下;拖动图标可以排序,把一个图标拖到另一个图标的中间就会合成一个分组(像 Windows 开始菜单的文件夹),点分组会以浮层弹出里面的图标。网格里自带「返回会话」「重启 DSH」「关闭 DSH」三个按钮,它们和「更多」一样也能拖进分组。',
|
|
111
111
|
'page.launcherToggle': '启用图标网格',
|
|
112
112
|
'page.launcherToggleHint': '关闭后侧边栏恢复宿主原本的列表样式;排序与分组仍会保留。',
|
|
113
113
|
'launcher.groupDefault': '分组',
|
|
@@ -118,6 +118,15 @@
|
|
|
118
118
|
'launcher.backToConversation': '返回会话',
|
|
119
119
|
'launcher.restart': '重启',
|
|
120
120
|
'launcher.restartHint': '重启 DSH(正在运行的任务会中断)',
|
|
121
|
+
'launcher.close': '关闭',
|
|
122
|
+
'launcher.closeHint': '关闭 DSH(正在运行的任务会中断)',
|
|
123
|
+
'close.title': '关闭 DSH?',
|
|
124
|
+
'close.desc': '关闭会退出 DSH,正在运行的任务会中断。',
|
|
125
|
+
'close.cancel': '取消',
|
|
126
|
+
'close.confirm': '关闭 DSH',
|
|
127
|
+
'close.closing': 'DSH 正在关闭…',
|
|
128
|
+
'close.failed': '关闭请求失败:{message}',
|
|
129
|
+
'close.unsupported': '当前运行方式无法自动关闭:{reason}',
|
|
121
130
|
'page.footer': 'Power-Up {version} · 设置在浏览器本地保存',
|
|
122
131
|
'page.localOnly': '仅影响当前浏览器',
|
|
123
132
|
'action.copy': '复制内容',
|
|
@@ -296,7 +305,7 @@
|
|
|
296
305
|
'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.',
|
|
297
306
|
'page.jobStopHow': 'Open a session, expand the background jobs panel, press stop on a running job, type a reason (optional), then confirm.',
|
|
298
307
|
'page.launcherTitle': 'Sidebar launcher',
|
|
299
|
-
'page.launcherDesc': 'Turns the left sidebar panel buttons into an adaptive icon grid: the column count follows the sidebar width, icons sit above their labels, icons can be dragged to reorder, dropping one icon onto the middle of another forms a folder (like a Windows Start menu folder), and clicking a folder opens its contents in a flyout. The grid also carries
|
|
308
|
+
'page.launcherDesc': 'Turns the left sidebar panel buttons into an adaptive icon grid: the column count follows the sidebar width, icons sit above their labels, icons can be dragged to reorder, dropping one icon onto the middle of another forms a folder (like a Windows Start menu folder), and clicking a folder opens its contents in a flyout. The grid also carries three built-in buttons — back to conversation, restart DSH and close DSH — and they, like the host\'s "more" entry, can be dragged into a folder too.',
|
|
300
309
|
'page.launcherToggle': 'Enable the icon grid',
|
|
301
310
|
'page.launcherToggleHint': 'When off, the sidebar keeps the host list; order and folders are remembered.',
|
|
302
311
|
'launcher.groupDefault': 'Group',
|
|
@@ -307,6 +316,15 @@
|
|
|
307
316
|
'launcher.backToConversation': 'Back to conversation',
|
|
308
317
|
'launcher.restart': 'Restart',
|
|
309
318
|
'launcher.restartHint': 'Restart DSH (running tasks are interrupted)',
|
|
319
|
+
'launcher.close': 'Close',
|
|
320
|
+
'launcher.closeHint': 'Close DSH (running tasks are interrupted)',
|
|
321
|
+
'close.title': 'Close DSH?',
|
|
322
|
+
'close.desc': 'Closing quits DSH; running tasks are interrupted.',
|
|
323
|
+
'close.cancel': 'Cancel',
|
|
324
|
+
'close.confirm': 'Close DSH',
|
|
325
|
+
'close.closing': 'DSH is closing…',
|
|
326
|
+
'close.failed': 'Close request failed: {message}',
|
|
327
|
+
'close.unsupported': 'This runtime cannot close itself: {reason}',
|
|
310
328
|
'page.footer': 'Power-Up {version} · Settings are stored in this browser',
|
|
311
329
|
'page.localOnly': 'This browser only',
|
|
312
330
|
'action.copy': 'Copy content',
|
|
@@ -556,6 +574,8 @@
|
|
|
556
574
|
const LAUNCHER_CHAT_KEY = '__chat';
|
|
557
575
|
/** Tile key of the Power-Up "restart DSH" tile. */
|
|
558
576
|
const LAUNCHER_RESTART_KEY = '__restart';
|
|
577
|
+
/** Tile key of the Power-Up "close DSH" tile. */
|
|
578
|
+
const LAUNCHER_CLOSE_KEY = '__close';
|
|
559
579
|
/** 16-grid chat glyph for the synthetic "back to conversation" tile. */
|
|
560
580
|
const LAUNCHER_CHAT_ICON = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M2.8 3.4h10.4v6.8H7.4L4.4 12.8v-2.6H2.8V3.4Z" stroke="currentColor" stroke-width="1.3" stroke-linejoin="round"/></svg>';
|
|
561
581
|
/**
|
|
@@ -564,6 +584,8 @@
|
|
|
564
584
|
* the opening (the previous Material glyph read as detached).
|
|
565
585
|
*/
|
|
566
586
|
const LAUNCHER_RESTART_ICON = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M11.94 5.34A4.75 4.75 0 1 1 8 3.25" stroke="currentColor" stroke-width="1.55" stroke-linecap="round"/><path d="M7.85 1.45 11 3.25 7.85 5.05Z" fill="currentColor"/></svg>';
|
|
587
|
+
/** 16-grid power glyph for the synthetic "close DSH" tile. */
|
|
588
|
+
const LAUNCHER_CLOSE_ICON = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M8 2.9v5.2" stroke="currentColor" stroke-width="1.55" stroke-linecap="round"/><path d="M5.77 3.81A4.75 4.75 0 1 0 10.23 3.81" stroke="currentColor" stroke-width="1.55" stroke-linecap="round"/></svg>';
|
|
567
589
|
/**
|
|
568
590
|
* Bridge to the Plugins overlay's React restart prompt. The launcher is
|
|
569
591
|
* plain DOM and cannot render React, so the overlay publishes its opener
|
|
@@ -571,35 +593,61 @@
|
|
|
571
593
|
* the same confirmation, capability check and locale-aware copy.
|
|
572
594
|
*/
|
|
573
595
|
const restartPromptBridge = { open: null };
|
|
596
|
+
/** Same bridge for the "close DSH" confirmation. */
|
|
597
|
+
const closePromptBridge = { open: null };
|
|
574
598
|
|
|
575
599
|
/**
|
|
576
600
|
* Last resort for a host where the Plugins overlay (and with it the
|
|
577
|
-
* React
|
|
578
|
-
* the Host
|
|
579
|
-
*
|
|
601
|
+
* React app-action prompt) is not mounted: confirm with the browser and
|
|
602
|
+
* ask the Host route directly. Unreachable on a normal desktop/web host,
|
|
603
|
+
* where `remote.pluginManager` mounts the overlay.
|
|
604
|
+
*
|
|
605
|
+
* @param {{ api: string, action: 'restart' | 'close', titleKey: string, descKey: string, unsupportedKey: string, failedKey: string }} options
|
|
580
606
|
*/
|
|
581
|
-
async function
|
|
607
|
+
async function appActionWithoutPrompt(options) {
|
|
582
608
|
const t = (key, params) => translateCurrent(key, params);
|
|
583
609
|
try {
|
|
584
|
-
const capability = await fetch(
|
|
610
|
+
const capability = await fetch(options.api, { headers: { accept: 'application/json' } })
|
|
585
611
|
.then((response) => response.json());
|
|
586
612
|
if (capability?.supported !== true) {
|
|
587
|
-
window.alert(t(
|
|
613
|
+
window.alert(t(options.unsupportedKey, { reason: capability?.reason ?? '' }));
|
|
588
614
|
return;
|
|
589
615
|
}
|
|
590
|
-
if (window.confirm(t(
|
|
591
|
-
const response = await fetch(
|
|
616
|
+
if (window.confirm(t(options.titleKey) + ' ' + t(options.descKey)) !== true) return;
|
|
617
|
+
const response = await fetch(options.api, {
|
|
592
618
|
method: 'POST',
|
|
593
619
|
headers: { 'content-type': 'application/json' },
|
|
594
|
-
body: JSON.stringify({ action:
|
|
620
|
+
body: JSON.stringify({ action: options.action }),
|
|
595
621
|
});
|
|
596
622
|
const data = await response.json().catch(() => null);
|
|
597
623
|
if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? 'HTTP ' + response.status);
|
|
598
624
|
} catch (error) {
|
|
599
|
-
window.alert(t(
|
|
625
|
+
window.alert(t(options.failedKey, { message: error?.message ?? String(error) }));
|
|
600
626
|
}
|
|
601
627
|
}
|
|
602
628
|
|
|
629
|
+
function restartWithoutPrompt() {
|
|
630
|
+
return appActionWithoutPrompt({
|
|
631
|
+
api: UPDATE_API,
|
|
632
|
+
action: 'restart',
|
|
633
|
+
titleKey: 'restart.title',
|
|
634
|
+
descKey: 'restart.desc',
|
|
635
|
+
unsupportedKey: 'update.restartUnsupported',
|
|
636
|
+
failedKey: 'update.restartFailed',
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
function closeWithoutPrompt() {
|
|
641
|
+
return appActionWithoutPrompt({
|
|
642
|
+
api: CLOSE_API,
|
|
643
|
+
action: 'close',
|
|
644
|
+
titleKey: 'close.title',
|
|
645
|
+
descKey: 'close.desc',
|
|
646
|
+
unsupportedKey: 'close.unsupported',
|
|
647
|
+
failedKey: 'close.failed',
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
|
|
603
651
|
function launcherGroupEntry(groupId) {
|
|
604
652
|
return LAUNCHER_GROUP_PREFIX + groupId;
|
|
605
653
|
}
|
|
@@ -614,16 +662,6 @@
|
|
|
614
662
|
return 'g' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
|
|
615
663
|
}
|
|
616
664
|
|
|
617
|
-
/**
|
|
618
|
-
* Synthetic tiles (back to conversation, restart DSH, the host's "more"
|
|
619
|
-
* launcher) always live directly on the grid and can never join a folder.
|
|
620
|
-
* @param {string} key tile key
|
|
621
|
-
* @returns {boolean}
|
|
622
|
-
*/
|
|
623
|
-
function isLauncherSpecialKey(key) {
|
|
624
|
-
return key === LAUNCHER_CHAT_KEY || key === LAUNCHER_RESTART_KEY || key === LAUNCHER_MORE_KEY;
|
|
625
|
-
}
|
|
626
|
-
|
|
627
665
|
/**
|
|
628
666
|
* Reconcile the saved launcher state with the panels that exist right now.
|
|
629
667
|
* Unknown panel keys (unregistered, unpinned) are dropped; panels without
|
|
@@ -645,7 +683,6 @@
|
|
|
645
683
|
const list = Array.isArray(value.items) ? value.items : [];
|
|
646
684
|
for (const key of list) {
|
|
647
685
|
if (typeof key !== 'string' || !known.has(key) || assigned.has(key)) continue;
|
|
648
|
-
if (key.startsWith('__')) continue;
|
|
649
686
|
assigned.add(key);
|
|
650
687
|
items.push(key);
|
|
651
688
|
}
|
|
@@ -702,7 +739,7 @@
|
|
|
702
739
|
const index = source.indexOf(folderEntry);
|
|
703
740
|
const members = [];
|
|
704
741
|
for (const key of Array.isArray(items) ? items : []) {
|
|
705
|
-
if (typeof key !== 'string' || key === ''
|
|
742
|
+
if (typeof key !== 'string' || key === '') continue;
|
|
706
743
|
if (list.includes(key) || members.includes(key)) continue;
|
|
707
744
|
members.push(key);
|
|
708
745
|
}
|
|
@@ -737,6 +774,7 @@
|
|
|
737
774
|
const listPanels = typeof options.listPanels === 'function' ? options.listPanels : () => [];
|
|
738
775
|
const selectConversation = typeof options.selectConversation === 'function' ? options.selectConversation : () => {};
|
|
739
776
|
const openRestart = typeof options.openRestart === 'function' ? options.openRestart : () => false;
|
|
777
|
+
const openClose = typeof options.openClose === 'function' ? options.openClose : () => false;
|
|
740
778
|
|
|
741
779
|
let nav = null;
|
|
742
780
|
let docObserver = null;
|
|
@@ -751,6 +789,7 @@
|
|
|
751
789
|
let folderButtons = new Map();
|
|
752
790
|
let chatButton = null;
|
|
753
791
|
let restartButton = null;
|
|
792
|
+
let closeButton = null;
|
|
754
793
|
let dropLine = null;
|
|
755
794
|
let drag = null;
|
|
756
795
|
let popup = null;
|
|
@@ -794,7 +833,9 @@
|
|
|
794
833
|
if (typeof candidate.children !== 'object' || candidate.children === null) return false;
|
|
795
834
|
for (const child of [...candidate.children]) {
|
|
796
835
|
if (child.tagName === 'BUTTON') return true;
|
|
797
|
-
|
|
836
|
+
/* 0.2.2+ wraps each row in a cell element (div.panelEntry /
|
|
837
|
+
span.moreAnchor) that holds the row button as its first child. */
|
|
838
|
+
if (typeof child.querySelector === 'function' && child.querySelector(':scope > button') !== null) return true;
|
|
798
839
|
}
|
|
799
840
|
return false;
|
|
800
841
|
}
|
|
@@ -839,6 +880,15 @@
|
|
|
839
880
|
sync();
|
|
840
881
|
}
|
|
841
882
|
|
|
883
|
+
/** True when a row button is the host's "More" launcher (it opens a menu). */
|
|
884
|
+
function rowOpensMenu(buttonEl, wrapper) {
|
|
885
|
+
if (buttonEl === null || typeof buttonEl.getAttribute !== 'function') return false;
|
|
886
|
+
if (buttonEl.hasAttribute('aria-haspopup') || buttonEl.hasAttribute('aria-expanded')) return true;
|
|
887
|
+
if (wrapper !== undefined && wrapper !== null && typeof wrapper.className === 'string'
|
|
888
|
+
&& wrapper.className.includes('moreAnchor')) return true;
|
|
889
|
+
return false;
|
|
890
|
+
}
|
|
891
|
+
|
|
842
892
|
/** Resolve the host panel rows (and the "more" launcher) into tile records. */
|
|
843
893
|
function collectHostTiles(container) {
|
|
844
894
|
const byLabel = new Map();
|
|
@@ -860,21 +910,25 @@
|
|
|
860
910
|
for (const child of [...container.children]) {
|
|
861
911
|
if (child.hasAttribute('data-powerup-folder')
|
|
862
912
|
|| child.hasAttribute('data-powerup-chat')
|
|
863
|
-
|| child.hasAttribute('data-powerup-restart')
|
|
913
|
+
|| child.hasAttribute('data-powerup-restart')
|
|
914
|
+
|| child.hasAttribute('data-powerup-close')) continue;
|
|
864
915
|
if (typeof child.classList === 'object' && child.classList !== null && child.classList.contains('dsh-powerup-drop-line')) continue;
|
|
916
|
+
/* A host row is either the button itself (older sidebars) or a
|
|
917
|
+
wrapper that carries the row plus its unpin overlay (0.2.2+:
|
|
918
|
+
`div.panelEntry` per panel, `span.moreAnchor` for More). The
|
|
919
|
+
wrapper is the grid cell; its row button is the click target. */
|
|
865
920
|
let gridEl = child;
|
|
866
921
|
let buttonEl = null;
|
|
867
922
|
if (child.tagName === 'BUTTON') buttonEl = child;
|
|
868
923
|
else if (typeof child.querySelector === 'function') {
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
buttonEl = child.querySelector(':scope > button');
|
|
924
|
+
buttonEl = child.querySelector(':scope > button[class*="panelRow"]');
|
|
925
|
+
if (buttonEl === null) buttonEl = child.querySelector(':scope > button:not([class*="panelUnpin"])');
|
|
926
|
+
if (buttonEl === null) buttonEl = child.querySelector(':scope > button');
|
|
873
927
|
if (buttonEl === null) continue;
|
|
874
928
|
} else continue;
|
|
875
929
|
const label = buttonEl.getAttribute('aria-label') ?? '';
|
|
876
930
|
if (label === '') continue;
|
|
877
|
-
const isMore = child
|
|
931
|
+
const isMore = rowOpensMenu(buttonEl, child);
|
|
878
932
|
let key = isMore ? LAUNCHER_MORE_KEY : (byLabel.get(label) ?? 'label:' + label);
|
|
879
933
|
if (key !== LAUNCHER_MORE_KEY && usedKeys.has(key)) {
|
|
880
934
|
let suffix = 2;
|
|
@@ -1019,6 +1073,80 @@
|
|
|
1019
1073
|
return button;
|
|
1020
1074
|
}
|
|
1021
1075
|
|
|
1076
|
+
/**
|
|
1077
|
+
* The synthetic "close DSH" tile. Like the restart tile it opens the
|
|
1078
|
+
* React confirmation owned by the Plugins overlay (same dialog, its own
|
|
1079
|
+
* route), so closing asks before ending the app.
|
|
1080
|
+
*/
|
|
1081
|
+
function ensureCloseButton() {
|
|
1082
|
+
if (closeButton !== null && closeButton.isConnected === true) return closeButton;
|
|
1083
|
+
const button = createSyntheticTile('dsh-powerup-close', 'data-powerup-close', LAUNCHER_CLOSE_ICON);
|
|
1084
|
+
button.addEventListener('click', (event) => {
|
|
1085
|
+
event.preventDefault();
|
|
1086
|
+
event.stopPropagation();
|
|
1087
|
+
if (drag !== null && drag.active) return;
|
|
1088
|
+
closePopup();
|
|
1089
|
+
try {
|
|
1090
|
+
if (openClose() === false) warn('the close prompt is not available in this host');
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
warn('close prompt could not be opened:', error);
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
nav.appendChild(button);
|
|
1096
|
+
closeButton = button;
|
|
1097
|
+
return button;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/** The synthetic tile buttons, for drag candidates and hit-testing. */
|
|
1101
|
+
function syntheticTileButtons() {
|
|
1102
|
+
return new Map([
|
|
1103
|
+
[LAUNCHER_CHAT_KEY, chatButton],
|
|
1104
|
+
[LAUNCHER_RESTART_KEY, restartButton],
|
|
1105
|
+
[LAUNCHER_CLOSE_KEY, closeButton],
|
|
1106
|
+
]);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
/**
|
|
1110
|
+
* Full tile records for the synthetic tiles, so a folder can list,
|
|
1111
|
+
* stack and open them exactly like a host panel row.
|
|
1112
|
+
*/
|
|
1113
|
+
function syntheticTileRecords() {
|
|
1114
|
+
const records = new Map();
|
|
1115
|
+
const add = (key, button, label, glyph, active) => {
|
|
1116
|
+
if (button === null || button.isConnected !== true) return;
|
|
1117
|
+
records.set(key, {
|
|
1118
|
+
key,
|
|
1119
|
+
label,
|
|
1120
|
+
glyphHtml: glyph,
|
|
1121
|
+
buttonEl: button,
|
|
1122
|
+
gridEl: button,
|
|
1123
|
+
isMore: false,
|
|
1124
|
+
active: active === true,
|
|
1125
|
+
});
|
|
1126
|
+
};
|
|
1127
|
+
add(LAUNCHER_CHAT_KEY, chatButton, t('launcher.backToConversation'), LAUNCHER_CHAT_ICON,
|
|
1128
|
+
hostTiles.every((tile) => tile.active !== true));
|
|
1129
|
+
add(LAUNCHER_RESTART_KEY, restartButton, t('launcher.restart'), LAUNCHER_RESTART_ICON);
|
|
1130
|
+
add(LAUNCHER_CLOSE_KEY, closeButton, t('launcher.close'), LAUNCHER_CLOSE_ICON);
|
|
1131
|
+
return records;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/** Host rows plus synthetic tiles; folders can hold either kind. */
|
|
1135
|
+
function tileMap() {
|
|
1136
|
+
return new Map([...syntheticTileRecords(), ...tileByKeyMap()]);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* Apply the shared state (label, visibility, grid position) to one
|
|
1141
|
+
* synthetic tile. A tile that a folder hides disappears from the grid.
|
|
1142
|
+
*/
|
|
1143
|
+
function syncSyntheticTile(button, key, label, hint, wide, memberOf, orderIndex) {
|
|
1144
|
+
setSyntheticLabel(button, label, hint);
|
|
1145
|
+
button.style.display = wide && !memberOf.has(key) ? '' : 'none';
|
|
1146
|
+
const position = orderIndex.get(key);
|
|
1147
|
+
button.style.order = position === undefined ? '' : String(position);
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1022
1150
|
function hideDropLine() {
|
|
1023
1151
|
if (dropLine !== null) dropLine.style.display = 'none';
|
|
1024
1152
|
if (nav !== null && typeof nav.querySelectorAll === 'function') {
|
|
@@ -1034,6 +1162,7 @@
|
|
|
1034
1162
|
folderButtons = new Map();
|
|
1035
1163
|
if (chatButton !== null) chatButton.style.display = 'none';
|
|
1036
1164
|
if (restartButton !== null) restartButton.style.display = 'none';
|
|
1165
|
+
if (closeButton !== null) closeButton.style.display = 'none';
|
|
1037
1166
|
if (dropLine !== null) {
|
|
1038
1167
|
dropLine.remove();
|
|
1039
1168
|
dropLine = null;
|
|
@@ -1080,14 +1209,13 @@
|
|
|
1080
1209
|
hostTiles = collectHostTiles(nav);
|
|
1081
1210
|
const wide = detectWide(hostTiles);
|
|
1082
1211
|
nav.classList.toggle('dsh-powerup-launcher-wide', wide);
|
|
1083
|
-
const panelKeys = [LAUNCHER_CHAT_KEY, LAUNCHER_RESTART_KEY, ...hostTiles.map((tile) => tile.key)];
|
|
1212
|
+
const panelKeys = [LAUNCHER_CHAT_KEY, LAUNCHER_RESTART_KEY, LAUNCHER_CLOSE_KEY, ...hostTiles.map((tile) => tile.key)];
|
|
1084
1213
|
if (pendingLoad) {
|
|
1085
1214
|
pendingLoad = false;
|
|
1086
1215
|
state = normalizeLauncherState(readPersisted(), panelKeys);
|
|
1087
1216
|
} else {
|
|
1088
1217
|
state = normalizeLauncherState(state, panelKeys);
|
|
1089
1218
|
}
|
|
1090
|
-
const tiles = tileByKeyMap();
|
|
1091
1219
|
const memberOf = new Map();
|
|
1092
1220
|
for (const group of Object.values(state.groups)) {
|
|
1093
1221
|
for (const key of group.items) memberOf.set(key, group.id);
|
|
@@ -1101,18 +1229,17 @@
|
|
|
1101
1229
|
tile.gridEl.style.display = hidden ? 'none' : '';
|
|
1102
1230
|
const position = orderIndex.get(tile.key);
|
|
1103
1231
|
tile.gridEl.style.order = position === undefined ? '' : String(position);
|
|
1232
|
+
if (tile.active) tile.gridEl.setAttribute('data-powerup-active', '');
|
|
1233
|
+
else tile.gridEl.removeAttribute('data-powerup-active');
|
|
1104
1234
|
}
|
|
1105
1235
|
const chat = ensureChatButton();
|
|
1106
|
-
|
|
1107
|
-
chat.style.display = wide ? '' : 'none';
|
|
1108
|
-
const chatPosition = orderIndex.get(LAUNCHER_CHAT_KEY);
|
|
1109
|
-
chat.style.order = chatPosition === undefined ? '' : String(chatPosition);
|
|
1236
|
+
syncSyntheticTile(chat, LAUNCHER_CHAT_KEY, t('launcher.backToConversation'), undefined, wide, memberOf, orderIndex);
|
|
1110
1237
|
chat.classList.toggle('is-active', hostTiles.every((tile) => tile.active !== true));
|
|
1111
1238
|
const restart = ensureRestartButton();
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1239
|
+
syncSyntheticTile(restart, LAUNCHER_RESTART_KEY, t('launcher.restart'), t('launcher.restartHint'), wide, memberOf, orderIndex);
|
|
1240
|
+
const close = ensureCloseButton();
|
|
1241
|
+
syncSyntheticTile(close, LAUNCHER_CLOSE_KEY, t('launcher.close'), t('launcher.closeHint'), wide, memberOf, orderIndex);
|
|
1242
|
+
const tiles = tileMap();
|
|
1116
1243
|
const live = new Set();
|
|
1117
1244
|
for (const [groupId, group] of Object.entries(state.groups)) {
|
|
1118
1245
|
live.add(groupId);
|
|
@@ -1288,8 +1415,7 @@
|
|
|
1288
1415
|
const element = popup.element;
|
|
1289
1416
|
element.textContent = '';
|
|
1290
1417
|
const head = document.createElement('div');
|
|
1291
|
-
head.className = 'dsh-powerup-folder-pop-head';
|
|
1292
|
-
const title = document.createElement('button');
|
|
1418
|
+
head.className = 'dsh-powerup-folder-pop-head'; const title = document.createElement('button');
|
|
1293
1419
|
title.type = 'button';
|
|
1294
1420
|
title.className = 'dsh-powerup-folder-pop-title';
|
|
1295
1421
|
title.textContent = group.name === '' ? t('launcher.groupDefault') : group.name;
|
|
@@ -1306,7 +1432,7 @@
|
|
|
1306
1432
|
head.append(title, count, dissolve);
|
|
1307
1433
|
const grid = document.createElement('div');
|
|
1308
1434
|
grid.className = 'dsh-powerup-folder-grid';
|
|
1309
|
-
const tiles =
|
|
1435
|
+
const tiles = tileMap();
|
|
1310
1436
|
for (const key of group.items) {
|
|
1311
1437
|
const tile = tiles.get(key);
|
|
1312
1438
|
if (tile === undefined) continue;
|
|
@@ -1534,9 +1660,36 @@
|
|
|
1534
1660
|
}
|
|
1535
1661
|
}
|
|
1536
1662
|
|
|
1663
|
+
/**
|
|
1664
|
+
* Activate one grid or folder flyout tile. The host's "more" row is
|
|
1665
|
+
* wrapped in a Menu root; when a folder hides it, the menu would anchor
|
|
1666
|
+
* to a zero-sized element, so briefly restore its box (transparent) and
|
|
1667
|
+
* let the host open the menu near the grid, then hide it again.
|
|
1668
|
+
*/
|
|
1537
1669
|
function selectPanel(tile) {
|
|
1538
1670
|
try {
|
|
1539
|
-
tile.
|
|
1671
|
+
const hiddenMore = tile.isMore === true
|
|
1672
|
+
&& tile.gridEl !== undefined
|
|
1673
|
+
&& typeof tile.gridEl.style === 'object'
|
|
1674
|
+
&& tile.gridEl.style.display === 'none';
|
|
1675
|
+
if (hiddenMore) {
|
|
1676
|
+
const element = tile.gridEl;
|
|
1677
|
+
const restore = { display: element.style.display, opacity: element.style.opacity, pointerEvents: element.style.pointerEvents };
|
|
1678
|
+
element.style.display = '';
|
|
1679
|
+
element.style.opacity = '0';
|
|
1680
|
+
element.style.pointerEvents = 'none';
|
|
1681
|
+
if (typeof element.getBoundingClientRect === 'function') void element.getBoundingClientRect();
|
|
1682
|
+
tile.buttonEl.click();
|
|
1683
|
+
const reset = () => {
|
|
1684
|
+
element.style.display = restore.display;
|
|
1685
|
+
element.style.opacity = restore.opacity;
|
|
1686
|
+
element.style.pointerEvents = restore.pointerEvents;
|
|
1687
|
+
};
|
|
1688
|
+
if (typeof window !== 'undefined' && window !== null && typeof window.setTimeout === 'function') window.setTimeout(reset, 400);
|
|
1689
|
+
else reset();
|
|
1690
|
+
} else {
|
|
1691
|
+
tile.buttonEl.click();
|
|
1692
|
+
}
|
|
1540
1693
|
} catch (error) {
|
|
1541
1694
|
warn('panel could not be selected:', error);
|
|
1542
1695
|
}
|
|
@@ -1595,12 +1748,13 @@
|
|
|
1595
1748
|
// ----------------------------------------------------------------
|
|
1596
1749
|
function topLevelCandidates(excludeKey) {
|
|
1597
1750
|
const candidates = [];
|
|
1751
|
+
const synthetic = syntheticTileButtons();
|
|
1598
1752
|
for (const entry of state.order) {
|
|
1599
1753
|
if (entry === excludeKey) continue;
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
if (
|
|
1603
|
-
candidates.push({ key: entry, el:
|
|
1754
|
+
const synth = synthetic.get(entry);
|
|
1755
|
+
if (synth !== undefined) {
|
|
1756
|
+
if (synth !== null && synth.isConnected === true && synth.style.display !== 'none') {
|
|
1757
|
+
candidates.push({ key: entry, el: synth, kind: 'synthetic' });
|
|
1604
1758
|
}
|
|
1605
1759
|
continue;
|
|
1606
1760
|
}
|
|
@@ -1621,13 +1775,36 @@
|
|
|
1621
1775
|
function describeTile(target) {
|
|
1622
1776
|
if (target === null || target === undefined || typeof target.closest !== 'function') return null;
|
|
1623
1777
|
const button = target.closest('button');
|
|
1624
|
-
if (button
|
|
1778
|
+
if (button !== null && nav !== null && nav.contains(button)) {
|
|
1779
|
+
const described = describeButton(button);
|
|
1780
|
+
if (described !== null) return described;
|
|
1781
|
+
}
|
|
1782
|
+
/* A press on the cell padding (or the unpin overlay) still belongs to
|
|
1783
|
+
the tile that owns the cell. */
|
|
1784
|
+
const cell = target.closest('[data-powerup-grid]');
|
|
1785
|
+
if (cell === null || nav === null || !nav.contains(cell)) return null;
|
|
1786
|
+
const key = cell.getAttribute('data-powerup-grid');
|
|
1787
|
+
const folderId = cell.getAttribute('data-powerup-folder');
|
|
1788
|
+
if (folderId !== null) {
|
|
1789
|
+
const group = state.groups[folderId];
|
|
1790
|
+
if (group === undefined) return null;
|
|
1791
|
+
return { kind: 'folder', key: launcherGroupEntry(folderId), gridEl: cell, label: group.name };
|
|
1792
|
+
}
|
|
1793
|
+
const tile = hostTiles.find((candidate) => candidate.key === key);
|
|
1794
|
+
if (tile === undefined) return null;
|
|
1795
|
+
return { kind: tile.isMore ? 'more' : 'panel', key: tile.key, gridEl: tile.gridEl, label: tile.label };
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
function describeButton(button) {
|
|
1625
1799
|
if (button.hasAttribute('data-powerup-chat')) {
|
|
1626
1800
|
return { kind: 'chat', key: LAUNCHER_CHAT_KEY, gridEl: button, label: t('launcher.backToConversation') };
|
|
1627
1801
|
}
|
|
1628
1802
|
if (button.hasAttribute('data-powerup-restart')) {
|
|
1629
1803
|
return { kind: 'restart', key: LAUNCHER_RESTART_KEY, gridEl: button, label: t('launcher.restart') };
|
|
1630
1804
|
}
|
|
1805
|
+
if (button.hasAttribute('data-powerup-close')) {
|
|
1806
|
+
return { kind: 'close', key: LAUNCHER_CLOSE_KEY, gridEl: button, label: t('launcher.close') };
|
|
1807
|
+
}
|
|
1631
1808
|
const folderId = button.getAttribute('data-powerup-folder');
|
|
1632
1809
|
if (folderId !== null) {
|
|
1633
1810
|
const group = state.groups[folderId];
|
|
@@ -1729,8 +1906,7 @@
|
|
|
1729
1906
|
const centerX = rect.left + rect.width / 2;
|
|
1730
1907
|
const centerY = rect.top + rect.height / 2;
|
|
1731
1908
|
const nearCenter = Math.abs(x - centerX) <= rect.width * 0.28 && Math.abs(y - centerY) <= rect.height * 0.32;
|
|
1732
|
-
|
|
1733
|
-
if (nearCenter && !special) {
|
|
1909
|
+
if (nearCenter) {
|
|
1734
1910
|
drop = { kind: 'merge', target: candidate };
|
|
1735
1911
|
} else {
|
|
1736
1912
|
drop = { kind: 'insert', index: candidates.indexOf(candidate) + (x < centerX ? 0 : 1), anchor: rect, after: x >= centerX };
|
|
@@ -1858,7 +2034,6 @@
|
|
|
1858
2034
|
|
|
1859
2035
|
function performMerge(sourceKey, targetKey) {
|
|
1860
2036
|
if (sourceKey === targetKey) return;
|
|
1861
|
-
if (isLauncherSpecialKey(sourceKey) || isLauncherSpecialKey(targetKey)) return;
|
|
1862
2037
|
const sourceGroupId = launcherEntryGroupId(sourceKey);
|
|
1863
2038
|
const targetGroupId = launcherEntryGroupId(targetKey);
|
|
1864
2039
|
if (sourceGroupId !== null && sourceGroupId === targetGroupId) return;
|
|
@@ -1955,6 +2130,10 @@
|
|
|
1955
2130
|
restartButton.remove();
|
|
1956
2131
|
restartButton = null;
|
|
1957
2132
|
}
|
|
2133
|
+
if (closeButton !== null) {
|
|
2134
|
+
closeButton.remove();
|
|
2135
|
+
closeButton = null;
|
|
2136
|
+
}
|
|
1958
2137
|
state = { order: [], groups: {} };
|
|
1959
2138
|
pendingLoad = true;
|
|
1960
2139
|
nav = null;
|
|
@@ -1971,6 +2150,9 @@
|
|
|
1971
2150
|
state = normalizeLauncherState(next, hostTiles.filter((tile) => !tile.isMore).map((tile) => tile.key));
|
|
1972
2151
|
},
|
|
1973
2152
|
getNav: () => nav,
|
|
2153
|
+
collectHostTiles,
|
|
2154
|
+
detectWide,
|
|
2155
|
+
rowOpensMenu,
|
|
1974
2156
|
},
|
|
1975
2157
|
};
|
|
1976
2158
|
}
|
|
@@ -2034,6 +2216,14 @@
|
|
|
2034
2216
|
void restartWithoutPrompt();
|
|
2035
2217
|
return true;
|
|
2036
2218
|
},
|
|
2219
|
+
openClose: () => {
|
|
2220
|
+
if (closePromptBridge.open !== null) {
|
|
2221
|
+
closePromptBridge.open();
|
|
2222
|
+
return true;
|
|
2223
|
+
}
|
|
2224
|
+
void closeWithoutPrompt();
|
|
2225
|
+
return true;
|
|
2226
|
+
},
|
|
2037
2227
|
});
|
|
2038
2228
|
ctx.effect(() => {
|
|
2039
2229
|
core.start();
|
|
@@ -2357,15 +2547,20 @@
|
|
|
2357
2547
|
*/
|
|
2358
2548
|
const LAUNCHER_CSS = `
|
|
2359
2549
|
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide{position:relative;display:grid!important;grid-template-columns:repeat(auto-fill,minmax(58px,1fr));grid-auto-rows:min-content;gap:2px;align-content:start;align-items:stretch;margin:0 0 10px;padding:2px 0}
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-
|
|
2550
|
+
/* One grid cell per tile. A host row arrives either as a bare button or as a
|
|
2551
|
+
wrapper that also holds the unpin overlay (0.2.2+: div.panelEntry, and
|
|
2552
|
+
span.moreAnchor for More), so the cell box and the tile face are styled
|
|
2553
|
+
separately: the wrapper is the cell, its row button is the face. */
|
|
2554
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid],.dsh-powerup-folder,.dsh-powerup-synth{position:relative;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;width:auto;min-width:0;height:auto;min-height:52px;margin:0;padding:0;border:0;border-inline:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:11px;line-height:14px;text-align:center}
|
|
2555
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]>button:not([class*="panelUnpin"]),nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button[data-powerup-grid],.dsh-powerup-folder,.dsh-powerup-synth{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;flex:1 1 auto;width:100%;min-width:0;height:auto;min-height:52px;margin:0;padding:6px 2px 5px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:inherit;font:inherit;font-size:11px;line-height:14px;text-align:center;cursor:pointer;user-select:none;-webkit-user-select:none;transition:background .12s ease,color .12s ease,transform .12s ease}
|
|
2556
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover,.dsh-powerup-folder:hover,.dsh-powerup-synth:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
2557
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:active,.dsh-powerup-folder:active,.dsh-powerup-synth:active{transform:scale(.96)}
|
|
2558
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid][data-powerup-active],nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid][class*="panelEntryActive"],nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:has(>button[aria-expanded=true]){background:var(--dsw-alias-interactive-bg-hover)}
|
|
2559
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelUnpin"]{display:none!important}
|
|
2365
2560
|
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelGlyph"]{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex:none}
|
|
2366
2561
|
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelGlyph"] svg{width:20px;height:20px}
|
|
2367
2562
|
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide [class*="panelTitle"]{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:14px;font-weight:400;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2368
|
-
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>
|
|
2563
|
+
nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid]:hover [class*="panelTitle"]{color:var(--dsw-alias-label-primary)}
|
|
2369
2564
|
.dsh-powerup-folder{position:relative;list-style:none;flex:none}
|
|
2370
2565
|
.dsh-powerup-folder-stack{display:grid;grid-template-columns:repeat(2,1fr);grid-template-rows:repeat(2,1fr);gap:1px;width:24px;height:24px;padding:2px;box-sizing:border-box;border-radius:6px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 9%,transparent);flex:none}
|
|
2371
2566
|
.dsh-powerup-folder-mini{display:inline-flex;align-items:center;justify-content:center;min-width:0;min-height:0;overflow:hidden;color:var(--dsw-alias-label-primary);opacity:.85}
|
|
@@ -2385,8 +2580,9 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
2385
2580
|
.dsh-powerup-merge-target{background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 17%,transparent)!important;box-shadow:inset 0 0 0 1px var(--dsw-alias-state-business-primary)}
|
|
2386
2581
|
.dsh-powerup-drop-line{position:absolute;z-index:6;display:none;width:2px;border-radius:999px;background:var(--dsw-alias-state-business-primary);box-shadow:0 0 0 1px color-mix(in srgb,var(--dsw-alias-state-business-primary) 26%,transparent);pointer-events:none}
|
|
2387
2582
|
.dsh-powerup-drag-ghost{position:fixed;z-index:1800;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:6px 2px 5px;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);font-size:11px;line-height:14px;pointer-events:none;opacity:.96;transform:scale(1.05);transition:opacity .1s ease}
|
|
2388
|
-
.dsh-powerup-drag-ghost>button{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;width:100%;min-height:0;margin:0;padding:6px 2px 5px;border:0;background:transparent;color:inherit;font:inherit;font-size:11px;line-height:14px;text-align:center;cursor:pointer;user-select:none;-webkit-user-select:none}
|
|
2583
|
+
.dsh-powerup-drag-ghost>button:not([class*="panelUnpin"]){box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;width:100%;min-height:0;margin:0;padding:6px 2px 5px;border:0;background:transparent;color:inherit;font:inherit;font-size:11px;line-height:14px;text-align:center;cursor:pointer;user-select:none;-webkit-user-select:none}
|
|
2389
2584
|
.dsh-powerup-drag-ghost [class*="panelGlyph"]{display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;flex:none}
|
|
2585
|
+
.dsh-powerup-drag-ghost [class*="panelUnpin"]{display:none!important}
|
|
2390
2586
|
.dsh-powerup-drag-ghost [class*="panelGlyph"] svg{width:20px;height:20px}
|
|
2391
2587
|
.dsh-powerup-drag-ghost [class*="panelTitle"]{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:14px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2392
2588
|
.dsh-powerup-folder-pop{position:fixed;z-index:1800;box-sizing:border-box;display:flex;flex-direction:column;gap:6px;width:max-content;min-width:196px;max-width:min(440px,calc(100vw - 24px));max-height:min(72vh,440px);padding:8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg,10px);background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);font-size:12px;line-height:16px;opacity:0;transform:scale(.92);transition:opacity .13s ease,transform .17s cubic-bezier(.22,.9,.3,1.06)}
|
|
@@ -2419,7 +2615,7 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
2419
2615
|
.dsh-powerup-folder-item-ghost .dsh-powerup-folder-item-glyph svg{width:20px;height:20px}
|
|
2420
2616
|
.dsh-powerup-folder-item-ghost .dsh-powerup-folder-item-label{display:block;width:100%;max-width:100%;color:var(--dsw-alias-label-secondary);text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
2421
2617
|
.dsh-powerup-folder-item-ghost .dsh-powerup-folder-item-remove{display:none}
|
|
2422
|
-
@media (prefers-reduced-motion:reduce){nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>
|
|
2618
|
+
@media (prefers-reduced-motion:reduce){nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>[data-powerup-grid],.dsh-powerup-folder,.dsh-powerup-synth,.dsh-powerup-folder-pop,.dsh-powerup-drag-ghost,.dsh-powerup-drop-line{transition:none}}
|
|
2423
2619
|
`;
|
|
2424
2620
|
|
|
2425
2621
|
const CSS = `
|
|
@@ -3054,6 +3250,8 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
3054
3250
|
const POWERUP_REGISTRY_KEY = 'dsh-powerup:update-registry:v1';
|
|
3055
3251
|
const PENDING_RESTART_KEY = 'dsh-powerup:pending-restart:v1';
|
|
3056
3252
|
const UPDATE_API = '/dsh-powerup/api/restart';
|
|
3253
|
+
/** Host route that closes the whole application. */
|
|
3254
|
+
const CLOSE_API = '/dsh-powerup/api/close';
|
|
3057
3255
|
const AUDIT_API = '/dsh-powerup/api/audit';
|
|
3058
3256
|
const SELF_UPDATE_API = '/dsh-powerup/api/self-update';
|
|
3059
3257
|
const JOB_KILL_API = '/dsh-powerup/api/job-kill';
|
|
@@ -4077,10 +4275,11 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
4077
4275
|
const [view, setView] = useState(null);
|
|
4078
4276
|
const [localeTick, forceLocale] = useState(0);
|
|
4079
4277
|
const [pending, setPending] = useState(() => readPendingRestarts());
|
|
4080
|
-
|
|
4081
|
-
const [
|
|
4082
|
-
const [
|
|
4083
|
-
const [
|
|
4278
|
+
/** Open app-level confirmation: null, 'restart' or 'close'. */
|
|
4279
|
+
const [appAsk, setAppAsk] = useState(null);
|
|
4280
|
+
const [appCapability, setAppCapability] = useState(null);
|
|
4281
|
+
const [appBusy, setAppBusy] = useState(false);
|
|
4282
|
+
const [appError, setAppError] = useState(null);
|
|
4084
4283
|
const tokenRef = useRef(null);
|
|
4085
4284
|
const abortRef = useRef(null);
|
|
4086
4285
|
const buttonsRef = useRef(new Set());
|
|
@@ -4495,18 +4694,18 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
4495
4694
|
};
|
|
4496
4695
|
}, [remote]);
|
|
4497
4696
|
|
|
4498
|
-
// Escape dismisses the
|
|
4499
|
-
//
|
|
4697
|
+
// Escape dismisses the app-level confirmation unless its request is
|
|
4698
|
+
// already in flight.
|
|
4500
4699
|
useEffect(() => {
|
|
4501
|
-
if (
|
|
4700
|
+
if (appAsk === null) return undefined;
|
|
4502
4701
|
const onKeyDown = (event) => {
|
|
4503
|
-
if (event.key !== 'Escape' ||
|
|
4702
|
+
if (event.key !== 'Escape' || appBusy) return;
|
|
4504
4703
|
event.stopPropagation();
|
|
4505
|
-
|
|
4704
|
+
setAppAsk(null);
|
|
4506
4705
|
};
|
|
4507
4706
|
document.addEventListener('keydown', onKeyDown, true);
|
|
4508
4707
|
return () => document.removeEventListener('keydown', onKeyDown, true);
|
|
4509
|
-
}, [
|
|
4708
|
+
}, [appAsk, appBusy]);
|
|
4510
4709
|
|
|
4511
4710
|
// A one-click update that does not restart leaves a completion panel;
|
|
4512
4711
|
// close it on its own so it never lingers over the Plugins page.
|
|
@@ -4747,10 +4946,10 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
4747
4946
|
}
|
|
4748
4947
|
};
|
|
4749
4948
|
|
|
4750
|
-
/** Ask
|
|
4751
|
-
const
|
|
4949
|
+
/** Ask one Host app-control route whether this runtime supports it. */
|
|
4950
|
+
const readAppCapability = async (api) => {
|
|
4752
4951
|
try {
|
|
4753
|
-
const response = await fetch(
|
|
4952
|
+
const response = await fetch(api, { headers: { accept: 'application/json' } });
|
|
4754
4953
|
const data = await response.json();
|
|
4755
4954
|
return {
|
|
4756
4955
|
supported: response.ok && data?.ok === true && data.supported === true,
|
|
@@ -4761,48 +4960,60 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
4761
4960
|
}
|
|
4762
4961
|
};
|
|
4763
4962
|
|
|
4764
|
-
/**
|
|
4765
|
-
const
|
|
4766
|
-
|
|
4963
|
+
/** The restart capability, used by the install flow as well. */
|
|
4964
|
+
const readRestartCapability = () => readAppCapability(UPDATE_API);
|
|
4965
|
+
|
|
4966
|
+
/** POST one app-control command; throws when the Host refuses. */
|
|
4967
|
+
const requestAppAction = async (action) => {
|
|
4968
|
+
const api = action === 'close' ? CLOSE_API : UPDATE_API;
|
|
4969
|
+
const response = await fetch(api, {
|
|
4767
4970
|
method: 'POST',
|
|
4768
4971
|
headers: { 'content-type': 'application/json' },
|
|
4769
|
-
body: JSON.stringify({ action
|
|
4972
|
+
body: JSON.stringify({ action }),
|
|
4770
4973
|
});
|
|
4771
4974
|
const data = await response.json().catch(() => null);
|
|
4772
4975
|
if (!response.ok || data?.ok !== true) throw new Error(data?.error ?? `HTTP ${response.status}`);
|
|
4773
4976
|
};
|
|
4774
4977
|
|
|
4775
|
-
/**
|
|
4776
|
-
const
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4780
|
-
|
|
4781
|
-
|
|
4978
|
+
/** The restart command, as the install flow spells it. */
|
|
4979
|
+
const requestAppRestart = () => requestAppAction('restart');
|
|
4980
|
+
|
|
4981
|
+
/** Open the app-level confirmation for one action and read its capability. */
|
|
4982
|
+
const openAppAction = (action) => {
|
|
4983
|
+
setAppAsk(action);
|
|
4984
|
+
setAppCapability(null);
|
|
4985
|
+
setAppError(null);
|
|
4986
|
+
setAppBusy(false);
|
|
4987
|
+
void readAppCapability(action === 'close' ? CLOSE_API : UPDATE_API)
|
|
4988
|
+
.then((capability) => setAppCapability(capability));
|
|
4782
4989
|
};
|
|
4783
|
-
|
|
4990
|
+
const openAppActionRef = useRef(() => {});
|
|
4991
|
+
openAppActionRef.current = openAppAction;
|
|
4992
|
+
openRestartRef.current = () => openAppActionRef.current('restart');
|
|
4784
4993
|
|
|
4785
4994
|
// The sidebar launcher is plain DOM and cannot render React, so it
|
|
4786
|
-
// calls
|
|
4787
|
-
//
|
|
4995
|
+
// calls these openers for its synthetic restart/close tiles. Keeping
|
|
4996
|
+
// them here means the sidebar and the pending-restart bar share one
|
|
4788
4997
|
// confirmation dialog, one capability read and one set of copy.
|
|
4789
4998
|
useEffect(() => {
|
|
4790
|
-
restartPromptBridge.open = () =>
|
|
4999
|
+
restartPromptBridge.open = () => openAppActionRef.current('restart');
|
|
5000
|
+
closePromptBridge.open = () => openAppActionRef.current('close');
|
|
4791
5001
|
return () => {
|
|
4792
5002
|
if (restartPromptBridge.open !== null) restartPromptBridge.open = null;
|
|
5003
|
+
if (closePromptBridge.open !== null) closePromptBridge.open = null;
|
|
4793
5004
|
};
|
|
4794
5005
|
}, []);
|
|
4795
5006
|
|
|
4796
|
-
/** Confirm the
|
|
4797
|
-
const
|
|
4798
|
-
if (
|
|
4799
|
-
|
|
4800
|
-
|
|
5007
|
+
/** Confirm the app-level action (restart or close). */
|
|
5008
|
+
const confirmAppAction = async () => {
|
|
5009
|
+
if (appBusy) return;
|
|
5010
|
+
setAppBusy(true);
|
|
5011
|
+
setAppError(null);
|
|
4801
5012
|
try {
|
|
4802
|
-
await
|
|
5013
|
+
await requestAppAction(appAsk === 'close' ? 'close' : 'restart');
|
|
4803
5014
|
} catch (error) {
|
|
4804
|
-
|
|
4805
|
-
|
|
5015
|
+
setAppBusy(false);
|
|
5016
|
+
setAppError(errorText(error) || tRef.current('update.unknown'));
|
|
4806
5017
|
}
|
|
4807
5018
|
};
|
|
4808
5019
|
|
|
@@ -4867,10 +5078,11 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
4867
5078
|
),
|
|
4868
5079
|
);
|
|
4869
5080
|
|
|
4870
|
-
const
|
|
5081
|
+
const appAction = appAsk === 'close' ? 'close' : 'restart';
|
|
5082
|
+
const appPrompt = appAsk === null ? null : h('div', {
|
|
4871
5083
|
className: 'dsh-powerup-update-mask',
|
|
4872
5084
|
onMouseDown: (event) => {
|
|
4873
|
-
if (event.target === event.currentTarget && !
|
|
5085
|
+
if (event.target === event.currentTarget && !appBusy) setAppAsk(null);
|
|
4874
5086
|
},
|
|
4875
5087
|
},
|
|
4876
5088
|
h('div', {
|
|
@@ -4878,43 +5090,43 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
4878
5090
|
style: { width: 'min(420px,100%)' },
|
|
4879
5091
|
role: 'dialog',
|
|
4880
5092
|
'aria-modal': 'true',
|
|
4881
|
-
'aria-labelledby': 'dsh-powerup-
|
|
5093
|
+
'aria-labelledby': 'dsh-powerup-app-action-title',
|
|
4882
5094
|
},
|
|
4883
5095
|
h('div', { className: 'dsh-powerup-update-head' },
|
|
4884
5096
|
h('div', { className: 'dsh-powerup-update-heading' },
|
|
4885
|
-
h('h2', { id: 'dsh-powerup-
|
|
5097
|
+
h('h2', { id: 'dsh-powerup-app-action-title' }, t(appAction === 'close' ? 'close.title' : 'restart.title')),
|
|
4886
5098
|
/* A sidebar-initiated restart usually has no pending plugins, so the
|
|
4887
5099
|
subtitle only appears when there is something to report. */
|
|
4888
|
-
pending.length
|
|
5100
|
+
appAction === 'restart' && pending.length > 0 ? h('p', null, t('restart.pending', { count: pending.length })) : null,
|
|
4889
5101
|
),
|
|
4890
|
-
|
|
5102
|
+
appBusy ? null : h('button', { type: 'button', className: 'dsh-powerup-update-close', 'aria-label': t('update.close'), onClick: () => setAppAsk(null) }, '×'),
|
|
4891
5103
|
),
|
|
4892
5104
|
h('div', { className: 'dsh-powerup-update-body' },
|
|
4893
|
-
h('p', { className: 'dsh-powerup-update-note' }, t('restart.desc')),
|
|
4894
|
-
|
|
4895
|
-
? notice('warn', h(WarnIcon, { size: 14 }), null, t('update.restartUnsupported', { reason:
|
|
5105
|
+
h('p', { className: 'dsh-powerup-update-note' }, t(appAction === 'close' ? 'close.desc' : 'restart.desc')),
|
|
5106
|
+
appCapability !== null && appCapability.supported !== true
|
|
5107
|
+
? notice('warn', h(WarnIcon, { size: 14 }), null, t(appAction === 'close' ? 'close.unsupported' : 'update.restartUnsupported', { reason: appCapability.reason ?? '' }))
|
|
4896
5108
|
: null,
|
|
4897
|
-
|
|
4898
|
-
|
|
5109
|
+
appError === null ? null : notice('error', h(WarnIcon, { size: 14 }), null, appError),
|
|
5110
|
+
appBusy
|
|
4899
5111
|
? h('div', { className: 'dsh-powerup-update-status' },
|
|
4900
5112
|
h('span', { className: 'dsh-powerup-update-spinner', 'aria-hidden': 'true' }),
|
|
4901
|
-
t('update.restarting'),
|
|
5113
|
+
t(appAction === 'close' ? 'close.closing' : 'update.restarting'),
|
|
4902
5114
|
)
|
|
4903
5115
|
: null,
|
|
4904
5116
|
),
|
|
4905
5117
|
h('div', { className: 'dsh-powerup-update-foot' },
|
|
4906
|
-
h('button', { type: 'button', className: 'dsh-powerup-update-ghost', disabled:
|
|
5118
|
+
h('button', { type: 'button', className: 'dsh-powerup-update-ghost', disabled: appBusy, onClick: () => setAppAsk(null) }, t(appAction === 'close' ? 'close.cancel' : 'restart.cancel')),
|
|
4907
5119
|
h('button', {
|
|
4908
5120
|
type: 'button',
|
|
4909
5121
|
className: 'dsh-powerup-update-primary',
|
|
4910
|
-
disabled:
|
|
4911
|
-
onClick:
|
|
4912
|
-
},
|
|
5122
|
+
disabled: appBusy || appCapability?.supported !== true,
|
|
5123
|
+
onClick: confirmAppAction,
|
|
5124
|
+
}, appBusy ? t(appAction === 'close' ? 'close.closing' : 'update.restarting') : t(appAction === 'close' ? 'close.confirm' : 'restart.confirm')),
|
|
4913
5125
|
),
|
|
4914
5126
|
),
|
|
4915
|
-
)
|
|
5127
|
+
);
|
|
4916
5128
|
|
|
4917
|
-
if (view === null) return
|
|
5129
|
+
if (view === null) return appPrompt;
|
|
4918
5130
|
const busy = view.phase === 'working' || view.phase === 'self-updating' || view.phase === 'restarting' || view.enabling === true;
|
|
4919
5131
|
const canClose = !busy;
|
|
4920
5132
|
const title = view.title === undefined || view.title === '' ? view.name : view.title;
|
|
@@ -5782,6 +5994,9 @@ nav.dsh-powerup-launcher.dsh-powerup-launcher-wide>button:hover [class*="panelTi
|
|
|
5782
5994
|
LAUNCHER_CHAT_KEY,
|
|
5783
5995
|
LAUNCHER_RESTART_KEY,
|
|
5784
5996
|
LAUNCHER_RESTART_ICON,
|
|
5997
|
+
LAUNCHER_CLOSE_KEY,
|
|
5998
|
+
LAUNCHER_MORE_KEY,
|
|
5999
|
+
LAUNCHER_CLOSE_ICON,
|
|
5785
6000
|
normalizeLauncherState,
|
|
5786
6001
|
dissolveGroupOrder,
|
|
5787
6002
|
createLauncherCore,
|
package/index.js
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* GET /dsh-powerup/api/restart → { ok, supported, reason? }
|
|
8
8
|
* POST /dsh-powerup/api/restart → schedules a whole-app restart
|
|
9
|
+
* GET /dsh-powerup/api/close → { ok, supported, reason? }
|
|
10
|
+
* POST /dsh-powerup/api/close → closes the whole app (no relaunch)
|
|
9
11
|
* GET /dsh-powerup/api/audit → profile bundles newer than this Host
|
|
10
12
|
* POST /dsh-powerup/api/self-update → removes and reinstalls this plugin
|
|
11
13
|
* in the background, surviving the
|
|
@@ -33,7 +35,7 @@ import { appendFileSync, mkdirSync, readFileSync, statSync } from 'node:fs';
|
|
|
33
35
|
import { dirname, join } from 'node:path';
|
|
34
36
|
import { homedir } from 'node:os';
|
|
35
37
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
36
|
-
import { describeRestart, requestRestart } from './lib/restart.js';
|
|
38
|
+
import { describeClose, describeRestart, requestRestart, requestShutdown } from './lib/restart.js';
|
|
37
39
|
import { createStepReadTool } from './lib/step-tool.js';
|
|
38
40
|
|
|
39
41
|
/** Prefix owned by this plugin. */
|
|
@@ -354,7 +356,7 @@ async function handle(req, res, ctx) {
|
|
|
354
356
|
|
|
355
357
|
const url = new URL(req.url ?? ROUTE, 'http://localhost');
|
|
356
358
|
const op = url.pathname.slice(ROUTE.length).replace(/^\/+/u, '') || url.searchParams.get('op') || '';
|
|
357
|
-
if (op !== '' && op !== 'restart' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill') {
|
|
359
|
+
if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill') {
|
|
358
360
|
sendJson(res, { ok: false, error: 'not-found' }, 404);
|
|
359
361
|
return;
|
|
360
362
|
}
|
|
@@ -440,22 +442,26 @@ async function handle(req, res, ctx) {
|
|
|
440
442
|
return;
|
|
441
443
|
}
|
|
442
444
|
|
|
443
|
-
if (
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
445
|
+
if (op === '' || op === 'restart' || op === 'close') {
|
|
446
|
+
const action = op === 'close' ? 'close' : 'restart';
|
|
447
|
+
if (req.method === 'GET') {
|
|
448
|
+
sendJson(res, { ok: true, action, ...(action === 'close' ? describeClose() : describeRestart()) });
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
if (req.method === 'POST') {
|
|
452
|
+
try {
|
|
453
|
+
const scheduled = action === 'close' ? requestShutdown() : requestRestart();
|
|
454
|
+
sendJson(res, { ok: true, [action === 'close' ? 'closing' : 'restarting']: true, ...scheduled });
|
|
455
|
+
} catch (error) {
|
|
456
|
+
sendJson(res, { ok: false, code: error?.code, error: String(error?.message ?? error) }, 409);
|
|
457
|
+
}
|
|
458
|
+
return;
|
|
454
459
|
}
|
|
460
|
+
sendJson(res, { ok: false, error: 'method-not-allowed' }, 405);
|
|
455
461
|
return;
|
|
456
462
|
}
|
|
457
463
|
|
|
458
|
-
sendJson(res, { ok: false, error: '
|
|
464
|
+
sendJson(res, { ok: false, error: 'not-found' }, 404);
|
|
459
465
|
}
|
|
460
466
|
|
|
461
467
|
/**
|
package/lib/restart.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-powerup — restart the whole DSH desktop app.
|
|
2
|
+
* dsh-powerup — restart or close the whole DSH desktop app.
|
|
3
3
|
*
|
|
4
4
|
* The Host half runs inside the `dsh-desktop-host` child process, whose parent
|
|
5
5
|
* is the Electron main process. The desktop shell exposes shutdown and update
|
|
6
6
|
* controls over IPC but no "restart application" request, so this module
|
|
7
7
|
* starts a detached helper (`restart-helper.cjs`), lets the HTTP response
|
|
8
8
|
* settle, then ends the Electron main process. The helper waits for this Host
|
|
9
|
-
* to exit and relaunches the same executable
|
|
9
|
+
* to exit and relaunches the same executable — or, in `shutdown` mode, just
|
|
10
|
+
* lets the app close.
|
|
10
11
|
*
|
|
11
12
|
* Only the Electron desktop build supports this. A plain `dsh web` process
|
|
12
13
|
* reports the reason instead, and the UI hides the action.
|
|
@@ -43,14 +44,15 @@ function dshHome() {
|
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
46
|
-
* Whether this runtime can
|
|
47
|
+
* Whether this runtime can control the whole application.
|
|
48
|
+
* @param {'restart' | 'close'} action
|
|
47
49
|
* @returns {{ supported: boolean, reason?: string }}
|
|
48
50
|
*/
|
|
49
|
-
|
|
51
|
+
function describeAction(action) {
|
|
50
52
|
if (process.versions.electron === undefined) {
|
|
51
53
|
return {
|
|
52
54
|
supported: false,
|
|
53
|
-
reason:
|
|
55
|
+
reason: `DSH is running as a command-line web process (dsh web); ${action} it from the terminal.`,
|
|
54
56
|
};
|
|
55
57
|
}
|
|
56
58
|
if (typeof process.execPath !== 'string' || process.execPath.length === 0 || !existsSync(process.execPath)) {
|
|
@@ -63,6 +65,22 @@ export function describeRestart() {
|
|
|
63
65
|
return { supported: true };
|
|
64
66
|
}
|
|
65
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Whether this runtime can restart the whole application.
|
|
70
|
+
* @returns {{ supported: boolean, reason?: string }}
|
|
71
|
+
*/
|
|
72
|
+
export function describeRestart() {
|
|
73
|
+
return describeAction('restart');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Whether this runtime can close the whole application.
|
|
78
|
+
* @returns {{ supported: boolean, reason?: string }}
|
|
79
|
+
*/
|
|
80
|
+
export function describeClose() {
|
|
81
|
+
return describeAction('close');
|
|
82
|
+
}
|
|
83
|
+
|
|
66
84
|
/**
|
|
67
85
|
* Schedule a full application restart. The caller must finish its HTTP
|
|
68
86
|
* response; the helper waits {@link ACTION_DELAY_MS} before acting.
|
|
@@ -71,13 +89,33 @@ export function describeRestart() {
|
|
|
71
89
|
* @throws {Error} with `code = 'restart-unsupported'` outside the desktop app.
|
|
72
90
|
*/
|
|
73
91
|
export function requestRestart() {
|
|
74
|
-
|
|
92
|
+
return scheduleAction('restart');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Schedule closing the whole application (the detached helper ends the
|
|
97
|
+
* Electron main process and does not relaunch it).
|
|
98
|
+
*
|
|
99
|
+
* @returns {{ supported: true, action: 'shutdown', pid: number | undefined, pending: boolean }}
|
|
100
|
+
* @throws {Error} with `code = 'shutdown-unsupported'` outside the desktop app.
|
|
101
|
+
*/
|
|
102
|
+
export function requestShutdown() {
|
|
103
|
+
return scheduleAction('shutdown');
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Start the detached helper for one application-level action.
|
|
108
|
+
* @param {'restart' | 'shutdown'} action
|
|
109
|
+
* @returns {{ supported: true, action: string, pid: number | undefined, pending: boolean }}
|
|
110
|
+
*/
|
|
111
|
+
function scheduleAction(action) {
|
|
112
|
+
const capability = describeAction(action === 'shutdown' ? 'close' : 'restart');
|
|
75
113
|
if (!capability.supported) {
|
|
76
|
-
const error = new Error(capability.reason ?? 'This runtime cannot
|
|
77
|
-
error.code = 'restart-unsupported';
|
|
114
|
+
const error = new Error(capability.reason ?? 'This runtime cannot control DSH.');
|
|
115
|
+
error.code = (action === 'shutdown' ? 'shutdown' : 'restart') + '-unsupported';
|
|
78
116
|
throw error;
|
|
79
117
|
}
|
|
80
|
-
if (scheduled) return { supported: true, action
|
|
118
|
+
if (scheduled) return { supported: true, action, pid: undefined, pending: true };
|
|
81
119
|
scheduled = true;
|
|
82
120
|
|
|
83
121
|
const executable = process.execPath;
|
|
@@ -97,7 +135,7 @@ export function requestRestart() {
|
|
|
97
135
|
String(process.pid),
|
|
98
136
|
dirname(executable),
|
|
99
137
|
'[]',
|
|
100
|
-
'restart',
|
|
138
|
+
action === 'shutdown' ? 'shutdown' : 'restart',
|
|
101
139
|
String(ACTION_DELAY_MS),
|
|
102
140
|
], {
|
|
103
141
|
cwd: dirname(executable),
|
|
@@ -124,7 +162,7 @@ export function requestRestart() {
|
|
|
124
162
|
child.on('error', () => {
|
|
125
163
|
scheduled = false;
|
|
126
164
|
});
|
|
127
|
-
return { supported: true, action
|
|
165
|
+
return { supported: true, action, pid: child.pid, pending: false };
|
|
128
166
|
}
|
|
129
167
|
|
|
130
168
|
/**
|
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, copy a step reference (session id + step id) that the read-only powerup_step_read tool resolves back into the raw session data, export the trajectory snapshot, and copy the session ID. The session header 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 install control on every third-party installed plugin: read versions from the registry, install the version in the input through the Add plugin path (removing the old copy first), then enable and optionally restart DSH. The install panel also offers a one-click install that installs the input version without the enable and restart questions, enabling and restarting automatically by default; both defaults are configurable on the Power-Up page. A sidebar launcher turns the left sidebar panel buttons into an adaptive icon grid (icon above label) with drag sorting and folders: drop an icon onto the middle of another to fold them into a folder like a Windows Start menu folder, click a folder to open its icons in a flyout, and switch the whole grid off on the Power-Up page. The grid also carries
|
|
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, copy a step reference (session id + step id) that the read-only powerup_step_read tool resolves back into the raw session data, export the trajectory snapshot, and copy the session ID. The session header 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 install control on every third-party installed plugin: read versions from the registry, install the version in the input through the Add plugin path (removing the old copy first), then enable and optionally restart DSH. The install panel also offers a one-click install that installs the input version without the enable and restart questions, enabling and restarting automatically by default; both defaults are configurable on the Power-Up page. A sidebar launcher turns the left sidebar panel buttons into an adaptive icon grid (icon above label) with drag sorting and folders: drop an icon onto the middle of another to fold them into a folder like a Windows Start menu folder, click a folder to open its icons in a flyout, and switch the whole grid off on the Power-Up page. The grid also carries three built-in buttons — back to conversation, restart DSH and close DSH — and they, like the host more entry, can be dragged into a folder; restart and close reuse the install flow's confirmation dialog."
|
|
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 + 步骤 ID」的步骤引用(Agent 用只读工具 powerup_step_read 取回该步骤完整数据)、导出轨迹快照、复制会话 ID。在会话顶部的后台任务面板手动停止任务时可以填写停止原因,原因会附加在任务结束后注入会话的提示里。插件页为每个第三方已安装插件增加安装按钮:从安装源读取版本,按输入框中的版本先卸载旧版再按「添加插件」流程安装,完成后可立即启用并选择是否重启 DSH。安装面板还提供「一键安装」:按输入框版本安装并跳过启用与重启的询问,默认自动启用并重启,可在 Power-Up 页面调整默认行为。侧边栏启动器把左侧边栏的面板按钮变成随宽度自适应的图标网格(图标在上、文字在下),支持拖拽排序与分组:把一个图标拖到另一个图标的中间即可合并成分组(像 Windows 开始菜单的文件夹),点击分组会以浮层弹出其中的图标;可在 Power-Up
|
|
4
|
+
"description": "在轨迹页面为记录增加右键操作菜单:复制内容、复制 Markdown 引用、引用到输入框、查看记录详情、从该记录 Fork 会话、复制「会话 ID + 步骤 ID」的步骤引用(Agent 用只读工具 powerup_step_read 取回该步骤完整数据)、导出轨迹快照、复制会话 ID。在会话顶部的后台任务面板手动停止任务时可以填写停止原因,原因会附加在任务结束后注入会话的提示里。插件页为每个第三方已安装插件增加安装按钮:从安装源读取版本,按输入框中的版本先卸载旧版再按「添加插件」流程安装,完成后可立即启用并选择是否重启 DSH。安装面板还提供「一键安装」:按输入框版本安装并跳过启用与重启的询问,默认自动启用并重启,可在 Power-Up 页面调整默认行为。侧边栏启动器把左侧边栏的面板按钮变成随宽度自适应的图标网格(图标在上、文字在下),支持拖拽排序与分组:把一个图标拖到另一个图标的中间即可合并成分组(像 Windows 开始菜单的文件夹),点击分组会以浮层弹出其中的图标;可在 Power-Up 页面整体关闭。网格里自带「返回会话」「重启 DSH」「关闭 DSH」三个按钮,它们和「更多」一样可以拖进分组;重启与关闭沿用插件安装流程的确认对话框。"
|
|
5
5
|
}
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.8.
|
|
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 install control for third-party plugins from the Plugins page: read versions from the configured registries, install the version in the input through the Add plugin path (removing the old copy first), mark restart-needed installs, hand Power-Up's own install to the background, and optionally restart DSH. One-click install skips the enable and restart questions and can apply those actions automatically with configurable defaults. The ledger menu also copies a step reference (session id + step id) that the read-only powerup_step_read tool resolves back into the raw session data. · 为 DeepSeek Harness 提供小型增强:在轨迹页面右键记录即可复制、引用、查看详情或从该记录 Fork;右键「复制步骤引用」得到「会话 ID + 步骤 ID」,Agent 用只读工具 powerup_step_read 即可取回该步骤的完整原始数据;在会话顶部的后台任务面板手动停止任务时可填写停止原因,原因会附加到任务结束后的会话提示;并在插件页为第三方已安装插件提供安装按钮,从安装源读取版本,按输入框中的版本沿用「添加插件」流程安装(先卸载旧版),支持待重启标记、Power-Up 自身后台安装与可选重启;安装面板提供「一键安装」,按输入框版本安装并跳过启用/重启询问,默认自动启用并重启,可在 Power-Up 页面调整默认行为。 ·
|
|
3
|
+
"version": "0.8.10",
|
|
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 install control for third-party plugins from the Plugins page: read versions from the configured registries, install the version in the input through the Add plugin path (removing the old copy first), mark restart-needed installs, hand Power-Up's own install to the background, and optionally restart DSH. One-click install skips the enable and restart questions and can apply those actions automatically with configurable defaults. The ledger menu also copies a step reference (session id + step id) that the read-only powerup_step_read tool resolves back into the raw session data. · 为 DeepSeek Harness 提供小型增强:在轨迹页面右键记录即可复制、引用、查看详情或从该记录 Fork;右键「复制步骤引用」得到「会话 ID + 步骤 ID」,Agent 用只读工具 powerup_step_read 即可取回该步骤的完整原始数据;在会话顶部的后台任务面板手动停止任务时可填写停止原因,原因会附加到任务结束后的会话提示;并在插件页为第三方已安装插件提供安装按钮,从安装源读取版本,按输入框中的版本沿用「添加插件」流程安装(先卸载旧版),支持待重启标记、Power-Up 自身后台安装与可选重启;安装面板提供「一键安装」,按输入框版本安装并跳过启用/重启询问,默认自动启用并重启,可在 Power-Up 页面调整默认行为。 · 侧边栏启动器:把左侧边栏的面板按钮变成随宽度自适应的图标网格(图标在上、文字在下),支持拖拽排序与分组(拖到另一个图标中间即合并为分组,点击分组弹出浮层展示内部图标),可随时整体关闭;网格里自带「返回会话」「重启 DSH」「关闭 DSH」三个按钮,它们和「更多」一样可以拖进分组,重启/关闭沿用插件安装流程的确认对话框。",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "index.js",
|
|
@@ -77,7 +77,8 @@
|
|
|
77
77
|
"launcher",
|
|
78
78
|
"drag-sort",
|
|
79
79
|
"folder",
|
|
80
|
-
"restart"
|
|
80
|
+
"restart",
|
|
81
|
+
"close"
|
|
81
82
|
],
|
|
82
83
|
"publishConfig": {
|
|
83
84
|
"access": "public",
|