@restregular/dsh-powerup 0.9.9 → 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 +130 -88
- 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.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)}
|
|
@@ -8407,6 +8404,85 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8407
8404
|
* host primary button keep their own behavior; we add explicit queued and
|
|
8408
8405
|
* interrupt controls that bypass the system busy-time setting.
|
|
8409
8406
|
*/
|
|
8407
|
+
/**
|
|
8408
|
+
* Whether the given session is currently working. Reads the host's
|
|
8409
|
+
* sessions list snapshot (`byId[id].running`) and re-renders when that
|
|
8410
|
+
* store changes. Falls back to false when the host exposes no list, so an
|
|
8411
|
+
* unknown state keeps the native single button.
|
|
8412
|
+
*/
|
|
8413
|
+
function useSessionRunning(ctx, sessionId) {
|
|
8414
|
+
const read = useCallback(() => {
|
|
8415
|
+
if (typeof sessionId !== 'string' || sessionId === '') return false;
|
|
8416
|
+
try {
|
|
8417
|
+
const list = ctx.get('sessions')?.list;
|
|
8418
|
+
if (list === undefined || typeof list.getSnapshot !== 'function') return false;
|
|
8419
|
+
const snapshot = list.getSnapshot();
|
|
8420
|
+
const byId = snapshot !== null && typeof snapshot === 'object' ? snapshot.byId : undefined;
|
|
8421
|
+
const item = byId !== null && typeof byId === 'object' ? byId[sessionId] : undefined;
|
|
8422
|
+
return item !== null && typeof item === 'object' && item.running === true;
|
|
8423
|
+
} catch {
|
|
8424
|
+
return false;
|
|
8425
|
+
}
|
|
8426
|
+
}, [ctx, sessionId]);
|
|
8427
|
+
const [running, setRunning] = useState(read);
|
|
8428
|
+
useEffect(() => {
|
|
8429
|
+
setRunning(read());
|
|
8430
|
+
const list = ctx.get('sessions')?.list;
|
|
8431
|
+
if (list === undefined || typeof list.subscribe !== 'function') return undefined;
|
|
8432
|
+
return list.subscribe(() => setRunning(read()));
|
|
8433
|
+
}, [read, ctx]);
|
|
8434
|
+
return running;
|
|
8435
|
+
}
|
|
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
|
+
|
|
8410
8486
|
function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
|
|
8411
8487
|
const settings = useSettings();
|
|
8412
8488
|
const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
|
|
@@ -8423,6 +8499,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8423
8499
|
}
|
|
8424
8500
|
};
|
|
8425
8501
|
const trimmed = typeof draft === 'string' ? draft.trim() : '';
|
|
8502
|
+
// Dual send only makes sense while the session is actually working:
|
|
8503
|
+
// "queue" vs "interrupt" is meaningless on an idle session, where the
|
|
8504
|
+
// host's single Send button is the correct affordance.
|
|
8505
|
+
const sessionRunning = useSessionRunning(ctx, sessionId);
|
|
8506
|
+
// Which strategy the host's own Send button already covers while busy.
|
|
8507
|
+
const busyEnter = useHostBusyEnter(ctx);
|
|
8426
8508
|
const currentDraft = { trimmed, sessionId, inputActions, ctx };
|
|
8427
8509
|
const send = (mode, text) => {
|
|
8428
8510
|
const value = typeof text === 'string' ? text.trim() : trimmed;
|
|
@@ -8442,10 +8524,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8442
8524
|
console.warn('[dsh-powerup] dual send failed:', error?.message ?? error);
|
|
8443
8525
|
}
|
|
8444
8526
|
};
|
|
8445
|
-
//
|
|
8446
|
-
// Enter
|
|
8447
|
-
// Shift+Enter
|
|
8448
|
-
//
|
|
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.
|
|
8449
8531
|
useEffect(() => {
|
|
8450
8532
|
if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
|
|
8451
8533
|
const onKeyDown = (event) => {
|
|
@@ -8466,95 +8548,51 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8466
8548
|
if (openMenu !== null && openMenu !== undefined) return;
|
|
8467
8549
|
if (editor.hasAttribute('data-composer-chip-selected')) return;
|
|
8468
8550
|
const interrupt = event.shiftKey && (event.ctrlKey || event.metaKey);
|
|
8469
|
-
if (
|
|
8470
|
-
if (!
|
|
8551
|
+
if (!interrupt) return; // plain Enter / Shift+Enter belong to the host
|
|
8552
|
+
if (!sessionRunning) return;
|
|
8471
8553
|
event.preventDefault();
|
|
8472
8554
|
event.stopPropagation();
|
|
8473
|
-
send(
|
|
8555
|
+
send(busyEnter === 'steer' ? 'queue' : 'steer');
|
|
8474
8556
|
};
|
|
8475
8557
|
document.addEventListener('keydown', onKeyDown, true);
|
|
8476
8558
|
return () => document.removeEventListener('keydown', onKeyDown, true);
|
|
8477
|
-
}, [settings.dualSend, sessionId, draft, ctx, inputActions]);
|
|
8559
|
+
}, [settings.dualSend, sessionId, draft, ctx, inputActions, sessionRunning, busyEnter]);
|
|
8478
8560
|
void currentDraft;
|
|
8479
|
-
//
|
|
8480
|
-
//
|
|
8481
|
-
// (
|
|
8482
|
-
const active = settings.dualSend && trimmed !== '';
|
|
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.
|
|
8564
|
+
const active = settings.dualSend && trimmed !== '' && sessionRunning;
|
|
8483
8565
|
const wrapRef = useRef(null);
|
|
8484
|
-
useEffect(() => {
|
|
8485
|
-
if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
|
|
8486
|
-
const clearAll = () => {
|
|
8487
|
-
for (const node of document.querySelectorAll('[data-powerup-send-hidden]')) {
|
|
8488
|
-
node.removeAttribute('data-powerup-send-hidden');
|
|
8489
|
-
}
|
|
8490
|
-
};
|
|
8491
|
-
if (!active) {
|
|
8492
|
-
clearAll();
|
|
8493
|
-
return undefined;
|
|
8494
|
-
}
|
|
8495
|
-
// Walk up from our own slot to the row that directly holds the host's
|
|
8496
|
-
// send buttons, then take its LAST direct button child — that is the
|
|
8497
|
-
// primary send/stop control (the optional interrupt-stop precedes it).
|
|
8498
|
-
const findScope = () => {
|
|
8499
|
-
let node = wrapRef.current;
|
|
8500
|
-
for (let depth = 0; node !== null && depth < 8; depth += 1) {
|
|
8501
|
-
const direct = typeof node.querySelectorAll === 'function'
|
|
8502
|
-
? node.querySelectorAll(':scope > button')
|
|
8503
|
-
: [];
|
|
8504
|
-
if (direct.length > 0) return node;
|
|
8505
|
-
node = node.parentElement;
|
|
8506
|
-
}
|
|
8507
|
-
return null;
|
|
8508
|
-
};
|
|
8509
|
-
const mark = () => {
|
|
8510
|
-
const scope = findScope();
|
|
8511
|
-
if (scope === null) return;
|
|
8512
|
-
const direct = [...scope.querySelectorAll(':scope > button')];
|
|
8513
|
-
const primary = direct[direct.length - 1];
|
|
8514
|
-
if (primary === undefined) return;
|
|
8515
|
-
primary.setAttribute('data-powerup-send-hidden', '');
|
|
8516
|
-
};
|
|
8517
|
-
mark();
|
|
8518
|
-
let scheduled = false;
|
|
8519
|
-
const schedule = () => {
|
|
8520
|
-
if (scheduled) return;
|
|
8521
|
-
scheduled = true;
|
|
8522
|
-
queueMicrotask(() => {
|
|
8523
|
-
scheduled = false;
|
|
8524
|
-
mark();
|
|
8525
|
-
});
|
|
8526
|
-
};
|
|
8527
|
-
const observer = typeof MutationObserver === 'function' ? new MutationObserver(schedule) : null;
|
|
8528
|
-
observer?.observe(document.body, { childList: true, subtree: true });
|
|
8529
|
-
return () => {
|
|
8530
|
-
observer?.disconnect();
|
|
8531
|
-
clearAll();
|
|
8532
|
-
};
|
|
8533
|
-
}, [settings.dualSend, active]);
|
|
8534
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';
|
|
8535
8572
|
return h('div', { className: 'dsh-powerup-dual-send', ref: wrapRef },
|
|
8536
|
-
|
|
8537
|
-
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
h('
|
|
8547
|
-
|
|
8548
|
-
|
|
8549
|
-
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8557
|
-
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' }))),
|
|
8558
8596
|
);
|
|
8559
8597
|
}
|
|
8560
8598
|
|
|
@@ -9143,6 +9181,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9143
9181
|
}
|
|
9144
9182
|
|
|
9145
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.
|
|
9146
9188
|
inject: ['slots', 'locale'],
|
|
9147
9189
|
apply,
|
|
9148
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.
|
|
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",
|