dsh-prompt-pool 1.1.1 → 1.3.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.
Files changed (3) hide show
  1. package/README.md +3 -1
  2. package/client.js +682 -81
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Prompt pool · 提示池
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/dsh-prompt-pool.svg)](https://www.npmjs.com/package/dsh-prompt-pool)
3
+ [![npm version](https://img.shields.io/npm/v/dsh-prompt-pool.svg)](https://www.npmjs.com/package/dsh-prompt-pool) [![dshfind](https://dshfind.com/api/badge/Ganttfly/dsh-prompt-pool)](https://dshfind.com/en/plugins/Ganttfly/dsh-prompt-pool?ref=badge)
4
4
 
5
5
  A staging pool for prompts inside DeepSeek Harness: park a draft without sending it, arrange a playlist
6
6
  of prompt items, and release the batch into the composer's send queue in order.
@@ -8,7 +8,9 @@ of prompt items, and release the batch into the composer's send queue in order.
8
8
  ![The prompt pool panel open above the composer](https://raw.githubusercontent.com/Ganttfly/dsh-prompt-pool/main/docs/images/panel.png)
9
9
 
10
10
  - Composer trigger beside the send controls (accent + count while something is queued)
11
+ - Starter prompts follow the host language; Settings can reset them in the current interface language, keeping edits as ordinary items
11
12
  - Composer panel with search, group tabs, row actions and a send-queue card
13
+ - Right-click on selected conversation text to copy it or save it into a group (the last destination leads the menu)
12
14
  - Full-height page in the right sidebar (native tab on DSH 0.2+, `dsh-better-sidebar` fallback)
13
15
  - Groups: built-in, custom and one tab per workspace; each can be expanded, folded or hidden
14
16
  - 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.1.1';
22
+ const PLUGIN_VERSION = '1.3.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';
@@ -134,6 +134,17 @@ window.__ModuleLoader__.load({
134
134
  'settings.keepInsertHint': '关闭后,插入成功的条目会从池子移出;提示条上的「撤销」可以恢复。',
135
135
  'settings.keepQueue': '加入待发送队列后,仍旧保留在池子中',
136
136
  'settings.keepQueueHint': '关闭后,条目一加入队列就从池子移出;队列里的那一条不受影响。',
137
+ 'settings.seedCard': '内置提示词',
138
+ 'settings.seedHint': '当前有 {builtin} 条内置提示词,其中 {edited} 条已编辑。重置只影响内置条目,自定义条目和队列不受影响。',
139
+ 'settings.seedLanguageZh': '中文',
140
+ 'settings.seedLanguageEn': 'English',
141
+ 'settings.seedNote': '将按当前界面语言「{language}」重置。',
142
+ 'settings.seedKeepEdited': '保留已编辑的内置条目',
143
+ 'settings.seedKeepEditedHint': '勾选后,编辑过的内置条目会转成普通条目保留;未勾选则一起删除。',
144
+ 'settings.seedResetButton': '重置内置提示词',
145
+ 'settings.seedResetTitle': '重置内置提示词?',
146
+ 'settings.seedResetConfirm': '将移除 {removed} 条内置提示词,保留 {kept} 条编辑为普通条目,并按「{language}」重新写入 {added} 条。',
147
+ 'settings.seedResetDone': '已重置:移除 {removed} 条,保留 {kept} 条编辑,写入 {added} 条。',
137
148
  'settings.about': '插件信息',
138
149
  'settings.aboutAuthor': '作者',
139
150
  'settings.aboutRepo': '仓库',
@@ -148,7 +159,7 @@ window.__ModuleLoader__.load({
148
159
  'row.edit': '编辑',
149
160
  'row.delete': '删除',
150
161
  'row.deleteTitle': '删除这条提示词',
151
- 'row.deleteConfirm': '「{title}」会从池子里移出。',
162
+ 'row.deleteConfirm': '删除后这条会从池子里移出,可以在提示条上撤销。',
152
163
  'row.deleteAction': '删除',
153
164
  'row.up': '上移',
154
165
  'row.down': '下移',
@@ -183,7 +194,7 @@ window.__ModuleLoader__.load({
183
194
  'tray.empty': '还没选中任何条目,点左侧「+」加入',
184
195
  'tray.remove': '移出',
185
196
  'tray.removeTitle': '移出这一条',
186
- 'tray.removeConfirm': '「{title}」会从待发送队列移出;这条如果在队列里改过,改动不会保留。',
197
+ 'tray.removeConfirm': '移出后不可撤销;这条如果在队列里改过,改动不会保留。',
187
198
  'tray.removeAction': '移出',
188
199
  'tray.duplicate': '复制一份,追加到末尾',
189
200
  'tray.queue': '队列中 {n}',
@@ -194,6 +205,13 @@ window.__ModuleLoader__.load({
194
205
  'status.savedTo': '已存入「{group}」',
195
206
  'status.savedPartialTo': '已存入「{group}」,但 {n} 个附件没有保存',
196
207
  'capture.title': '存到哪个分组?',
208
+ 'menu.title': '添加到提示池',
209
+ 'menu.copy': '复制',
210
+ 'menu.copied': '已复制',
211
+ 'menu.copyFailed': '复制失败:请按 {shortcut}',
212
+ 'menu.last': '上次',
213
+ 'menu.count': '{n} 条',
214
+ 'menu.saved': '已加入「{group}」',
197
215
  'status.storageFailed': '保存失败:浏览器存储不可写(可能已满)。改动只在当前页面有效。',
198
216
  'status.nothing': '草稿是空的,先写点什么',
199
217
  'status.emptyBody': '内容不能是空的',
@@ -204,7 +222,7 @@ window.__ModuleLoader__.load({
204
222
  'status.released': '已释放 {n} 条',
205
223
  'status.releaseStopped': '已释放 {n} 条,其余 {rest} 条没发出去:输入框繁忙或内容被改动',
206
224
  'status.draftBusy': '输入框里还有内容,先清空或存进池子再释放',
207
- 'status.deleted': '已删除「{title}」',
225
+ 'status.deleted': '已删除这条提示词',
208
226
  'status.cleared': '已清空 {n} 条待发送',
209
227
  'status.undo': '撤销',
210
228
  'release.title': '正在发送',
@@ -293,6 +311,17 @@ window.__ModuleLoader__.load({
293
311
  'settings.keepInsertHint': 'Turned off, an inserted item leaves the pool; the toast offers an undo.',
294
312
  'settings.keepQueue': 'Keep it in the pool after adding it to the send queue',
295
313
  'settings.keepQueueHint': 'Turned off, the item leaves the pool as soon as it is queued; the queued copy stays.',
314
+ 'settings.seedCard': 'Built-in prompts',
315
+ 'settings.seedHint': 'The pool has {builtin} built-in prompts, {edited} of them edited. Resetting only touches built-ins; custom items and the queue are left alone.',
316
+ 'settings.seedLanguageZh': 'Chinese',
317
+ 'settings.seedLanguageEn': 'English',
318
+ 'settings.seedNote': 'Resets in the current interface language: {language}.',
319
+ 'settings.seedKeepEdited': 'Keep edited built-in items',
320
+ 'settings.seedKeepEditedHint': 'Checked, edited built-ins become ordinary items; unchecked, they are removed too.',
321
+ 'settings.seedResetButton': 'Reset built-in prompts',
322
+ 'settings.seedResetTitle': 'Reset built-in prompts?',
323
+ 'settings.seedResetConfirm': 'Remove {removed} built-in prompts, keep {kept} edited as ordinary items, and add {added} in {language}.',
324
+ 'settings.seedResetDone': 'Reset: {removed} removed, {kept} edits kept, {added} added.',
296
325
  'settings.about': 'Plugin info',
297
326
  'settings.aboutAuthor': 'Author',
298
327
  'settings.aboutRepo': 'Repository',
@@ -307,7 +336,7 @@ window.__ModuleLoader__.load({
307
336
  'row.edit': 'Edit',
308
337
  'row.delete': 'Delete',
309
338
  'row.deleteTitle': 'Delete this prompt',
310
- 'row.deleteConfirm': '{title} will be removed from the pool.',
339
+ 'row.deleteConfirm': 'This prompt will be removed from the pool. You can undo it from the toast.',
311
340
  'row.deleteAction': 'Delete',
312
341
  'row.up': 'Move up',
313
342
  'row.down': 'Move down',
@@ -342,7 +371,7 @@ window.__ModuleLoader__.load({
342
371
  'tray.empty': 'Nothing selected yet — use the + control on a row',
343
372
  'tray.remove': 'Remove',
344
373
  'tray.removeTitle': 'Remove this queued item',
345
- 'tray.removeConfirm': '{title} will be removed from the send queue. Edits made to this queued copy are lost.',
374
+ 'tray.removeConfirm': 'This cannot be undone. Edits made to this queued copy are lost.',
346
375
  'tray.removeAction': 'Remove',
347
376
  'tray.duplicate': 'Duplicate and append to the end',
348
377
  'tray.queue': '{n} in queue',
@@ -353,6 +382,13 @@ window.__ModuleLoader__.load({
353
382
  'status.savedTo': 'Saved to {group}',
354
383
  'status.savedPartialTo': 'Saved to {group}; {n} attachment(s) were not captured',
355
384
  'capture.title': 'Save to which group?',
385
+ 'menu.title': 'Add to the prompt pool',
386
+ 'menu.copy': 'Copy',
387
+ 'menu.copied': 'Copied',
388
+ 'menu.copyFailed': 'Copy failed: press {shortcut}',
389
+ 'menu.last': 'Last used',
390
+ 'menu.count': '{n} item(s)',
391
+ 'menu.saved': 'Added to {group}',
356
392
  'status.storageFailed': 'Could not save: browser storage is unwritable (possibly full). Changes last only for this page.',
357
393
  'status.nothing': 'The composer is empty',
358
394
  'status.emptyBody': 'The content cannot be empty',
@@ -475,13 +511,43 @@ window.__ModuleLoader__.load({
475
511
  return line.length > 48 ? line.slice(0, 48) + '…' : line;
476
512
  }
477
513
 
478
- /** The name an item shows under, also used when a confirmation names it. */
479
- function itemLabel(item) {
480
- const image = item.images && item.images[0];
481
- return item.title
482
- || firstLine(item.body)
483
- || (image && (image.name || translate('image.only')))
484
- || translate('group.untitled');
514
+ /**
515
+ * Copy text while the menu still holds the pointer gesture. The legacy path
516
+ * answers synchronously, which is what lets the menu report a failed copy;
517
+ * the async Clipboard API is the fallback for hosts that refuse execCommand.
518
+ */
519
+ function copyText(text) {
520
+ try {
521
+ if (typeof document !== 'undefined' && document.body) {
522
+ const area = document.createElement('textarea');
523
+ area.value = text;
524
+ area.setAttribute('readonly', '');
525
+ area.style.position = 'fixed';
526
+ area.style.top = '-1000px';
527
+ area.style.opacity = '0';
528
+ document.body.appendChild(area);
529
+ let copied = false;
530
+ try {
531
+ area.select();
532
+ copied = document.execCommand('copy') === true;
533
+ } finally {
534
+ document.body.removeChild(area);
535
+ }
536
+ if (copied) return true;
537
+ }
538
+ } catch (_error) {
539
+ /* fall through to the async clipboard */
540
+ }
541
+ try {
542
+ if (typeof navigator !== 'undefined' && navigator.clipboard && typeof navigator.clipboard.writeText === 'function') {
543
+ const result = navigator.clipboard.writeText(text);
544
+ if (result && typeof result.catch === 'function') result.catch(() => {});
545
+ return true;
546
+ }
547
+ } catch (_error) {
548
+ /* nothing else to try */
549
+ }
550
+ return false;
485
551
  }
486
552
 
487
553
  /**
@@ -785,6 +851,8 @@ window.__ModuleLoader__.load({
785
851
  images,
786
852
  createdAt: Number.isFinite(raw.createdAt) ? raw.createdAt : now,
787
853
  updatedAt: Number.isFinite(raw.updatedAt) ? raw.updatedAt : now,
854
+ ...(raw.seed === true ? { seed: true } : {}),
855
+ ...(raw.locale === 'zh' || raw.locale === 'en' ? { locale: raw.locale } : {}),
788
856
  };
789
857
  }
790
858
 
@@ -1099,7 +1167,7 @@ window.__ModuleLoader__.load({
1099
1167
  function ItemDeleteConfirm(props) {
1100
1168
  return h(ConfirmModal, {
1101
1169
  label: translate('row.deleteTitle'),
1102
- text: translate('row.deleteConfirm', { title: props.title }),
1170
+ text: translate('row.deleteConfirm'),
1103
1171
  cancelText: translate('row.cancel'),
1104
1172
  confirmText: translate('row.deleteAction'),
1105
1173
  onCancel: props.onCancel,
@@ -1111,7 +1179,7 @@ window.__ModuleLoader__.load({
1111
1179
  function TrayRemoveConfirm(props) {
1112
1180
  return h(ConfirmModal, {
1113
1181
  label: translate('tray.removeTitle'),
1114
- text: translate('tray.removeConfirm', { title: props.title }),
1182
+ text: translate('tray.removeConfirm'),
1115
1183
  cancelText: translate('row.cancel'),
1116
1184
  confirmText: translate('tray.removeAction'),
1117
1185
  onCancel: props.onCancel,
@@ -1119,6 +1187,23 @@ window.__ModuleLoader__.load({
1119
1187
  });
1120
1188
  }
1121
1189
 
1190
+ /** Confirmation before the built-in set is replaced with a fresh language batch. */
1191
+ function SeedResetConfirm(props) {
1192
+ return h(ConfirmModal, {
1193
+ label: translate('settings.seedResetTitle'),
1194
+ text: translate('settings.seedResetConfirm', {
1195
+ removed: props.removed,
1196
+ kept: props.kept,
1197
+ added: props.added,
1198
+ language: props.language,
1199
+ }),
1200
+ cancelText: translate('row.cancel'),
1201
+ confirmText: translate('settings.seedResetButton'),
1202
+ onCancel: props.onCancel,
1203
+ onConfirm: props.onConfirm,
1204
+ });
1205
+ }
1206
+
1122
1207
  /** The workspace rail, or just its items when there is nothing to switch between. */
1123
1208
  function renderWorkspacePanes(props) {
1124
1209
  const rail = props.rail || [];
@@ -1214,97 +1299,176 @@ window.__ModuleLoader__.load({
1214
1299
  }
1215
1300
 
1216
1301
  function emptyPool() {
1217
- return { version: POOL_VERSION, categories: [], items: [], tray: [], settings: normalizeSettings(undefined), seeded: true };
1302
+ return { version: POOL_VERSION, categories: [], items: [], tray: [], settings: normalizeSettings(undefined), seeded: SEED_LEVEL };
1218
1303
  }
1219
1304
 
1220
1305
  /**
1221
1306
  * First-run content: five behaviour switches that stay valid as one-liners.
1222
- * They land in the 常用 group and stay ordinary, deletable items.
1307
+ * They land in the 常用 / Frequent group and stay ordinary, deletable items.
1308
+ * The locale is fixed at first run; switching languages later does not rewrite
1309
+ * items the user may already have edited.
1223
1310
  */
1224
- const SEED_PROMPTS = [
1225
- ['seed:plan-first', '先给方案', '先列改动清单:要改哪些文件、每处改什么、怎么验证。等我确认后再动手。'],
1226
- ['seed:scope-guard', '不动无关代码', '只改与目标直接相关的行;看到别的问题只记录,不顺手修。'],
1227
- [
1228
- 'seed:pre-delivery',
1229
- '交付前自检',
1230
- '交付前给一条最小验证(命令或测试),并回答三件事:最可能出问题的地方、怎么回滚、哪些假设我没验证过。',
1311
+ const SEED_PROMPTS = {
1312
+ zh: [
1313
+ ['seed:plan-first', '先给方案', '先列改动清单:要改哪些文件、每处改什么、怎么验证。等我确认后再动手。'],
1314
+ ['seed:scope-guard', '不动无关代码', '只改与目标直接相关的行;看到别的问题只记录,不顺手修。'],
1315
+ [
1316
+ 'seed:pre-delivery',
1317
+ '交付前自检',
1318
+ '交付前给一条最小验证(命令或测试),并回答三件事:最可能出问题的地方、怎么回滚、哪些假设我没验证过。',
1319
+ ],
1320
+ ['seed:stop-restate', '停下重述', '停一下:重述我的原始要求和当前实际在做的事,指出偏差,再决定继续还是回退。'],
1321
+ ['seed:commands', '给命令不给描述', '需要我操作时直接给可粘贴的命令、路径或代码块。'],
1322
+ ],
1323
+ en: [
1324
+ [
1325
+ 'seed:plan-first',
1326
+ 'Plan first',
1327
+ 'List the changes before touching code: which files, what changes in each, and how you will verify. Wait for my go-ahead before editing.',
1328
+ ],
1329
+ [
1330
+ 'seed:scope-guard',
1331
+ 'Stay in scope',
1332
+ 'Change only the lines directly related to the goal. If you spot other issues, note them instead of fixing them.',
1333
+ ],
1334
+ [
1335
+ 'seed:pre-delivery',
1336
+ 'Check before delivery',
1337
+ 'Before delivering, give one minimal verification (a command or test) and answer three things: what is most likely to break, how to roll back, and which assumptions I have not verified.',
1338
+ ],
1339
+ [
1340
+ 'seed:stop-restate',
1341
+ 'Stop and restate',
1342
+ 'Pause: restate my original request and what you are actually doing, call out the drift, then decide whether to continue or roll back.',
1343
+ ],
1344
+ [
1345
+ 'seed:commands',
1346
+ 'Commands, not prose',
1347
+ 'When I need to act, give me commands, paths, or code blocks I can paste directly.',
1348
+ ],
1231
1349
  ],
1232
- ['seed:stop-restate', '停下重述', '停一下:重述我的原始要求和当前实际在做的事,指出偏差,再决定继续还是回退。'],
1233
- ['seed:commands', '给命令不给描述', '需要我操作时直接给可粘贴的命令、路径或代码块。'],
1234
- ];
1350
+ };
1235
1351
 
1236
1352
  /** Templates: each one has a hole to fill and a shape the answer must take. */
1237
- const SEED_TEMPLATES = [
1238
- [
1239
- 'seed:review',
1240
- '代码审查',
1241
- '审阅 {{贴 diff 或文件}}:先用一句话给结论(能否合入、卡在哪);再按「阻塞 / 建议 / 可选」分级列问题,每条给行号、触发条件、修法。不要重述代码在做什么。',
1242
- ],
1243
- [
1244
- 'seed:options',
1245
- '方案对比',
1246
- '针对 {{决策点}} 给 2–3 个候选方案,用表格对比:改动范围、风险、回滚难度、后续维护成本;最后给推荐项和一句理由。',
1353
+ const SEED_TEMPLATES = {
1354
+ zh: [
1355
+ [
1356
+ 'seed:review',
1357
+ '代码审查',
1358
+ '审阅 {{贴 diff 或文件}}:先用一句话给结论(能否合入、卡在哪);再按「阻塞 / 建议 / 可选」分级列问题,每条给行号、触发条件、修法。不要重述代码在做什么。',
1359
+ ],
1360
+ [
1361
+ 'seed:options',
1362
+ '方案对比',
1363
+ '针对 {{决策点}} 给 2–3 个候选方案,用表格对比:改动范围、风险、回滚难度、后续维护成本;最后给推荐项和一句理由。',
1364
+ ],
1365
+ [
1366
+ 'seed:acceptance',
1367
+ '验收清单',
1368
+ '为 {{功能名}} 输出可勾选清单,按「正常路径 / 边界 / 失败恢复」分组;每条写成一个可观察的结果,能被执行或验证。',
1369
+ ],
1370
+ [
1371
+ 'seed:changelog',
1372
+ '变更说明',
1373
+ '按 Keep a Changelog 写 {{版本号}} 的变更说明:动词开头、一条一个变更、修复与新增不混在同一条;破坏性变更单独列一节。',
1374
+ ],
1375
+ [
1376
+ 'seed:explain',
1377
+ '解释这段代码',
1378
+ '解释 {{代码或模块}}:先用一句话说它解决什么问题,再说依赖的关键不变量、最容易踩的坑、以及改动时不能破坏的东西。',
1379
+ ],
1247
1380
  ],
1248
- [
1249
- 'seed:acceptance',
1250
- '验收清单',
1251
- '为 {{功能名}} 输出可勾选清单,按「正常路径 / 边界 / 失败恢复」分组;每条写成一个可观察的结果,能被执行或验证。',
1381
+ en: [
1382
+ [
1383
+ 'seed:review',
1384
+ 'Code review',
1385
+ 'Review {{paste a diff or file}}: open with a one-sentence verdict (mergeable, and where it is blocked), then list issues as Blocking / Suggestion / Optional, each with line number, trigger, and fix. Do not restate what the code does.',
1386
+ ],
1387
+ [
1388
+ 'seed:options',
1389
+ 'Compare options',
1390
+ 'For {{decision point}}, give 2–3 candidates in a table comparing change scope, risk, rollback difficulty, and maintenance cost. End with the recommended option and one reason.',
1391
+ ],
1392
+ [
1393
+ 'seed:acceptance',
1394
+ 'Acceptance checklist',
1395
+ 'For {{feature name}}, output a checkable list grouped by Happy path / Edge cases / Failure recovery; each line must be an observable result that can be executed or verified.',
1396
+ ],
1397
+ [
1398
+ 'seed:changelog',
1399
+ 'Changelog entry',
1400
+ 'Write the {{version}} entry in Keep a Changelog style: start each line with a verb, one change per line, and do not mix fixes with additions. Give breaking changes their own section.',
1401
+ ],
1402
+ [
1403
+ 'seed:explain',
1404
+ 'Explain this code',
1405
+ 'Explain {{code or module}}: one sentence on the problem it solves, then the key invariants it relies on, the most likely pitfalls, and what must not break when changing it.',
1406
+ ],
1252
1407
  ],
1253
- [
1254
- 'seed:changelog',
1255
- '变更说明',
1256
- '按 Keep a Changelog 写 {{版本号}} 的变更说明:动词开头、一条一个变更、修复与新增不混在同一条;破坏性变更单独列一节。',
1257
- ],
1258
- [
1259
- 'seed:explain',
1260
- '解释这段代码',
1261
- '解释 {{代码或模块}}:先用一句话说它解决什么问题,再说依赖的关键不变量、最容易踩的坑、以及改动时不能破坏的东西。',
1262
- ],
1263
- ];
1408
+ };
1264
1409
 
1265
1410
  /** A build bumps this and adds one batch; older pools receive only the new batch. */
1266
1411
  /** Bump when the stored item shape changes: older pools are reseeded, not migrated. */
1267
1412
  const POOL_VERSION = 2;
1268
1413
 
1269
1414
  const SEED_LEVEL = 2;
1415
+ const SEED_TOTAL = SEED_PROMPTS.en.length + SEED_TEMPLATES.en.length;
1270
1416
 
1271
- function seedItem([id, title, body], group, now) {
1272
- return { id, group, title, body, createdAt: now, updatedAt: now };
1417
+ function seedItem([id, title, body], group, now, locale) {
1418
+ return { id, group, title, body, seed: true, locale, createdAt: now, updatedAt: now };
1273
1419
  }
1274
1420
 
1275
- function seedsAbove(level, now) {
1421
+ /**
1422
+ * Every built-in id knows both language variants. The locale marker on a
1423
+ * saved item plus an exact title/body match is what proves it is still the
1424
+ * untouched built-in rather than a user edit.
1425
+ */
1426
+ const SEED_CATALOG = new Map();
1427
+ function registerSeedBatch(entries, locale, level, group) {
1428
+ for (const [id, title, body] of entries) {
1429
+ const record = SEED_CATALOG.get(id) || { level, group, content: {} };
1430
+ record.content[locale] = { title, body };
1431
+ SEED_CATALOG.set(id, record);
1432
+ }
1433
+ }
1434
+ registerSeedBatch(SEED_PROMPTS.zh, 'zh', 1, BUILTIN_GROUP.oftenuse);
1435
+ registerSeedBatch(SEED_PROMPTS.en, 'en', 1, BUILTIN_GROUP.oftenuse);
1436
+ registerSeedBatch(SEED_TEMPLATES.zh, 'zh', 2, BUILTIN_GROUP.template);
1437
+ registerSeedBatch(SEED_TEMPLATES.en, 'en', 2, BUILTIN_GROUP.template);
1438
+
1439
+ function seedsAbove(level, now, locale) {
1440
+ const language = locale === 'zh' ? 'zh' : 'en';
1276
1441
  const batches = [
1277
- { level: 1, items: SEED_PROMPTS.map((entry) => seedItem(entry, BUILTIN_GROUP.oftenuse, now)) },
1278
- { level: 2, items: SEED_TEMPLATES.map((entry) => seedItem(entry, BUILTIN_GROUP.template, now)) },
1442
+ { level: 1, items: SEED_PROMPTS[language].map((entry) => seedItem(entry, BUILTIN_GROUP.oftenuse, now, language)) },
1443
+ { level: 2, items: SEED_TEMPLATES[language].map((entry) => seedItem(entry, BUILTIN_GROUP.template, now, language)) },
1279
1444
  ];
1280
1445
  return batches.filter((batch) => batch.level > level).reduce((list, batch) => list.concat(batch.items), []);
1281
1446
  }
1282
1447
 
1283
- function seededPool() {
1448
+ /**
1449
+ * An untitled empty pool is not the same as a deliberate empty one: it waits
1450
+ * for apply() so the first-run seeds can follow the host locale.
1451
+ */
1452
+ function pendingPool() {
1284
1453
  return {
1285
1454
  version: POOL_VERSION,
1286
1455
  categories: [],
1287
- items: seedsAbove(0, Date.now()),
1456
+ items: [],
1288
1457
  tray: [],
1289
1458
  settings: normalizeSettings(undefined),
1290
- seeded: SEED_LEVEL,
1459
+ seeded: 0,
1291
1460
  };
1292
1461
  }
1293
1462
 
1294
- function seedItems(existing, level) {
1463
+ function seedItems(existing, level, locale) {
1295
1464
  const taken = new Set(existing.map((item) => item.id));
1296
- return seedsAbove(level, Date.now()).filter((item) => !taken.has(item.id));
1465
+ return seedsAbove(level, Date.now(), locale).filter((item) => !taken.has(item.id));
1297
1466
  }
1298
1467
 
1299
1468
  function loadPool() {
1300
1469
  try {
1301
1470
  const raw = localStorage.getItem(STORAGE_KEY);
1302
- if (!raw) {
1303
- // Brand-new install only: an existing (even empty) pool is never reseeded.
1304
- const seeded = seededPool();
1305
- persist(seeded);
1306
- return seeded;
1307
- }
1471
+ if (!raw) return pendingPool();
1308
1472
  const parsed = JSON.parse(raw);
1309
1473
  const storedVersion = parsed && typeof parsed.version === 'number' ? parsed.version : 1;
1310
1474
  if (storedVersion < POOL_VERSION) {
@@ -1316,12 +1480,8 @@ window.__ModuleLoader__.load({
1316
1480
  /* the backup is best effort; the pool itself still loads */
1317
1481
  }
1318
1482
  }
1319
- const pool = normalizePool(parsed);
1320
- const level = Number(pool.seeded) || 0;
1321
- if (storedVersion >= POOL_VERSION && level >= SEED_LEVEL) return pool;
1322
- const migrated = level >= SEED_LEVEL ? pool : { ...pool, items: [...pool.items, ...seedItems(pool.items, level)], seeded: SEED_LEVEL };
1323
- persist(migrated);
1324
- return migrated;
1483
+ // Seed batches are added in apply(), where the host locale is known.
1484
+ return normalizePool(parsed);
1325
1485
  } catch (_error) {
1326
1486
  return emptyPool();
1327
1487
  }
@@ -1441,6 +1601,8 @@ window.__ModuleLoader__.load({
1441
1601
  : [],
1442
1602
  currentWorkspaceTab: settings.currentWorkspaceTab !== false,
1443
1603
  queueCollapsed: settings.queueCollapsed === true,
1604
+ // The group the right-click menu offered last, so it can lead the list.
1605
+ lastCaptureGroup: typeof settings.lastCaptureGroup === 'string' ? settings.lastCaptureGroup : '',
1444
1606
  // Whether an item leaves the pool after it is used.
1445
1607
  keepAfterInsert: settings.keepAfterInsert !== false,
1446
1608
  keepAfterQueue: settings.keepAfterQueue !== false,
@@ -1588,6 +1750,76 @@ window.__ModuleLoader__.load({
1588
1750
  }
1589
1751
  }
1590
1752
 
1753
+ /**
1754
+ * Screenshot/test override: setting this key to 'en' or 'zh' makes the
1755
+ * plugin's own copy and its new seed batches use that language without
1756
+ * changing the host UI. Unset in normal use.
1757
+ */
1758
+ const PREVIEW_LOCALE_KEY = 'dsh.prompt-pool.preview-locale';
1759
+
1760
+ function previewLocaleId() {
1761
+ try {
1762
+ const value = localStorage.getItem(PREVIEW_LOCALE_KEY);
1763
+ return value === 'zh' || value === 'en' ? value : null;
1764
+ } catch (_error) {
1765
+ return null;
1766
+ }
1767
+ }
1768
+
1769
+ /** The host locale at first run; unsupported locales fall back to English seeds. */
1770
+ function activeLocaleId() {
1771
+ const preview = previewLocaleId();
1772
+ if (preview) return preview;
1773
+ try {
1774
+ const snapshot =
1775
+ localeCtx && typeof localeCtx.getLocale === 'function'
1776
+ ? localeCtx.getLocale()
1777
+ : localeCtx && typeof localeCtx.getSnapshot === 'function'
1778
+ ? localeCtx.getSnapshot()
1779
+ : null;
1780
+ const active = snapshot && (snapshot.active || snapshot.id || snapshot.locale || snapshot.language);
1781
+ if (typeof active === 'string' && active) return active.toLowerCase().startsWith('zh') ? 'zh' : 'en';
1782
+ } catch (_error) {
1783
+ /* a locale service that cannot answer still gets the document fallback */
1784
+ }
1785
+ try {
1786
+ const htmlLang = typeof document !== 'undefined' && document.documentElement ? document.documentElement.lang : '';
1787
+ if (typeof htmlLang === 'string' && htmlLang) return htmlLang.toLowerCase().startsWith('zh') ? 'zh' : 'en';
1788
+ } catch (_error) {
1789
+ /* no document in a non-browser host */
1790
+ }
1791
+ return 'en';
1792
+ }
1793
+
1794
+ /**
1795
+ * Add the missing seed batches now that apply() knows the host locale. A
1796
+ * brand-new pool is seeded only here; an existing pool keeps every saved
1797
+ * item, and its ids prevent a batch from being duplicated.
1798
+ */
1799
+ function seedPoolIfNeeded() {
1800
+ const current = pool.get();
1801
+ const level = current.seeded === true ? SEED_LEVEL : Number(current.seeded) || 0;
1802
+ if (level >= SEED_LEVEL) return;
1803
+ const missing = seedItems(current.items, level, activeLocaleId());
1804
+ const next = { ...current, items: [...current.items, ...missing], seeded: SEED_LEVEL };
1805
+ persist(next);
1806
+ pool.set(next);
1807
+ }
1808
+
1809
+ /** Which language variant this item still exactly matches, or null once edited. */
1810
+ function seedContentLocale(item, record) {
1811
+ for (const locale of ['zh', 'en']) {
1812
+ const content = record.content[locale];
1813
+ if (content && item.title === content.title && item.body === content.body) return locale;
1814
+ }
1815
+ return null;
1816
+ }
1817
+
1818
+ /** An extra image also counts as an edit, because a reset would lose it. */
1819
+ function seedIsEdited(item, record) {
1820
+ return seedContentLocale(item, record) === null || (Array.isArray(item.images) && item.images.length > 0);
1821
+ }
1822
+
1591
1823
  function mutate(fn) {
1592
1824
  const prev = pool.get();
1593
1825
  const next = fn(prev);
@@ -1601,6 +1833,40 @@ window.__ModuleLoader__.load({
1601
1833
  mutate((state) => ({ ...state, items: [...state.items, item] }));
1602
1834
  return item;
1603
1835
  },
1836
+ /**
1837
+ * Replace every built-in item with a fresh set in `target`. A kept edit
1838
+ * becomes an ordinary item with a new id, so the incoming set can use the
1839
+ * canonical ids without a duplicate. Custom items and the tray are untouched.
1840
+ */
1841
+ resetBuiltins(target, keepEdited) {
1842
+ const language = target === 'zh' ? 'zh' : 'en';
1843
+ const current = pool.get();
1844
+ const now = Date.now();
1845
+ const items = [];
1846
+ let removed = 0;
1847
+ let kept = 0;
1848
+ for (const item of current.items) {
1849
+ const record = SEED_CATALOG.get(item.id);
1850
+ if (!record) {
1851
+ items.push(item);
1852
+ continue;
1853
+ }
1854
+ if (keepEdited && seedIsEdited(item, record)) {
1855
+ const preserved = { ...item, id: uid() };
1856
+ delete preserved.seed;
1857
+ delete preserved.locale;
1858
+ items.push(preserved);
1859
+ kept += 1;
1860
+ } else {
1861
+ removed += 1;
1862
+ }
1863
+ }
1864
+ const fresh = seedsAbove(0, now, language);
1865
+ const next = { ...current, items: [...items, ...fresh], seeded: SEED_LEVEL };
1866
+ persist(next);
1867
+ pool.set(next);
1868
+ return { removed, kept, added: fresh.length, language };
1869
+ },
1604
1870
  /** Copy one pool item (current text) and append the copy last. */
1605
1871
  duplicateItem(id) {
1606
1872
  mutate((state) => {
@@ -2863,7 +3129,7 @@ window.__ModuleLoader__.load({
2863
3129
  poolActions.remove(item.id);
2864
3130
  flash({
2865
3131
  kind: 'info',
2866
- text: text || translate('status.deleted', { title: itemLabel(item) }),
3132
+ text: text || translate('status.deleted'),
2867
3133
  undo: () => {
2868
3134
  poolActions.restore(item, index);
2869
3135
  setStatus(null);
@@ -3030,7 +3296,6 @@ window.__ModuleLoader__.load({
3030
3296
  : null,
3031
3297
  pendingDelete
3032
3298
  ? h(ItemDeleteConfirm, {
3033
- title: itemLabel(pendingDelete),
3034
3299
  onCancel: () => setPendingDelete(null),
3035
3300
  onConfirm: () => {
3036
3301
  removeItem(pendingDelete);
@@ -3040,7 +3305,6 @@ window.__ModuleLoader__.load({
3040
3305
  : null,
3041
3306
  pendingRemove && state.tray.some((entry) => entry.key === pendingRemove.key)
3042
3307
  ? h(TrayRemoveConfirm, {
3043
- title: itemLabel(pendingRemove),
3044
3308
  onCancel: () => setPendingRemove(null),
3045
3309
  onConfirm: () => {
3046
3310
  poolActions.removeTray(pendingRemove.key);
@@ -3169,6 +3433,21 @@ window.__ModuleLoader__.load({
3169
3433
  poolActions.setSetting('hiddenWorkspaces', next);
3170
3434
  };
3171
3435
  const [section, setSection] = useState('order');
3436
+ const [seedKeepEdited, setSeedKeepEdited] = useState(true);
3437
+ const [seedConfirm, setSeedConfirm] = useState(false);
3438
+ const [seedStatus, setSeedStatus] = useState('');
3439
+ const seedItems = state.items.filter((item) => SEED_CATALOG.has(item.id));
3440
+ const editedSeeds = seedItems.filter((item) => seedIsEdited(item, SEED_CATALOG.get(item.id)));
3441
+ const seedLanguageLabel = translate(
3442
+ activeLocaleId() === 'zh' ? 'settings.seedLanguageZh' : 'settings.seedLanguageEn',
3443
+ );
3444
+ const seedRemoveCount = seedItems.length - (seedKeepEdited ? editedSeeds.length : 0);
3445
+ const seedKeptCount = seedKeepEdited ? editedSeeds.length : 0;
3446
+ const resetSeeds = () => {
3447
+ const result = poolActions.resetBuiltins(activeLocaleId(), seedKeepEdited);
3448
+ setSeedConfirm(false);
3449
+ setSeedStatus(translate('settings.seedResetDone', result));
3450
+ };
3172
3451
  const moveOrder = (index, delta) => {
3173
3452
  const order = settings.order.slice();
3174
3453
  const to = index + delta;
@@ -3241,6 +3520,48 @@ window.__ModuleLoader__.load({
3241
3520
  h('div', { className: 'pp-set-divider' }),
3242
3521
  check('keepAfterQueue', 'settings.keepQueue', 'settings.keepQueueHint'),
3243
3522
  ),
3523
+ h(
3524
+ 'div',
3525
+ { className: 'pp-set-group pp-set-card', style: { display: section === 'prompts' ? '' : 'none' } },
3526
+ h('div', { className: 'pp-set-label' }, translate('settings.seedCard')),
3527
+ h(
3528
+ 'div',
3529
+ { className: 'pp-hint' },
3530
+ translate('settings.seedHint', { builtin: seedItems.length, edited: editedSeeds.length }),
3531
+ ),
3532
+ h(
3533
+ 'label',
3534
+ { className: 'pp-set-row' },
3535
+ h('input', {
3536
+ type: 'checkbox',
3537
+ name: 'seedKeepEdited',
3538
+ checked: seedKeepEdited,
3539
+ onChange: () => setSeedKeepEdited((value) => !value),
3540
+ }),
3541
+ h('span', null, translate('settings.seedKeepEdited')),
3542
+ ),
3543
+ h('div', { className: 'pp-hint pp-set-hint' }, translate('settings.seedKeepEditedHint')),
3544
+ h(
3545
+ 'div',
3546
+ { className: 'pp-set-actions' },
3547
+ h(
3548
+ 'span',
3549
+ { className: 'pp-hint pp-set-note' },
3550
+ translate('settings.seedNote', { language: seedLanguageLabel }),
3551
+ ),
3552
+ h(
3553
+ 'button',
3554
+ {
3555
+ type: 'button',
3556
+ className: 'pp-mini',
3557
+ 'data-pp': 'seed-reset',
3558
+ onClick: () => setSeedConfirm(true),
3559
+ },
3560
+ translate('settings.seedResetButton'),
3561
+ ),
3562
+ ),
3563
+ seedStatus ? h('div', { className: 'pp-hint' }, seedStatus) : null,
3564
+ ),
3244
3565
  h(
3245
3566
  'div',
3246
3567
  { className: 'pp-set-group pp-set-card', style: { display: section === 'workspace' ? '' : 'none' } },
@@ -3355,6 +3676,16 @@ window.__ModuleLoader__.load({
3355
3676
  )
3356
3677
  : null,
3357
3678
  ),
3679
+ seedConfirm
3680
+ ? h(SeedResetConfirm, {
3681
+ removed: seedRemoveCount,
3682
+ kept: seedKeptCount,
3683
+ added: SEED_TOTAL,
3684
+ language: seedLanguageLabel,
3685
+ onCancel: () => setSeedConfirm(false),
3686
+ onConfirm: resetSeeds,
3687
+ })
3688
+ : null,
3358
3689
  );
3359
3690
  }
3360
3691
 
@@ -3672,6 +4003,201 @@ window.__ModuleLoader__.load({
3672
4003
  );
3673
4004
  }
3674
4005
 
4006
+ // --------------------------------------------------- conversation selection
4007
+ /**
4008
+ * Right-click destinations for text selected in the conversation. The host
4009
+ * opens this surface at the pointer; the top level keeps Copy (the menu
4010
+ * replaces the browser's own) and one pool entry whose submenu lists the
4011
+ * groups on show. Picking a group stores the selection there, and the group
4012
+ * used last time leads that submenu. The surface only exists while the Chat
4013
+ * view is mounted, and a selection lost between the gesture and this mount
4014
+ * leaves it with nothing to offer.
4015
+ */
4016
+ function SelectionMenu(props) {
4017
+ useLocaleTick();
4018
+ const state = usePoolState();
4019
+ const published = useWorkspaceDir();
4020
+ // The Chat view can read the workspace roster itself; the module store is
4021
+ // the fallback for a host that does not hand `useWorkspaces` to this seat.
4022
+ const snapshot = typeof props.useWorkspaces === 'function' ? props.useWorkspaces(selectAllInput) : undefined;
4023
+ const workspaces = snapshot ? workspaceEntriesOf(snapshot) : published.items || [];
4024
+ const currentWorkspaceId = snapshot ? currentWorkspaceOf(snapshot, props.sessionId) : published.currentId || '';
4025
+ // The gesture captured the text before this surface mounted; keeping it in
4026
+ // state means a collapsed selection cannot empty the menu mid-click.
4027
+ const [body] = useState(() => {
4028
+ const text = typeof props.readText === 'function' ? props.readText() : null;
4029
+ return typeof text === 'string' ? text.replace(/\r\n?/g, '\n').trim() : '';
4030
+ });
4031
+ const [done, setDone] = useState(null);
4032
+ // The group list lives one level down; Copy stays at the top.
4033
+ const [submenu, setSubmenu] = useState(false);
4034
+ const timer = useRef(0);
4035
+ const dismiss = typeof props.dismiss === 'function' ? props.dismiss : () => {};
4036
+
4037
+ useEffect(() => () => window.clearTimeout(timer.current), []);
4038
+ useEffect(() => {
4039
+ // The selection was gone before the surface mounted; nothing to offer.
4040
+ if (!body) dismiss();
4041
+ }, [body, dismiss]);
4042
+
4043
+ if (!body) return null;
4044
+
4045
+ const choices = captureChoices(state.categories, workspaces, currentWorkspaceId, state.settings);
4046
+ const last = state.settings && state.settings.lastCaptureGroup;
4047
+ const remembered = choices.find((choice) => choice.value === last) || null;
4048
+ const ordered = remembered ? [remembered, ...choices.filter((choice) => choice !== remembered)] : choices;
4049
+ const counts = {};
4050
+ for (const item of state.items) {
4051
+ const group = groupOf(item);
4052
+ counts[group] = (counts[group] || 0) + 1;
4053
+ }
4054
+
4055
+ const pick = (choice) => {
4056
+ if (done) return;
4057
+ const now = Date.now();
4058
+ poolActions.add({
4059
+ id: uid(),
4060
+ group: choice.value,
4061
+ title: draftTitle(body),
4062
+ body,
4063
+ images: [],
4064
+ createdAt: now,
4065
+ updatedAt: now,
4066
+ });
4067
+ // Remembering the destination makes the next right-click a single pick.
4068
+ poolActions.setSetting('lastCaptureGroup', choice.value);
4069
+ // The write can fail on a full or blocked store; say so instead of
4070
+ // claiming a save the pool would lose on reload.
4071
+ const failed = storageState.get().failed === true;
4072
+ setDone({ kind: failed ? 'failed' : 'saved', label: choice.label });
4073
+ timer.current = window.setTimeout(() => dismiss(), failed ? 2600 : 900);
4074
+ };
4075
+
4076
+ /**
4077
+ * The menu replaces the browser's own menu, so it has to keep Copy. The
4078
+ * selection is already captured, and the click still counts as a gesture.
4079
+ */
4080
+ const copySelection = () => {
4081
+ if (done) return;
4082
+ const copied = copyText(body);
4083
+ setDone({ kind: copied ? 'copied' : 'copyFailed' });
4084
+ // A failed copy stays up so the shortcut hint can be read and used.
4085
+ if (copied) timer.current = window.setTimeout(() => dismiss(), 900);
4086
+ };
4087
+
4088
+ /** Open the destination submenu; a click serves touch, hover serves mouse. */
4089
+ const openGroups = () => {
4090
+ if (done !== null) return;
4091
+ setSubmenu(true);
4092
+ };
4093
+
4094
+ const error = done !== null && (done.kind === 'failed' || done.kind === 'copyFailed');
4095
+ const shortcut = /Mac|iPhone|iPad/.test(typeof navigator === 'undefined' ? '' : String(navigator.userAgent || '')) ? '⌘C' : 'Ctrl+C';
4096
+ const doneText = done === null
4097
+ ? ''
4098
+ : done.kind === 'saved'
4099
+ ? translate('menu.saved', { group: done.label })
4100
+ : done.kind === 'copied'
4101
+ ? translate('menu.copied')
4102
+ : done.kind === 'copyFailed'
4103
+ ? translate('menu.copyFailed', { shortcut })
4104
+ : translate('status.storageFailed');
4105
+
4106
+ return h(
4107
+ 'div',
4108
+ {
4109
+ className: 'pp-selwrap',
4110
+ role: 'menu',
4111
+ 'aria-label': translate('menu.title'),
4112
+ // Keep the browser selection alive while the pointer is over the menu.
4113
+ onPointerDown: (event) => event.preventDefault(),
4114
+ },
4115
+ h('style', { key: 'css' }, MENU_CSS),
4116
+ done !== null
4117
+ ? h(
4118
+ 'div',
4119
+ { key: 'done', className: 'pp-selmenu pp-seldonecard' },
4120
+ h(
4121
+ 'div',
4122
+ { className: 'pp-seldone', 'data-kind': error ? 'error' : 'ok', role: 'status' },
4123
+ h('span', { key: 'mark', className: 'pp-seldone-mark', 'aria-hidden': true }, error ? '!' : '✓'),
4124
+ h('span', { key: 'text', className: 'pp-seldone-text' }, doneText),
4125
+ ),
4126
+ )
4127
+ : [
4128
+ h(
4129
+ 'div',
4130
+ { key: 'main', className: 'pp-selmenu' },
4131
+ h(
4132
+ 'button',
4133
+ {
4134
+ key: 'copy',
4135
+ type: 'button',
4136
+ role: 'menuitem',
4137
+ className: 'pp-selrow',
4138
+ onClick: copySelection,
4139
+ // Moving back to the first row folds the submenu away.
4140
+ onPointerEnter: () => setSubmenu(false),
4141
+ },
4142
+ h('span', { key: 'name', className: 'pp-selname' }, translate('menu.copy')),
4143
+ h('span', { key: 'key', className: 'pp-selkey' }, shortcut),
4144
+ ),
4145
+ h('div', { key: 'rule', className: 'pp-selrule', role: 'separator' }),
4146
+ h(
4147
+ 'button',
4148
+ {
4149
+ key: 'pool',
4150
+ type: 'button',
4151
+ role: 'menuitem',
4152
+ className: 'pp-selrow',
4153
+ 'aria-haspopup': 'menu',
4154
+ 'aria-expanded': submenu,
4155
+ onClick: openGroups,
4156
+ onPointerEnter: openGroups,
4157
+ },
4158
+ h('span', { key: 'name', className: 'pp-selname' }, translate('menu.title')),
4159
+ h('span', { key: 'chev', className: 'pp-selchev', 'aria-hidden': true }, '▸'),
4160
+ ),
4161
+ ),
4162
+ submenu
4163
+ ? h(
4164
+ 'div',
4165
+ { key: 'groups', className: 'pp-selpanel', role: 'menu', 'aria-label': translate('menu.title') },
4166
+ h(
4167
+ 'div',
4168
+ { key: 'list', className: 'pp-sellist' },
4169
+ ordered.map((choice) =>
4170
+ h(
4171
+ 'button',
4172
+ {
4173
+ key: choice.value,
4174
+ type: 'button',
4175
+ role: 'menuitem',
4176
+ className: 'pp-selrow',
4177
+ onClick: () => pick(choice),
4178
+ },
4179
+ h('span', { key: 'name', className: 'pp-selname' }, choice.label),
4180
+ remembered && choice === remembered
4181
+ ? h('span', { key: 'last', className: 'pp-sellast' }, translate('menu.last'))
4182
+ : null,
4183
+ h(
4184
+ 'span',
4185
+ {
4186
+ key: 'count',
4187
+ className: 'pp-selcount',
4188
+ title: translate('menu.count', { n: counts[choice.value] || 0 }),
4189
+ },
4190
+ String(counts[choice.value] || 0),
4191
+ ),
4192
+ ),
4193
+ ),
4194
+ ),
4195
+ )
4196
+ : null,
4197
+ ],
4198
+ );
4199
+ }
4200
+
3675
4201
  // ------------------------------------------------------------------ panel
3676
4202
  function PromptPoolPanel(props) {
3677
4203
  useLocaleTick();
@@ -4143,7 +4669,7 @@ window.__ModuleLoader__.load({
4143
4669
  poolActions.remove(item.id);
4144
4670
  flash({
4145
4671
  kind: 'info',
4146
- text: text || translate('status.deleted', { title: itemLabel(item) }),
4672
+ text: text || translate('status.deleted'),
4147
4673
  undo: () => {
4148
4674
  poolActions.restore(item, index);
4149
4675
  setStatus(null);
@@ -4521,7 +5047,6 @@ window.__ModuleLoader__.load({
4521
5047
  : null,
4522
5048
  pendingDelete
4523
5049
  ? h(ItemDeleteConfirm, {
4524
- title: itemLabel(pendingDelete),
4525
5050
  onCancel: () => setPendingDelete(null),
4526
5051
  onConfirm: () => {
4527
5052
  deleteItem(pendingDelete);
@@ -4531,7 +5056,6 @@ window.__ModuleLoader__.load({
4531
5056
  : null,
4532
5057
  pendingRemove && tray.some((entry) => entry.key === pendingRemove.key)
4533
5058
  ? h(TrayRemoveConfirm, {
4534
- title: itemLabel(pendingRemove),
4535
5059
  onCancel: () => setPendingRemove(null),
4536
5060
  onConfirm: () => {
4537
5061
  poolActions.removeTray(pendingRemove.key);
@@ -4751,6 +5275,8 @@ window.__ModuleLoader__.load({
4751
5275
  '.pp-set-ws-tag{margin-left:6px;padding:0 5px;border-radius:5px;background:var(--pp-accent-soft);color:var(--pp-accent);font-size:10px}' +
4752
5276
  '.pp-set-ws-path{margin-left:auto;color:var(--pp-ink-2);font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:340px}' +
4753
5277
  '.pp-set-label{font-size:12px;color:var(--pp-ink-2);margin:2px 0 4px}' +
5278
+ '.pp-set-note{margin-right:auto;padding:0;line-height:1.4}' +
5279
+ '.pp-set-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-top:8px}' +
4754
5280
  '.pp-set-card{padding:10px 12px;border:1px solid var(--pp-line-2);border-radius:10px;background:var(--pp-surface);box-shadow:0 1px 3px rgba(0,0,0,.08)}' +
4755
5281
  '.pp-set-card .pp-set-label{margin:0 0 6px;font-size:12px;font-weight:600;color:var(--pp-ink)}' +
4756
5282
  '.pp-set-card .pp-set-row{padding:3px 0}' +
@@ -4866,12 +5392,44 @@ window.__ModuleLoader__.load({
4866
5392
  '.pp-status-float .pp-link{pointer-events:auto}' +
4867
5393
  '@keyframes pp-status-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}';
4868
5394
 
5395
+ /**
5396
+ * The right-click menu is mounted by the conversation view, not by a pool
5397
+ * view, so it carries its own copy of the shared tokens. The host positions
5398
+ * the surrounding surface and caps its height; `max-height: inherit` lets the
5399
+ * lists scroll inside that cap instead of running past the pointer. The menu
5400
+ * and its submenu are two cards in one wrapping row: the host measures the
5401
+ * grown surface and moves it back inside the pane, and a narrow pane drops
5402
+ * the submenu under the menu instead of clipping it.
5403
+ */
5404
+ const MENU_CSS =
5405
+ '.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}' +
5406
+ '.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}' +
5407
+ '.pp-selmenu{width:214px}' +
5408
+ '.pp-selpanel{width:190px}' +
5409
+ '.pp-seldonecard{width:280px}' +
5410
+ '.pp-sellist{display:flex;flex-direction:column;min-height:0;overflow-y:auto}' +
5411
+ '.pp-selrule{height:1px;margin:3px 4px;background:var(--pp-line)}' +
5412
+ '.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}' +
5413
+ '.pp-selrow:hover,.pp-selrow:focus-visible{background:color-mix(in srgb,var(--pp-accent) 11%,transparent)}' +
5414
+ '.pp-selrow:focus-visible{outline:2px solid var(--pp-accent);outline-offset:-2px}' +
5415
+ '.pp-selname{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
5416
+ '.pp-selchev{flex:none;color:var(--pp-ink-2);font-size:11px}' +
5417
+ '.pp-selkey{flex:none;color:var(--pp-ink-2);font-size:11px}' +
5418
+ '.pp-selcount{flex:none;color:var(--pp-ink-2);font-size:11px;font-variant-numeric:tabular-nums}' +
5419
+ '.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}' +
5420
+ '.pp-seldone{display:flex;align-items:flex-start;gap:6px;padding:2px;color:var(--pp-ink);font-size:12px}' +
5421
+ '.pp-seldone-text{flex:1;min-width:0;line-height:1.5}' +
5422
+ '.pp-seldone[data-kind="error"]{color:var(--pp-danger)}' +
5423
+ '.pp-seldone-mark{flex:none;color:var(--pp-ok);font-size:12px}' +
5424
+ '.pp-seldone[data-kind="error"] .pp-seldone-mark{color:var(--pp-danger)}';
5425
+
4869
5426
  // ------------------------------------------------------------------- plugin
4870
5427
  return {
4871
5428
  inject: ['slots', 'locale'],
4872
5429
  apply(ctx) {
4873
5430
  localeCtx = ctx.locale;
4874
5431
  pluginCtx = ctx;
5432
+ seedPoolIfNeeded();
4875
5433
  // Optional services: bind late, and stay idle when they never mount.
4876
5434
  const bindOptional = (names, assign) => {
4877
5435
  const run = (target) => {
@@ -4909,9 +5467,44 @@ window.__ModuleLoader__.load({
4909
5467
  bindOptional(['sessions'], (target) => {
4910
5468
  sessionsFace = serviceOf(target, 'sessions');
4911
5469
  });
5470
+ // Right-click on selected conversation text: the host asks plugins in
5471
+ // registration order and the first surface that opens wins. Only the
5472
+ // context-menu trigger is claimed, so the built-in Quote action keeps the
5473
+ // plain drag selection. A host without this service keeps its native menu.
5474
+ let selectionMenuMounted = false;
5475
+ bindOptional(['uiConversation'], (target) => {
5476
+ if (selectionMenuMounted) return;
5477
+ const service = serviceOf(target, 'uiConversation');
5478
+ const interactions = service && service.interactions;
5479
+ if (!interactions || typeof interactions.register !== 'function') return;
5480
+ selectionMenuMounted = true;
5481
+ try {
5482
+ ctx.effect(() =>
5483
+ interactions.register({
5484
+ id: 'prompt-pool',
5485
+ onInteraction(request) {
5486
+ if (!request || request.trigger !== 'contextmenu') return;
5487
+ if (typeof request.readText !== 'function' || request.readText() === null) return;
5488
+ // Opening alone does not suppress the browser menu: without this
5489
+ // the native menu and our surface would both show.
5490
+ request.preventDefault();
5491
+ request.open();
5492
+ },
5493
+ }),
5494
+ );
5495
+ } catch (_error) {
5496
+ selectionMenuMounted = false;
5497
+ }
5498
+ });
4912
5499
  if (ctx.locale && typeof ctx.locale.register === 'function' && typeof ctx.locale.bind === 'function') {
4913
5500
  ctx.effect(() => ctx.locale.register(NS, { zh: ZH, en: EN }));
4914
- translate = ctx.locale.bind(NS);
5501
+ const preview = previewLocaleId();
5502
+ if (preview) {
5503
+ const table = preview === 'zh' ? ZH : EN;
5504
+ translate = (key, params) => interpolate(table[key] || key, params);
5505
+ } else {
5506
+ translate = ctx.locale.bind(NS);
5507
+ }
4915
5508
  }
4916
5509
  // The composer keeps two pieces: the trigger beside the input, and the
4917
5510
  // overlay panel. The overlay stays mounted even while closed, which is
@@ -4928,6 +5521,14 @@ window.__ModuleLoader__.load({
4928
5521
  PromptPoolPanel,
4929
5522
  ),
4930
5523
  );
5524
+ // The Chat view renders the surface the interaction above opened, keyed by
5525
+ // that interaction's id. The slot is declared only while Chat is mounted.
5526
+ ctx.slots.inject('conversation.chat.text-interaction', () =>
5527
+ ctx.slots.register(
5528
+ { name: 'conversation.chat.text-interaction', key: 'prompt-pool', locale: NS },
5529
+ SelectionMenu,
5530
+ ),
5531
+ );
4931
5532
 
4932
5533
  ctx.slots.inject('settings.section', () =>
4933
5534
  ctx.slots.register(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-prompt-pool",
3
- "version": "1.1.1",
3
+ "version": "1.3.0",
4
4
  "private": false,
5
5
  "description": "A prompt staging pool beside the DSH composer: capture drafts, arrange a playlist, release it into the queue.",
6
6
  "license": "MIT",