dsh-prompt-pool 1.1.0 → 1.2.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/README.md +3 -0
- package/client.js +326 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Prompt pool · 提示池
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/dsh-prompt-pool)
|
|
4
|
+
|
|
3
5
|
A staging pool for prompts inside DeepSeek Harness: park a draft without sending it, arrange a playlist
|
|
4
6
|
of prompt items, and release the batch into the composer's send queue in order.
|
|
5
7
|
|
|
@@ -7,6 +9,7 @@ of prompt items, and release the batch into the composer's send queue in order.
|
|
|
7
9
|
|
|
8
10
|
- Composer trigger beside the send controls (accent + count while something is queued)
|
|
9
11
|
- Composer panel with search, group tabs, row actions and a send-queue card
|
|
12
|
+
- Right-click on selected conversation text to copy it or save it into a group (the last destination leads the menu)
|
|
10
13
|
- Full-height page in the right sidebar (native tab on DSH 0.2+, `dsh-better-sidebar` fallback)
|
|
11
14
|
- Groups: built-in, custom and one tab per workspace; each can be expanded, folded or hidden
|
|
12
15
|
- Settings for group order/display, visible workspaces and post-use retention
|
package/client.js
CHANGED
|
@@ -19,7 +19,7 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
const NATIVE_TAB_ID = 'dsh-prompt-pool';
|
|
20
20
|
const NATIVE_TAB_KIND = 'prompt-pool';
|
|
21
21
|
/** Shown in the settings about card; keep in step with plugin/package.json. */
|
|
22
|
-
const PLUGIN_VERSION = '1.
|
|
22
|
+
const PLUGIN_VERSION = '1.2.0';
|
|
23
23
|
const PLUGIN_AUTHOR = 'GanttShen';
|
|
24
24
|
/** Replace once the public repository exists; the row hides while it is empty. */
|
|
25
25
|
const PLUGIN_REPO = 'https://github.com/Ganttfly/dsh-prompt-pool';
|
|
@@ -148,7 +148,7 @@ window.__ModuleLoader__.load({
|
|
|
148
148
|
'row.edit': '编辑',
|
|
149
149
|
'row.delete': '删除',
|
|
150
150
|
'row.deleteTitle': '删除这条提示词',
|
|
151
|
-
'row.deleteConfirm': '
|
|
151
|
+
'row.deleteConfirm': '删除后这条会从池子里移出,可以在提示条上撤销。',
|
|
152
152
|
'row.deleteAction': '删除',
|
|
153
153
|
'row.up': '上移',
|
|
154
154
|
'row.down': '下移',
|
|
@@ -183,7 +183,7 @@ window.__ModuleLoader__.load({
|
|
|
183
183
|
'tray.empty': '还没选中任何条目,点左侧「+」加入',
|
|
184
184
|
'tray.remove': '移出',
|
|
185
185
|
'tray.removeTitle': '移出这一条',
|
|
186
|
-
'tray.removeConfirm': '
|
|
186
|
+
'tray.removeConfirm': '移出后不可撤销;这条如果在队列里改过,改动不会保留。',
|
|
187
187
|
'tray.removeAction': '移出',
|
|
188
188
|
'tray.duplicate': '复制一份,追加到末尾',
|
|
189
189
|
'tray.queue': '队列中 {n}',
|
|
@@ -194,6 +194,13 @@ window.__ModuleLoader__.load({
|
|
|
194
194
|
'status.savedTo': '已存入「{group}」',
|
|
195
195
|
'status.savedPartialTo': '已存入「{group}」,但 {n} 个附件没有保存',
|
|
196
196
|
'capture.title': '存到哪个分组?',
|
|
197
|
+
'menu.title': '添加到提示池',
|
|
198
|
+
'menu.copy': '复制',
|
|
199
|
+
'menu.copied': '已复制',
|
|
200
|
+
'menu.copyFailed': '复制失败:请按 {shortcut}',
|
|
201
|
+
'menu.last': '上次',
|
|
202
|
+
'menu.count': '{n} 条',
|
|
203
|
+
'menu.saved': '已加入「{group}」',
|
|
197
204
|
'status.storageFailed': '保存失败:浏览器存储不可写(可能已满)。改动只在当前页面有效。',
|
|
198
205
|
'status.nothing': '草稿是空的,先写点什么',
|
|
199
206
|
'status.emptyBody': '内容不能是空的',
|
|
@@ -204,7 +211,7 @@ window.__ModuleLoader__.load({
|
|
|
204
211
|
'status.released': '已释放 {n} 条',
|
|
205
212
|
'status.releaseStopped': '已释放 {n} 条,其余 {rest} 条没发出去:输入框繁忙或内容被改动',
|
|
206
213
|
'status.draftBusy': '输入框里还有内容,先清空或存进池子再释放',
|
|
207
|
-
'status.deleted': '
|
|
214
|
+
'status.deleted': '已删除这条提示词',
|
|
208
215
|
'status.cleared': '已清空 {n} 条待发送',
|
|
209
216
|
'status.undo': '撤销',
|
|
210
217
|
'release.title': '正在发送',
|
|
@@ -307,7 +314,7 @@ window.__ModuleLoader__.load({
|
|
|
307
314
|
'row.edit': 'Edit',
|
|
308
315
|
'row.delete': 'Delete',
|
|
309
316
|
'row.deleteTitle': 'Delete this prompt',
|
|
310
|
-
'row.deleteConfirm': '
|
|
317
|
+
'row.deleteConfirm': 'This prompt will be removed from the pool. You can undo it from the toast.',
|
|
311
318
|
'row.deleteAction': 'Delete',
|
|
312
319
|
'row.up': 'Move up',
|
|
313
320
|
'row.down': 'Move down',
|
|
@@ -342,7 +349,7 @@ window.__ModuleLoader__.load({
|
|
|
342
349
|
'tray.empty': 'Nothing selected yet — use the + control on a row',
|
|
343
350
|
'tray.remove': 'Remove',
|
|
344
351
|
'tray.removeTitle': 'Remove this queued item',
|
|
345
|
-
'tray.removeConfirm': '
|
|
352
|
+
'tray.removeConfirm': 'This cannot be undone. Edits made to this queued copy are lost.',
|
|
346
353
|
'tray.removeAction': 'Remove',
|
|
347
354
|
'tray.duplicate': 'Duplicate and append to the end',
|
|
348
355
|
'tray.queue': '{n} in queue',
|
|
@@ -353,6 +360,13 @@ window.__ModuleLoader__.load({
|
|
|
353
360
|
'status.savedTo': 'Saved to {group}',
|
|
354
361
|
'status.savedPartialTo': 'Saved to {group}; {n} attachment(s) were not captured',
|
|
355
362
|
'capture.title': 'Save to which group?',
|
|
363
|
+
'menu.title': 'Add to the prompt pool',
|
|
364
|
+
'menu.copy': 'Copy',
|
|
365
|
+
'menu.copied': 'Copied',
|
|
366
|
+
'menu.copyFailed': 'Copy failed: press {shortcut}',
|
|
367
|
+
'menu.last': 'Last used',
|
|
368
|
+
'menu.count': '{n} item(s)',
|
|
369
|
+
'menu.saved': 'Added to {group}',
|
|
356
370
|
'status.storageFailed': 'Could not save: browser storage is unwritable (possibly full). Changes last only for this page.',
|
|
357
371
|
'status.nothing': 'The composer is empty',
|
|
358
372
|
'status.emptyBody': 'The content cannot be empty',
|
|
@@ -475,13 +489,43 @@ window.__ModuleLoader__.load({
|
|
|
475
489
|
return line.length > 48 ? line.slice(0, 48) + '…' : line;
|
|
476
490
|
}
|
|
477
491
|
|
|
478
|
-
/**
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
492
|
+
/**
|
|
493
|
+
* Copy text while the menu still holds the pointer gesture. The legacy path
|
|
494
|
+
* answers synchronously, which is what lets the menu report a failed copy;
|
|
495
|
+
* the async Clipboard API is the fallback for hosts that refuse execCommand.
|
|
496
|
+
*/
|
|
497
|
+
function copyText(text) {
|
|
498
|
+
try {
|
|
499
|
+
if (typeof document !== 'undefined' && document.body) {
|
|
500
|
+
const area = document.createElement('textarea');
|
|
501
|
+
area.value = text;
|
|
502
|
+
area.setAttribute('readonly', '');
|
|
503
|
+
area.style.position = 'fixed';
|
|
504
|
+
area.style.top = '-1000px';
|
|
505
|
+
area.style.opacity = '0';
|
|
506
|
+
document.body.appendChild(area);
|
|
507
|
+
let copied = false;
|
|
508
|
+
try {
|
|
509
|
+
area.select();
|
|
510
|
+
copied = document.execCommand('copy') === true;
|
|
511
|
+
} finally {
|
|
512
|
+
document.body.removeChild(area);
|
|
513
|
+
}
|
|
514
|
+
if (copied) return true;
|
|
515
|
+
}
|
|
516
|
+
} catch (_error) {
|
|
517
|
+
/* fall through to the async clipboard */
|
|
518
|
+
}
|
|
519
|
+
try {
|
|
520
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
|
|
521
|
+
const result = navigator.clipboard.writeText(text);
|
|
522
|
+
if (result && typeof result.catch === 'function') result.catch(() => {});
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
} catch (_error) {
|
|
526
|
+
/* nothing else to try */
|
|
527
|
+
}
|
|
528
|
+
return false;
|
|
485
529
|
}
|
|
486
530
|
|
|
487
531
|
/**
|
|
@@ -1099,7 +1143,7 @@ window.__ModuleLoader__.load({
|
|
|
1099
1143
|
function ItemDeleteConfirm(props) {
|
|
1100
1144
|
return h(ConfirmModal, {
|
|
1101
1145
|
label: translate('row.deleteTitle'),
|
|
1102
|
-
text: translate('row.deleteConfirm'
|
|
1146
|
+
text: translate('row.deleteConfirm'),
|
|
1103
1147
|
cancelText: translate('row.cancel'),
|
|
1104
1148
|
confirmText: translate('row.deleteAction'),
|
|
1105
1149
|
onCancel: props.onCancel,
|
|
@@ -1111,7 +1155,7 @@ window.__ModuleLoader__.load({
|
|
|
1111
1155
|
function TrayRemoveConfirm(props) {
|
|
1112
1156
|
return h(ConfirmModal, {
|
|
1113
1157
|
label: translate('tray.removeTitle'),
|
|
1114
|
-
text: translate('tray.removeConfirm'
|
|
1158
|
+
text: translate('tray.removeConfirm'),
|
|
1115
1159
|
cancelText: translate('row.cancel'),
|
|
1116
1160
|
confirmText: translate('tray.removeAction'),
|
|
1117
1161
|
onCancel: props.onCancel,
|
|
@@ -1441,6 +1485,8 @@ window.__ModuleLoader__.load({
|
|
|
1441
1485
|
: [],
|
|
1442
1486
|
currentWorkspaceTab: settings.currentWorkspaceTab !== false,
|
|
1443
1487
|
queueCollapsed: settings.queueCollapsed === true,
|
|
1488
|
+
// The group the right-click menu offered last, so it can lead the list.
|
|
1489
|
+
lastCaptureGroup: typeof settings.lastCaptureGroup === 'string' ? settings.lastCaptureGroup : '',
|
|
1444
1490
|
// Whether an item leaves the pool after it is used.
|
|
1445
1491
|
keepAfterInsert: settings.keepAfterInsert !== false,
|
|
1446
1492
|
keepAfterQueue: settings.keepAfterQueue !== false,
|
|
@@ -2863,7 +2909,7 @@ window.__ModuleLoader__.load({
|
|
|
2863
2909
|
poolActions.remove(item.id);
|
|
2864
2910
|
flash({
|
|
2865
2911
|
kind: 'info',
|
|
2866
|
-
text: text || translate('status.deleted'
|
|
2912
|
+
text: text || translate('status.deleted'),
|
|
2867
2913
|
undo: () => {
|
|
2868
2914
|
poolActions.restore(item, index);
|
|
2869
2915
|
setStatus(null);
|
|
@@ -3030,7 +3076,6 @@ window.__ModuleLoader__.load({
|
|
|
3030
3076
|
: null,
|
|
3031
3077
|
pendingDelete
|
|
3032
3078
|
? h(ItemDeleteConfirm, {
|
|
3033
|
-
title: itemLabel(pendingDelete),
|
|
3034
3079
|
onCancel: () => setPendingDelete(null),
|
|
3035
3080
|
onConfirm: () => {
|
|
3036
3081
|
removeItem(pendingDelete);
|
|
@@ -3040,7 +3085,6 @@ window.__ModuleLoader__.load({
|
|
|
3040
3085
|
: null,
|
|
3041
3086
|
pendingRemove && state.tray.some((entry) => entry.key === pendingRemove.key)
|
|
3042
3087
|
? h(TrayRemoveConfirm, {
|
|
3043
|
-
title: itemLabel(pendingRemove),
|
|
3044
3088
|
onCancel: () => setPendingRemove(null),
|
|
3045
3089
|
onConfirm: () => {
|
|
3046
3090
|
poolActions.removeTray(pendingRemove.key);
|
|
@@ -3672,6 +3716,201 @@ window.__ModuleLoader__.load({
|
|
|
3672
3716
|
);
|
|
3673
3717
|
}
|
|
3674
3718
|
|
|
3719
|
+
// --------------------------------------------------- conversation selection
|
|
3720
|
+
/**
|
|
3721
|
+
* Right-click destinations for text selected in the conversation. The host
|
|
3722
|
+
* opens this surface at the pointer; the top level keeps Copy (the menu
|
|
3723
|
+
* replaces the browser's own) and one pool entry whose submenu lists the
|
|
3724
|
+
* groups on show. Picking a group stores the selection there, and the group
|
|
3725
|
+
* used last time leads that submenu. The surface only exists while the Chat
|
|
3726
|
+
* view is mounted, and a selection lost between the gesture and this mount
|
|
3727
|
+
* leaves it with nothing to offer.
|
|
3728
|
+
*/
|
|
3729
|
+
function SelectionMenu(props) {
|
|
3730
|
+
useLocaleTick();
|
|
3731
|
+
const state = usePoolState();
|
|
3732
|
+
const published = useWorkspaceDir();
|
|
3733
|
+
// The Chat view can read the workspace roster itself; the module store is
|
|
3734
|
+
// the fallback for a host that does not hand `useWorkspaces` to this seat.
|
|
3735
|
+
const snapshot = typeof props.useWorkspaces === 'function' ? props.useWorkspaces(selectAllInput) : undefined;
|
|
3736
|
+
const workspaces = snapshot ? workspaceEntriesOf(snapshot) : published.items || [];
|
|
3737
|
+
const currentWorkspaceId = snapshot ? currentWorkspaceOf(snapshot, props.sessionId) : published.currentId || '';
|
|
3738
|
+
// The gesture captured the text before this surface mounted; keeping it in
|
|
3739
|
+
// state means a collapsed selection cannot empty the menu mid-click.
|
|
3740
|
+
const [body] = useState(() => {
|
|
3741
|
+
const text = typeof props.readText === 'function' ? props.readText() : null;
|
|
3742
|
+
return typeof text === 'string' ? text.replace(/\r\n?/g, '\n').trim() : '';
|
|
3743
|
+
});
|
|
3744
|
+
const [done, setDone] = useState(null);
|
|
3745
|
+
// The group list lives one level down; Copy stays at the top.
|
|
3746
|
+
const [submenu, setSubmenu] = useState(false);
|
|
3747
|
+
const timer = useRef(0);
|
|
3748
|
+
const dismiss = typeof props.dismiss === 'function' ? props.dismiss : () => {};
|
|
3749
|
+
|
|
3750
|
+
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
3751
|
+
useEffect(() => {
|
|
3752
|
+
// The selection was gone before the surface mounted; nothing to offer.
|
|
3753
|
+
if (!body) dismiss();
|
|
3754
|
+
}, [body, dismiss]);
|
|
3755
|
+
|
|
3756
|
+
if (!body) return null;
|
|
3757
|
+
|
|
3758
|
+
const choices = captureChoices(state.categories, workspaces, currentWorkspaceId, state.settings);
|
|
3759
|
+
const last = state.settings && state.settings.lastCaptureGroup;
|
|
3760
|
+
const remembered = choices.find((choice) => choice.value === last) || null;
|
|
3761
|
+
const ordered = remembered ? [remembered, ...choices.filter((choice) => choice !== remembered)] : choices;
|
|
3762
|
+
const counts = {};
|
|
3763
|
+
for (const item of state.items) {
|
|
3764
|
+
const group = groupOf(item);
|
|
3765
|
+
counts[group] = (counts[group] || 0) + 1;
|
|
3766
|
+
}
|
|
3767
|
+
|
|
3768
|
+
const pick = (choice) => {
|
|
3769
|
+
if (done) return;
|
|
3770
|
+
const now = Date.now();
|
|
3771
|
+
poolActions.add({
|
|
3772
|
+
id: uid(),
|
|
3773
|
+
group: choice.value,
|
|
3774
|
+
title: draftTitle(body),
|
|
3775
|
+
body,
|
|
3776
|
+
images: [],
|
|
3777
|
+
createdAt: now,
|
|
3778
|
+
updatedAt: now,
|
|
3779
|
+
});
|
|
3780
|
+
// Remembering the destination makes the next right-click a single pick.
|
|
3781
|
+
poolActions.setSetting('lastCaptureGroup', choice.value);
|
|
3782
|
+
// The write can fail on a full or blocked store; say so instead of
|
|
3783
|
+
// claiming a save the pool would lose on reload.
|
|
3784
|
+
const failed = storageState.get().failed === true;
|
|
3785
|
+
setDone({ kind: failed ? 'failed' : 'saved', label: choice.label });
|
|
3786
|
+
timer.current = window.setTimeout(() => dismiss(), failed ? 2600 : 900);
|
|
3787
|
+
};
|
|
3788
|
+
|
|
3789
|
+
/**
|
|
3790
|
+
* The menu replaces the browser's own menu, so it has to keep Copy. The
|
|
3791
|
+
* selection is already captured, and the click still counts as a gesture.
|
|
3792
|
+
*/
|
|
3793
|
+
const copySelection = () => {
|
|
3794
|
+
if (done) return;
|
|
3795
|
+
const copied = copyText(body);
|
|
3796
|
+
setDone({ kind: copied ? 'copied' : 'copyFailed' });
|
|
3797
|
+
// A failed copy stays up so the shortcut hint can be read and used.
|
|
3798
|
+
if (copied) timer.current = window.setTimeout(() => dismiss(), 900);
|
|
3799
|
+
};
|
|
3800
|
+
|
|
3801
|
+
/** Open the destination submenu; a click serves touch, hover serves mouse. */
|
|
3802
|
+
const openGroups = () => {
|
|
3803
|
+
if (done !== null) return;
|
|
3804
|
+
setSubmenu(true);
|
|
3805
|
+
};
|
|
3806
|
+
|
|
3807
|
+
const error = done !== null && (done.kind === 'failed' || done.kind === 'copyFailed');
|
|
3808
|
+
const shortcut = /Mac|iPhone|iPad/.test(typeof navigator === 'undefined' ? '' : String(navigator.userAgent || '')) ? '⌘C' : 'Ctrl+C';
|
|
3809
|
+
const doneText = done === null
|
|
3810
|
+
? ''
|
|
3811
|
+
: done.kind === 'saved'
|
|
3812
|
+
? translate('menu.saved', { group: done.label })
|
|
3813
|
+
: done.kind === 'copied'
|
|
3814
|
+
? translate('menu.copied')
|
|
3815
|
+
: done.kind === 'copyFailed'
|
|
3816
|
+
? translate('menu.copyFailed', { shortcut })
|
|
3817
|
+
: translate('status.storageFailed');
|
|
3818
|
+
|
|
3819
|
+
return h(
|
|
3820
|
+
'div',
|
|
3821
|
+
{
|
|
3822
|
+
className: 'pp-selwrap',
|
|
3823
|
+
role: 'menu',
|
|
3824
|
+
'aria-label': translate('menu.title'),
|
|
3825
|
+
// Keep the browser selection alive while the pointer is over the menu.
|
|
3826
|
+
onPointerDown: (event) => event.preventDefault(),
|
|
3827
|
+
},
|
|
3828
|
+
h('style', { key: 'css' }, MENU_CSS),
|
|
3829
|
+
done !== null
|
|
3830
|
+
? h(
|
|
3831
|
+
'div',
|
|
3832
|
+
{ key: 'done', className: 'pp-selmenu pp-seldonecard' },
|
|
3833
|
+
h(
|
|
3834
|
+
'div',
|
|
3835
|
+
{ className: 'pp-seldone', 'data-kind': error ? 'error' : 'ok', role: 'status' },
|
|
3836
|
+
h('span', { key: 'mark', className: 'pp-seldone-mark', 'aria-hidden': true }, error ? '!' : '✓'),
|
|
3837
|
+
h('span', { key: 'text', className: 'pp-seldone-text' }, doneText),
|
|
3838
|
+
),
|
|
3839
|
+
)
|
|
3840
|
+
: [
|
|
3841
|
+
h(
|
|
3842
|
+
'div',
|
|
3843
|
+
{ key: 'main', className: 'pp-selmenu' },
|
|
3844
|
+
h(
|
|
3845
|
+
'button',
|
|
3846
|
+
{
|
|
3847
|
+
key: 'copy',
|
|
3848
|
+
type: 'button',
|
|
3849
|
+
role: 'menuitem',
|
|
3850
|
+
className: 'pp-selrow',
|
|
3851
|
+
onClick: copySelection,
|
|
3852
|
+
// Moving back to the first row folds the submenu away.
|
|
3853
|
+
onPointerEnter: () => setSubmenu(false),
|
|
3854
|
+
},
|
|
3855
|
+
h('span', { key: 'name', className: 'pp-selname' }, translate('menu.copy')),
|
|
3856
|
+
h('span', { key: 'key', className: 'pp-selkey' }, shortcut),
|
|
3857
|
+
),
|
|
3858
|
+
h('div', { key: 'rule', className: 'pp-selrule', role: 'separator' }),
|
|
3859
|
+
h(
|
|
3860
|
+
'button',
|
|
3861
|
+
{
|
|
3862
|
+
key: 'pool',
|
|
3863
|
+
type: 'button',
|
|
3864
|
+
role: 'menuitem',
|
|
3865
|
+
className: 'pp-selrow',
|
|
3866
|
+
'aria-haspopup': 'menu',
|
|
3867
|
+
'aria-expanded': submenu,
|
|
3868
|
+
onClick: openGroups,
|
|
3869
|
+
onPointerEnter: openGroups,
|
|
3870
|
+
},
|
|
3871
|
+
h('span', { key: 'name', className: 'pp-selname' }, translate('menu.title')),
|
|
3872
|
+
h('span', { key: 'chev', className: 'pp-selchev', 'aria-hidden': true }, '▸'),
|
|
3873
|
+
),
|
|
3874
|
+
),
|
|
3875
|
+
submenu
|
|
3876
|
+
? h(
|
|
3877
|
+
'div',
|
|
3878
|
+
{ key: 'groups', className: 'pp-selpanel', role: 'menu', 'aria-label': translate('menu.title') },
|
|
3879
|
+
h(
|
|
3880
|
+
'div',
|
|
3881
|
+
{ key: 'list', className: 'pp-sellist' },
|
|
3882
|
+
ordered.map((choice) =>
|
|
3883
|
+
h(
|
|
3884
|
+
'button',
|
|
3885
|
+
{
|
|
3886
|
+
key: choice.value,
|
|
3887
|
+
type: 'button',
|
|
3888
|
+
role: 'menuitem',
|
|
3889
|
+
className: 'pp-selrow',
|
|
3890
|
+
onClick: () => pick(choice),
|
|
3891
|
+
},
|
|
3892
|
+
h('span', { key: 'name', className: 'pp-selname' }, choice.label),
|
|
3893
|
+
remembered && choice === remembered
|
|
3894
|
+
? h('span', { key: 'last', className: 'pp-sellast' }, translate('menu.last'))
|
|
3895
|
+
: null,
|
|
3896
|
+
h(
|
|
3897
|
+
'span',
|
|
3898
|
+
{
|
|
3899
|
+
key: 'count',
|
|
3900
|
+
className: 'pp-selcount',
|
|
3901
|
+
title: translate('menu.count', { n: counts[choice.value] || 0 }),
|
|
3902
|
+
},
|
|
3903
|
+
String(counts[choice.value] || 0),
|
|
3904
|
+
),
|
|
3905
|
+
),
|
|
3906
|
+
),
|
|
3907
|
+
),
|
|
3908
|
+
)
|
|
3909
|
+
: null,
|
|
3910
|
+
],
|
|
3911
|
+
);
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3675
3914
|
// ------------------------------------------------------------------ panel
|
|
3676
3915
|
function PromptPoolPanel(props) {
|
|
3677
3916
|
useLocaleTick();
|
|
@@ -4143,7 +4382,7 @@ window.__ModuleLoader__.load({
|
|
|
4143
4382
|
poolActions.remove(item.id);
|
|
4144
4383
|
flash({
|
|
4145
4384
|
kind: 'info',
|
|
4146
|
-
text: text || translate('status.deleted'
|
|
4385
|
+
text: text || translate('status.deleted'),
|
|
4147
4386
|
undo: () => {
|
|
4148
4387
|
poolActions.restore(item, index);
|
|
4149
4388
|
setStatus(null);
|
|
@@ -4521,7 +4760,6 @@ window.__ModuleLoader__.load({
|
|
|
4521
4760
|
: null,
|
|
4522
4761
|
pendingDelete
|
|
4523
4762
|
? h(ItemDeleteConfirm, {
|
|
4524
|
-
title: itemLabel(pendingDelete),
|
|
4525
4763
|
onCancel: () => setPendingDelete(null),
|
|
4526
4764
|
onConfirm: () => {
|
|
4527
4765
|
deleteItem(pendingDelete);
|
|
@@ -4531,7 +4769,6 @@ window.__ModuleLoader__.load({
|
|
|
4531
4769
|
: null,
|
|
4532
4770
|
pendingRemove && tray.some((entry) => entry.key === pendingRemove.key)
|
|
4533
4771
|
? h(TrayRemoveConfirm, {
|
|
4534
|
-
title: itemLabel(pendingRemove),
|
|
4535
4772
|
onCancel: () => setPendingRemove(null),
|
|
4536
4773
|
onConfirm: () => {
|
|
4537
4774
|
poolActions.removeTray(pendingRemove.key);
|
|
@@ -4866,6 +5103,37 @@ window.__ModuleLoader__.load({
|
|
|
4866
5103
|
'.pp-status-float .pp-link{pointer-events:auto}' +
|
|
4867
5104
|
'@keyframes pp-status-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}';
|
|
4868
5105
|
|
|
5106
|
+
/**
|
|
5107
|
+
* The right-click menu is mounted by the conversation view, not by a pool
|
|
5108
|
+
* view, so it carries its own copy of the shared tokens. The host positions
|
|
5109
|
+
* the surrounding surface and caps its height; `max-height: inherit` lets the
|
|
5110
|
+
* lists scroll inside that cap instead of running past the pointer. The menu
|
|
5111
|
+
* and its submenu are two cards in one wrapping row: the host measures the
|
|
5112
|
+
* grown surface and moves it back inside the pane, and a narrow pane drops
|
|
5113
|
+
* the submenu under the menu instead of clipping it.
|
|
5114
|
+
*/
|
|
5115
|
+
const MENU_CSS =
|
|
5116
|
+
'.pp-selwrap{--pp-accent:var(--dsw-alias-state-business-primary,var(--dsw-alias-brand-primary));--pp-accent-soft:color-mix(in srgb,var(--pp-accent) 13%,transparent);--pp-ink:var(--dsw-alias-label-primary);--pp-ink-2:var(--dsw-alias-label-secondary);--pp-line:var(--dsw-alias-border-l1);--pp-surface:var(--dsw-alias-bg-overlay);--pp-ok:var(--dsw-alias-state-success-primary);--pp-danger:var(--dsw-alias-state-error-primary);display:flex;flex-wrap:wrap;align-items:flex-start;gap:6px;max-height:inherit}' +
|
|
5117
|
+
'.pp-selmenu,.pp-selpanel{display:flex;flex-direction:column;box-sizing:border-box;max-width:100%;max-height:inherit;padding:6px;border:1px solid var(--pp-line);border-radius:10px;background:var(--pp-surface);box-shadow:0 12px 32px rgba(0,0,0,.18);color:var(--pp-ink);font-size:12px;line-height:1.5;text-align:left;overflow:hidden}' +
|
|
5118
|
+
'.pp-selmenu{width:214px}' +
|
|
5119
|
+
'.pp-selpanel{width:190px}' +
|
|
5120
|
+
'.pp-seldonecard{width:280px}' +
|
|
5121
|
+
'.pp-sellist{display:flex;flex-direction:column;min-height:0;overflow-y:auto}' +
|
|
5122
|
+
'.pp-selrule{height:1px;margin:3px 4px;background:var(--pp-line)}' +
|
|
5123
|
+
'.pp-selrow{display:flex;align-items:center;gap:8px;width:100%;height:26px;padding:0 8px;border:0;border-radius:6px;background:transparent;color:var(--pp-ink);font:inherit;font-size:12px;text-align:left;cursor:pointer}' +
|
|
5124
|
+
'.pp-selrow:hover,.pp-selrow:focus-visible{background:color-mix(in srgb,var(--pp-accent) 11%,transparent)}' +
|
|
5125
|
+
'.pp-selrow:focus-visible{outline:2px solid var(--pp-accent);outline-offset:-2px}' +
|
|
5126
|
+
'.pp-selname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
|
|
5127
|
+
'.pp-selchev{flex:none;color:var(--pp-ink-2);font-size:11px}' +
|
|
5128
|
+
'.pp-selkey{flex:none;color:var(--pp-ink-2);font-size:11px}' +
|
|
5129
|
+
'.pp-selcount{flex:none;color:var(--pp-ink-2);font-size:11px;font-variant-numeric:tabular-nums}' +
|
|
5130
|
+
'.pp-sellast{flex:none;padding:0 5px;border-radius:5px;background:var(--pp-accent-soft);color:var(--pp-accent);font-size:10px;line-height:16px}' +
|
|
5131
|
+
'.pp-seldone{display:flex;align-items:flex-start;gap:6px;padding:2px;color:var(--pp-ink);font-size:12px}' +
|
|
5132
|
+
'.pp-seldone-text{flex:1;min-width:0;line-height:1.5}' +
|
|
5133
|
+
'.pp-seldone[data-kind="error"]{color:var(--pp-danger)}' +
|
|
5134
|
+
'.pp-seldone-mark{flex:none;color:var(--pp-ok);font-size:12px}' +
|
|
5135
|
+
'.pp-seldone[data-kind="error"] .pp-seldone-mark{color:var(--pp-danger)}';
|
|
5136
|
+
|
|
4869
5137
|
// ------------------------------------------------------------------- plugin
|
|
4870
5138
|
return {
|
|
4871
5139
|
inject: ['slots', 'locale'],
|
|
@@ -4909,6 +5177,35 @@ window.__ModuleLoader__.load({
|
|
|
4909
5177
|
bindOptional(['sessions'], (target) => {
|
|
4910
5178
|
sessionsFace = serviceOf(target, 'sessions');
|
|
4911
5179
|
});
|
|
5180
|
+
// Right-click on selected conversation text: the host asks plugins in
|
|
5181
|
+
// registration order and the first surface that opens wins. Only the
|
|
5182
|
+
// context-menu trigger is claimed, so the built-in Quote action keeps the
|
|
5183
|
+
// plain drag selection. A host without this service keeps its native menu.
|
|
5184
|
+
let selectionMenuMounted = false;
|
|
5185
|
+
bindOptional(['uiConversation'], (target) => {
|
|
5186
|
+
if (selectionMenuMounted) return;
|
|
5187
|
+
const service = serviceOf(target, 'uiConversation');
|
|
5188
|
+
const interactions = service && service.interactions;
|
|
5189
|
+
if (!interactions || typeof interactions.register !== 'function') return;
|
|
5190
|
+
selectionMenuMounted = true;
|
|
5191
|
+
try {
|
|
5192
|
+
ctx.effect(() =>
|
|
5193
|
+
interactions.register({
|
|
5194
|
+
id: 'prompt-pool',
|
|
5195
|
+
onInteraction(request) {
|
|
5196
|
+
if (!request || request.trigger !== 'contextmenu') return;
|
|
5197
|
+
if (typeof request.readText !== 'function' || request.readText() === null) return;
|
|
5198
|
+
// Opening alone does not suppress the browser menu: without this
|
|
5199
|
+
// the native menu and our surface would both show.
|
|
5200
|
+
request.preventDefault();
|
|
5201
|
+
request.open();
|
|
5202
|
+
},
|
|
5203
|
+
}),
|
|
5204
|
+
);
|
|
5205
|
+
} catch (_error) {
|
|
5206
|
+
selectionMenuMounted = false;
|
|
5207
|
+
}
|
|
5208
|
+
});
|
|
4912
5209
|
if (ctx.locale && typeof ctx.locale.register === 'function' && typeof ctx.locale.bind === 'function') {
|
|
4913
5210
|
ctx.effect(() => ctx.locale.register(NS, { zh: ZH, en: EN }));
|
|
4914
5211
|
translate = ctx.locale.bind(NS);
|
|
@@ -4928,6 +5225,14 @@ window.__ModuleLoader__.load({
|
|
|
4928
5225
|
PromptPoolPanel,
|
|
4929
5226
|
),
|
|
4930
5227
|
);
|
|
5228
|
+
// The Chat view renders the surface the interaction above opened, keyed by
|
|
5229
|
+
// that interaction's id. The slot is declared only while Chat is mounted.
|
|
5230
|
+
ctx.slots.inject('conversation.chat.text-interaction', () =>
|
|
5231
|
+
ctx.slots.register(
|
|
5232
|
+
{ name: 'conversation.chat.text-interaction', key: 'prompt-pool', locale: NS },
|
|
5233
|
+
SelectionMenu,
|
|
5234
|
+
),
|
|
5235
|
+
);
|
|
4931
5236
|
|
|
4932
5237
|
ctx.slots.inject('settings.section', () =>
|
|
4933
5238
|
ctx.slots.register(
|
package/package.json
CHANGED