@restregular/dsh-powerup 0.9.8 → 0.10.0
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/client.js +95 -3
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
const promptCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
|
|
84
84
|
/** Fallback bucket when the hero cannot resolve an owning workspace yet. */
|
|
85
85
|
const UNSCOPED_WORKSPACE = '__unscoped__';
|
|
86
|
-
const VERSION = '0.
|
|
86
|
+
const VERSION = '0.10.0';
|
|
87
87
|
const MENU_GAP = 8;
|
|
88
88
|
const MENU_WIDTH = 248;
|
|
89
89
|
/** Reference scheme understood by the Host's `powerup_step_read` tool. */
|
|
@@ -3939,6 +3939,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
3939
3939
|
.dsh-powerup-send[data-kind="interrupt"]{color:var(--dsw-alias-state-warn-label,var(--dsw-alias-label-secondary))}
|
|
3940
3940
|
.dsh-powerup-send svg{width:16px;height:16px}
|
|
3941
3941
|
.dsh-powerup-dual-send{display:inline-flex;align-items:center;gap:4px}
|
|
3942
|
+
/* Our buttons replace the host's primary button while the draft has text. The
|
|
3943
|
+
component marks the host button with data-powerup-send-hidden. */
|
|
3944
|
+
[data-powerup-send-hidden]{display:none!important}
|
|
3942
3945
|
.dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
|
|
3943
3946
|
.dsh-powerup-mask-row{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) auto auto;gap:8px;align-items:center;padding:8px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1)}
|
|
3944
3947
|
.dsh-powerup-mask-default.on{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-layer-1);border-color:var(--dsw-alias-brand-primary)}
|
|
@@ -8404,6 +8407,36 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8404
8407
|
* host primary button keep their own behavior; we add explicit queued and
|
|
8405
8408
|
* interrupt controls that bypass the system busy-time setting.
|
|
8406
8409
|
*/
|
|
8410
|
+
/**
|
|
8411
|
+
* Whether the given session is currently working. Reads the host's
|
|
8412
|
+
* sessions list snapshot (`byId[id].running`) and re-renders when that
|
|
8413
|
+
* store changes. Falls back to false when the host exposes no list, so an
|
|
8414
|
+
* unknown state keeps the native single button.
|
|
8415
|
+
*/
|
|
8416
|
+
function useSessionRunning(ctx, sessionId) {
|
|
8417
|
+
const read = useCallback(() => {
|
|
8418
|
+
if (typeof sessionId !== 'string' || sessionId === '') return false;
|
|
8419
|
+
try {
|
|
8420
|
+
const list = ctx.get('sessions')?.list;
|
|
8421
|
+
if (list === undefined || typeof list.getSnapshot !== 'function') return false;
|
|
8422
|
+
const snapshot = list.getSnapshot();
|
|
8423
|
+
const byId = snapshot !== null && typeof snapshot === 'object' ? snapshot.byId : undefined;
|
|
8424
|
+
const item = byId !== null && typeof byId === 'object' ? byId[sessionId] : undefined;
|
|
8425
|
+
return item !== null && typeof item === 'object' && item.running === true;
|
|
8426
|
+
} catch {
|
|
8427
|
+
return false;
|
|
8428
|
+
}
|
|
8429
|
+
}, [ctx, sessionId]);
|
|
8430
|
+
const [running, setRunning] = useState(read);
|
|
8431
|
+
useEffect(() => {
|
|
8432
|
+
setRunning(read());
|
|
8433
|
+
const list = ctx.get('sessions')?.list;
|
|
8434
|
+
if (list === undefined || typeof list.subscribe !== 'function') return undefined;
|
|
8435
|
+
return list.subscribe(() => setRunning(read()));
|
|
8436
|
+
}, [read, ctx]);
|
|
8437
|
+
return running;
|
|
8438
|
+
}
|
|
8439
|
+
|
|
8407
8440
|
function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
|
|
8408
8441
|
const settings = useSettings();
|
|
8409
8442
|
const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
|
|
@@ -8420,6 +8453,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8420
8453
|
}
|
|
8421
8454
|
};
|
|
8422
8455
|
const trimmed = typeof draft === 'string' ? draft.trim() : '';
|
|
8456
|
+
// Dual send only makes sense while the session is actually working:
|
|
8457
|
+
// "queue" vs "interrupt" is meaningless on an idle session, where the
|
|
8458
|
+
// host's single Send button is the correct affordance.
|
|
8459
|
+
const sessionRunning = useSessionRunning(ctx, sessionId);
|
|
8423
8460
|
const currentDraft = { trimmed, sessionId, inputActions, ctx };
|
|
8424
8461
|
const send = (mode, text) => {
|
|
8425
8462
|
const value = typeof text === 'string' ? text.trim() : trimmed;
|
|
@@ -8473,8 +8510,63 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8473
8510
|
return () => document.removeEventListener('keydown', onKeyDown, true);
|
|
8474
8511
|
}, [settings.dualSend, sessionId, draft, ctx, inputActions]);
|
|
8475
8512
|
void currentDraft;
|
|
8476
|
-
|
|
8477
|
-
|
|
8513
|
+
// Replace the host's single primary button with our two only while the
|
|
8514
|
+
// composer holds text AND the session is working. An idle session (or
|
|
8515
|
+
// an empty draft) keeps the native button, where it is Send or Stop.
|
|
8516
|
+
const active = settings.dualSend && trimmed !== '' && sessionRunning;
|
|
8517
|
+
const wrapRef = useRef(null);
|
|
8518
|
+
useEffect(() => {
|
|
8519
|
+
if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
|
|
8520
|
+
const clearAll = () => {
|
|
8521
|
+
for (const node of document.querySelectorAll('[data-powerup-send-hidden]')) {
|
|
8522
|
+
node.removeAttribute('data-powerup-send-hidden');
|
|
8523
|
+
}
|
|
8524
|
+
};
|
|
8525
|
+
if (!active) {
|
|
8526
|
+
clearAll();
|
|
8527
|
+
return undefined;
|
|
8528
|
+
}
|
|
8529
|
+
// Walk up from our own slot to the row that directly holds the host's
|
|
8530
|
+
// send buttons, then take its LAST direct button child — that is the
|
|
8531
|
+
// primary send/stop control (the optional interrupt-stop precedes it).
|
|
8532
|
+
const findScope = () => {
|
|
8533
|
+
let node = wrapRef.current;
|
|
8534
|
+
for (let depth = 0; node !== null && depth < 8; depth += 1) {
|
|
8535
|
+
const direct = typeof node.querySelectorAll === 'function'
|
|
8536
|
+
? node.querySelectorAll(':scope > button')
|
|
8537
|
+
: [];
|
|
8538
|
+
if (direct.length > 0) return node;
|
|
8539
|
+
node = node.parentElement;
|
|
8540
|
+
}
|
|
8541
|
+
return null;
|
|
8542
|
+
};
|
|
8543
|
+
const mark = () => {
|
|
8544
|
+
const scope = findScope();
|
|
8545
|
+
if (scope === null) return;
|
|
8546
|
+
const direct = [...scope.querySelectorAll(':scope > button')];
|
|
8547
|
+
const primary = direct[direct.length - 1];
|
|
8548
|
+
if (primary === undefined) return;
|
|
8549
|
+
primary.setAttribute('data-powerup-send-hidden', '');
|
|
8550
|
+
};
|
|
8551
|
+
mark();
|
|
8552
|
+
let scheduled = false;
|
|
8553
|
+
const schedule = () => {
|
|
8554
|
+
if (scheduled) return;
|
|
8555
|
+
scheduled = true;
|
|
8556
|
+
queueMicrotask(() => {
|
|
8557
|
+
scheduled = false;
|
|
8558
|
+
mark();
|
|
8559
|
+
});
|
|
8560
|
+
};
|
|
8561
|
+
const observer = typeof MutationObserver === 'function' ? new MutationObserver(schedule) : null;
|
|
8562
|
+
observer?.observe(document.body, { childList: true, subtree: true });
|
|
8563
|
+
return () => {
|
|
8564
|
+
observer?.disconnect();
|
|
8565
|
+
clearAll();
|
|
8566
|
+
};
|
|
8567
|
+
}, [settings.dualSend, active]);
|
|
8568
|
+
if (!active) return null;
|
|
8569
|
+
return h('div', { className: 'dsh-powerup-dual-send', ref: wrapRef },
|
|
8478
8570
|
h('button', {
|
|
8479
8571
|
type: 'button',
|
|
8480
8572
|
className: 'dsh-powerup-send',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, and workspace prompts — each toggled independently on the Power-Up page.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|