@restregular/dsh-powerup 0.10.0 → 0.10.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/client.js +95 -87
- 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.10.
|
|
86
|
+
const VERSION = '0.10.1';
|
|
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,9 +3939,6 @@ 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}
|
|
3945
3942
|
.dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
|
|
3946
3943
|
.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)}
|
|
3947
3944
|
.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)}
|
|
@@ -8437,6 +8434,55 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8437
8434
|
return running;
|
|
8438
8435
|
}
|
|
8439
8436
|
|
|
8437
|
+
/**
|
|
8438
|
+
* The host's live "busy Enter" preference: 'queue' or 'steer'. The host
|
|
8439
|
+
* composer resolves plain Enter (and its single Send button) with this
|
|
8440
|
+
* value, so knowing it tells us which delivery mode the native button
|
|
8441
|
+
* already covers. Reads the Host config form for the ui-conversation
|
|
8442
|
+
* namespace and subscribes, so a Settings change applies immediately.
|
|
8443
|
+
*/
|
|
8444
|
+
function useHostBusyEnter(ctx) {
|
|
8445
|
+
const formOf = useCallback(() => {
|
|
8446
|
+
try {
|
|
8447
|
+
return ctx.get('configForms')?.get?.('ui-conversation');
|
|
8448
|
+
} catch {
|
|
8449
|
+
return undefined;
|
|
8450
|
+
}
|
|
8451
|
+
}, [ctx]);
|
|
8452
|
+
const read = useCallback(() => {
|
|
8453
|
+
try {
|
|
8454
|
+
const value = formOf()?.getSnapshot?.()?.value;
|
|
8455
|
+
const behavior = value !== null && typeof value === 'object' ? value.busyEnter : undefined;
|
|
8456
|
+
return behavior === 'steer' ? 'steer' : 'queue';
|
|
8457
|
+
} catch {
|
|
8458
|
+
return 'queue';
|
|
8459
|
+
}
|
|
8460
|
+
}, [formOf]);
|
|
8461
|
+
const [behavior, setBehavior] = useState(read);
|
|
8462
|
+
useEffect(() => {
|
|
8463
|
+
setBehavior(read());
|
|
8464
|
+
let off;
|
|
8465
|
+
let timer;
|
|
8466
|
+
// The settings service may be provided after this plugin applies;
|
|
8467
|
+
// keep looking briefly instead of latching onto a missing service.
|
|
8468
|
+
const attach = (attempt) => {
|
|
8469
|
+
const form = formOf();
|
|
8470
|
+
if (form !== undefined && typeof form.subscribe === 'function') {
|
|
8471
|
+
off = form.subscribe(() => setBehavior(read()));
|
|
8472
|
+
return;
|
|
8473
|
+
}
|
|
8474
|
+
if (attempt >= 20) return;
|
|
8475
|
+
timer = setTimeout(() => attach(attempt + 1), 500);
|
|
8476
|
+
};
|
|
8477
|
+
attach(0);
|
|
8478
|
+
return () => {
|
|
8479
|
+
if (timer !== undefined) clearTimeout(timer);
|
|
8480
|
+
if (typeof off === 'function') off();
|
|
8481
|
+
};
|
|
8482
|
+
}, [read, formOf]);
|
|
8483
|
+
return behavior;
|
|
8484
|
+
}
|
|
8485
|
+
|
|
8440
8486
|
function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
|
|
8441
8487
|
const settings = useSettings();
|
|
8442
8488
|
const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
|
|
@@ -8457,6 +8503,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8457
8503
|
// "queue" vs "interrupt" is meaningless on an idle session, where the
|
|
8458
8504
|
// host's single Send button is the correct affordance.
|
|
8459
8505
|
const sessionRunning = useSessionRunning(ctx, sessionId);
|
|
8506
|
+
// Which strategy the host's own Send button already covers while busy.
|
|
8507
|
+
const busyEnter = useHostBusyEnter(ctx);
|
|
8460
8508
|
const currentDraft = { trimmed, sessionId, inputActions, ctx };
|
|
8461
8509
|
const send = (mode, text) => {
|
|
8462
8510
|
const value = typeof text === 'string' ? text.trim() : trimmed;
|
|
@@ -8476,10 +8524,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8476
8524
|
console.warn('[dsh-powerup] dual send failed:', error?.message ?? error);
|
|
8477
8525
|
}
|
|
8478
8526
|
};
|
|
8479
|
-
//
|
|
8480
|
-
// Enter
|
|
8481
|
-
// Shift+Enter
|
|
8482
|
-
//
|
|
8527
|
+
// Accelerated Enter (Ctrl/Cmd+Shift+Enter) delivers the strategy the
|
|
8528
|
+
// host's plain Enter does NOT use — the same split as the button pair.
|
|
8529
|
+
// Plain Enter and Shift+Enter stay entirely with the host so the
|
|
8530
|
+
// "busy Enter" setting keeps its meaning.
|
|
8483
8531
|
useEffect(() => {
|
|
8484
8532
|
if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
|
|
8485
8533
|
const onKeyDown = (event) => {
|
|
@@ -8500,95 +8548,51 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8500
8548
|
if (openMenu !== null && openMenu !== undefined) return;
|
|
8501
8549
|
if (editor.hasAttribute('data-composer-chip-selected')) return;
|
|
8502
8550
|
const interrupt = event.shiftKey && (event.ctrlKey || event.metaKey);
|
|
8503
|
-
if (
|
|
8504
|
-
if (!
|
|
8551
|
+
if (!interrupt) return; // plain Enter / Shift+Enter belong to the host
|
|
8552
|
+
if (!sessionRunning) return;
|
|
8505
8553
|
event.preventDefault();
|
|
8506
8554
|
event.stopPropagation();
|
|
8507
|
-
send(
|
|
8555
|
+
send(busyEnter === 'steer' ? 'queue' : 'steer');
|
|
8508
8556
|
};
|
|
8509
8557
|
document.addEventListener('keydown', onKeyDown, true);
|
|
8510
8558
|
return () => document.removeEventListener('keydown', onKeyDown, true);
|
|
8511
|
-
}, [settings.dualSend, sessionId, draft, ctx, inputActions]);
|
|
8559
|
+
}, [settings.dualSend, sessionId, draft, ctx, inputActions, sessionRunning, busyEnter]);
|
|
8512
8560
|
void currentDraft;
|
|
8513
|
-
//
|
|
8514
|
-
//
|
|
8515
|
-
// an empty draft) keeps the native button
|
|
8561
|
+
// Our extra button only appears while the session is actually working and
|
|
8562
|
+
// the draft has text: that is when queue-vs-steer is a real choice. An
|
|
8563
|
+
// idle session (or an empty draft) keeps just the native button.
|
|
8516
8564
|
const active = settings.dualSend && trimmed !== '' && sessionRunning;
|
|
8517
8565
|
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
8566
|
if (!active) return null;
|
|
8567
|
+
// The host's own Send button already delivers `busyEnter` (that is the
|
|
8568
|
+
// value plain Enter resolves to while busy). So we only contribute the
|
|
8569
|
+
// OTHER strategy — one button, never both, and never a duplicate of what
|
|
8570
|
+
// the native button does.
|
|
8571
|
+
const ours = busyEnter === 'steer' ? 'queue' : 'steer';
|
|
8569
8572
|
return h('div', { className: 'dsh-powerup-dual-send', ref: wrapRef },
|
|
8570
|
-
|
|
8571
|
-
|
|
8572
|
-
|
|
8573
|
-
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
h('
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
h('
|
|
8573
|
+
ours === 'queue'
|
|
8574
|
+
? h('button', {
|
|
8575
|
+
type: 'button',
|
|
8576
|
+
className: 'dsh-powerup-send',
|
|
8577
|
+
'data-kind': 'wait',
|
|
8578
|
+
'aria-label': t('send.waitHint'),
|
|
8579
|
+
title: t('send.waitHint'),
|
|
8580
|
+
disabled: trimmed === '',
|
|
8581
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
8582
|
+
onClick: () => send('queue'),
|
|
8583
|
+
}, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
|
|
8584
|
+
h('path', { d: 'M3 8h9M8.5 4.5 12 8l-3.5 3.5', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' })))
|
|
8585
|
+
: h('button', {
|
|
8586
|
+
type: 'button',
|
|
8587
|
+
className: 'dsh-powerup-send',
|
|
8588
|
+
'data-kind': 'interrupt',
|
|
8589
|
+
'aria-label': t('send.interruptHint'),
|
|
8590
|
+
title: t('send.interruptHint'),
|
|
8591
|
+
disabled: trimmed === '',
|
|
8592
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
8593
|
+
onClick: () => send('steer'),
|
|
8594
|
+
}, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
|
|
8595
|
+
h('path', { d: 'M8 2v12M3 6l5-4 5 4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
|
|
8592
8596
|
);
|
|
8593
8597
|
}
|
|
8594
8598
|
|
|
@@ -9177,6 +9181,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9177
9181
|
}
|
|
9178
9182
|
|
|
9179
9183
|
return {
|
|
9184
|
+
// `configForms` is optional: it carries the Host "busy Enter" preference.
|
|
9185
|
+
// Read through ctx.get with a defensive fallback instead of a hard
|
|
9186
|
+
// inject dependency, so a deployment without the settings service still
|
|
9187
|
+
// gets every other Power-Up feature.
|
|
9180
9188
|
inject: ['slots', 'locale'],
|
|
9181
9189
|
apply,
|
|
9182
9190
|
// Exported for smoke tests only; the host never reads this.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.1",
|
|
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",
|