@restregular/dsh-powerup 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/client.js +102 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,11 +37,15 @@ uses.
|
|
|
37
37
|
### Stop a background job with a reason
|
|
38
38
|
|
|
39
39
|
The session header's background jobs panel keeps the host's list, live output,
|
|
40
|
-
and stop button. Clicking a running job's stop button opens a
|
|
41
|
-
dialog instead of the host's two-press stop
|
|
40
|
+
and stop button. Clicking a running job's stop button opens a themed Power-Up
|
|
41
|
+
dialog instead of the host's two-press stop. The dialog is portaled to the
|
|
42
|
+
document body, so it renders above the jobs menu (which is itself a body portal)
|
|
43
|
+
and is not clipped by any slot's stacking context; its colors come only from
|
|
44
|
+
`--dsw-alias-*` tokens, so light and dark themes both work.
|
|
42
45
|
|
|
43
46
|
- The reason field is optional; an empty field keeps the host's default
|
|
44
|
-
`cancelled by the user` reason.
|
|
47
|
+
`cancelled by the user` reason. A live character counter shows the 200-character
|
|
48
|
+
limit, and `Enter` confirms while `Esc` cancels.
|
|
45
49
|
- Confirming stops the job through the Host route, which records
|
|
46
50
|
`cancelled by the user: <reason>`. The completion notice injected into the
|
|
47
51
|
session and the shell tool's result therefore carry the reason.
|
|
@@ -148,6 +152,13 @@ fiber is unloaded. The panel closes; refresh the page when the install finishes.
|
|
|
148
152
|
auto-enable off the new copy stays disabled and nothing restarts. When no
|
|
149
153
|
restart happens the completion panel closes on a timer; install, enable, and
|
|
150
154
|
restart failures stay on screen with their reason instead.
|
|
155
|
+
- **The stop dialog is a body portal.** `shell.overlay` is an absolute layer at
|
|
156
|
+
`z-index: 20`, and the host jobs menu is a `document.body` portal at
|
|
157
|
+
`z-index: 100`; a high z-index inside the overlay layer therefore still loses.
|
|
158
|
+
The reason popover is rendered through `react-dom`'s `createPortal` into
|
|
159
|
+
`document.body`, uses `z-index: 1400`, and draws its icon chip, input, error
|
|
160
|
+
strip, and solid confirm button from host tokens, so it stays readable in both
|
|
161
|
+
themes. Without `react-dom` it falls back to in-place rendering.
|
|
151
162
|
- **Restart status lives in this browser session.** A management result that
|
|
152
163
|
says `restart-required` is written to `sessionStorage`; the card gets a
|
|
153
164
|
**Restart needed** tag and the group heading gets a count plus a restart
|
package/client.js
CHANGED
|
@@ -41,10 +41,35 @@
|
|
|
41
41
|
const React = require('react');
|
|
42
42
|
const h = React.createElement;
|
|
43
43
|
const { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } = React;
|
|
44
|
+
// react-dom is a seed module in the host's ModuleLoader (the built-in
|
|
45
|
+
// Client packages require it too). Fall back to in-place rendering when
|
|
46
|
+
// it is missing, so an older host loses layering but keeps working.
|
|
47
|
+
const createPortal = (() => {
|
|
48
|
+
try {
|
|
49
|
+
const dom = require('react-dom');
|
|
50
|
+
return dom !== null && dom !== undefined && typeof dom.createPortal === 'function' ? dom.createPortal : null;
|
|
51
|
+
} catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
})();
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Render a floating panel at the document root. Slot containers own
|
|
58
|
+
* stacking contexts (`position:fixed; z-index:…`), so a high z-index
|
|
59
|
+
* inside a slot still loses to a body-level popover such as the jobs menu.
|
|
60
|
+
* Portaling escapes that context; without react-dom the node stays in
|
|
61
|
+
* place rather than failing.
|
|
62
|
+
* @param {object} node
|
|
63
|
+
* @returns {object}
|
|
64
|
+
*/
|
|
65
|
+
function renderInBody(node) {
|
|
66
|
+
const body = typeof document === 'undefined' || document === null ? null : document.body;
|
|
67
|
+
return createPortal !== null && body !== null ? createPortal(node, body) : node;
|
|
68
|
+
}
|
|
44
69
|
|
|
45
70
|
const NS = 'dsh-powerup';
|
|
46
71
|
const SETTINGS_KEY = 'dsh-powerup:settings:v1';
|
|
47
|
-
const VERSION = '0.5.
|
|
72
|
+
const VERSION = '0.5.1';
|
|
48
73
|
const MENU_GAP = 8;
|
|
49
74
|
const MENU_WIDTH = 248;
|
|
50
75
|
/** How long a one-click update's completion panel stays open when nothing restarts. */
|
|
@@ -124,6 +149,9 @@
|
|
|
124
149
|
'toast.forkUnavailable': '当前宿主没有提供 Fork 接口',
|
|
125
150
|
'toast.noSession': '还没有打开会话',
|
|
126
151
|
'jobStop.title': '停止后台任务',
|
|
152
|
+
'jobStop.subtitle': '停止后无法恢复,正在运行的工作会中断。',
|
|
153
|
+
'jobStop.close': '关闭',
|
|
154
|
+
'jobStop.hint': 'Enter 确认 · Esc 取消',
|
|
127
155
|
'jobStop.reasonLabel': '停止原因(可选)',
|
|
128
156
|
'jobStop.reasonPlaceholder': '例如:已经不需要这个结果了',
|
|
129
157
|
'jobStop.reasonNote': '原因会附加在任务结束后注入会话的提示里。',
|
|
@@ -295,6 +323,9 @@
|
|
|
295
323
|
'toast.forkUnavailable': 'This host does not expose the fork API',
|
|
296
324
|
'toast.noSession': 'No session is open',
|
|
297
325
|
'jobStop.title': 'Stop background job',
|
|
326
|
+
'jobStop.subtitle': 'This cannot be undone; running work will be interrupted.',
|
|
327
|
+
'jobStop.close': 'Close',
|
|
328
|
+
'jobStop.hint': 'Enter to confirm · Esc to cancel',
|
|
298
329
|
'jobStop.reasonLabel': 'Stop reason (optional)',
|
|
299
330
|
'jobStop.reasonPlaceholder': 'e.g. the result is no longer needed',
|
|
300
331
|
'jobStop.reasonNote': 'The reason is appended to the notice injected into the session when the job settles.',
|
|
@@ -807,26 +838,36 @@
|
|
|
807
838
|
.dsh-powerup-menu-foot-id{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace)}
|
|
808
839
|
.dsh-powerup-toast{position:fixed;left:50%;bottom:30px;transform:translateX(-50%);z-index:1001;max-width:min(440px,calc(100vw - 32px));padding:7px 12px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));color:var(--dsw-alias-label-primary);box-shadow:var(--dsw-elevation-lv2,0 8px 24px rgba(15,23,42,.18));font-size:12px;line-height:1.45;pointer-events:none;animation:dsh-powerup-toast-in .14s ease-out}
|
|
809
840
|
@keyframes dsh-powerup-toast-in{from{opacity:0;transform:translate(-50%,5px)}to{opacity:1;transform:translate(-50%,0)}}
|
|
810
|
-
.dsh-powerup-jobstop{position:fixed;z-index:
|
|
811
|
-
@keyframes dsh-powerup-jobstop-in{from{opacity:0;transform:translateY(
|
|
812
|
-
.dsh-powerup-jobstop-head{display:flex;align-items:
|
|
813
|
-
.dsh-powerup-jobstop-
|
|
814
|
-
.dsh-powerup-jobstop-
|
|
815
|
-
.dsh-powerup-jobstop-
|
|
816
|
-
.dsh-powerup-jobstop-
|
|
841
|
+
.dsh-powerup-jobstop{position:fixed;z-index:1400;box-sizing:border-box;display:flex;flex-direction:column;gap:12px;padding:14px;border:.5px solid var(--dsw-alias-border-l2);border-radius:14px;background:var(--dsw-alias-bg-overlay,var(--dsw-alias-bg-layer-1));box-shadow:var(--dsw-elevation-prominent,0 18px 44px rgba(15,23,42,.26),0 2px 8px rgba(15,23,42,.12));color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5;pointer-events:auto;overflow-y:auto;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);animation:dsh-powerup-jobstop-in .16s cubic-bezier(.2,.8,.3,1)}
|
|
842
|
+
@keyframes dsh-powerup-jobstop-in{from{opacity:0;transform:translateY(4px) scale(.99)}to{opacity:1;transform:none}}
|
|
843
|
+
.dsh-powerup-jobstop-head{display:flex;align-items:flex-start;gap:10px}
|
|
844
|
+
.dsh-powerup-jobstop-icon{flex:none;display:flex;align-items:center;justify-content:center;width:30px;height:30px;border-radius:9px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent);color:var(--dsw-alias-state-error-primary)}
|
|
845
|
+
.dsh-powerup-jobstop-heading{display:flex;flex:1 1 auto;flex-direction:column;gap:1px;min-width:0}
|
|
846
|
+
.dsh-powerup-jobstop-title{color:var(--dsw-alias-label-primary);font-size:13.5px;line-height:19px;font-weight:600}
|
|
847
|
+
.dsh-powerup-jobstop-subtitle{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
848
|
+
.dsh-powerup-jobstop-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;margin:-3px -3px 0 0;padding:0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:16px;line-height:1;cursor:pointer}
|
|
849
|
+
.dsh-powerup-jobstop-close:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-primary)}
|
|
850
|
+
.dsh-powerup-jobstop-label{display:flex;align-items:center;gap:8px;min-width:0;margin:0;padding:7px 10px;border:.5px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font-family:var(--dsw-font-family-code,ui-monospace,SFMono-Regular,Consolas,monospace);font-size:11.5px;line-height:17px}
|
|
851
|
+
.dsh-powerup-jobstop-dot{flex:none;width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-success-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-state-success-primary) 14%,transparent)}
|
|
852
|
+
.dsh-powerup-jobstop-label-text{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
853
|
+
.dsh-powerup-jobstop-field{display:flex;flex-direction:column;gap:6px;min-width:0}
|
|
854
|
+
.dsh-powerup-jobstop-field-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
817
855
|
.dsh-powerup-jobstop-field-label{color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:17px}
|
|
818
|
-
.dsh-powerup-jobstop-
|
|
856
|
+
.dsh-powerup-jobstop-count{color:var(--dsw-alias-label-caption);font-size:10.5px;line-height:16px;font-variant-numeric:tabular-nums}
|
|
857
|
+
.dsh-powerup-jobstop-input{box-sizing:border-box;width:100%;height:36px;padding:0 11px;border:.5px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;outline:none;transition:border-color .14s ease,box-shadow .14s ease}
|
|
819
858
|
.dsh-powerup-jobstop-input::placeholder{color:var(--dsw-alias-label-caption)}
|
|
820
859
|
.dsh-powerup-jobstop-input:focus{border-color:var(--dsw-alias-state-business-primary);box-shadow:inset 0 0 0 .5px var(--dsw-alias-state-business-primary)}
|
|
821
|
-
.dsh-powerup-jobstop-note{margin:0;color:var(--dsw-alias-label-tertiary);font-size:
|
|
822
|
-
.dsh-powerup-jobstop-error{margin:0;color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:
|
|
860
|
+
.dsh-powerup-jobstop-note{margin:0;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px}
|
|
861
|
+
.dsh-powerup-jobstop-error{margin:0;padding:7px 9px;border:.5px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 32%,transparent);border-radius:8px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 8%,transparent);color:var(--dsw-alias-state-error-primary);font-size:11.5px;line-height:17px;overflow-wrap:anywhere}
|
|
862
|
+
.dsh-powerup-jobstop-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px;padding-top:2px}
|
|
863
|
+
.dsh-powerup-jobstop-hint{color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:16px;white-space:nowrap}
|
|
823
864
|
.dsh-powerup-jobstop-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px}
|
|
824
|
-
.dsh-powerup-jobstop-cancel{height:
|
|
865
|
+
.dsh-powerup-jobstop-cancel{height:32px;padding:0 12px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12.5px;line-height:18px;cursor:pointer}
|
|
825
866
|
.dsh-powerup-jobstop-cancel:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-primary)}
|
|
826
|
-
.dsh-powerup-jobstop-confirm{height:
|
|
827
|
-
.dsh-powerup-jobstop-confirm:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary)
|
|
828
|
-
.dsh-powerup-jobstop-confirm:disabled,.dsh-powerup-jobstop-cancel:disabled{opacity:.55;cursor:default}
|
|
829
|
-
.dsh-powerup-jobstop-cancel:focus-visible,.dsh-powerup-jobstop-confirm:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
867
|
+
.dsh-powerup-jobstop-confirm{height:32px;padding:0 13px;border:0;border-radius:8px;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground);font:inherit;font-size:12.5px;line-height:18px;font-weight:500;cursor:pointer;transition:background .14s ease,opacity .14s ease}
|
|
868
|
+
.dsh-powerup-jobstop-confirm:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 86%,var(--dsw-alias-label-primary))}
|
|
869
|
+
.dsh-powerup-jobstop-confirm:disabled,.dsh-powerup-jobstop-cancel:disabled,.dsh-powerup-jobstop-close:disabled{opacity:.55;cursor:default}
|
|
870
|
+
.dsh-powerup-jobstop-cancel:focus-visible,.dsh-powerup-jobstop-confirm:focus-visible,.dsh-powerup-jobstop-close:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
|
|
830
871
|
@media (prefers-reduced-motion:reduce){.dsh-powerup-jobstop{animation:none}}
|
|
831
872
|
.dsh-powerup-update-button{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-caption);cursor:pointer}
|
|
832
873
|
.dsh-powerup-update-button:hover{background:var(--dsw-alias-interactive-bg-hover,var(--dsw-alias-bg-layer-2));color:var(--dsw-alias-label-secondary)}
|
|
@@ -2267,8 +2308,10 @@
|
|
|
2267
2308
|
};
|
|
2268
2309
|
|
|
2269
2310
|
if (target === null) return null;
|
|
2270
|
-
const placement = popoverPlacement({ getBoundingClientRect: () => target.rect },
|
|
2271
|
-
|
|
2311
|
+
const placement = popoverPlacement({ getBoundingClientRect: () => target.rect }, 340, 260);
|
|
2312
|
+
// The body portal escapes every slot's stacking context, so the same
|
|
2313
|
+
// panel is above the host jobs menu (z-index 100) in both themes.
|
|
2314
|
+
return renderInBody(h('div', {
|
|
2272
2315
|
ref: panelRef,
|
|
2273
2316
|
className: 'dsh-powerup-jobstop',
|
|
2274
2317
|
role: 'dialog',
|
|
@@ -2295,10 +2338,30 @@
|
|
|
2295
2338
|
void submit();
|
|
2296
2339
|
},
|
|
2297
2340
|
},
|
|
2298
|
-
h('div', { className: 'dsh-powerup-jobstop-head' },
|
|
2299
|
-
|
|
2341
|
+
h('div', { className: 'dsh-powerup-jobstop-head' },
|
|
2342
|
+
h('div', { className: 'dsh-powerup-jobstop-icon' }, h(StopIcon, { size: 14 })),
|
|
2343
|
+
h('div', { className: 'dsh-powerup-jobstop-heading' },
|
|
2344
|
+
h('span', { className: 'dsh-powerup-jobstop-title' }, t('jobStop.title')),
|
|
2345
|
+
h('span', { className: 'dsh-powerup-jobstop-subtitle' }, t('jobStop.subtitle')),
|
|
2346
|
+
),
|
|
2347
|
+
h('button', {
|
|
2348
|
+
type: 'button',
|
|
2349
|
+
className: 'dsh-powerup-jobstop-close',
|
|
2350
|
+
'aria-label': t('jobStop.close'),
|
|
2351
|
+
title: t('jobStop.close'),
|
|
2352
|
+
disabled: pending,
|
|
2353
|
+
onClick: close,
|
|
2354
|
+
}, '×'),
|
|
2355
|
+
),
|
|
2356
|
+
h('div', { className: 'dsh-powerup-jobstop-label', title: target.job.label },
|
|
2357
|
+
h('span', { className: 'dsh-powerup-jobstop-dot', 'aria-hidden': 'true' }),
|
|
2358
|
+
h('span', { className: 'dsh-powerup-jobstop-label-text' }, target.job.label),
|
|
2359
|
+
),
|
|
2300
2360
|
h('label', { className: 'dsh-powerup-jobstop-field' },
|
|
2301
|
-
h('span', { className: 'dsh-powerup-jobstop-field-
|
|
2361
|
+
h('span', { className: 'dsh-powerup-jobstop-field-head' },
|
|
2362
|
+
h('span', { className: 'dsh-powerup-jobstop-field-label' }, t('jobStop.reasonLabel')),
|
|
2363
|
+
h('span', { className: 'dsh-powerup-jobstop-count' }, `${reason.length}/${JOB_STOP_REASON_MAX}`),
|
|
2364
|
+
),
|
|
2302
2365
|
h('input', {
|
|
2303
2366
|
ref: inputRef,
|
|
2304
2367
|
className: 'dsh-powerup-jobstop-input',
|
|
@@ -2312,20 +2375,23 @@
|
|
|
2312
2375
|
),
|
|
2313
2376
|
h('p', { className: 'dsh-powerup-jobstop-note' }, t('jobStop.reasonNote')),
|
|
2314
2377
|
error === null ? null : h('p', { className: 'dsh-powerup-jobstop-error', role: 'alert' }, error),
|
|
2315
|
-
h('div', { className: 'dsh-powerup-jobstop-
|
|
2316
|
-
h('
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2378
|
+
h('div', { className: 'dsh-powerup-jobstop-foot' },
|
|
2379
|
+
h('span', { className: 'dsh-powerup-jobstop-hint' }, t('jobStop.hint')),
|
|
2380
|
+
h('div', { className: 'dsh-powerup-jobstop-actions' },
|
|
2381
|
+
h('button', {
|
|
2382
|
+
type: 'button',
|
|
2383
|
+
className: 'dsh-powerup-jobstop-cancel',
|
|
2384
|
+
disabled: pending,
|
|
2385
|
+
onClick: close,
|
|
2386
|
+
}, t('jobStop.cancel')),
|
|
2387
|
+
h('button', {
|
|
2388
|
+
type: 'button',
|
|
2389
|
+
className: 'dsh-powerup-jobstop-confirm',
|
|
2390
|
+
disabled: pending,
|
|
2391
|
+
onClick: () => { void submit(); },
|
|
2392
|
+
}, pending ? t('jobStop.stopping') : t('jobStop.confirm')),
|
|
2393
|
+
),
|
|
2394
|
+
)));
|
|
2329
2395
|
}
|
|
2330
2396
|
|
|
2331
2397
|
/**
|
|
@@ -4011,6 +4077,7 @@
|
|
|
4011
4077
|
PowerUpOverlay,
|
|
4012
4078
|
PluginUpdateOverlay,
|
|
4013
4079
|
JobStopOverlay,
|
|
4080
|
+
renderInBody,
|
|
4014
4081
|
stopButtonLabel,
|
|
4015
4082
|
resolveStopTarget,
|
|
4016
4083
|
ensureUpdateButtons,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Power-Up — small, opt-in upgrades for DeepSeek Harness. Adds a right-click action menu to the Trajectory ledger, an optional stop reason in the session header's background jobs panel (appended to the injected completion notice), and an update control for third-party plugins installed from the Plugins page, with version lookup from the configured registries, a starred default source, uninstall-and-reinstall through the Add plugin path, restart-needed markers, a background self-update, and an optional DSH restart, plus a one-click update that installs the newest version and can enable and restart automatically. · 为 DeepSeek Harness 提供小型增强:在轨迹页面右键记录即可复制、引用、查看详情或从该记录 Fork;在会话顶部的后台任务面板手动停止任务时可填写停止原因,原因会附加到任务结束后的会话提示;并在插件页为已安装插件提供带版本查询的更新按钮,安装源可设默认,沿用「添加插件」的安装流程,支持待重启标记、后台自更新与一键重启;插件更新面板提供「一键更新」,默认安装最新版后自动启用并重启,可在 Power-Up 页面调整默认行为。",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|