dsh-prompt-pool 1.0.2 → 1.1.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 +1 -0
- package/client.js +1124 -747
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -7,24 +7,19 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
const h = React.createElement;
|
|
8
8
|
const { useCallback, useEffect, useMemo, useRef, useState } = React;
|
|
9
9
|
|
|
10
|
-
const useSyncExternalStore = React.useSyncExternalStore
|
|
11
|
-
const [value, setValue] = useState(getSnapshot);
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
setValue(getSnapshot());
|
|
14
|
-
return subscribe(() => setValue(getSnapshot()));
|
|
15
|
-
}, [subscribe, getSnapshot]);
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
10
|
+
const useSyncExternalStore = React.useSyncExternalStore;
|
|
18
11
|
|
|
19
12
|
const NS = 'prompt-pool';
|
|
20
13
|
const STORAGE_KEY = 'dsh.prompt-pool.v1';
|
|
14
|
+
/** One pre-migration copy of the stored payload, written before the first rewrite. */
|
|
15
|
+
const BACKUP_KEY = STORAGE_KEY + '.backup';
|
|
21
16
|
/** The sidebar tool tab this plugin owns; it also names the open tab. */
|
|
22
17
|
const SIDEBAR_TAB_ID = 'prompt-pool:pool';
|
|
23
18
|
/** Native right-sidebar registry identity (DSH 0.2) and the page kind it opens. */
|
|
24
19
|
const NATIVE_TAB_ID = 'dsh-prompt-pool';
|
|
25
20
|
const NATIVE_TAB_KIND = 'prompt-pool';
|
|
26
21
|
/** Shown in the settings about card; keep in step with plugin/package.json. */
|
|
27
|
-
const PLUGIN_VERSION = '1.0
|
|
22
|
+
const PLUGIN_VERSION = '1.1.0';
|
|
28
23
|
const PLUGIN_AUTHOR = 'GanttShen';
|
|
29
24
|
/** Replace once the public repository exists; the row hides while it is empty. */
|
|
30
25
|
const PLUGIN_REPO = 'https://github.com/Ganttfly/dsh-prompt-pool';
|
|
@@ -43,6 +38,8 @@ window.__ModuleLoader__.load({
|
|
|
43
38
|
* running past it.
|
|
44
39
|
*/
|
|
45
40
|
const PANEL_TOP_GAP = 10;
|
|
41
|
+
/** How long a release waits on the composer at each step, in ms. */
|
|
42
|
+
const RELEASE_WAIT = { idle: 2500, accept: 3000, plain: 1500 };
|
|
46
43
|
|
|
47
44
|
/**
|
|
48
45
|
* Top of the nearest ancestor that clips its overflow — the pane the panel
|
|
@@ -70,12 +67,13 @@ window.__ModuleLoader__.load({
|
|
|
70
67
|
'panel.capture': '存草稿',
|
|
71
68
|
'panel.captureHint': '把输入框里的内容复制一份存进池子(图片附件一起存);输入框里的字会保留',
|
|
72
69
|
'panel.resize': '拖动调整高度,双击还原',
|
|
73
|
-
'panel.
|
|
70
|
+
'panel.resizeWidth': '拖动调整宽度,双击还原',
|
|
71
|
+
'panel.pin': '钉住面板',
|
|
72
|
+
'panel.unpin': '取消钉住',
|
|
73
|
+
'panel.empty': '池子是空的。写一句,然后点「存草稿」。',
|
|
74
74
|
'panel.emptyTab': '这一栏还没有内容。',
|
|
75
75
|
'tab.all': '全部',
|
|
76
76
|
'tab.oftenuse': '常用',
|
|
77
|
-
'tab.workspace': '工作区',
|
|
78
|
-
'tab.currentWorkspace': '当前工作区',
|
|
79
77
|
'ws.none': '没有可用的工作区',
|
|
80
78
|
'ws.empty': '这个工作区还没有条目',
|
|
81
79
|
'tab.note': '便签',
|
|
@@ -93,37 +91,30 @@ window.__ModuleLoader__.load({
|
|
|
93
91
|
'group.untitled': '(未命名)',
|
|
94
92
|
'mention.loading': '正在读取…',
|
|
95
93
|
'mention.empty': '没有匹配项',
|
|
96
|
-
'mention.
|
|
94
|
+
'mention.noSessionTag': '无会话',
|
|
95
|
+
'mention.directory': '目录',
|
|
97
96
|
'mention.noSkillService': '读不到技能目录(remote 服务未绑定)',
|
|
98
|
-
'mention.noDirectoryService': '读不到目录服务(uiWorkspace 未绑定)',
|
|
99
97
|
'mention.noSessionService': '读不到会话服务(sessions 未绑定)',
|
|
100
98
|
'mention.sessionClosed': '会话未打开,无法读取技能目录',
|
|
101
99
|
'mention.failed': '读取失败',
|
|
102
100
|
'mention.timeout': '读取超时:宿主没有响应(可能没有活跃会话)',
|
|
103
101
|
'row.insert': '插入到输入框',
|
|
104
102
|
'row.select': '加入待发送队列',
|
|
105
|
-
'row.copy': '复制内容',
|
|
106
103
|
'row.duplicate': '复制一份,追加到池子末尾',
|
|
107
104
|
'page.title': '提示池',
|
|
108
105
|
'tab.description': '暂存、编辑、编排你的提示词,按住顺序一次性释放',
|
|
109
106
|
'page.count': '共 {n} 条',
|
|
110
107
|
'page.search': '搜索标题或内容…',
|
|
111
|
-
'page.empty': '还没有内容。点右上角「+
|
|
108
|
+
'page.empty': '还没有内容。点右上角「+ 提示词」开始。',
|
|
112
109
|
'page.emptyOftenuse': '还没有常用条目。把条目的「分组」改成「常用」即可。',
|
|
113
110
|
'page.noMatch': '没有匹配的条目。',
|
|
114
|
-
'page.trayReady': '已选 {n} 条 · 去对话释放',
|
|
115
|
-
'page.gotoConversation': '去对话',
|
|
116
111
|
'status.noComposer': '没有可用的输入框:请先打开一个对话页签',
|
|
117
112
|
'status.releaseSent': '已交给输入框,按顺序排队中',
|
|
118
|
-
'status.copied': '已复制',
|
|
119
|
-
'status.copyFailed': '复制失败',
|
|
120
113
|
'status.savedToPool': '已保存',
|
|
121
|
-
'sidebar.label': '提示池',
|
|
122
114
|
'settings.nav': '提示池',
|
|
123
115
|
'settings.open': '提示池设置',
|
|
124
116
|
'settings.button': '设置',
|
|
125
117
|
'settings.tab.order': '分组',
|
|
126
|
-
'settings.display': '分组怎么显示',
|
|
127
118
|
'settings.table': '分组的顺序与显示',
|
|
128
119
|
'settings.tableHint': '箭头调整先后顺序;右侧三列决定这一组怎么显示。',
|
|
129
120
|
'settings.tableGroup': '分组',
|
|
@@ -146,27 +137,14 @@ window.__ModuleLoader__.load({
|
|
|
146
137
|
'settings.about': '插件信息',
|
|
147
138
|
'settings.aboutAuthor': '作者',
|
|
148
139
|
'settings.aboutRepo': '仓库',
|
|
149
|
-
'settings.tab.display': '展示',
|
|
150
|
-
'settings.customNested': '自定义分组折叠成一个 Tab',
|
|
151
|
-
'settings.customNestedHint': '分组多时打开:Tab 行只保留一个「自定义」,组内用横排胶囊切换。',
|
|
152
140
|
'settings.workspaceCard': '工作区如何展示',
|
|
153
141
|
'settings.workspacesVisible': '显示哪些工作区',
|
|
154
142
|
'settings.workspacesCurrent': '当前',
|
|
155
143
|
'settings.workspacesEmpty': '还没有读到工作区列表。打开一次提示池页面后,这里会列出全部工作区。',
|
|
156
|
-
'settings.leading': '哪一组排在前面',
|
|
157
|
-
'settings.leading.workspace': '工作区',
|
|
158
|
-
'settings.leading.custom': '自定义分组',
|
|
159
|
-
'settings.leading.builtin': '内置分组',
|
|
160
|
-
'settings.leadingHint': '「全部」始终在最前;这里决定它后面先出现哪一组,另外两组按固定顺序跟随。',
|
|
161
|
-
'settings.reload': '重新加载界面',
|
|
162
|
-
'settings.reloadHint': '插件代码更新后,界面不会自动换新。点这里重新加载(比重启应用快)。',
|
|
163
144
|
'settings.title': '提示池',
|
|
164
|
-
'settings.desc': '
|
|
165
|
-
'settings.workspaceTabs': '在工作区 Tab 中列出全部工作区',
|
|
166
|
-
'settings.workspaceTabsHint': '「工作区」Tab 里用横向胶囊切换工作区;关掉后只保留当前工作区。',
|
|
145
|
+
'settings.desc': '控制分组顺序、显示方式和工作区 Tab。改动立即生效。',
|
|
167
146
|
'settings.currentWorkspaceTab': '当前工作区排在最前',
|
|
168
147
|
'settings.currentWorkspaceTabHint': '当前会话所属的工作区固定排第一;其余按原顺序。',
|
|
169
|
-
'settings.label': '提示池',
|
|
170
148
|
'row.edit': '编辑',
|
|
171
149
|
'row.delete': '删除',
|
|
172
150
|
'row.deleteTitle': '删除这条提示词',
|
|
@@ -192,7 +170,6 @@ window.__ModuleLoader__.load({
|
|
|
192
170
|
'row.familyCustom': '自定义',
|
|
193
171
|
'row.familyWorkspace': '工作区分组',
|
|
194
172
|
'tab.familyBuiltin': '内置分组',
|
|
195
|
-
'row.categoryLabel': '自定义分组',
|
|
196
173
|
'row.classification': '分组',
|
|
197
174
|
'page.new': '提示词',
|
|
198
175
|
'row.noCategory': '未分组',
|
|
@@ -209,15 +186,15 @@ window.__ModuleLoader__.load({
|
|
|
209
186
|
'tray.removeConfirm': '「{title}」会从待发送队列移出;这条如果在队列里改过,改动不会保留。',
|
|
210
187
|
'tray.removeAction': '移出',
|
|
211
188
|
'tray.duplicate': '复制一份,追加到末尾',
|
|
212
|
-
'tray.hint': '释放后会按这个顺序排队,当前这轮结束后自动接着执行。',
|
|
213
189
|
'tray.queue': '队列中 {n}',
|
|
214
190
|
'tray.collapseTitle': '收起待发送队列',
|
|
215
191
|
'tray.expandTitle': '展开待发送队列',
|
|
216
|
-
'confirm.title': '将按此顺序排队 {n} 条:',
|
|
217
|
-
'confirm.ok': '确认释放',
|
|
218
|
-
'confirm.cancel': '再想想',
|
|
219
192
|
'status.saved': '已存入池子',
|
|
220
193
|
'status.savedPartial': '已存入池子,但这 {n} 个附件没有一起保存',
|
|
194
|
+
'status.savedTo': '已存入「{group}」',
|
|
195
|
+
'status.savedPartialTo': '已存入「{group}」,但 {n} 个附件没有保存',
|
|
196
|
+
'capture.title': '存到哪个分组?',
|
|
197
|
+
'status.storageFailed': '保存失败:浏览器存储不可写(可能已满)。改动只在当前页面有效。',
|
|
221
198
|
'status.nothing': '草稿是空的,先写点什么',
|
|
222
199
|
'status.emptyBody': '内容不能是空的',
|
|
223
200
|
'status.inserted': '已插入到输入框',
|
|
@@ -230,6 +207,14 @@ window.__ModuleLoader__.load({
|
|
|
230
207
|
'status.deleted': '已删除「{title}」',
|
|
231
208
|
'status.cleared': '已清空 {n} 条待发送',
|
|
232
209
|
'status.undo': '撤销',
|
|
210
|
+
'release.title': '正在发送',
|
|
211
|
+
'release.progress': '已发送 {sent} / {total} 条',
|
|
212
|
+
'release.hint': '发送期间请勿操作输入框',
|
|
213
|
+
'release.stop': '停止',
|
|
214
|
+
'release.stopping': '正在停止…',
|
|
215
|
+
'status.releaseHalted': '已停止:发送了 {n} 条,剩余 {rest} 条还在队列里',
|
|
216
|
+
'status.releaseFailed': '队列提交失败:已发送 {n} 条,剩余 {rest} 条还在队列里',
|
|
217
|
+
'status.queueFailed': '提交到队列失败',
|
|
233
218
|
'status.releasing': '正在释放 {n} 条…',
|
|
234
219
|
};
|
|
235
220
|
|
|
@@ -241,12 +226,13 @@ window.__ModuleLoader__.load({
|
|
|
241
226
|
'panel.capture': 'Save draft',
|
|
242
227
|
'panel.captureHint': 'Copy the composer draft into the pool; the composer keeps its text',
|
|
243
228
|
'panel.resize': 'Drag to resize, double-click to reset',
|
|
229
|
+
'panel.resizeWidth': 'Drag to resize the width, double-click to reset',
|
|
230
|
+
'panel.pin': 'Pin the panel',
|
|
231
|
+
'panel.unpin': 'Unpin the panel',
|
|
244
232
|
'panel.empty': 'The pool is empty. Write something, then press Save draft.',
|
|
245
233
|
'panel.emptyTab': 'Nothing in this tab yet.',
|
|
246
234
|
'tab.all': 'All',
|
|
247
235
|
'tab.oftenuse': 'Frequent',
|
|
248
|
-
'tab.workspace': 'Workspaces',
|
|
249
|
-
'tab.currentWorkspace': 'Current workspace',
|
|
250
236
|
'ws.none': 'No workspaces available',
|
|
251
237
|
'ws.empty': 'No items in this workspace yet',
|
|
252
238
|
'tab.note': 'Notes',
|
|
@@ -264,37 +250,30 @@ window.__ModuleLoader__.load({
|
|
|
264
250
|
'group.untitled': '(untitled)',
|
|
265
251
|
'mention.loading': 'Loading…',
|
|
266
252
|
'mention.empty': 'No matches',
|
|
267
|
-
'mention.
|
|
253
|
+
'mention.noSessionTag': 'no session',
|
|
254
|
+
'mention.directory': 'folder',
|
|
268
255
|
'mention.noSkillService': 'Skill catalog unavailable (remote service not bound)',
|
|
269
|
-
'mention.noDirectoryService': 'Directory service unavailable (uiWorkspace not bound)',
|
|
270
256
|
'mention.noSessionService': 'Session service unavailable (sessions not bound)',
|
|
271
257
|
'mention.sessionClosed': 'The session is not open, so the catalog is unavailable',
|
|
272
258
|
'mention.failed': 'Failed to load',
|
|
273
259
|
'mention.timeout': 'Timed out: the host did not answer (no live session?)',
|
|
274
260
|
'row.insert': 'Insert into the composer',
|
|
275
261
|
'row.select': 'Add to the send queue',
|
|
276
|
-
'row.copy': 'Copy the text',
|
|
277
262
|
'row.duplicate': 'Duplicate and append to the pool',
|
|
278
263
|
'page.title': 'Prompt pool',
|
|
279
264
|
'tab.description': 'Stage, edit and arrange prompts, then release them in order',
|
|
280
265
|
'page.count': '{n} items',
|
|
281
266
|
'page.search': 'Search title or text…',
|
|
282
|
-
'page.empty': 'Nothing yet. Use “+
|
|
267
|
+
'page.empty': 'Nothing yet. Use “+ Prompt” in the top right.',
|
|
283
268
|
'page.emptyOftenuse': 'Nothing here yet. Set an item’s group to Frequent.',
|
|
284
269
|
'page.noMatch': 'No matching item.',
|
|
285
|
-
'page.trayReady': '{n} selected · release in a conversation',
|
|
286
|
-
'page.gotoConversation': 'Open the conversation',
|
|
287
270
|
'status.noComposer': 'No composer available: open a conversation tab first',
|
|
288
271
|
'status.releaseSent': 'Handed to the composer; queuing in order',
|
|
289
|
-
'status.copied': 'Copied',
|
|
290
|
-
'status.copyFailed': 'Copy failed',
|
|
291
272
|
'status.savedToPool': 'Saved',
|
|
292
|
-
'sidebar.label': 'Prompt pool',
|
|
293
273
|
'settings.nav': 'Prompt pool',
|
|
294
274
|
'settings.open': 'Prompt pool settings',
|
|
295
275
|
'settings.button': 'Settings',
|
|
296
276
|
'settings.tab.order': 'Groups',
|
|
297
|
-
'settings.display': 'How groups show up',
|
|
298
277
|
'settings.table': 'Group order and display',
|
|
299
278
|
'settings.tableHint': 'Use the arrows to reorder; the three columns decide how each family shows up.',
|
|
300
279
|
'settings.tableGroup': 'Group',
|
|
@@ -317,27 +296,14 @@ window.__ModuleLoader__.load({
|
|
|
317
296
|
'settings.about': 'Plugin info',
|
|
318
297
|
'settings.aboutAuthor': 'Author',
|
|
319
298
|
'settings.aboutRepo': 'Repository',
|
|
320
|
-
'settings.tab.display': 'Display',
|
|
321
|
-
'settings.customNested': 'Fold custom groups into one tab',
|
|
322
|
-
'settings.customNestedHint': 'Useful once you have many groups: one “Custom” tab keeps them as chips inside.',
|
|
323
299
|
'settings.workspaceCard': 'How workspaces appear',
|
|
324
300
|
'settings.workspacesVisible': 'Workspaces to show',
|
|
325
301
|
'settings.workspacesCurrent': 'current',
|
|
326
302
|
'settings.workspacesEmpty': 'No workspace roster yet. Open the prompt pool page once and every workspace will be listed here.',
|
|
327
|
-
'settings.leading': 'Which group comes first',
|
|
328
|
-
'settings.leading.workspace': 'Workspaces',
|
|
329
|
-
'settings.leading.custom': 'Custom groups',
|
|
330
|
-
'settings.leading.builtin': 'Built-in groups',
|
|
331
|
-
'settings.leadingHint': '"All" always leads; this picks which group follows it, the other two keep their fixed order.',
|
|
332
|
-
'settings.reload': 'Reload the UI',
|
|
333
|
-
'settings.reloadHint': 'A plugin code change does not swap the running UI. Use this instead of restarting the app.',
|
|
334
303
|
'settings.title': 'Prompt pool',
|
|
335
|
-
'settings.desc': 'Controls how the
|
|
336
|
-
'settings.workspaceTabs': 'List every workspace in the Workspaces tab',
|
|
337
|
-
'settings.workspaceTabsHint': 'The Workspaces tab switches workspaces with horizontal chips; off keeps only the current workspace.',
|
|
304
|
+
'settings.desc': 'Controls group order, how each family is displayed, and the workspace tabs. Changes apply immediately.',
|
|
338
305
|
'settings.currentWorkspaceTab': 'Put the current workspace first',
|
|
339
306
|
'settings.currentWorkspaceTabHint': 'The workspace owning this session stays first; the rest keep their order.',
|
|
340
|
-
'settings.label': 'Prompt pool',
|
|
341
307
|
'row.edit': 'Edit',
|
|
342
308
|
'row.delete': 'Delete',
|
|
343
309
|
'row.deleteTitle': 'Delete this prompt',
|
|
@@ -363,7 +329,6 @@ window.__ModuleLoader__.load({
|
|
|
363
329
|
'row.familyCustom': 'Custom',
|
|
364
330
|
'row.familyWorkspace': 'Workspace groups',
|
|
365
331
|
'tab.familyBuiltin': 'Built-in groups',
|
|
366
|
-
'row.categoryLabel': 'Custom',
|
|
367
332
|
'row.classification': 'Group',
|
|
368
333
|
'page.new': 'Prompt',
|
|
369
334
|
'row.noCategory': 'Ungrouped',
|
|
@@ -380,15 +345,15 @@ window.__ModuleLoader__.load({
|
|
|
380
345
|
'tray.removeConfirm': '{title} will be removed from the send queue. Edits made to this queued copy are lost.',
|
|
381
346
|
'tray.removeAction': 'Remove',
|
|
382
347
|
'tray.duplicate': 'Duplicate and append to the end',
|
|
383
|
-
'tray.hint': 'Released items queue up in this order and run as soon as the current turn ends.',
|
|
384
348
|
'tray.queue': '{n} in queue',
|
|
385
349
|
'tray.collapseTitle': 'Collapse the send queue',
|
|
386
350
|
'tray.expandTitle': 'Expand the send queue',
|
|
387
|
-
'confirm.title': 'Queue {n} in this order:',
|
|
388
|
-
'confirm.ok': 'Queue them',
|
|
389
|
-
'confirm.cancel': 'Not yet',
|
|
390
351
|
'status.saved': 'Saved to the pool',
|
|
391
352
|
'status.savedPartial': 'Saved to the pool; {n} attachment(s) were not captured',
|
|
353
|
+
'status.savedTo': 'Saved to {group}',
|
|
354
|
+
'status.savedPartialTo': 'Saved to {group}; {n} attachment(s) were not captured',
|
|
355
|
+
'capture.title': 'Save to which group?',
|
|
356
|
+
'status.storageFailed': 'Could not save: browser storage is unwritable (possibly full). Changes last only for this page.',
|
|
392
357
|
'status.nothing': 'The composer is empty',
|
|
393
358
|
'status.emptyBody': 'The content cannot be empty',
|
|
394
359
|
'status.inserted': 'Inserted into the composer',
|
|
@@ -401,6 +366,14 @@ window.__ModuleLoader__.load({
|
|
|
401
366
|
'status.deleted': 'Deleted this item',
|
|
402
367
|
'status.cleared': 'Cleared {n} queued items',
|
|
403
368
|
'status.undo': 'Undo',
|
|
369
|
+
'release.title': 'Sending',
|
|
370
|
+
'release.progress': '{sent} of {total} sent',
|
|
371
|
+
'release.hint': 'Leave the composer alone while this runs',
|
|
372
|
+
'release.stop': 'Stop',
|
|
373
|
+
'release.stopping': 'Stopping…',
|
|
374
|
+
'status.releaseHalted': 'Stopped: {n} sent, {rest} left in the queue',
|
|
375
|
+
'status.releaseFailed': 'Queueing failed: {n} sent, {rest} left in the queue',
|
|
376
|
+
'status.queueFailed': 'Could not queue the prompt',
|
|
404
377
|
'status.releasing': 'Releasing {n}…',
|
|
405
378
|
};
|
|
406
379
|
|
|
@@ -464,6 +437,31 @@ window.__ModuleLoader__.load({
|
|
|
464
437
|
};
|
|
465
438
|
}
|
|
466
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Whether the last write reached localStorage. Both views surface this,
|
|
442
|
+
* because a full quota would otherwise look like a successful save.
|
|
443
|
+
*/
|
|
444
|
+
const storageState = createStore({ failed: false });
|
|
445
|
+
|
|
446
|
+
/** Progress of the one release in flight, shared by the panel and the page. */
|
|
447
|
+
const RELEASE_SINGLETON = '__dshPromptPoolReleaseV1';
|
|
448
|
+
const releaseState = (() => {
|
|
449
|
+
const initial = { active: false, sent: 0, total: 0, stopping: false };
|
|
450
|
+
if (typeof window === 'undefined') return createStore(initial);
|
|
451
|
+
if (!window[RELEASE_SINGLETON]) window[RELEASE_SINGLETON] = createStore(initial);
|
|
452
|
+
return window[RELEASE_SINGLETON];
|
|
453
|
+
})();
|
|
454
|
+
let releaseCancel = false;
|
|
455
|
+
|
|
456
|
+
/** Ask the running release to stop after the item it is sending. */
|
|
457
|
+
function requestReleaseStop() {
|
|
458
|
+
const state = releaseState.get();
|
|
459
|
+
if (!state.active || releaseCancel) return false;
|
|
460
|
+
releaseCancel = true;
|
|
461
|
+
releaseState.set({ ...state, stopping: true });
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
|
|
467
465
|
function uid() {
|
|
468
466
|
try {
|
|
469
467
|
return crypto.randomUUID();
|
|
@@ -616,6 +614,61 @@ window.__ModuleLoader__.load({
|
|
|
616
614
|
);
|
|
617
615
|
}
|
|
618
616
|
|
|
617
|
+
function deleteImageBlobs(ids) {
|
|
618
|
+
const list = (Array.isArray(ids) ? ids : []).filter((id) => typeof id === 'string' && id);
|
|
619
|
+
if (list.length === 0) return Promise.resolve(true);
|
|
620
|
+
return openImageDb().then(
|
|
621
|
+
(db) =>
|
|
622
|
+
new Promise((resolve, reject) => {
|
|
623
|
+
const tx = db.transaction(IMAGE_STORE, 'readwrite');
|
|
624
|
+
const store = tx.objectStore(IMAGE_STORE);
|
|
625
|
+
for (const id of list) store.delete(id);
|
|
626
|
+
tx.oncomplete = () => resolve(true);
|
|
627
|
+
tx.onerror = () => reject(tx.error || new Error('image-delete-failed'));
|
|
628
|
+
tx.onabort = () => reject(tx.error || new Error('image-delete-failed'));
|
|
629
|
+
}),
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** Drop bytes the editor added but never saved; stored images stay. */
|
|
634
|
+
function discardUnsavedImages(edited, stored) {
|
|
635
|
+
const keep = new Set(((stored && stored.images) || []).map((image) => image.id));
|
|
636
|
+
const drop = ((edited && edited.images) || []).map((image) => image.id).filter((imageId) => !keep.has(imageId));
|
|
637
|
+
if (drop.length > 0) deleteImageBlobs(drop).catch(() => {});
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Every image id the pool still points at. Duplicated items and queued
|
|
642
|
+
* copies share ids, so an id is garbage only when nothing references it.
|
|
643
|
+
*/
|
|
644
|
+
function referencedImageIds() {
|
|
645
|
+
const keep = new Set();
|
|
646
|
+
const state = pool.get();
|
|
647
|
+
for (const item of state.items) for (const image of item.images || []) keep.add(image.id);
|
|
648
|
+
for (const entry of state.tray) for (const image of entry.images || []) keep.add(image.id);
|
|
649
|
+
return keep;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* Delete blobs nothing references, once per page load. This also clears the
|
|
654
|
+
* bytes of items deleted earlier, which cannot be freed immediately because
|
|
655
|
+
* the delete offers an undo.
|
|
656
|
+
*/
|
|
657
|
+
function sweepImageBlobs() {
|
|
658
|
+
return new Promise((resolve, reject) => {
|
|
659
|
+
openImageDb().then((db) => {
|
|
660
|
+
const tx = db.transaction(IMAGE_STORE, 'readonly');
|
|
661
|
+
const request = tx.objectStore(IMAGE_STORE).getAllKeys();
|
|
662
|
+
request.onsuccess = () => resolve(request.result || []);
|
|
663
|
+
request.onerror = () => reject(request.error || new Error('image-read-failed'));
|
|
664
|
+
}, reject);
|
|
665
|
+
}).then((keys) => {
|
|
666
|
+
const keep = referencedImageIds();
|
|
667
|
+
const drop = keys.filter((key) => !keep.has(key));
|
|
668
|
+
return drop.length > 0 ? deleteImageBlobs(drop) : null;
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
|
|
619
672
|
/** A small data-URL thumbnail keeps the list rendering synchronous. */
|
|
620
673
|
function makeImageThumb(file) {
|
|
621
674
|
return new Promise((resolve) => {
|
|
@@ -765,10 +818,19 @@ window.__ModuleLoader__.load({
|
|
|
765
818
|
}
|
|
766
819
|
|
|
767
820
|
|
|
768
|
-
/**
|
|
821
|
+
/**
|
|
822
|
+
* The one read path: item → canonical group id. Older pools predate the
|
|
823
|
+
* group id and stored pinned / categoryId (`cat:<id>`) / kind instead, so
|
|
824
|
+
* map those once on load rather than dropping the user's classification.
|
|
825
|
+
*/
|
|
769
826
|
function groupOf(item) {
|
|
770
827
|
const group = item && typeof item.group === 'string' ? item.group : '';
|
|
771
|
-
|
|
828
|
+
if (group && familyOf(group)) return group;
|
|
829
|
+
const categoryId = item && typeof item.categoryId === 'string' ? item.categoryId : '';
|
|
830
|
+
if (categoryId) return 'custom:' + categoryId.replace(/^cat:/, '');
|
|
831
|
+
if (item && item.pinned === true) return BUILTIN_GROUP.oftenuse;
|
|
832
|
+
if (item && item.kind === 'snippet') return BUILTIN_GROUP.template;
|
|
833
|
+
return BUILTIN_GROUP.note;
|
|
772
834
|
}
|
|
773
835
|
|
|
774
836
|
/** The one write path: canonical group id → item. */
|
|
@@ -898,8 +960,58 @@ window.__ModuleLoader__.load({
|
|
|
898
960
|
];
|
|
899
961
|
}
|
|
900
962
|
|
|
963
|
+
/** Small chooser: where should the captured draft go? */
|
|
964
|
+
function CaptureMenu(props) {
|
|
965
|
+
useEffect(() => {
|
|
966
|
+
const onKeyDown = (event) => {
|
|
967
|
+
if (event.key !== 'Escape') return;
|
|
968
|
+
event.preventDefault();
|
|
969
|
+
event.stopPropagation();
|
|
970
|
+
props.onCancel();
|
|
971
|
+
};
|
|
972
|
+
window.addEventListener('keydown', onKeyDown, true);
|
|
973
|
+
return () => window.removeEventListener('keydown', onKeyDown, true);
|
|
974
|
+
}, [props.onCancel]);
|
|
975
|
+
|
|
976
|
+
return h(
|
|
977
|
+
'div',
|
|
978
|
+
{
|
|
979
|
+
className: 'pp-modal',
|
|
980
|
+
onMouseDown: (event) => {
|
|
981
|
+
if (event.target === event.currentTarget) props.onCancel();
|
|
982
|
+
},
|
|
983
|
+
},
|
|
984
|
+
h(
|
|
985
|
+
'div',
|
|
986
|
+
{ className: 'pp-modal-card', role: 'dialog', 'aria-modal': 'true', 'aria-label': translate('capture.title') },
|
|
987
|
+
h('div', { className: 'pp-modal-text' }, translate('capture.title')),
|
|
988
|
+
h(
|
|
989
|
+
'div',
|
|
990
|
+
{ className: 'pp-capture-options' },
|
|
991
|
+
props.groups.map((group, index) => h(
|
|
992
|
+
'button',
|
|
993
|
+
{
|
|
994
|
+
key: group.value,
|
|
995
|
+
type: 'button',
|
|
996
|
+
className: 'pp-mini pp-capture-option',
|
|
997
|
+
autoFocus: index === 0,
|
|
998
|
+
onClick: () => props.onPick(group.value),
|
|
999
|
+
},
|
|
1000
|
+
group.label,
|
|
1001
|
+
)),
|
|
1002
|
+
),
|
|
1003
|
+
h(
|
|
1004
|
+
'div',
|
|
1005
|
+
{ className: 'pp-modal-actions' },
|
|
1006
|
+
h('button', { type: 'button', className: 'pp-mini', onClick: props.onCancel }, translate('row.cancel')),
|
|
1007
|
+
),
|
|
1008
|
+
),
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
|
|
901
1012
|
/** Shared confirm modal: backdrop click and Escape both cancel. */
|
|
902
1013
|
function ConfirmModal(props) {
|
|
1014
|
+
const cardRef = useRef(null);
|
|
903
1015
|
useEffect(() => {
|
|
904
1016
|
const onKeyDown = (event) => {
|
|
905
1017
|
if (event.key !== 'Escape') return;
|
|
@@ -911,6 +1023,32 @@ window.__ModuleLoader__.load({
|
|
|
911
1023
|
return () => window.removeEventListener('keydown', onKeyDown, true);
|
|
912
1024
|
}, [props.onCancel]);
|
|
913
1025
|
|
|
1026
|
+
// Keep focus inside the dialog and start on the safe action, never on
|
|
1027
|
+
// the destructive one (Enter must not delete by accident).
|
|
1028
|
+
useEffect(() => {
|
|
1029
|
+
const card = cardRef.current;
|
|
1030
|
+
if (!card || typeof document === 'undefined') return undefined;
|
|
1031
|
+
const focusables = () => Array.from(card.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter((node) => !node.disabled);
|
|
1032
|
+
const first = focusables()[0];
|
|
1033
|
+
if (first) first.focus();
|
|
1034
|
+
const onTab = (event) => {
|
|
1035
|
+
if (event.key !== 'Tab') return;
|
|
1036
|
+
const list = focusables();
|
|
1037
|
+
if (list.length === 0) return;
|
|
1038
|
+
const firstNode = list[0];
|
|
1039
|
+
const lastNode = list[list.length - 1];
|
|
1040
|
+
if (event.shiftKey && document.activeElement === firstNode) {
|
|
1041
|
+
event.preventDefault();
|
|
1042
|
+
lastNode.focus();
|
|
1043
|
+
} else if (!event.shiftKey && document.activeElement === lastNode) {
|
|
1044
|
+
event.preventDefault();
|
|
1045
|
+
firstNode.focus();
|
|
1046
|
+
}
|
|
1047
|
+
};
|
|
1048
|
+
card.addEventListener('keydown', onTab);
|
|
1049
|
+
return () => card.removeEventListener('keydown', onTab);
|
|
1050
|
+
}, []);
|
|
1051
|
+
|
|
914
1052
|
return h(
|
|
915
1053
|
'div',
|
|
916
1054
|
{
|
|
@@ -921,13 +1059,13 @@ window.__ModuleLoader__.load({
|
|
|
921
1059
|
},
|
|
922
1060
|
h(
|
|
923
1061
|
'div',
|
|
924
|
-
{ className: 'pp-modal-card', role: 'dialog', 'aria-modal': 'true', 'aria-label': props.label },
|
|
1062
|
+
{ ref: cardRef, className: 'pp-modal-card', role: 'dialog', 'aria-modal': 'true', 'aria-label': props.label },
|
|
925
1063
|
h('div', { className: 'pp-modal-text' }, props.text),
|
|
926
1064
|
h(
|
|
927
1065
|
'div',
|
|
928
1066
|
{ className: 'pp-modal-actions' },
|
|
929
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: props.onCancel }, props.cancelText),
|
|
930
|
-
h('button', { type: 'button', className: 'pp-primary',
|
|
1067
|
+
h('button', { type: 'button', className: 'pp-mini', autoFocus: true, onClick: props.onCancel }, props.cancelText),
|
|
1068
|
+
h('button', { type: 'button', className: 'pp-primary', onClick: props.onConfirm }, props.confirmText),
|
|
931
1069
|
),
|
|
932
1070
|
),
|
|
933
1071
|
);
|
|
@@ -1018,11 +1156,18 @@ window.__ModuleLoader__.load({
|
|
|
1018
1156
|
{
|
|
1019
1157
|
className: 'pp-tab-x',
|
|
1020
1158
|
role: 'button',
|
|
1159
|
+
tabIndex: 0,
|
|
1021
1160
|
title: translate('tab.delete'),
|
|
1022
1161
|
onClick: (event) => {
|
|
1023
1162
|
event.stopPropagation();
|
|
1024
1163
|
if (props.onDelete) props.onDelete(workspace.id);
|
|
1025
1164
|
},
|
|
1165
|
+
onKeyDown: (event) => {
|
|
1166
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
1167
|
+
event.preventDefault();
|
|
1168
|
+
event.stopPropagation();
|
|
1169
|
+
if (props.onDelete) props.onDelete(workspace.id);
|
|
1170
|
+
},
|
|
1026
1171
|
},
|
|
1027
1172
|
'×',
|
|
1028
1173
|
)
|
|
@@ -1157,34 +1302,25 @@ window.__ModuleLoader__.load({
|
|
|
1157
1302
|
if (!raw) {
|
|
1158
1303
|
// Brand-new install only: an existing (even empty) pool is never reseeded.
|
|
1159
1304
|
const seeded = seededPool();
|
|
1160
|
-
|
|
1161
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(seeded));
|
|
1162
|
-
} catch (_error) {
|
|
1163
|
-
/* storage unavailable: keep the in-memory copy only */
|
|
1164
|
-
}
|
|
1305
|
+
persist(seeded);
|
|
1165
1306
|
return seeded;
|
|
1166
1307
|
}
|
|
1167
1308
|
const parsed = JSON.parse(raw);
|
|
1168
1309
|
const storedVersion = parsed && typeof parsed.version === 'number' ? parsed.version : 1;
|
|
1169
1310
|
if (storedVersion < POOL_VERSION) {
|
|
1170
|
-
//
|
|
1171
|
-
|
|
1311
|
+
// Keep the payload this build first saw: normalization is lossy, and the
|
|
1312
|
+
// backup is the only way back if an older shape maps differently.
|
|
1172
1313
|
try {
|
|
1173
|
-
localStorage.setItem(
|
|
1314
|
+
localStorage.setItem(BACKUP_KEY, raw);
|
|
1174
1315
|
} catch (_error) {
|
|
1175
|
-
/*
|
|
1316
|
+
/* the backup is best effort; the pool itself still loads */
|
|
1176
1317
|
}
|
|
1177
|
-
return reset;
|
|
1178
1318
|
}
|
|
1179
1319
|
const pool = normalizePool(parsed);
|
|
1180
1320
|
const level = Number(pool.seeded) || 0;
|
|
1181
|
-
if (level >= SEED_LEVEL) return pool;
|
|
1182
|
-
const migrated = { ...pool, items: [...pool.items, ...seedItems(pool.items, level)], seeded: SEED_LEVEL };
|
|
1183
|
-
|
|
1184
|
-
localStorage.setItem(STORAGE_KEY, JSON.stringify(migrated));
|
|
1185
|
-
} catch (_error) {
|
|
1186
|
-
/* storage unavailable: keep the in-memory copy only */
|
|
1187
|
-
}
|
|
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);
|
|
1188
1324
|
return migrated;
|
|
1189
1325
|
} catch (_error) {
|
|
1190
1326
|
return emptyPool();
|
|
@@ -1217,8 +1353,29 @@ window.__ModuleLoader__.load({
|
|
|
1217
1353
|
return window[POOL_SINGLETON];
|
|
1218
1354
|
})();
|
|
1219
1355
|
|
|
1356
|
+
// Clear orphaned image bytes once the pool is readable; the delay keeps the
|
|
1357
|
+
// first paint cheap and lets another window finish its own load.
|
|
1358
|
+
if (typeof window !== 'undefined' && typeof indexedDB !== 'undefined' && typeof window.setTimeout === 'function') {
|
|
1359
|
+
window.setTimeout(() => {
|
|
1360
|
+
sweepImageBlobs().catch(() => {});
|
|
1361
|
+
}, 5000);
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1220
1364
|
const ui = createStore({ open: false });
|
|
1221
1365
|
|
|
1366
|
+
/**
|
|
1367
|
+
* The sidebar page's active group tab. The pane can be remounted by the
|
|
1368
|
+
* host when another sidebar tab is shown, so this lives outside the
|
|
1369
|
+
* component and survives that remount.
|
|
1370
|
+
*/
|
|
1371
|
+
const PAGE_TAB_SINGLETON = '__dshPromptPoolPageTabV1';
|
|
1372
|
+
const pageTabState = (() => {
|
|
1373
|
+
const initial = { id: 'all' };
|
|
1374
|
+
if (typeof window === 'undefined') return createStore(initial);
|
|
1375
|
+
if (!window[PAGE_TAB_SINGLETON]) window[PAGE_TAB_SINGLETON] = createStore(initial);
|
|
1376
|
+
return window[PAGE_TAB_SINGLETON];
|
|
1377
|
+
})();
|
|
1378
|
+
|
|
1222
1379
|
/**
|
|
1223
1380
|
* Live workspace directory: derived (never persisted) and published by
|
|
1224
1381
|
* whichever view can read the workspace snapshot, so one tab appears per
|
|
@@ -1292,6 +1449,13 @@ window.__ModuleLoader__.load({
|
|
|
1292
1449
|
const value = Number(settings.panelHeight);
|
|
1293
1450
|
return Number.isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
1294
1451
|
})(),
|
|
1452
|
+
// 0 keeps the default width; anything else is a dragged width in px.
|
|
1453
|
+
panelWidth: (() => {
|
|
1454
|
+
const value = Number(settings.panelWidth);
|
|
1455
|
+
return Number.isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
1456
|
+
})(),
|
|
1457
|
+
// A pinned panel ignores outside clicks and stays over the conversation.
|
|
1458
|
+
panelPinned: settings.panelPinned === true,
|
|
1295
1459
|
orderExplicit: settings.orderExplicit === true,
|
|
1296
1460
|
order: (() => {
|
|
1297
1461
|
const stored = Array.isArray(settings.order) ? settings.order.filter((name) => leaders.indexOf(name) >= 0) : [];
|
|
@@ -1319,6 +1483,50 @@ window.__ModuleLoader__.load({
|
|
|
1319
1483
|
];
|
|
1320
1484
|
}
|
|
1321
1485
|
|
|
1486
|
+
/** Item counts per group id for one family, for the nested rail chips. */
|
|
1487
|
+
function groupCounts(items, family) {
|
|
1488
|
+
const counts = {};
|
|
1489
|
+
for (const item of items) {
|
|
1490
|
+
const group = groupOf(item);
|
|
1491
|
+
if (familyOf(group) === family) counts[group] = (counts[group] || 0) + 1;
|
|
1492
|
+
}
|
|
1493
|
+
return counts;
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1496
|
+
/** Per-tab counts: every group id, each folded family, and the all tab. */
|
|
1497
|
+
function tabCountsOf(items) {
|
|
1498
|
+
const counts = { all: (items || []).length };
|
|
1499
|
+
for (const item of items || []) {
|
|
1500
|
+
const group = groupOf(item);
|
|
1501
|
+
counts[group] = (counts[group] || 0) + 1;
|
|
1502
|
+
const family = familyOf(group);
|
|
1503
|
+
if (family) counts['nested:' + family] = (counts['nested:' + family] || 0) + 1;
|
|
1504
|
+
}
|
|
1505
|
+
return counts;
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1508
|
+
/** Destinations offered when a captured draft is saved: the groups on show. */
|
|
1509
|
+
function captureChoices(categories, workspaces, currentWorkspaceId, settings) {
|
|
1510
|
+
const flags = normalizeSettings(settings).display;
|
|
1511
|
+
const list = [];
|
|
1512
|
+
if (flags.builtin !== 'hidden') {
|
|
1513
|
+
list.push({ value: BUILTIN_GROUP.note, label: translate('group.note') });
|
|
1514
|
+
list.push({ value: BUILTIN_GROUP.oftenuse, label: translate('group.oftenuse') });
|
|
1515
|
+
list.push({ value: BUILTIN_GROUP.template, label: translate('group.template') });
|
|
1516
|
+
}
|
|
1517
|
+
if (flags.custom !== 'hidden') {
|
|
1518
|
+
for (const category of categories || []) list.push({ value: 'custom:' + category.id, label: category.name });
|
|
1519
|
+
}
|
|
1520
|
+
if (flags.workspace !== 'hidden') {
|
|
1521
|
+
for (const workspace of workspaceRail(workspaces, settings, currentWorkspaceId)) {
|
|
1522
|
+
list.push({ value: 'workspace:' + workspace.workspaceId, label: workspace.name });
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
// A pool with every family hidden still needs one destination.
|
|
1526
|
+
if (list.length === 0) list.push({ value: BUILTIN_GROUP.note, label: translate('group.note') });
|
|
1527
|
+
return list;
|
|
1528
|
+
}
|
|
1529
|
+
|
|
1322
1530
|
/** One family's tab block: hidden / one folded tab / one tab per group. */
|
|
1323
1531
|
function displayBlock(family, groups, settings) {
|
|
1324
1532
|
const mode = normalizeSettings(settings).display[family];
|
|
@@ -1343,15 +1551,19 @@ window.__ModuleLoader__.load({
|
|
|
1343
1551
|
|
|
1344
1552
|
const bridge = (() => {
|
|
1345
1553
|
const create = () => {
|
|
1346
|
-
|
|
1554
|
+
const handlers = [];
|
|
1347
1555
|
return {
|
|
1348
1556
|
listen(fn) {
|
|
1349
|
-
|
|
1557
|
+
handlers.push(fn);
|
|
1350
1558
|
return () => {
|
|
1351
|
-
|
|
1559
|
+
const at = handlers.lastIndexOf(fn);
|
|
1560
|
+
if (at >= 0) handlers.splice(at, 1);
|
|
1352
1561
|
};
|
|
1353
1562
|
},
|
|
1354
1563
|
request(command) {
|
|
1564
|
+
// The newest mounted panel owns the composer; an older one takes
|
|
1565
|
+
// over again when the newer unmounts.
|
|
1566
|
+
const handler = handlers[handlers.length - 1];
|
|
1355
1567
|
if (!handler) return { ok: false, reason: 'unavailable' };
|
|
1356
1568
|
try {
|
|
1357
1569
|
return handler(command) || { ok: true };
|
|
@@ -1369,8 +1581,10 @@ window.__ModuleLoader__.load({
|
|
|
1369
1581
|
function persist(next) {
|
|
1370
1582
|
try {
|
|
1371
1583
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
|
1584
|
+
if (storageState.get().failed) storageState.set({ failed: false });
|
|
1372
1585
|
} catch (_error) {
|
|
1373
|
-
|
|
1586
|
+
// The in-memory copy stays usable, but both views now say it is not saved.
|
|
1587
|
+
if (!storageState.get().failed) storageState.set({ failed: true });
|
|
1374
1588
|
}
|
|
1375
1589
|
}
|
|
1376
1590
|
|
|
@@ -1387,7 +1601,8 @@ window.__ModuleLoader__.load({
|
|
|
1387
1601
|
mutate((state) => ({ ...state, items: [...state.items, item] }));
|
|
1388
1602
|
return item;
|
|
1389
1603
|
},
|
|
1390
|
-
/** Copy one pool item (current text) and append the copy last. */
|
|
1604
|
+
/** Copy one pool item (current text) and append the copy last. */
|
|
1605
|
+
duplicateItem(id) {
|
|
1391
1606
|
mutate((state) => {
|
|
1392
1607
|
const found = state.items.find((item) => item.id === id);
|
|
1393
1608
|
if (!found) return null;
|
|
@@ -1397,10 +1612,21 @@ window.__ModuleLoader__.load({
|
|
|
1397
1612
|
});
|
|
1398
1613
|
},
|
|
1399
1614
|
patch(id, fields) {
|
|
1615
|
+
const before = pool.get().items.find((item) => item.id === id);
|
|
1400
1616
|
mutate((state) => ({
|
|
1401
1617
|
...state,
|
|
1402
1618
|
items: state.items.map((item) => (item.id === id ? { ...item, ...fields, updatedAt: Date.now() } : item)),
|
|
1403
1619
|
}));
|
|
1620
|
+
// Saving is the point of no return for an image removed in the editor.
|
|
1621
|
+
// A duplicate or a queued copy may share the id, so drop it only when
|
|
1622
|
+
// nothing else points at it any more.
|
|
1623
|
+
if (before && Array.isArray(fields.images)) {
|
|
1624
|
+
const keep = new Set(fields.images.map((image) => image.id));
|
|
1625
|
+
const drop = (before.images || []).map((image) => image.id).filter((imageId) => !keep.has(imageId));
|
|
1626
|
+
const used = referencedImageIds();
|
|
1627
|
+
const garbage = drop.filter((imageId) => !used.has(imageId));
|
|
1628
|
+
if (garbage.length > 0) deleteImageBlobs(garbage).catch(() => {});
|
|
1629
|
+
}
|
|
1404
1630
|
},
|
|
1405
1631
|
|
|
1406
1632
|
addCategory(name) {
|
|
@@ -1522,6 +1748,339 @@ window.__ModuleLoader__.load({
|
|
|
1522
1748
|
return useSyncExternalStore(pool.subscribe, pool.get, pool.get);
|
|
1523
1749
|
}
|
|
1524
1750
|
|
|
1751
|
+
function useStorageState() {
|
|
1752
|
+
return useSyncExternalStore(storageState.subscribe, storageState.get, storageState.get);
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
function useReleaseState() {
|
|
1756
|
+
return useSyncExternalStore(releaseState.subscribe, releaseState.get, releaseState.get);
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* Editor state shared by both views: the item being edited plus the save and
|
|
1761
|
+
* cancel paths. Keeping them here stops the empty-row and unsaved-image
|
|
1762
|
+
* rules from drifting between the panel and the page.
|
|
1763
|
+
*/
|
|
1764
|
+
function usePoolEditor(flash) {
|
|
1765
|
+
const [editing, setEditing] = useState(null);
|
|
1766
|
+
|
|
1767
|
+
const startEdit = (item) => setEditing({
|
|
1768
|
+
id: item.id,
|
|
1769
|
+
group: groupOf(item),
|
|
1770
|
+
title: item.title,
|
|
1771
|
+
body: item.body,
|
|
1772
|
+
images: normalizeImages(item.images),
|
|
1773
|
+
});
|
|
1774
|
+
|
|
1775
|
+
const cancelEdit = () => {
|
|
1776
|
+
const current = editing;
|
|
1777
|
+
setEditing(null);
|
|
1778
|
+
if (!current) return;
|
|
1779
|
+
const stored = pool.get().items.find((item) => item.id === current.id);
|
|
1780
|
+
discardUnsavedImages(current, stored);
|
|
1781
|
+
if (stored && !stored.body.trim() && !(stored.images && stored.images.length > 0)) poolActions.remove(stored.id);
|
|
1782
|
+
};
|
|
1783
|
+
|
|
1784
|
+
const save = () => {
|
|
1785
|
+
if (!editing) return false;
|
|
1786
|
+
if (!editing.body.trim() && (!editing.images || editing.images.length === 0)) {
|
|
1787
|
+
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
poolActions.patch(editing.id, {
|
|
1791
|
+
group: editing.group,
|
|
1792
|
+
title: editing.title.trim(),
|
|
1793
|
+
body: editing.body,
|
|
1794
|
+
images: editing.images || [],
|
|
1795
|
+
});
|
|
1796
|
+
setEditing(null);
|
|
1797
|
+
flash({ kind: 'ok', text: translate('status.savedToPool') });
|
|
1798
|
+
return true;
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
const pasteImages = (files) => {
|
|
1802
|
+
const id = editing && editing.id;
|
|
1803
|
+
appendImageAssets(files, editing && editing.images ? editing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
1804
|
+
setEditing((current) => (current && current.id === id ? { ...current, images } : current));
|
|
1805
|
+
});
|
|
1806
|
+
};
|
|
1807
|
+
|
|
1808
|
+
return { editing, setEditing, startEdit, save, cancelEdit, pasteImages };
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1811
|
+
/** Editor state for a queued copy; the queue card is shared by both views. */
|
|
1812
|
+
function useTrayEditor(flash) {
|
|
1813
|
+
const [trayEditing, setTrayEditing] = useState(null);
|
|
1814
|
+
|
|
1815
|
+
const saveTrayEdit = () => {
|
|
1816
|
+
if (!trayEditing) return;
|
|
1817
|
+
if (!trayEditing.body.trim() && (!trayEditing.images || trayEditing.images.length === 0)) {
|
|
1818
|
+
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
1819
|
+
return;
|
|
1820
|
+
}
|
|
1821
|
+
poolActions.patchTray(trayEditing.key, { body: trayEditing.body, images: trayEditing.images || [] });
|
|
1822
|
+
setTrayEditing(null);
|
|
1823
|
+
};
|
|
1824
|
+
|
|
1825
|
+
const pasteTrayImages = (files) => {
|
|
1826
|
+
const key = trayEditing && trayEditing.key;
|
|
1827
|
+
appendImageAssets(files, trayEditing && trayEditing.images ? trayEditing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
1828
|
+
setTrayEditing((current) => (current && current.key === key ? { ...current, images } : current));
|
|
1829
|
+
});
|
|
1830
|
+
};
|
|
1831
|
+
|
|
1832
|
+
return { trayEditing, setTrayEditing, saveTrayEdit, pasteTrayImages };
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
/** One pool row (or its editor), shared by the panel and the page. */
|
|
1836
|
+
function renderPoolRow(props) {
|
|
1837
|
+
const {
|
|
1838
|
+
item, index, total, editing, setEditing, categories, workspaces, sessionId,
|
|
1839
|
+
editRows, editStyle, mainTitle, showTag, onInsert, onMain, onStartEdit,
|
|
1840
|
+
onQueue, onDelete, onSave, onCancel, onPasteImages, onOpenImage, onError,
|
|
1841
|
+
} = props;
|
|
1842
|
+
|
|
1843
|
+
if (editing && editing.id === item.id) {
|
|
1844
|
+
return h(
|
|
1845
|
+
'div',
|
|
1846
|
+
{ key: item.id, className: 'pp-edit', ...(editStyle ? { style: editStyle } : {}) },
|
|
1847
|
+
h('input', {
|
|
1848
|
+
className: 'pp-input',
|
|
1849
|
+
value: editing.title,
|
|
1850
|
+
placeholder: translate('row.titlePlaceholder'),
|
|
1851
|
+
onChange: (event) => setEditing({ ...editing, title: event.target.value }),
|
|
1852
|
+
}),
|
|
1853
|
+
h(MentionField, {
|
|
1854
|
+
value: editing.body,
|
|
1855
|
+
placeholder: translate('row.bodyPlaceholder'),
|
|
1856
|
+
rows: editRows || 4,
|
|
1857
|
+
autoFocus: true,
|
|
1858
|
+
sessionId,
|
|
1859
|
+
onChange: (event) => setEditing({ ...editing, body: event.target.value }),
|
|
1860
|
+
onPasteImages,
|
|
1861
|
+
onKeyDown: (event) => {
|
|
1862
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
1863
|
+
event.preventDefault();
|
|
1864
|
+
onSave();
|
|
1865
|
+
}
|
|
1866
|
+
},
|
|
1867
|
+
}),
|
|
1868
|
+
h(ImagePicker, {
|
|
1869
|
+
images: editing.images || [],
|
|
1870
|
+
onChange: (images) => setEditing((current) => (current ? { ...current, images } : current)),
|
|
1871
|
+
onError,
|
|
1872
|
+
onOpen: onOpenImage,
|
|
1873
|
+
}),
|
|
1874
|
+
h(
|
|
1875
|
+
'div',
|
|
1876
|
+
{ className: 'pp-edit-actions' },
|
|
1877
|
+
h(
|
|
1878
|
+
'select',
|
|
1879
|
+
{
|
|
1880
|
+
className: 'pp-input',
|
|
1881
|
+
style: { width: 'auto', maxWidth: '220px' },
|
|
1882
|
+
value: groupOf(editing),
|
|
1883
|
+
'aria-label': translate('row.classification'),
|
|
1884
|
+
onChange: (event) => setEditing(withGroup(editing, event.target.value)),
|
|
1885
|
+
},
|
|
1886
|
+
h(
|
|
1887
|
+
'optgroup',
|
|
1888
|
+
{ label: translate('row.familyBuiltin') },
|
|
1889
|
+
h('option', { value: BUILTIN_GROUP.oftenuse }, translate('group.oftenuse')),
|
|
1890
|
+
h('option', { value: BUILTIN_GROUP.note }, translate('group.note')),
|
|
1891
|
+
h('option', { value: BUILTIN_GROUP.template }, translate('group.template')),
|
|
1892
|
+
),
|
|
1893
|
+
workspaces.length > 0
|
|
1894
|
+
? h(
|
|
1895
|
+
'optgroup',
|
|
1896
|
+
{ label: translate('row.familyWorkspace') },
|
|
1897
|
+
workspaces.map((workspace) => h('option', { key: workspace.id, value: 'workspace:' + workspace.workspaceId }, workspace.name)),
|
|
1898
|
+
)
|
|
1899
|
+
: null,
|
|
1900
|
+
categories.length > 0
|
|
1901
|
+
? h(
|
|
1902
|
+
'optgroup',
|
|
1903
|
+
{ label: translate('row.familyCustom') },
|
|
1904
|
+
categories.map((category) => h('option', { key: category.id, value: 'custom:' + category.id }, category.name)),
|
|
1905
|
+
)
|
|
1906
|
+
: null,
|
|
1907
|
+
),
|
|
1908
|
+
h('span', { className: 'pp-grow' }),
|
|
1909
|
+
h('button', { type: 'button', className: 'pp-mini', onClick: onCancel }, translate('row.cancel')),
|
|
1910
|
+
h('button', { type: 'button', className: 'pp-primary', onClick: onSave }, translate('row.save')),
|
|
1911
|
+
),
|
|
1912
|
+
);
|
|
1913
|
+
}
|
|
1914
|
+
|
|
1915
|
+
return h(
|
|
1916
|
+
'div',
|
|
1917
|
+
{ key: item.id, className: 'pp-row pp-page-item' },
|
|
1918
|
+
h(IconButton, { name: 'insert', label: translate('row.insert'), onClick: () => onInsert(item) }),
|
|
1919
|
+
h(TrayAdd, { label: translate('row.select'), onClick: () => onQueue(item) }),
|
|
1920
|
+
h(
|
|
1921
|
+
'div',
|
|
1922
|
+
{ className: 'pp-main', ...(mainTitle ? { title: mainTitle } : {}), onClick: () => (onMain || onStartEdit)(item) },
|
|
1923
|
+
h('div', { className: 'pp-title' }, item.title || item.body.split('\n')[0] || (item.images && item.images[0] && (item.images[0].name || translate('image.only'))) || translate('group.untitled')),
|
|
1924
|
+
item.body.trim() === (item.title || '').trim() ? null : h('div', { className: 'pp-body' }, item.body),
|
|
1925
|
+
h(ImageStrip, { images: item.images, compact: true, onOpen: onOpenImage }),
|
|
1926
|
+
),
|
|
1927
|
+
showTag ? h('span', { className: 'pp-tag' }, clipLabel(groupLabelOf(item, categories, workspaces))) : null,
|
|
1928
|
+
h(
|
|
1929
|
+
'div',
|
|
1930
|
+
{ className: 'pp-actions' },
|
|
1931
|
+
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.move(item.id, -1) }),
|
|
1932
|
+
h(IconButton, { name: 'down', label: translate('row.down'), disabled: index === total - 1, onClick: () => poolActions.move(item.id, 1) }),
|
|
1933
|
+
h(IconButton, { name: 'edit', label: translate('row.edit'), onClick: () => onStartEdit(item) }),
|
|
1934
|
+
h(IconButton, { name: 'copy', label: translate('row.duplicate'), onClick: () => poolActions.duplicateItem(item.id) }),
|
|
1935
|
+
h(IconButton, { name: 'trash', label: translate('row.delete'), danger: true, onClick: () => onDelete(item) }),
|
|
1936
|
+
),
|
|
1937
|
+
);
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
/** The send-queue card, shared by the panel and the page. */
|
|
1941
|
+
function renderTrayCard(props) {
|
|
1942
|
+
const {
|
|
1943
|
+
entries, queuePending, collapsed, busy, sessionId, trayRef,
|
|
1944
|
+
editing, setEditing, onSaveEdit, onPasteImages, onClear, onRelease,
|
|
1945
|
+
onRemove, onOpenImage, onError,
|
|
1946
|
+
} = props;
|
|
1947
|
+
|
|
1948
|
+
if (collapsed) {
|
|
1949
|
+
return h(
|
|
1950
|
+
'button',
|
|
1951
|
+
{
|
|
1952
|
+
type: 'button',
|
|
1953
|
+
className: 'pp-queue-strip',
|
|
1954
|
+
title: translate('tray.expandTitle'),
|
|
1955
|
+
'aria-label': translate('tray.expandTitle'),
|
|
1956
|
+
'aria-expanded': 'false',
|
|
1957
|
+
onClick: () => poolActions.setSetting('queueCollapsed', false),
|
|
1958
|
+
},
|
|
1959
|
+
h('span', { className: 'pp-queue-strip-action' }, icon('chevronUp')),
|
|
1960
|
+
h('span', { className: 'pp-queue-strip-title' }, translate('tray.title')),
|
|
1961
|
+
h('span', { className: 'pp-hint' }, translate('tray.selected', { n: entries.length })),
|
|
1962
|
+
h('span', { className: 'pp-grow' }),
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
return h(
|
|
1967
|
+
'div',
|
|
1968
|
+
{ className: 'pp-page-foot' },
|
|
1969
|
+
h(
|
|
1970
|
+
'div',
|
|
1971
|
+
{ className: 'pp-foot-head' },
|
|
1972
|
+
h(
|
|
1973
|
+
'button',
|
|
1974
|
+
{
|
|
1975
|
+
type: 'button',
|
|
1976
|
+
className: 'pp-queue-toggle',
|
|
1977
|
+
title: translate('tray.collapseTitle'),
|
|
1978
|
+
'aria-label': translate('tray.collapseTitle'),
|
|
1979
|
+
'aria-expanded': 'true',
|
|
1980
|
+
onClick: () => poolActions.setSetting('queueCollapsed', true),
|
|
1981
|
+
},
|
|
1982
|
+
h('span', { className: 'pp-queue-toggle-icon' }, icon('chevronDown')),
|
|
1983
|
+
),
|
|
1984
|
+
h('span', { className: 'pp-foot-title' }, translate('tray.title')),
|
|
1985
|
+
h('span', { className: 'pp-hint' }, translate('tray.selected', { n: entries.length })),
|
|
1986
|
+
queuePending > 0 ? h('span', { className: 'pp-hint' }, translate('tray.queue', { n: queuePending })) : null,
|
|
1987
|
+
h('span', { className: 'pp-grow' }),
|
|
1988
|
+
entries.length > 0 ? h('button', { type: 'button', className: 'pp-link', onClick: onClear }, translate('tray.clear')) : null,
|
|
1989
|
+
entries.length > 0
|
|
1990
|
+
? h('button', { type: 'button', className: 'pp-primary', disabled: busy, onClick: onRelease }, translate('tray.release'))
|
|
1991
|
+
: null,
|
|
1992
|
+
),
|
|
1993
|
+
h(
|
|
1994
|
+
'div',
|
|
1995
|
+
{ className: entries.length === 0 ? 'pp-tray pp-tray-empty' : 'pp-tray', ref: trayRef },
|
|
1996
|
+
entries.length === 0
|
|
1997
|
+
? h('div', { className: 'pp-hint' }, translate('tray.empty'))
|
|
1998
|
+
: entries.map((entry, index) => {
|
|
1999
|
+
if (editing && editing.key === entry.key) {
|
|
2000
|
+
return h(
|
|
2001
|
+
'div',
|
|
2002
|
+
{ key: entry.key, className: 'pp-edit', style: { margin: '4px 0' } },
|
|
2003
|
+
h(MentionField, {
|
|
2004
|
+
value: editing.body,
|
|
2005
|
+
placeholder: translate('row.bodyPlaceholder'),
|
|
2006
|
+
rows: 4,
|
|
2007
|
+
autoFocus: true,
|
|
2008
|
+
sessionId,
|
|
2009
|
+
onChange: (event) => setEditing((current) => (current ? { ...current, body: event.target.value } : current)),
|
|
2010
|
+
onPasteImages,
|
|
2011
|
+
onKeyDown: (event) => {
|
|
2012
|
+
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
2013
|
+
event.preventDefault();
|
|
2014
|
+
onSaveEdit();
|
|
2015
|
+
}
|
|
2016
|
+
},
|
|
2017
|
+
}),
|
|
2018
|
+
h(ImagePicker, {
|
|
2019
|
+
images: editing.images || [],
|
|
2020
|
+
onChange: (images) => setEditing((current) => (current ? { ...current, images } : current)),
|
|
2021
|
+
onError,
|
|
2022
|
+
onOpen: onOpenImage,
|
|
2023
|
+
}),
|
|
2024
|
+
h(
|
|
2025
|
+
'div',
|
|
2026
|
+
{ className: 'pp-edit-actions' },
|
|
2027
|
+
h('button', { type: 'button', className: 'pp-mini', onClick: () => setEditing(null) }, translate('row.cancel')),
|
|
2028
|
+
h('button', { type: 'button', className: 'pp-primary', onClick: onSaveEdit }, translate('row.save')),
|
|
2029
|
+
),
|
|
2030
|
+
);
|
|
2031
|
+
}
|
|
2032
|
+
return h(
|
|
2033
|
+
'div',
|
|
2034
|
+
{ key: entry.key, className: 'pp-chip' },
|
|
2035
|
+
h('span', { className: 'pp-chip-n' }, String(index + 1) + '.'),
|
|
2036
|
+
h('div', { className: 'pp-chip-t', title: entry.body }, entry.body),
|
|
2037
|
+
h(ImageStrip, { images: entry.images, compact: true, max: 4, onOpen: onOpenImage }),
|
|
2038
|
+
h(
|
|
2039
|
+
'div',
|
|
2040
|
+
{ className: 'pp-chip-actions' },
|
|
2041
|
+
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.moveTray(entry.key, -1) }),
|
|
2042
|
+
h(IconButton, { name: 'down', label: translate('row.down'), disabled: index === entries.length - 1, onClick: () => poolActions.moveTray(entry.key, 1) }),
|
|
2043
|
+
h(IconButton, { name: 'edit', label: translate('row.edit'), onClick: () => setEditing({ key: entry.key, body: entry.body || '', images: normalizeImages(entry.images) }) }),
|
|
2044
|
+
h(IconButton, { name: 'copy', label: translate('tray.duplicate'), onClick: () => poolActions.duplicateTray(entry.key) }),
|
|
2045
|
+
h(IconButton, { name: 'close', label: translate('tray.remove'), onClick: () => onRemove(entry) }),
|
|
2046
|
+
),
|
|
2047
|
+
);
|
|
2048
|
+
}),
|
|
2049
|
+
),
|
|
2050
|
+
);
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
/** Blocks the pool while a release runs; only Stop is allowed. */
|
|
2054
|
+
function renderReleaseOverlay(props) {
|
|
2055
|
+
const state = props.state;
|
|
2056
|
+
if (!state || !state.active) return null;
|
|
2057
|
+
return h(
|
|
2058
|
+
'div',
|
|
2059
|
+
{
|
|
2060
|
+
className: 'pp-release-mask',
|
|
2061
|
+
role: 'dialog',
|
|
2062
|
+
'aria-modal': 'true',
|
|
2063
|
+
'aria-label': translate('release.title'),
|
|
2064
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
2065
|
+
onKeyDown: (event) => {
|
|
2066
|
+
if (event.key === 'Tab') event.preventDefault();
|
|
2067
|
+
},
|
|
2068
|
+
},
|
|
2069
|
+
h(
|
|
2070
|
+
'div',
|
|
2071
|
+
{ className: 'pp-release-card' },
|
|
2072
|
+
h('div', { className: 'pp-release-title' }, translate('release.title')),
|
|
2073
|
+
h('div', { className: 'pp-release-count', 'aria-live': 'polite' }, translate('release.progress', { sent: state.sent, total: state.total })),
|
|
2074
|
+
h('div', { className: 'pp-hint' }, translate('release.hint')),
|
|
2075
|
+
h(
|
|
2076
|
+
'button',
|
|
2077
|
+
{ type: 'button', className: 'pp-primary', autoFocus: true, disabled: state.stopping, onClick: props.onStop },
|
|
2078
|
+
state.stopping ? translate('release.stopping') : translate('release.stop'),
|
|
2079
|
+
),
|
|
2080
|
+
),
|
|
2081
|
+
);
|
|
2082
|
+
}
|
|
2083
|
+
|
|
1525
2084
|
function useUiState() {
|
|
1526
2085
|
return useSyncExternalStore(ui.subscribe, ui.get, ui.get);
|
|
1527
2086
|
}
|
|
@@ -1603,6 +2162,14 @@ window.__ModuleLoader__.load({
|
|
|
1603
2162
|
h('path', { d: 'M2.6 6.2h10.8M2.6 9.6h10.8M2.6 13h6' }),
|
|
1604
2163
|
h('path', { d: 'M11.6 2.4v4.4M9.4 4.6h4.4' }),
|
|
1605
2164
|
);
|
|
2165
|
+
case 'pin':
|
|
2166
|
+
return h(
|
|
2167
|
+
'svg',
|
|
2168
|
+
base,
|
|
2169
|
+
h('path', { d: 'M3.6 1.6h4.8' }),
|
|
2170
|
+
h('path', { d: 'M4.5 1.6v3.4L2.6 7h6.8L7.5 5V1.6' }),
|
|
2171
|
+
h('path', { d: 'M6 7v3.6' }),
|
|
2172
|
+
);
|
|
1606
2173
|
default:
|
|
1607
2174
|
return null;
|
|
1608
2175
|
}
|
|
@@ -1634,6 +2201,7 @@ window.__ModuleLoader__.load({
|
|
|
1634
2201
|
useLocaleTick();
|
|
1635
2202
|
const state = usePoolState();
|
|
1636
2203
|
const view = useUiState();
|
|
2204
|
+
const release = useReleaseState();
|
|
1637
2205
|
const label = translate('button.label');
|
|
1638
2206
|
const count = state.tray.length;
|
|
1639
2207
|
const queued = count > 0;
|
|
@@ -1651,12 +2219,16 @@ window.__ModuleLoader__.load({
|
|
|
1651
2219
|
'data-pp-trigger': 'true',
|
|
1652
2220
|
'data-open': view.open ? 'true' : 'false',
|
|
1653
2221
|
'data-queued': queued ? 'true' : 'false',
|
|
2222
|
+
disabled: release.active,
|
|
1654
2223
|
title: hint,
|
|
1655
2224
|
'aria-label': hint,
|
|
1656
2225
|
'aria-haspopup': 'dialog',
|
|
1657
2226
|
'aria-expanded': view.open ? 'true' : 'false',
|
|
1658
2227
|
onMouseDown: (event) => event.preventDefault(),
|
|
1659
|
-
onClick: () =>
|
|
2228
|
+
onClick: () => {
|
|
2229
|
+
if (release.active) return;
|
|
2230
|
+
ui.set({ open: !ui.get().open });
|
|
2231
|
+
},
|
|
1660
2232
|
},
|
|
1661
2233
|
icon('pool'),
|
|
1662
2234
|
h('span', { className: 'pp-trigger-label' }, label),
|
|
@@ -1946,6 +2518,7 @@ window.__ModuleLoader__.load({
|
|
|
1946
2518
|
});
|
|
1947
2519
|
}
|
|
1948
2520
|
const active = props.active === tab.id;
|
|
2521
|
+
const count = props.counts && typeof props.counts[tab.id] === 'number' ? props.counts[tab.id] : 0;
|
|
1949
2522
|
return h(
|
|
1950
2523
|
'button',
|
|
1951
2524
|
{
|
|
@@ -1958,17 +2531,27 @@ window.__ModuleLoader__.load({
|
|
|
1958
2531
|
onDoubleClick: tab.category ? () => setRenaming({ id: tab.id, name: tab.label, original: tab.label }) : undefined,
|
|
1959
2532
|
},
|
|
1960
2533
|
tab.label,
|
|
2534
|
+
count > 0 && tab.id !== 'all'
|
|
2535
|
+
? h('span', { className: 'pp-tab-count' }, String(count))
|
|
2536
|
+
: null,
|
|
1961
2537
|
tab.category && active
|
|
1962
2538
|
? h(
|
|
1963
2539
|
'span',
|
|
1964
2540
|
{
|
|
1965
2541
|
className: 'pp-tab-x',
|
|
1966
2542
|
role: 'button',
|
|
2543
|
+
tabIndex: 0,
|
|
1967
2544
|
title: translate('tab.delete'),
|
|
1968
2545
|
onClick: (event) => {
|
|
1969
2546
|
event.stopPropagation();
|
|
1970
2547
|
props.onDelete(tab.id);
|
|
1971
2548
|
},
|
|
2549
|
+
onKeyDown: (event) => {
|
|
2550
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
2551
|
+
event.preventDefault();
|
|
2552
|
+
event.stopPropagation();
|
|
2553
|
+
props.onDelete(tab.id);
|
|
2554
|
+
},
|
|
1972
2555
|
},
|
|
1973
2556
|
'×',
|
|
1974
2557
|
)
|
|
@@ -2048,6 +2631,8 @@ window.__ModuleLoader__.load({
|
|
|
2048
2631
|
function PromptPoolPage(props) {
|
|
2049
2632
|
useLocaleTick();
|
|
2050
2633
|
const state = usePoolState();
|
|
2634
|
+
const storage = useStorageState();
|
|
2635
|
+
const releaseInfo = useReleaseState();
|
|
2051
2636
|
const queueCollapsed = state.settings && state.settings.queueCollapsed === true;
|
|
2052
2637
|
const workspaces = useWorkspaceDir();
|
|
2053
2638
|
const sessionHint = useSessionDir().sessionId;
|
|
@@ -2066,15 +2651,21 @@ window.__ModuleLoader__.load({
|
|
|
2066
2651
|
return pool.length > 0 ? pool[pool.length - 1] : '';
|
|
2067
2652
|
})();
|
|
2068
2653
|
const activeSessionId = pageSessionId || sessionHint || workspaceSession || '';
|
|
2069
|
-
const
|
|
2654
|
+
const tabs = buildTabs(state.categories, workspaceList, state.settings, currentWorkspaceId);
|
|
2655
|
+
const captureGroups = captureChoices(state.categories, workspaceList, currentWorkspaceId, state.settings);
|
|
2656
|
+
const tabCounts = tabCountsOf(state.items);
|
|
2657
|
+
const [tab, setPageTab] = useState(() => pageTabState.get().id || 'all');
|
|
2658
|
+
const setTab = (id) => {
|
|
2659
|
+
pageTabState.set({ id });
|
|
2660
|
+
setPageTab(id);
|
|
2661
|
+
};
|
|
2070
2662
|
const [query, setQuery] = useState('');
|
|
2071
|
-
const [editing, setEditing] = useState(null);
|
|
2072
|
-
const [trayEditing, setTrayEditing] = useState(null);
|
|
2073
2663
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
2074
2664
|
const [pendingCategory, setPendingCategory] = useState(null);
|
|
2075
2665
|
const [confirmClear, setConfirmClear] = useState(false);
|
|
2076
2666
|
const [pendingDelete, setPendingDelete] = useState(null);
|
|
2077
2667
|
const [pendingRemove, setPendingRemove] = useState(null);
|
|
2668
|
+
const [captureOpen, setCaptureOpen] = useState(false);
|
|
2078
2669
|
const [wsSelected, setWsSelected] = useState('');
|
|
2079
2670
|
const [customPick, setCustomPick] = useState('');
|
|
2080
2671
|
const [builtinPick, setBuiltinPick] = useState('');
|
|
@@ -2087,6 +2678,15 @@ window.__ModuleLoader__.load({
|
|
|
2087
2678
|
statusTimer.current = window.setTimeout(() => setStatus(null), 5000);
|
|
2088
2679
|
}, []);
|
|
2089
2680
|
useEffect(() => () => window.clearTimeout(statusTimer.current), []);
|
|
2681
|
+
const { editing, setEditing, startEdit, save, cancelEdit, pasteImages } = usePoolEditor(flash);
|
|
2682
|
+
const { trayEditing, setTrayEditing, saveTrayEdit, pasteTrayImages } = useTrayEditor(flash);
|
|
2683
|
+
// A stored tab can point at a group that was hidden or deleted since.
|
|
2684
|
+
useEffect(() => {
|
|
2685
|
+
if (tabs.some((entry) => entry.id === tab)) return;
|
|
2686
|
+
setTab('all');
|
|
2687
|
+
}, [tabs, tab]);
|
|
2688
|
+
// A failed write outranks a transient toast: the change is not saved.
|
|
2689
|
+
const notice = status || (storage.failed ? { kind: 'error', text: translate('status.storageFailed') } : null);
|
|
2090
2690
|
const trayRef = useRef(null);
|
|
2091
2691
|
const trayCount = state.tray.length;
|
|
2092
2692
|
const lastTrayCount = useRef(trayCount);
|
|
@@ -2179,23 +2779,6 @@ window.__ModuleLoader__.load({
|
|
|
2179
2779
|
}
|
|
2180
2780
|
};
|
|
2181
2781
|
|
|
2182
|
-
const saveTrayEdit = () => {
|
|
2183
|
-
if (!trayEditing) return;
|
|
2184
|
-
if (!trayEditing.body.trim() && !(trayEditing.images && trayEditing.images.length)) {
|
|
2185
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
2186
|
-
return;
|
|
2187
|
-
}
|
|
2188
|
-
poolActions.patchTray(trayEditing.key, { body: trayEditing.body, images: trayEditing.images || [] });
|
|
2189
|
-
setTrayEditing(null);
|
|
2190
|
-
};
|
|
2191
|
-
|
|
2192
|
-
const pasteTrayImages = (files) => {
|
|
2193
|
-
const key = trayEditing && trayEditing.key;
|
|
2194
|
-
appendImageAssets(files, trayEditing && trayEditing.images ? trayEditing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
2195
|
-
setTrayEditing((current) => (current && current.key === key ? { ...current, images } : current));
|
|
2196
|
-
});
|
|
2197
|
-
};
|
|
2198
|
-
|
|
2199
2782
|
const sendToComposer = async (command, okText, onSuccess) => {
|
|
2200
2783
|
let result;
|
|
2201
2784
|
try {
|
|
@@ -2217,11 +2800,35 @@ window.__ModuleLoader__.load({
|
|
|
2217
2800
|
flash({ kind: 'error', text });
|
|
2218
2801
|
};
|
|
2219
2802
|
|
|
2803
|
+
/** Ask the panel whether the composer has content before opening the chooser. */
|
|
2804
|
+
const openCapture = () => {
|
|
2805
|
+
let result;
|
|
2806
|
+
try {
|
|
2807
|
+
result = bridge.request({ type: 'capture-check' });
|
|
2808
|
+
} catch (error) {
|
|
2809
|
+
result = { ok: false, reason: String((error && error.message) || error) };
|
|
2810
|
+
}
|
|
2811
|
+
Promise.resolve(result).then(
|
|
2812
|
+
(value) => {
|
|
2813
|
+
if (value && value.ok) {
|
|
2814
|
+
if (value.ready) {
|
|
2815
|
+
setCaptureOpen(true);
|
|
2816
|
+
} else {
|
|
2817
|
+
flash({ kind: 'error', text: translate('status.nothing') });
|
|
2818
|
+
}
|
|
2819
|
+
return;
|
|
2820
|
+
}
|
|
2821
|
+
flash({ kind: 'error', text: translate('status.noComposer') });
|
|
2822
|
+
},
|
|
2823
|
+
() => flash({ kind: 'error', text: translate('status.noComposer') }),
|
|
2824
|
+
);
|
|
2825
|
+
};
|
|
2826
|
+
|
|
2220
2827
|
/** The page cannot read the composer, so the mounted panel performs it. */
|
|
2221
|
-
const captureDraft = () => {
|
|
2828
|
+
const captureDraft = (group) => {
|
|
2222
2829
|
let result;
|
|
2223
2830
|
try {
|
|
2224
|
-
result = bridge.request({ type: 'capture' });
|
|
2831
|
+
result = bridge.request({ type: 'capture', group });
|
|
2225
2832
|
} catch (error) {
|
|
2226
2833
|
result = { ok: false, reason: String((error && error.message) || error) };
|
|
2227
2834
|
}
|
|
@@ -2229,9 +2836,18 @@ window.__ModuleLoader__.load({
|
|
|
2229
2836
|
(value) => {
|
|
2230
2837
|
if (value && value.ok) {
|
|
2231
2838
|
const skipped = Number(value.skipped) || 0;
|
|
2839
|
+
const label = typeof value.label === 'string' ? value.label : '';
|
|
2232
2840
|
flash(skipped > 0
|
|
2233
|
-
? {
|
|
2234
|
-
|
|
2841
|
+
? {
|
|
2842
|
+
kind: 'info',
|
|
2843
|
+
text: label
|
|
2844
|
+
? translate('status.savedPartialTo', { group: label, n: skipped })
|
|
2845
|
+
: translate('status.savedPartial', { n: skipped }),
|
|
2846
|
+
}
|
|
2847
|
+
: {
|
|
2848
|
+
kind: 'ok',
|
|
2849
|
+
text: label ? translate('status.savedTo', { group: label }) : translate('status.saved'),
|
|
2850
|
+
});
|
|
2235
2851
|
return;
|
|
2236
2852
|
}
|
|
2237
2853
|
const reason = value && value.reason;
|
|
@@ -2241,29 +2857,6 @@ window.__ModuleLoader__.load({
|
|
|
2241
2857
|
);
|
|
2242
2858
|
};
|
|
2243
2859
|
|
|
2244
|
-
const save = () => {
|
|
2245
|
-
if (!editing) return;
|
|
2246
|
-
if (!editing.body.trim() && (!editing.images || editing.images.length === 0)) {
|
|
2247
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
2248
|
-
return;
|
|
2249
|
-
}
|
|
2250
|
-
poolActions.patch(editing.id, {
|
|
2251
|
-
group: editing.group,
|
|
2252
|
-
title: editing.title.trim(),
|
|
2253
|
-
body: editing.body,
|
|
2254
|
-
images: editing.images || [],
|
|
2255
|
-
});
|
|
2256
|
-
setEditing(null);
|
|
2257
|
-
flash({ kind: 'ok', text: translate('status.savedToPool') });
|
|
2258
|
-
};
|
|
2259
|
-
|
|
2260
|
-
const pasteImages = (files) => {
|
|
2261
|
-
const id = editing && editing.id;
|
|
2262
|
-
appendImageAssets(files, editing && editing.images ? editing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
2263
|
-
setEditing((current) => (current && current.id === id ? { ...current, images } : current));
|
|
2264
|
-
});
|
|
2265
|
-
};
|
|
2266
|
-
|
|
2267
2860
|
/** The confirmed delete: drop the item, then offer the same undo as the panel. */
|
|
2268
2861
|
const removeItem = (item, text) => {
|
|
2269
2862
|
const index = pool.get().items.findIndex((entry) => entry.id === item.id);
|
|
@@ -2300,137 +2893,42 @@ window.__ModuleLoader__.load({
|
|
|
2300
2893
|
body: '',
|
|
2301
2894
|
images: [],
|
|
2302
2895
|
createdAt: Date.now(),
|
|
2303
|
-
updatedAt: Date.now(),
|
|
2304
|
-
});
|
|
2305
|
-
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
2306
|
-
};
|
|
2307
|
-
|
|
2308
|
-
/**
|
|
2309
|
-
* Cancel drops an item the editor created and never saved, so no empty
|
|
2310
|
-
* row is left behind; an existing item keeps its stored content.
|
|
2311
|
-
*/
|
|
2312
|
-
const cancelEdit = () => {
|
|
2313
|
-
const current = editing;
|
|
2314
|
-
setEditing(null);
|
|
2315
|
-
if (!current) return;
|
|
2316
|
-
const stored = pool.get().items.find((item) => item.id === current.id);
|
|
2317
|
-
if (stored && !stored.body.trim() && !(stored.images && stored.images.length > 0)) poolActions.remove(stored.id);
|
|
2318
|
-
};
|
|
2319
|
-
|
|
2320
|
-
const rowOf = (item, index) => {
|
|
2321
|
-
if (editing && editing.id === item.id) {
|
|
2322
|
-
return h(
|
|
2323
|
-
'div',
|
|
2324
|
-
{ key: item.id, className: 'pp-edit', style: { margin: '6px 0' } },
|
|
2325
|
-
h('input', {
|
|
2326
|
-
className: 'pp-input',
|
|
2327
|
-
value: editing.title,
|
|
2328
|
-
placeholder: translate('row.titlePlaceholder'),
|
|
2329
|
-
onChange: (event) => setEditing({ ...editing, title: event.target.value }),
|
|
2330
|
-
}),
|
|
2331
|
-
h(MentionField, {
|
|
2332
|
-
value: editing.body,
|
|
2333
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
2334
|
-
rows: 5,
|
|
2335
|
-
autoFocus: true,
|
|
2336
|
-
sessionId: activeSessionId,
|
|
2337
|
-
onChange: (event) => setEditing({ ...editing, body: event.target.value }),
|
|
2338
|
-
onPasteImages: pasteImages,
|
|
2339
|
-
onKeyDown: (event) => {
|
|
2340
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
2341
|
-
event.preventDefault();
|
|
2342
|
-
save();
|
|
2343
|
-
}
|
|
2344
|
-
},
|
|
2345
|
-
}),
|
|
2346
|
-
h(ImagePicker, {
|
|
2347
|
-
images: editing.images || [],
|
|
2348
|
-
onChange: (images) => setEditing((current) => (current ? { ...current, images } : current)),
|
|
2349
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
2350
|
-
onOpen: openImage,
|
|
2351
|
-
}),
|
|
2352
|
-
h(
|
|
2353
|
-
'div',
|
|
2354
|
-
{ className: 'pp-edit-actions' },
|
|
2355
|
-
h(
|
|
2356
|
-
'select',
|
|
2357
|
-
{
|
|
2358
|
-
className: 'pp-input',
|
|
2359
|
-
style: { width: 'auto', maxWidth: '220px' },
|
|
2360
|
-
value: groupOf(editing),
|
|
2361
|
-
'aria-label': translate('row.classification'),
|
|
2362
|
-
onChange: (event) => setEditing(withGroup(editing, event.target.value)),
|
|
2363
|
-
},
|
|
2364
|
-
h(
|
|
2365
|
-
'optgroup',
|
|
2366
|
-
{ label: translate('row.familyBuiltin') },
|
|
2367
|
-
h('option', { value: BUILTIN_GROUP.oftenuse }, translate('group.oftenuse')),
|
|
2368
|
-
h('option', { value: BUILTIN_GROUP.note }, translate('group.note')),
|
|
2369
|
-
h('option', { value: BUILTIN_GROUP.template }, translate('group.template')),
|
|
2370
|
-
),
|
|
2371
|
-
workspaces.items.length > 0
|
|
2372
|
-
? h(
|
|
2373
|
-
'optgroup',
|
|
2374
|
-
{ label: translate('row.familyWorkspace') },
|
|
2375
|
-
workspaces.items.map((workspace) => h('option', { key: workspace.id, value: 'workspace:' + workspace.workspaceId }, workspace.name)),
|
|
2376
|
-
)
|
|
2377
|
-
: null,
|
|
2378
|
-
state.categories.length > 0
|
|
2379
|
-
? h(
|
|
2380
|
-
'optgroup',
|
|
2381
|
-
{ label: translate('row.familyCustom') },
|
|
2382
|
-
state.categories.map((category) => h('option', { key: category.id, value: 'custom:' + category.id }, category.name)),
|
|
2383
|
-
)
|
|
2384
|
-
: null,
|
|
2385
|
-
),
|
|
2386
|
-
h('span', { className: 'pp-grow' }),
|
|
2387
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: cancelEdit }, translate('row.cancel')),
|
|
2388
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: save }, translate('row.save')),
|
|
2389
|
-
),
|
|
2390
|
-
);
|
|
2391
|
-
}
|
|
2392
|
-
return h(
|
|
2393
|
-
'div',
|
|
2394
|
-
{ key: item.id, className: 'pp-row pp-page-item' },
|
|
2395
|
-
h(IconButton, {
|
|
2396
|
-
name: 'insert',
|
|
2397
|
-
label: translate('row.insert'),
|
|
2398
|
-
onClick: () => sendToComposer(
|
|
2399
|
-
{ type: 'insert', text: item.body, images: normalizeImages(item.images) },
|
|
2400
|
-
item.body.trim() ? translate('status.inserted') : translate('image.inserted'),
|
|
2401
|
-
() => {
|
|
2402
|
-
if (!normalizeSettings(state.settings).keepAfterInsert) removeItem(item, translate('status.insertedAndRemoved'));
|
|
2403
|
-
},
|
|
2404
|
-
),
|
|
2405
|
-
}),
|
|
2406
|
-
h(TrayAdd, { label: translate('row.select'), onClick: () => queueItem(item) }),
|
|
2407
|
-
h(
|
|
2408
|
-
'div',
|
|
2409
|
-
{ className: 'pp-main', onClick: () => setEditing({ id: item.id, group: groupOf(item), title: item.title, body: item.body, images: normalizeImages(item.images) }) },
|
|
2410
|
-
h('div', { className: 'pp-title' }, item.title || item.body.split('\n')[0] || (item.images && item.images[0] && (item.images[0].name || translate('image.only'))) || translate('group.untitled')),
|
|
2411
|
-
item.body.trim() === (item.title || '').trim() ? null : h('div', { className: 'pp-body' }, item.body),
|
|
2412
|
-
h(ImageStrip, { images: item.images, compact: true, onOpen: openImage }),
|
|
2413
|
-
),
|
|
2414
|
-
tab === 'all'
|
|
2415
|
-
? h('span', { className: 'pp-tag' }, clipLabel(groupLabelOf(item, state.categories, workspaces.items)))
|
|
2416
|
-
: null,
|
|
2417
|
-
h(
|
|
2418
|
-
'div',
|
|
2419
|
-
{ className: 'pp-actions' },
|
|
2420
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.move(item.id, -1) }),
|
|
2421
|
-
h(IconButton, {
|
|
2422
|
-
name: 'down',
|
|
2423
|
-
label: translate('row.down'),
|
|
2424
|
-
disabled: index === items.length - 1,
|
|
2425
|
-
onClick: () => poolActions.move(item.id, 1),
|
|
2426
|
-
}),
|
|
2427
|
-
h(IconButton, { name: 'edit', label: translate('row.edit'), onClick: () => setEditing({ id: item.id, group: groupOf(item), title: item.title, body: item.body, images: normalizeImages(item.images) }) }),
|
|
2428
|
-
h(IconButton, { name: 'copy', label: translate('row.duplicate'), onClick: () => poolActions.duplicateItem(item.id) }),
|
|
2429
|
-
h(IconButton, { name: 'trash', label: translate('row.delete'), danger: true, onClick: () => setPendingDelete(item) }),
|
|
2430
|
-
),
|
|
2431
|
-
);
|
|
2896
|
+
updatedAt: Date.now(),
|
|
2897
|
+
});
|
|
2898
|
+
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
2432
2899
|
};
|
|
2433
2900
|
|
|
2901
|
+
const rowOf = (item, index) => renderPoolRow({
|
|
2902
|
+
key: item.id,
|
|
2903
|
+
item,
|
|
2904
|
+
index,
|
|
2905
|
+
total: items.length,
|
|
2906
|
+
editing,
|
|
2907
|
+
setEditing,
|
|
2908
|
+
categories: state.categories,
|
|
2909
|
+
workspaces: workspaces.items,
|
|
2910
|
+
sessionId: activeSessionId,
|
|
2911
|
+
editRows: 5,
|
|
2912
|
+
editStyle: { margin: '6px 0' },
|
|
2913
|
+
showTag: tab === 'all',
|
|
2914
|
+
onInsert: (entry) => sendToComposer(
|
|
2915
|
+
{ type: 'insert', text: entry.body, images: normalizeImages(entry.images) },
|
|
2916
|
+
entry.body.trim() ? translate('status.inserted') : translate('image.inserted'),
|
|
2917
|
+
() => {
|
|
2918
|
+
if (!normalizeSettings(state.settings).keepAfterInsert) removeItem(entry, translate('status.insertedAndRemoved'));
|
|
2919
|
+
},
|
|
2920
|
+
),
|
|
2921
|
+
onMain: startEdit,
|
|
2922
|
+
onStartEdit: startEdit,
|
|
2923
|
+
onQueue: queueItem,
|
|
2924
|
+
onDelete: setPendingDelete,
|
|
2925
|
+
onSave: save,
|
|
2926
|
+
onCancel: cancelEdit,
|
|
2927
|
+
onPasteImages: pasteImages,
|
|
2928
|
+
onOpenImage: openImage,
|
|
2929
|
+
onError: (text) => flash({ kind: 'error', text }),
|
|
2930
|
+
});
|
|
2931
|
+
|
|
2434
2932
|
// A folded family renders its groups as chips inside one tab.
|
|
2435
2933
|
const customGroups = state.categories.map((category) => ({ id: 'custom:' + category.id, name: category.name }));
|
|
2436
2934
|
const customActive = customGroups.some((entry) => entry.id === customPick)
|
|
@@ -2438,11 +2936,8 @@ window.__ModuleLoader__.load({
|
|
|
2438
2936
|
: customGroups.length > 0
|
|
2439
2937
|
? customGroups[0].id
|
|
2440
2938
|
: '';
|
|
2441
|
-
const customCounts =
|
|
2442
|
-
|
|
2443
|
-
const group = groupOf(item);
|
|
2444
|
-
if (familyOf(group) === 'custom') customCounts[group] = (customCounts[group] || 0) + 1;
|
|
2445
|
-
}
|
|
2939
|
+
const customCounts = groupCounts(state.items, 'custom');
|
|
2940
|
+
const builtinCounts = groupCounts(state.items, 'builtin');
|
|
2446
2941
|
const builtinList = builtinGroups();
|
|
2447
2942
|
const builtinActive = builtinList.some((entry) => entry.id === builtinPick) ? builtinPick : builtinList[0].id;
|
|
2448
2943
|
const nestedView =
|
|
@@ -2471,7 +2966,7 @@ window.__ModuleLoader__.load({
|
|
|
2471
2966
|
rail: builtinList,
|
|
2472
2967
|
activeId: builtinActive,
|
|
2473
2968
|
onSelect: setBuiltinPick,
|
|
2474
|
-
counts:
|
|
2969
|
+
counts: builtinCounts,
|
|
2475
2970
|
emptyText: translate('panel.emptyTab'),
|
|
2476
2971
|
scoped: state.items.filter((item) => groupOf(item) === builtinActive),
|
|
2477
2972
|
}
|
|
@@ -2491,17 +2986,19 @@ window.__ModuleLoader__.load({
|
|
|
2491
2986
|
className: 'pp-search',
|
|
2492
2987
|
value: query,
|
|
2493
2988
|
placeholder: translate('page.search'),
|
|
2989
|
+
'aria-label': translate('page.search'),
|
|
2494
2990
|
onChange: (event) => setQuery(event.target.value),
|
|
2495
2991
|
}),
|
|
2496
2992
|
h('button', { type: 'button', className: 'pp-mini', onClick: create }, '+ ', translate('page.new')),
|
|
2497
|
-
h('button', { type: 'button', className: 'pp-mini', title: translate('panel.captureHint'), onClick:
|
|
2993
|
+
h('button', { type: 'button', className: 'pp-mini', title: translate('panel.captureHint'), onClick: openCapture }, translate('panel.capture')),
|
|
2498
2994
|
h(SettingsButton, { active: settingsOpen, onClick: () => setSettingsOpen(!settingsOpen) }),
|
|
2499
2995
|
),
|
|
2500
2996
|
h(
|
|
2501
2997
|
'div',
|
|
2502
2998
|
{ className: 'pp-bar', style: { padding: '8px 12px 2px' } },
|
|
2503
2999
|
h(TabBar, {
|
|
2504
|
-
tabs:
|
|
3000
|
+
tabs: tabs,
|
|
3001
|
+
counts: tabCounts,
|
|
2505
3002
|
active: tab,
|
|
2506
3003
|
...tabHandlers((next) => {
|
|
2507
3004
|
setSettingsOpen(false);
|
|
@@ -2551,6 +3048,16 @@ window.__ModuleLoader__.load({
|
|
|
2551
3048
|
},
|
|
2552
3049
|
})
|
|
2553
3050
|
: null,
|
|
3051
|
+
captureOpen
|
|
3052
|
+
? h(CaptureMenu, {
|
|
3053
|
+
groups: captureGroups,
|
|
3054
|
+
onPick: (group) => {
|
|
3055
|
+
setCaptureOpen(false);
|
|
3056
|
+
captureDraft(group);
|
|
3057
|
+
},
|
|
3058
|
+
onCancel: () => setCaptureOpen(false),
|
|
3059
|
+
})
|
|
3060
|
+
: null,
|
|
2554
3061
|
h(
|
|
2555
3062
|
'div',
|
|
2556
3063
|
{ className: 'pp-page-body', ref: pageListRef },
|
|
@@ -2585,19 +3092,19 @@ window.__ModuleLoader__.load({
|
|
|
2585
3092
|
h(
|
|
2586
3093
|
'div',
|
|
2587
3094
|
{ className: 'pp-queue-dock' },
|
|
2588
|
-
|
|
3095
|
+
notice
|
|
2589
3096
|
? h(
|
|
2590
3097
|
'div',
|
|
2591
|
-
{ className: 'pp-status pp-status-float', 'data-kind':
|
|
2592
|
-
h('span', null,
|
|
2593
|
-
|
|
3098
|
+
{ className: 'pp-status pp-status-float', role: 'status', 'aria-live': 'polite', 'data-kind': notice.kind || 'info' },
|
|
3099
|
+
h('span', null, notice.text),
|
|
3100
|
+
notice.undo
|
|
2594
3101
|
? h(
|
|
2595
3102
|
'button',
|
|
2596
3103
|
{
|
|
2597
3104
|
type: 'button',
|
|
2598
3105
|
className: 'pp-link',
|
|
2599
3106
|
onClick: () => {
|
|
2600
|
-
|
|
3107
|
+
notice.undo();
|
|
2601
3108
|
},
|
|
2602
3109
|
},
|
|
2603
3110
|
translate('status.undo'),
|
|
@@ -2606,132 +3113,26 @@ window.__ModuleLoader__.load({
|
|
|
2606
3113
|
)
|
|
2607
3114
|
: null,
|
|
2608
3115
|
settingsOpen
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
)
|
|
2626
|
-
: h(
|
|
2627
|
-
'div',
|
|
2628
|
-
{ className: 'pp-page-foot' },
|
|
2629
|
-
h(
|
|
2630
|
-
'div',
|
|
2631
|
-
{ className: 'pp-foot-head' },
|
|
2632
|
-
h(
|
|
2633
|
-
'button',
|
|
2634
|
-
{
|
|
2635
|
-
type: 'button',
|
|
2636
|
-
className: 'pp-queue-toggle',
|
|
2637
|
-
title: translate('tray.collapseTitle'),
|
|
2638
|
-
'aria-label': translate('tray.collapseTitle'),
|
|
2639
|
-
'aria-expanded': 'true',
|
|
2640
|
-
onClick: () => poolActions.setSetting('queueCollapsed', true),
|
|
2641
|
-
},
|
|
2642
|
-
h('span', { className: 'pp-queue-toggle-icon' }, icon('chevronDown')),
|
|
2643
|
-
),
|
|
2644
|
-
h('span', { className: 'pp-foot-title' }, translate('tray.title')),
|
|
2645
|
-
h('span', { className: 'pp-hint' }, translate('tray.selected', { n: state.tray.length })),
|
|
2646
|
-
queuePending > 0 ? h('span', { className: 'pp-hint' }, translate('tray.queue', { n: queuePending })) : null,
|
|
2647
|
-
h('span', { className: 'pp-grow' }),
|
|
2648
|
-
state.tray.length > 0
|
|
2649
|
-
? h('button', { type: 'button', className: 'pp-link', onClick: () => setConfirmClear(true) }, translate('tray.clear'))
|
|
2650
|
-
: null,
|
|
2651
|
-
state.tray.length > 0
|
|
2652
|
-
? h(
|
|
2653
|
-
'button',
|
|
2654
|
-
{ type: 'button', className: 'pp-primary', onClick: () => sendToComposer({ type: 'release' }, translate('status.releaseSent')) },
|
|
2655
|
-
translate('tray.release'),
|
|
2656
|
-
)
|
|
2657
|
-
: null,
|
|
2658
|
-
),
|
|
2659
|
-
state.tray.length === 0
|
|
2660
|
-
? h(
|
|
2661
|
-
'div',
|
|
2662
|
-
{ className: 'pp-tray pp-tray-empty', ref: trayRef },
|
|
2663
|
-
h('div', { className: 'pp-hint' }, translate('tray.empty')),
|
|
2664
|
-
)
|
|
2665
|
-
: h(
|
|
2666
|
-
'div',
|
|
2667
|
-
{
|
|
2668
|
-
className: 'pp-tray',
|
|
2669
|
-
ref: trayRef,
|
|
2670
|
-
},
|
|
2671
|
-
state.tray.map((entry, index) => {
|
|
2672
|
-
if (trayEditing && trayEditing.key === entry.key) {
|
|
2673
|
-
return h(
|
|
2674
|
-
'div',
|
|
2675
|
-
{ key: entry.key, className: 'pp-edit', style: { margin: '4px 0' } },
|
|
2676
|
-
h(MentionField, {
|
|
2677
|
-
value: trayEditing.body,
|
|
2678
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
2679
|
-
rows: 4,
|
|
2680
|
-
autoFocus: true,
|
|
2681
|
-
sessionId: activeSessionId,
|
|
2682
|
-
onChange: (event) => setTrayEditing((current) => (current ? { ...current, body: event.target.value } : current)),
|
|
2683
|
-
onPasteImages: pasteTrayImages,
|
|
2684
|
-
onKeyDown: (event) => {
|
|
2685
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
2686
|
-
event.preventDefault();
|
|
2687
|
-
saveTrayEdit();
|
|
2688
|
-
}
|
|
2689
|
-
},
|
|
2690
|
-
}),
|
|
2691
|
-
h(ImagePicker, {
|
|
2692
|
-
images: trayEditing.images || [],
|
|
2693
|
-
onChange: (images) => setTrayEditing((current) => (current ? { ...current, images } : current)),
|
|
2694
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
2695
|
-
onOpen: openImage,
|
|
2696
|
-
}),
|
|
2697
|
-
h(
|
|
2698
|
-
'div',
|
|
2699
|
-
{ className: 'pp-edit-actions' },
|
|
2700
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: () => setTrayEditing(null) }, translate('row.cancel')),
|
|
2701
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: saveTrayEdit }, translate('row.save')),
|
|
2702
|
-
),
|
|
2703
|
-
);
|
|
2704
|
-
}
|
|
2705
|
-
return h(
|
|
2706
|
-
'div',
|
|
2707
|
-
{ key: entry.key, className: 'pp-chip' },
|
|
2708
|
-
h('span', { className: 'pp-chip-n' }, String(index + 1) + '.'),
|
|
2709
|
-
h('div', { className: 'pp-chip-t', title: entry.body }, entry.body),
|
|
2710
|
-
h(ImageStrip, { images: entry.images, compact: true, max: 4, onOpen: openImage }),
|
|
2711
|
-
h(
|
|
2712
|
-
'div',
|
|
2713
|
-
{ className: 'pp-chip-actions' },
|
|
2714
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.moveTray(entry.key, -1) }),
|
|
2715
|
-
h(IconButton, {
|
|
2716
|
-
name: 'down',
|
|
2717
|
-
label: translate('row.down'),
|
|
2718
|
-
disabled: index === state.tray.length - 1,
|
|
2719
|
-
onClick: () => poolActions.moveTray(entry.key, 1),
|
|
2720
|
-
}),
|
|
2721
|
-
h(IconButton, {
|
|
2722
|
-
name: 'edit',
|
|
2723
|
-
label: translate('row.edit'),
|
|
2724
|
-
onClick: () => setTrayEditing({ key: entry.key, body: entry.body || '', images: normalizeImages(entry.images) }),
|
|
2725
|
-
}),
|
|
2726
|
-
h(IconButton, { name: 'copy', label: translate('tray.duplicate'), onClick: () => poolActions.duplicateTray(entry.key) }),
|
|
2727
|
-
h(IconButton, { name: 'close', label: translate('tray.remove'), onClick: () => setPendingRemove(entry) }),
|
|
2728
|
-
),
|
|
2729
|
-
);
|
|
2730
|
-
}),
|
|
2731
|
-
),
|
|
2732
|
-
),
|
|
3116
|
+
? null
|
|
3117
|
+
: renderTrayCard({
|
|
3118
|
+
entries: state.tray,
|
|
3119
|
+
queuePending,
|
|
3120
|
+
collapsed: queueCollapsed,
|
|
3121
|
+
sessionId: activeSessionId,
|
|
3122
|
+
trayRef,
|
|
3123
|
+
editing: trayEditing,
|
|
3124
|
+
setEditing: setTrayEditing,
|
|
3125
|
+
onSaveEdit: saveTrayEdit,
|
|
3126
|
+
onPasteImages: pasteTrayImages,
|
|
3127
|
+
onClear: () => setConfirmClear(true),
|
|
3128
|
+
onRelease: () => sendToComposer({ type: 'release' }, translate('status.releaseSent')),
|
|
3129
|
+
onRemove: setPendingRemove,
|
|
3130
|
+
onOpenImage: openImage,
|
|
3131
|
+
onError: (text) => flash({ kind: 'error', text }),
|
|
3132
|
+
}),
|
|
2733
3133
|
h(ImageLightbox, { preview, onClose: closeImage }),
|
|
2734
3134
|
),
|
|
3135
|
+
renderReleaseOverlay({ state: releaseInfo, onStop: () => bridge.request({ type: 'stop' }) }),
|
|
2735
3136
|
);
|
|
2736
3137
|
}
|
|
2737
3138
|
|
|
@@ -3067,7 +3468,7 @@ window.__ModuleLoader__.load({
|
|
|
3067
3468
|
setActive(0);
|
|
3068
3469
|
};
|
|
3069
3470
|
|
|
3070
|
-
const sessionTag = () => (props.sessionId ? 'session=' + String(props.sessionId).slice(-8) : '
|
|
3471
|
+
const sessionTag = () => (props.sessionId ? 'session=' + String(props.sessionId).slice(-8) : translate('mention.noSessionTag'));
|
|
3071
3472
|
|
|
3072
3473
|
const openFor = (value, caret) => {
|
|
3073
3474
|
const before = String(value || '').slice(0, caret);
|
|
@@ -3126,7 +3527,7 @@ window.__ModuleLoader__.load({
|
|
|
3126
3527
|
window.clearTimeout(timer);
|
|
3127
3528
|
setItems([]);
|
|
3128
3529
|
setNote(
|
|
3129
|
-
translate('mention.failed') + '
|
|
3530
|
+
translate('mention.failed') + ': ' + String((error && error.message) || error).slice(0, 90) + ' · ' + sessionTag(),
|
|
3130
3531
|
);
|
|
3131
3532
|
return;
|
|
3132
3533
|
}
|
|
@@ -3143,7 +3544,7 @@ window.__ModuleLoader__.load({
|
|
|
3143
3544
|
setItems([]);
|
|
3144
3545
|
const message = String((error && error.message) || error).slice(0, 90);
|
|
3145
3546
|
setNote(
|
|
3146
|
-
(abort.signal.aborted ? translate('mention.timeout') : translate('mention.failed') + '
|
|
3547
|
+
(abort.signal.aborted ? translate('mention.timeout') : translate('mention.failed') + ': ' + message) +
|
|
3147
3548
|
' · ' +
|
|
3148
3549
|
sessionTag(),
|
|
3149
3550
|
);
|
|
@@ -3158,7 +3559,7 @@ window.__ModuleLoader__.load({
|
|
|
3158
3559
|
workspace
|
|
3159
3560
|
.listDirectory(undefined)
|
|
3160
3561
|
.then((listing) => {
|
|
3161
|
-
apply(entriesOfListing(listing).map((entry) => ({ name: entry.name, hint: entry.directory ? '
|
|
3562
|
+
apply(entriesOfListing(listing).map((entry) => ({ name: entry.name, hint: entry.directory ? translate('mention.directory') : '' })), query);
|
|
3162
3563
|
})
|
|
3163
3564
|
.catch(() => apply([], query));
|
|
3164
3565
|
};
|
|
@@ -3179,7 +3580,7 @@ window.__ModuleLoader__.load({
|
|
|
3179
3580
|
openFor(event.target.value, event.target.selectionStart || 0);
|
|
3180
3581
|
} catch (error) {
|
|
3181
3582
|
setItems([]);
|
|
3182
|
-
setNote(translate('mention.failed') + '
|
|
3583
|
+
setNote(translate('mention.failed') + ': ' + String((error && error.message) || error).slice(0, 90));
|
|
3183
3584
|
}
|
|
3184
3585
|
},
|
|
3185
3586
|
onPaste: (event) => {
|
|
@@ -3275,6 +3676,8 @@ window.__ModuleLoader__.load({
|
|
|
3275
3676
|
function PromptPoolPanel(props) {
|
|
3276
3677
|
useLocaleTick();
|
|
3277
3678
|
const state = usePoolState();
|
|
3679
|
+
const storage = useStorageState();
|
|
3680
|
+
const releaseInfo = useReleaseState();
|
|
3278
3681
|
const view = useUiState();
|
|
3279
3682
|
const workspaces = useWorkspaceDir();
|
|
3280
3683
|
const sessionHint = useSessionDir().sessionId;
|
|
@@ -3329,8 +3732,6 @@ window.__ModuleLoader__.load({
|
|
|
3329
3732
|
|
|
3330
3733
|
const [tab, setTab] = useState('all');
|
|
3331
3734
|
const [query, setQuery] = useState('');
|
|
3332
|
-
const [editing, setEditing] = useState(null);
|
|
3333
|
-
const [trayEditing, setTrayEditing] = useState(null);
|
|
3334
3735
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
3335
3736
|
const [pendingCategory, setPendingCategory] = useState(null);
|
|
3336
3737
|
const [wsSelected, setWsSelected] = useState('');
|
|
@@ -3339,6 +3740,7 @@ window.__ModuleLoader__.load({
|
|
|
3339
3740
|
const [confirmClear, setConfirmClear] = useState(false);
|
|
3340
3741
|
const [pendingDelete, setPendingDelete] = useState(null);
|
|
3341
3742
|
const [pendingRemove, setPendingRemove] = useState(null);
|
|
3743
|
+
const [captureOpen, setCaptureOpen] = useState(false);
|
|
3342
3744
|
const [status, setStatus] = useState(null);
|
|
3343
3745
|
const [busy, setBusy] = useState(false);
|
|
3344
3746
|
const { preview, openImage, closeImage } = useImagePreview();
|
|
@@ -3351,6 +3753,12 @@ window.__ModuleLoader__.load({
|
|
|
3351
3753
|
}, []);
|
|
3352
3754
|
useEffect(() => () => window.clearTimeout(statusTimer.current), []);
|
|
3353
3755
|
|
|
3756
|
+
const { editing, setEditing, startEdit, save, cancelEdit, pasteImages } = usePoolEditor(flash);
|
|
3757
|
+
const { trayEditing, setTrayEditing, saveTrayEdit, pasteTrayImages } = useTrayEditor(flash);
|
|
3758
|
+
|
|
3759
|
+
// A failed write outranks a transient toast: the change is not saved.
|
|
3760
|
+
const notice = status || (storage.failed ? { kind: 'error', text: translate('status.storageFailed') } : null);
|
|
3761
|
+
|
|
3354
3762
|
const confirmCategoryDelete = () => {
|
|
3355
3763
|
const target = pendingCategory;
|
|
3356
3764
|
setPendingCategory(null);
|
|
@@ -3360,13 +3768,21 @@ window.__ModuleLoader__.load({
|
|
|
3360
3768
|
};
|
|
3361
3769
|
|
|
3362
3770
|
const panelRef = useRef(null);
|
|
3771
|
+
const panelChrome = normalizeSettings(state.settings);
|
|
3363
3772
|
|
|
3364
3773
|
// The panel can be dragged taller or shorter; 0 means the CSS default.
|
|
3365
3774
|
const [dragHeight, setDragHeight] = useState(0);
|
|
3366
|
-
const panelHeight = dragHeight ||
|
|
3775
|
+
const panelHeight = dragHeight || panelChrome.panelHeight;
|
|
3367
3776
|
const panelHeightRef = useRef(panelHeight);
|
|
3368
3777
|
panelHeightRef.current = panelHeight;
|
|
3369
3778
|
|
|
3779
|
+
// The panel's left edge can be dragged too; 0 means the CSS default width.
|
|
3780
|
+
const [dragWidth, setDragWidth] = useState(0);
|
|
3781
|
+
const panelWidth = dragWidth || panelChrome.panelWidth;
|
|
3782
|
+
const panelWidthRef = useRef(panelWidth);
|
|
3783
|
+
panelWidthRef.current = panelWidth;
|
|
3784
|
+
const panelPinned = panelChrome.panelPinned;
|
|
3785
|
+
|
|
3370
3786
|
// Room from the top of the pane that clips the panel down to the panel's
|
|
3371
3787
|
// own bottom edge. The overlay anchors that bottom edge to the composer,
|
|
3372
3788
|
// and a new session puts the composer mid-page, so the panel is capped by
|
|
@@ -3430,8 +3846,44 @@ window.__ModuleLoader__.load({
|
|
|
3430
3846
|
poolActions.setSetting('panelHeight', 0);
|
|
3431
3847
|
};
|
|
3432
3848
|
|
|
3849
|
+
const startResizeWidth = (event) => {
|
|
3850
|
+
if (event.button !== undefined && event.button !== 0) return;
|
|
3851
|
+
event.preventDefault();
|
|
3852
|
+
const node = panelRef.current;
|
|
3853
|
+
const rect = node ? node.getBoundingClientRect() : null;
|
|
3854
|
+
const startX = event.clientX;
|
|
3855
|
+
const startWidth = rect ? rect.width : panelWidthRef.current || 920;
|
|
3856
|
+
// The slot wrapper around the panel can be a zero-width anchor, so the
|
|
3857
|
+
// limit comes from the containing block (offsetParent) and the panel's
|
|
3858
|
+
// anchored right edge, not from parentElement.
|
|
3859
|
+
const containing = node && node.offsetParent ? node.offsetParent.getBoundingClientRect() : null;
|
|
3860
|
+
const byParent = containing && containing.width > 0 ? containing.width : Infinity;
|
|
3861
|
+
const byRight = rect && rect.right > 0 ? rect.right - 8 : window.innerWidth - 24;
|
|
3862
|
+
const ceiling = Math.max(360, Math.round(Math.min(window.innerWidth - 24, byParent, byRight)));
|
|
3863
|
+
let latest = Math.round(startWidth);
|
|
3864
|
+
const apply = (clientX) => {
|
|
3865
|
+
latest = Math.round(Math.min(ceiling, Math.max(360, startWidth + (startX - clientX))));
|
|
3866
|
+
setDragWidth(latest);
|
|
3867
|
+
};
|
|
3868
|
+
const onMove = (moveEvent) => {
|
|
3869
|
+
moveEvent.preventDefault();
|
|
3870
|
+
apply(moveEvent.clientX);
|
|
3871
|
+
};
|
|
3872
|
+
const onUp = () => {
|
|
3873
|
+
window.removeEventListener('pointermove', onMove);
|
|
3874
|
+
window.removeEventListener('pointerup', onUp);
|
|
3875
|
+
poolActions.setSetting('panelWidth', latest);
|
|
3876
|
+
};
|
|
3877
|
+
window.addEventListener('pointermove', onMove);
|
|
3878
|
+
window.addEventListener('pointerup', onUp);
|
|
3879
|
+
};
|
|
3880
|
+
const resetResizeWidth = () => {
|
|
3881
|
+
setDragWidth(0);
|
|
3882
|
+
poolActions.setSetting('panelWidth', 0);
|
|
3883
|
+
};
|
|
3884
|
+
|
|
3433
3885
|
useEffect(() => {
|
|
3434
|
-
if (!view.open) return undefined;
|
|
3886
|
+
if (!view.open || panelPinned) return undefined;
|
|
3435
3887
|
const onPointerDown = (event) => {
|
|
3436
3888
|
const target = event.target;
|
|
3437
3889
|
if (!(target instanceof Element)) return;
|
|
@@ -3441,12 +3893,12 @@ window.__ModuleLoader__.load({
|
|
|
3441
3893
|
};
|
|
3442
3894
|
document.addEventListener('pointerdown', onPointerDown, true);
|
|
3443
3895
|
return () => document.removeEventListener('pointerdown', onPointerDown, true);
|
|
3444
|
-
}, [view.open]);
|
|
3896
|
+
}, [view.open, panelPinned]);
|
|
3445
3897
|
|
|
3446
3898
|
useEffect(() => {
|
|
3447
3899
|
if (!view.open || preview) return undefined;
|
|
3448
3900
|
const onKey = (event) => {
|
|
3449
|
-
if (event.key !== 'Escape') return;
|
|
3901
|
+
if (event.key !== 'Escape' || captureOpen) return;
|
|
3450
3902
|
if (editing) {
|
|
3451
3903
|
setEditing(null);
|
|
3452
3904
|
} else {
|
|
@@ -3457,7 +3909,7 @@ window.__ModuleLoader__.load({
|
|
|
3457
3909
|
};
|
|
3458
3910
|
window.addEventListener('keydown', onKey, true);
|
|
3459
3911
|
return () => window.removeEventListener('keydown', onKey, true);
|
|
3460
|
-
}, [view.open, editing, preview]);
|
|
3912
|
+
}, [view.open, editing, preview, captureOpen]);
|
|
3461
3913
|
|
|
3462
3914
|
const rail = workspaceRail(workspaces.items, state.settings, currentWorkspaceId);
|
|
3463
3915
|
const wsActive = rail.some((entry) => entry.id === wsSelected) ? wsSelected : rail.length > 0 ? rail[0].id : '';
|
|
@@ -3490,18 +3942,79 @@ window.__ModuleLoader__.load({
|
|
|
3490
3942
|
actions.setDraft(text);
|
|
3491
3943
|
};
|
|
3492
3944
|
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
if (list.length === 0) return 0;
|
|
3496
|
-
if (!actions || typeof actions.addAttachments !== 'function') throw new Error(translate('image.insertFailed'));
|
|
3497
|
-
const api = conversationFace || serviceOf(pluginCtx, 'conversation');
|
|
3498
|
-
if (!api || typeof api.createDrafts !== 'function' || !props.sessionId) throw new Error(translate('image.insertFailed'));
|
|
3945
|
+
/** Bytes for pooled images, as browser files the host can accept. */
|
|
3946
|
+
const loadImageFiles = async (images) => {
|
|
3499
3947
|
const files = [];
|
|
3500
|
-
for (const image of
|
|
3948
|
+
for (const image of normalizeImages(images)) {
|
|
3501
3949
|
const blob = await getImageBlob(image.id);
|
|
3502
3950
|
if (!blob) throw new Error(translate('image.missing'));
|
|
3503
3951
|
files.push(new File([blob], image.name || 'image', { type: image.type || blob.type || 'image/png' }));
|
|
3504
3952
|
}
|
|
3953
|
+
return files;
|
|
3954
|
+
};
|
|
3955
|
+
|
|
3956
|
+
/**
|
|
3957
|
+
* The host's queue admission, if this context can reach it. Sending here
|
|
3958
|
+
* keeps the composer untouched, which is the only way a batch release
|
|
3959
|
+
* avoids resizing the input for every item.
|
|
3960
|
+
*/
|
|
3961
|
+
const resolveDirectQueue = () => {
|
|
3962
|
+
if (!props.sessionId) return null;
|
|
3963
|
+
const candidates = [];
|
|
3964
|
+
const base = conversationFace || serviceOf(pluginCtx, 'conversation');
|
|
3965
|
+
if (base) candidates.push(base);
|
|
3966
|
+
const sessions = sessionsFace || serviceOf(pluginCtx, 'sessions');
|
|
3967
|
+
if (sessions && typeof sessions.scope === 'function') {
|
|
3968
|
+
try {
|
|
3969
|
+
const scoped = sessions.scope(props.sessionId);
|
|
3970
|
+
const scopedConversation = serviceOf(scoped, 'conversation');
|
|
3971
|
+
if (scopedConversation) candidates.push(scopedConversation);
|
|
3972
|
+
} catch (_error) {
|
|
3973
|
+
/* the context is not session-scoped */
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
for (const api of candidates) {
|
|
3977
|
+
if (typeof api.createDrafts !== 'function' || typeof api.sendSession !== 'function' || typeof api.scopedSession !== 'function') continue;
|
|
3978
|
+
try {
|
|
3979
|
+
const session = api.scopedSession('send');
|
|
3980
|
+
if (session && typeof session.prompt === 'function' && typeof session.beginSubmission === 'function') return { api, session };
|
|
3981
|
+
} catch (_error) {
|
|
3982
|
+
/* root-scoped service; try the next candidate */
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
return null;
|
|
3986
|
+
};
|
|
3987
|
+
|
|
3988
|
+
/** Queue one occurrence without touching the composer. */
|
|
3989
|
+
const sendDirect = async (direct, body, images) => {
|
|
3990
|
+
const files = images.length > 0 ? await loadImageFiles(images) : [];
|
|
3991
|
+
let drafts = [];
|
|
3992
|
+
if (files.length > 0) {
|
|
3993
|
+
drafts = direct.api.createDrafts(props.sessionId, files);
|
|
3994
|
+
if (!Array.isArray(drafts) || drafts.length !== files.length) throw new Error(translate('image.insertFailed'));
|
|
3995
|
+
}
|
|
3996
|
+
try {
|
|
3997
|
+
const outcome = await direct.api.sendSession(direct.session, body, drafts.map((draft) => draft.id), 'queue');
|
|
3998
|
+
if (!outcome || outcome.kind !== 'success') throw new Error(translate('status.queueFailed'));
|
|
3999
|
+
} catch (error) {
|
|
4000
|
+
if (drafts.length > 0 && typeof direct.api.releaseDraftAttachments === 'function') {
|
|
4001
|
+
try {
|
|
4002
|
+
direct.api.releaseDraftAttachments(drafts);
|
|
4003
|
+
} catch (_cleanupError) {
|
|
4004
|
+
/* the draft attachment owner may already be gone */
|
|
4005
|
+
}
|
|
4006
|
+
}
|
|
4007
|
+
throw error;
|
|
4008
|
+
}
|
|
4009
|
+
return drafts.length;
|
|
4010
|
+
};
|
|
4011
|
+
|
|
4012
|
+
const addImages = async (images) => {
|
|
4013
|
+
const files = await loadImageFiles(images);
|
|
4014
|
+
if (files.length === 0) return 0;
|
|
4015
|
+
if (!actions || typeof actions.addAttachments !== 'function') throw new Error(translate('image.insertFailed'));
|
|
4016
|
+
const api = conversationFace || serviceOf(pluginCtx, 'conversation');
|
|
4017
|
+
if (!api || typeof api.createDrafts !== 'function' || !props.sessionId) throw new Error(translate('image.insertFailed'));
|
|
3505
4018
|
const drafts = api.createDrafts(props.sessionId, files);
|
|
3506
4019
|
if (!Array.isArray(drafts) || drafts.length !== files.length) throw new Error(translate('image.insertFailed'));
|
|
3507
4020
|
try {
|
|
@@ -3546,23 +4059,6 @@ window.__ModuleLoader__.load({
|
|
|
3546
4059
|
}
|
|
3547
4060
|
};
|
|
3548
4061
|
|
|
3549
|
-
const saveTrayEdit = () => {
|
|
3550
|
-
if (!trayEditing) return;
|
|
3551
|
-
if (!trayEditing.body.trim() && !(trayEditing.images && trayEditing.images.length)) {
|
|
3552
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
3553
|
-
return;
|
|
3554
|
-
}
|
|
3555
|
-
poolActions.patchTray(trayEditing.key, { body: trayEditing.body, images: trayEditing.images || [] });
|
|
3556
|
-
setTrayEditing(null);
|
|
3557
|
-
};
|
|
3558
|
-
|
|
3559
|
-
const pasteTrayImages = (files) => {
|
|
3560
|
-
const key = trayEditing && trayEditing.key;
|
|
3561
|
-
appendImageAssets(files, trayEditing && trayEditing.images ? trayEditing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
3562
|
-
setTrayEditing((current) => (current && current.key === key ? { ...current, images } : current));
|
|
3563
|
-
});
|
|
3564
|
-
};
|
|
3565
|
-
|
|
3566
4062
|
/** The composer's draft attachments as descriptors, when the host exposes them. */
|
|
3567
4063
|
const resolveAttachments = () => {
|
|
3568
4064
|
const api = conversationFace || serviceOf(pluginCtx, 'conversation');
|
|
@@ -3575,12 +4071,22 @@ window.__ModuleLoader__.load({
|
|
|
3575
4071
|
}
|
|
3576
4072
|
};
|
|
3577
4073
|
|
|
4074
|
+
/** Only open the destination chooser when the composer has something. */
|
|
4075
|
+
const openCapture = () => {
|
|
4076
|
+
if (!draftRef.current.trim()) {
|
|
4077
|
+
flash({ kind: 'error', text: translate('status.nothing') });
|
|
4078
|
+
return;
|
|
4079
|
+
}
|
|
4080
|
+
setCaptureOpen(true);
|
|
4081
|
+
};
|
|
4082
|
+
|
|
3578
4083
|
/**
|
|
3579
4084
|
* Copies the composer content into the pool; the composer keeps its text.
|
|
3580
4085
|
* Attached images come along (their browser files are copied into the pool's
|
|
3581
4086
|
* image store); other files have no local copy to keep, so they are counted.
|
|
3582
4087
|
*/
|
|
3583
|
-
const captureDraft = async () => {
|
|
4088
|
+
const captureDraft = async (groupArg) => {
|
|
4089
|
+
const group = typeof groupArg === 'string' && familyOf(groupArg) ? groupArg : BUILTIN_GROUP.note;
|
|
3584
4090
|
const text = draftRef.current;
|
|
3585
4091
|
if (!text || !text.trim()) {
|
|
3586
4092
|
flash({ kind: 'error', text: translate('status.nothing') });
|
|
@@ -3595,7 +4101,7 @@ window.__ModuleLoader__.load({
|
|
|
3595
4101
|
}
|
|
3596
4102
|
const item = {
|
|
3597
4103
|
id: uid(),
|
|
3598
|
-
group
|
|
4104
|
+
group,
|
|
3599
4105
|
title: draftTitle(text, occurrenceRef.current),
|
|
3600
4106
|
body: text,
|
|
3601
4107
|
images: normalizeImages(stored),
|
|
@@ -3603,13 +4109,14 @@ window.__ModuleLoader__.load({
|
|
|
3603
4109
|
updatedAt: Date.now(),
|
|
3604
4110
|
};
|
|
3605
4111
|
poolActions.add(item);
|
|
3606
|
-
// The copy lands in
|
|
4112
|
+
// The copy lands in the chosen group, which a folded/workspace tab may not show.
|
|
3607
4113
|
if (!matchesTab(item, tab)) setTab('all');
|
|
3608
4114
|
const skipped = others.length + (images.length - item.images.length);
|
|
4115
|
+
const label = groupLabelOf(item, state.categories, workspaces.items);
|
|
3609
4116
|
flash(skipped > 0
|
|
3610
|
-
? { kind: 'info', text: translate('status.
|
|
3611
|
-
: { kind: 'ok', text: translate('status.
|
|
3612
|
-
return { ok: true, skipped };
|
|
4117
|
+
? { kind: 'info', text: translate('status.savedPartialTo', { group: label, n: skipped }) }
|
|
4118
|
+
: { kind: 'ok', text: translate('status.savedTo', { group: label }) });
|
|
4119
|
+
return { ok: true, skipped, label };
|
|
3613
4120
|
};
|
|
3614
4121
|
|
|
3615
4122
|
const newItem = () => {
|
|
@@ -3631,42 +4138,6 @@ window.__ModuleLoader__.load({
|
|
|
3631
4138
|
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
3632
4139
|
};
|
|
3633
4140
|
|
|
3634
|
-
/**
|
|
3635
|
-
* Cancel drops an item the editor created and never saved, so no empty
|
|
3636
|
-
* row is left behind; an existing item keeps its stored content.
|
|
3637
|
-
*/
|
|
3638
|
-
const cancelEdit = () => {
|
|
3639
|
-
const current = editing;
|
|
3640
|
-
setEditing(null);
|
|
3641
|
-
if (!current) return;
|
|
3642
|
-
const stored = pool.get().items.find((item) => item.id === current.id);
|
|
3643
|
-
if (stored && !stored.body.trim() && !(stored.images && stored.images.length > 0)) poolActions.remove(stored.id);
|
|
3644
|
-
};
|
|
3645
|
-
|
|
3646
|
-
const startEdit = (item) => setEditing({ id: item.id, group: groupOf(item), title: item.title, body: item.body, images: normalizeImages(item.images) });
|
|
3647
|
-
|
|
3648
|
-
const saveEdit = () => {
|
|
3649
|
-
if (!editing) return;
|
|
3650
|
-
if (!editing.body.trim() && (!editing.images || editing.images.length === 0)) {
|
|
3651
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
3652
|
-
return;
|
|
3653
|
-
}
|
|
3654
|
-
poolActions.patch(editing.id, {
|
|
3655
|
-
group: editing.group,
|
|
3656
|
-
title: editing.title.trim(),
|
|
3657
|
-
body: editing.body,
|
|
3658
|
-
images: editing.images || [],
|
|
3659
|
-
});
|
|
3660
|
-
setEditing(null);
|
|
3661
|
-
};
|
|
3662
|
-
|
|
3663
|
-
const pasteImages = (files) => {
|
|
3664
|
-
const id = editing && editing.id;
|
|
3665
|
-
appendImageAssets(files, editing && editing.images ? editing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
3666
|
-
setEditing((current) => (current && current.id === id ? { ...current, images } : current));
|
|
3667
|
-
});
|
|
3668
|
-
};
|
|
3669
|
-
|
|
3670
4141
|
const deleteItem = (item, text) => {
|
|
3671
4142
|
const index = pool.get().items.findIndex((entry) => entry.id === item.id);
|
|
3672
4143
|
poolActions.remove(item.id);
|
|
@@ -3692,26 +4163,54 @@ window.__ModuleLoader__.load({
|
|
|
3692
4163
|
if (busyRef.current) return;
|
|
3693
4164
|
const entries = state.tray.slice();
|
|
3694
4165
|
if (entries.length === 0) return;
|
|
3695
|
-
|
|
4166
|
+
const direct = resolveDirectQueue();
|
|
4167
|
+
if (!direct && draftRef.current.trim() !== '') {
|
|
3696
4168
|
flash({ kind: 'error', text: translate('status.draftBusy') });
|
|
3697
4169
|
return;
|
|
3698
4170
|
}
|
|
3699
4171
|
busyRef.current = true;
|
|
3700
4172
|
setBusy(true);
|
|
4173
|
+
releaseCancel = false;
|
|
4174
|
+
releaseState.set({ active: true, sent: 0, total: entries.length, stopping: false });
|
|
3701
4175
|
setStatus({ kind: 'info', text: translate('status.releasing', { n: entries.length }) });
|
|
3702
4176
|
let sent = 0;
|
|
4177
|
+
let canceled = false;
|
|
4178
|
+
let failed = false;
|
|
3703
4179
|
// Keys finished by this run; the queue is filtered by key afterwards so
|
|
3704
4180
|
// rows queued (or removed) meanwhile are not overwritten.
|
|
3705
4181
|
const done = [];
|
|
3706
4182
|
try {
|
|
3707
4183
|
for (const entry of entries) {
|
|
4184
|
+
if (releaseCancel) {
|
|
4185
|
+
canceled = true;
|
|
4186
|
+
break;
|
|
4187
|
+
}
|
|
3708
4188
|
const body = typeof entry.body === 'string' ? entry.body : '';
|
|
3709
4189
|
const images = normalizeImages(entry.images);
|
|
3710
4190
|
if (!body.trim() && images.length === 0) {
|
|
3711
4191
|
done.push(entry.key);
|
|
3712
4192
|
continue;
|
|
3713
4193
|
}
|
|
3714
|
-
|
|
4194
|
+
if (direct) {
|
|
4195
|
+
try {
|
|
4196
|
+
// Straight into the host queue: the composer is never touched,
|
|
4197
|
+
// so a batch release cannot resize the input per item.
|
|
4198
|
+
await sendDirect(direct, body, images);
|
|
4199
|
+
} catch (error) {
|
|
4200
|
+
failed = true;
|
|
4201
|
+
flash({ kind: 'error', text: String((error && error.message) || error) });
|
|
4202
|
+
break;
|
|
4203
|
+
}
|
|
4204
|
+
sent += 1;
|
|
4205
|
+
done.push(entry.key);
|
|
4206
|
+
releaseState.set({ active: true, sent, total: entries.length, stopping: releaseCancel });
|
|
4207
|
+
if (releaseCancel) {
|
|
4208
|
+
canceled = true;
|
|
4209
|
+
break;
|
|
4210
|
+
}
|
|
4211
|
+
continue;
|
|
4212
|
+
}
|
|
4213
|
+
const clear = await waitFor(() => draftRef.current.trim() === '' && phaseRef.current === 'plain', RELEASE_WAIT.idle);
|
|
3715
4214
|
if (!clear) break;
|
|
3716
4215
|
try {
|
|
3717
4216
|
if (images.length > 0) await addImages(images);
|
|
@@ -3724,14 +4223,10 @@ window.__ModuleLoader__.load({
|
|
|
3724
4223
|
const pendingBefore = pendingRef.current.length;
|
|
3725
4224
|
try {
|
|
3726
4225
|
setDraft(body);
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
// Wait until the editor really holds this occurrence before submitting it.
|
|
3732
|
-
const loaded = await waitFor(() => draftRef.current.trim() === body.trim(), 2500);
|
|
3733
|
-
if (!loaded) break;
|
|
3734
|
-
try {
|
|
4226
|
+
// The host applies setDraft as a discrete editor update and submit
|
|
4227
|
+
// clears the draft in the same transaction. Submitting here keeps
|
|
4228
|
+
// the prompt from being painted into the composer between the two
|
|
4229
|
+
// steps, which made the conversation flash for every queued item.
|
|
3735
4230
|
actions.submit();
|
|
3736
4231
|
} catch (error) {
|
|
3737
4232
|
flash({ kind: 'error', text: String((error && error.message) || error) });
|
|
@@ -3741,134 +4236,68 @@ window.__ModuleLoader__.load({
|
|
|
3741
4236
|
() =>
|
|
3742
4237
|
(queueRef.current.length > queuedBefore || pendingRef.current.length > pendingBefore) &&
|
|
3743
4238
|
draftRef.current.trim() === '',
|
|
3744
|
-
|
|
4239
|
+
RELEASE_WAIT.accept,
|
|
3745
4240
|
);
|
|
3746
4241
|
if (!accepted) {
|
|
3747
4242
|
// The first send of an idle session becomes the live turn, not a queue row.
|
|
3748
4243
|
if (!(sent === 0 && draftRef.current.trim() === '')) break;
|
|
3749
4244
|
}
|
|
3750
|
-
await waitFor(() => phaseRef.current === 'plain',
|
|
4245
|
+
await waitFor(() => phaseRef.current === 'plain', RELEASE_WAIT.plain);
|
|
3751
4246
|
sent += 1;
|
|
3752
4247
|
done.push(entry.key);
|
|
4248
|
+
releaseState.set({ active: true, sent, total: entries.length, stopping: releaseCancel });
|
|
4249
|
+
if (releaseCancel) {
|
|
4250
|
+
canceled = true;
|
|
4251
|
+
break;
|
|
4252
|
+
}
|
|
3753
4253
|
}
|
|
3754
4254
|
} catch (error) {
|
|
3755
4255
|
flash({ kind: 'error', text: String((error && error.message) || error) });
|
|
3756
4256
|
} finally {
|
|
3757
4257
|
busyRef.current = false;
|
|
3758
4258
|
setBusy(false);
|
|
4259
|
+
releaseState.set({ active: false, sent, total: entries.length, stopping: false });
|
|
4260
|
+
releaseCancel = false;
|
|
3759
4261
|
}
|
|
3760
4262
|
poolActions.removeTrayKeys(done);
|
|
3761
|
-
|
|
3762
|
-
sent
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
return h(
|
|
3771
|
-
'div',
|
|
3772
|
-
{ key: item.id, className: 'pp-edit' },
|
|
3773
|
-
h('input', {
|
|
3774
|
-
className: 'pp-input',
|
|
3775
|
-
value: editing.title,
|
|
3776
|
-
placeholder: translate('row.titlePlaceholder'),
|
|
3777
|
-
onChange: (event) => setEditing({ ...editing, title: event.target.value }),
|
|
3778
|
-
}),
|
|
3779
|
-
h(MentionField, {
|
|
3780
|
-
value: editing.body,
|
|
3781
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
3782
|
-
rows: 4,
|
|
3783
|
-
autoFocus: true,
|
|
3784
|
-
sessionId: props.sessionId,
|
|
3785
|
-
onChange: (event) => setEditing({ ...editing, body: event.target.value }),
|
|
3786
|
-
onPasteImages: pasteImages,
|
|
3787
|
-
onKeyDown: (event) => {
|
|
3788
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
3789
|
-
event.preventDefault();
|
|
3790
|
-
saveEdit();
|
|
3791
|
-
}
|
|
3792
|
-
},
|
|
3793
|
-
}),
|
|
3794
|
-
h(ImagePicker, {
|
|
3795
|
-
images: editing.images || [],
|
|
3796
|
-
onChange: (images) => setEditing((current) => (current ? { ...current, images } : current)),
|
|
3797
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
3798
|
-
onOpen: openImage,
|
|
3799
|
-
}),
|
|
3800
|
-
h(
|
|
3801
|
-
'div',
|
|
3802
|
-
{ className: 'pp-edit-actions' },
|
|
3803
|
-
h(
|
|
3804
|
-
'select',
|
|
3805
|
-
{
|
|
3806
|
-
className: 'pp-input',
|
|
3807
|
-
style: { width: 'auto', maxWidth: '220px' },
|
|
3808
|
-
value: groupOf(editing),
|
|
3809
|
-
'aria-label': translate('row.classification'),
|
|
3810
|
-
onChange: (event) => setEditing(withGroup(editing, event.target.value)),
|
|
3811
|
-
},
|
|
3812
|
-
h(
|
|
3813
|
-
'optgroup',
|
|
3814
|
-
{ label: translate('row.familyBuiltin') },
|
|
3815
|
-
h('option', { value: BUILTIN_GROUP.oftenuse }, translate('group.oftenuse')),
|
|
3816
|
-
h('option', { value: BUILTIN_GROUP.note }, translate('group.note')),
|
|
3817
|
-
h('option', { value: BUILTIN_GROUP.template }, translate('group.template')),
|
|
3818
|
-
),
|
|
3819
|
-
workspaces.items.length > 0
|
|
3820
|
-
? h(
|
|
3821
|
-
'optgroup',
|
|
3822
|
-
{ label: translate('row.familyWorkspace') },
|
|
3823
|
-
workspaces.items.map((workspace) => h('option', { key: workspace.id, value: 'workspace:' + workspace.workspaceId }, workspace.name)),
|
|
3824
|
-
)
|
|
3825
|
-
: null,
|
|
3826
|
-
state.categories.length > 0
|
|
3827
|
-
? h(
|
|
3828
|
-
'optgroup',
|
|
3829
|
-
{ label: translate('row.familyCustom') },
|
|
3830
|
-
state.categories.map((category) => h('option', { key: category.id, value: 'custom:' + category.id }, category.name)),
|
|
3831
|
-
)
|
|
3832
|
-
: null,
|
|
3833
|
-
),
|
|
3834
|
-
h('span', { className: 'pp-grow' }),
|
|
3835
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: cancelEdit }, translate('row.cancel')),
|
|
3836
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: saveEdit }, translate('row.save')),
|
|
3837
|
-
),
|
|
4263
|
+
if (canceled) {
|
|
4264
|
+
flash({ kind: 'info', text: translate('status.releaseHalted', { n: sent, rest: entries.length - sent }) });
|
|
4265
|
+
} else if (failed) {
|
|
4266
|
+
flash({ kind: 'error', text: translate('status.releaseFailed', { n: sent, rest: entries.length - sent }) });
|
|
4267
|
+
} else {
|
|
4268
|
+
flash(
|
|
4269
|
+
sent === entries.length
|
|
4270
|
+
? { kind: 'ok', text: translate('status.released', { n: sent }) }
|
|
4271
|
+
: { kind: 'error', text: translate('status.releaseStopped', { n: sent, rest: entries.length - sent }) },
|
|
3838
4272
|
);
|
|
3839
4273
|
}
|
|
3840
|
-
return h(
|
|
3841
|
-
'div',
|
|
3842
|
-
{ key: item.id, className: 'pp-row pp-page-item' },
|
|
3843
|
-
h(IconButton, { name: 'insert', label: translate('row.insert'), onClick: () => insertItem(item) }),
|
|
3844
|
-
h(TrayAdd, { label: translate('row.select'), onClick: () => queueItem(item) }),
|
|
3845
|
-
h(
|
|
3846
|
-
'div',
|
|
3847
|
-
{ className: 'pp-main', title: translate('row.insert'), onClick: () => insertItem(item) },
|
|
3848
|
-
h('div', { className: 'pp-title' }, item.title || item.body.split('\n')[0] || (item.images && item.images[0] && (item.images[0].name || translate('image.only'))) || translate('group.untitled')),
|
|
3849
|
-
item.body.trim() === (item.title || '').trim() ? null : h('div', { className: 'pp-body' }, item.body),
|
|
3850
|
-
h(ImageStrip, { images: item.images, compact: true, onOpen: openImage }),
|
|
3851
|
-
),
|
|
3852
|
-
tab === 'all'
|
|
3853
|
-
? h('span', { className: 'pp-tag' }, clipLabel(groupLabelOf(item, state.categories, workspaces.items)))
|
|
3854
|
-
: null,
|
|
3855
|
-
h(
|
|
3856
|
-
'div',
|
|
3857
|
-
{ className: 'pp-actions' },
|
|
3858
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.move(item.id, -1) }),
|
|
3859
|
-
h(IconButton, {
|
|
3860
|
-
name: 'down',
|
|
3861
|
-
label: translate('row.down'),
|
|
3862
|
-
disabled: index === items.length - 1,
|
|
3863
|
-
onClick: () => poolActions.move(item.id, 1),
|
|
3864
|
-
}),
|
|
3865
|
-
h(IconButton, { name: 'edit', label: translate('row.edit'), onClick: () => startEdit(item) }),
|
|
3866
|
-
h(IconButton, { name: 'copy', label: translate('row.duplicate'), onClick: () => poolActions.duplicateItem(item.id) }),
|
|
3867
|
-
h(IconButton, { name: 'trash', label: translate('row.delete'), danger: true, onClick: () => setPendingDelete(item) }),
|
|
3868
|
-
),
|
|
3869
|
-
);
|
|
3870
4274
|
};
|
|
3871
4275
|
|
|
4276
|
+
const rowOf = (item, index) => renderPoolRow({
|
|
4277
|
+
key: item.id,
|
|
4278
|
+
item,
|
|
4279
|
+
index,
|
|
4280
|
+
total: items.length,
|
|
4281
|
+
editing,
|
|
4282
|
+
setEditing,
|
|
4283
|
+
categories: state.categories,
|
|
4284
|
+
workspaces: workspaces.items,
|
|
4285
|
+
sessionId: props.sessionId,
|
|
4286
|
+
editRows: 4,
|
|
4287
|
+
mainTitle: translate('row.insert'),
|
|
4288
|
+
showTag: tab === 'all',
|
|
4289
|
+
onInsert: insertItem,
|
|
4290
|
+
onMain: insertItem,
|
|
4291
|
+
onStartEdit: startEdit,
|
|
4292
|
+
onQueue: queueItem,
|
|
4293
|
+
onDelete: setPendingDelete,
|
|
4294
|
+
onSave: save,
|
|
4295
|
+
onCancel: cancelEdit,
|
|
4296
|
+
onPasteImages: pasteImages,
|
|
4297
|
+
onOpenImage: openImage,
|
|
4298
|
+
onError: (text) => flash({ kind: 'error', text }),
|
|
4299
|
+
});
|
|
4300
|
+
|
|
3872
4301
|
const tray = state.tray;
|
|
3873
4302
|
const queueCollapsed = normalizeSettings(state.settings).queueCollapsed;
|
|
3874
4303
|
|
|
@@ -3906,11 +4335,18 @@ window.__ModuleLoader__.load({
|
|
|
3906
4335
|
api.release();
|
|
3907
4336
|
return { ok: true };
|
|
3908
4337
|
}
|
|
4338
|
+
if (command.type === 'stop') {
|
|
4339
|
+
return { ok: requestReleaseStop() };
|
|
4340
|
+
}
|
|
3909
4341
|
// The sidebar page cannot read the composer, so it asks for the capture.
|
|
4342
|
+
if (command.type === 'capture-check') {
|
|
4343
|
+
return { ok: true, ready: draftRef.current.trim() !== '' };
|
|
4344
|
+
}
|
|
3910
4345
|
if (command.type === 'capture') {
|
|
3911
4346
|
// The capture is async (it copies attachments), so the answer is a promise;
|
|
3912
4347
|
// reading `.ok` off it always failed and reported an empty composer.
|
|
3913
|
-
|
|
4348
|
+
const group = typeof command.group === 'string' ? command.group : '';
|
|
4349
|
+
return Promise.resolve(api.capture(group)).then(
|
|
3914
4350
|
(result) => (result && result.ok ? result : { ok: false, reason: (result && result.reason) || 'empty' }),
|
|
3915
4351
|
(error) => ({ ok: false, reason: String((error && error.message) || error) }),
|
|
3916
4352
|
);
|
|
@@ -3922,6 +4358,8 @@ window.__ModuleLoader__.load({
|
|
|
3922
4358
|
if (!view.open) return null;
|
|
3923
4359
|
|
|
3924
4360
|
const panelCount = state.items.length;
|
|
4361
|
+
const captureGroups = captureChoices(state.categories, workspaces.items, currentWorkspaceId, state.settings);
|
|
4362
|
+
const tabCounts = tabCountsOf(state.items);
|
|
3925
4363
|
|
|
3926
4364
|
// A folded family renders its groups as chips inside one tab.
|
|
3927
4365
|
const customGroups = state.categories.map((category) => ({ id: 'custom:' + category.id, name: category.name }));
|
|
@@ -3930,11 +4368,8 @@ window.__ModuleLoader__.load({
|
|
|
3930
4368
|
: customGroups.length > 0
|
|
3931
4369
|
? customGroups[0].id
|
|
3932
4370
|
: '';
|
|
3933
|
-
const customCounts =
|
|
3934
|
-
|
|
3935
|
-
const group = groupOf(item);
|
|
3936
|
-
if (familyOf(group) === 'custom') customCounts[group] = (customCounts[group] || 0) + 1;
|
|
3937
|
-
}
|
|
4371
|
+
const customCounts = groupCounts(state.items, 'custom');
|
|
4372
|
+
const builtinCounts = groupCounts(state.items, 'builtin');
|
|
3938
4373
|
const builtinList = builtinGroups();
|
|
3939
4374
|
const builtinActive = builtinList.some((entry) => entry.id === builtinPick) ? builtinPick : builtinList[0].id;
|
|
3940
4375
|
const nestedView =
|
|
@@ -3963,7 +4398,7 @@ window.__ModuleLoader__.load({
|
|
|
3963
4398
|
rail: builtinList,
|
|
3964
4399
|
activeId: builtinActive,
|
|
3965
4400
|
onSelect: setBuiltinPick,
|
|
3966
|
-
counts:
|
|
4401
|
+
counts: builtinCounts,
|
|
3967
4402
|
emptyText: translate('panel.emptyTab'),
|
|
3968
4403
|
scoped: state.items.filter((item) => groupOf(item) === builtinActive),
|
|
3969
4404
|
}
|
|
@@ -3981,6 +4416,7 @@ window.__ModuleLoader__.load({
|
|
|
3981
4416
|
panelStyle.height = size;
|
|
3982
4417
|
panelStyle.maxHeight = 'none';
|
|
3983
4418
|
}
|
|
4419
|
+
if (panelWidth) panelStyle['--pp-w'] = panelWidth + 'px';
|
|
3984
4420
|
|
|
3985
4421
|
return h(
|
|
3986
4422
|
'div',
|
|
@@ -4006,6 +4442,19 @@ window.__ModuleLoader__.load({
|
|
|
4006
4442
|
},
|
|
4007
4443
|
h('span', { className: 'pp-grip-bar' }),
|
|
4008
4444
|
),
|
|
4445
|
+
h(
|
|
4446
|
+
'div',
|
|
4447
|
+
{
|
|
4448
|
+
key: 'grip-width',
|
|
4449
|
+
className: 'pp-panel-grip-x',
|
|
4450
|
+
role: 'separator',
|
|
4451
|
+
'aria-orientation': 'vertical',
|
|
4452
|
+
title: translate('panel.resizeWidth'),
|
|
4453
|
+
onPointerDown: startResizeWidth,
|
|
4454
|
+
onDoubleClick: resetResizeWidth,
|
|
4455
|
+
},
|
|
4456
|
+
h('span', { className: 'pp-grip-bar-x' }),
|
|
4457
|
+
),
|
|
4009
4458
|
// Same header and tab strip as the sidebar page, so both views read alike.
|
|
4010
4459
|
h(
|
|
4011
4460
|
'div',
|
|
@@ -4017,11 +4466,18 @@ window.__ModuleLoader__.load({
|
|
|
4017
4466
|
className: 'pp-search',
|
|
4018
4467
|
value: query,
|
|
4019
4468
|
placeholder: translate('page.search'),
|
|
4469
|
+
'aria-label': translate('page.search'),
|
|
4020
4470
|
onChange: (event) => setQuery(event.target.value),
|
|
4021
4471
|
}),
|
|
4022
4472
|
h('button', { type: 'button', className: 'pp-mini', onClick: newItem }, '+ ', translate('page.new')),
|
|
4023
|
-
h('button', { type: 'button', className: 'pp-mini', title: translate('panel.captureHint'), onClick:
|
|
4473
|
+
h('button', { type: 'button', className: 'pp-mini', title: translate('panel.captureHint'), onClick: openCapture }, translate('panel.capture')),
|
|
4024
4474
|
h(SettingsButton, { active: settingsOpen, onClick: () => setSettingsOpen(!settingsOpen) }),
|
|
4475
|
+
h(IconButton, {
|
|
4476
|
+
name: 'pin',
|
|
4477
|
+
label: panelPinned ? translate('panel.unpin') : translate('panel.pin'),
|
|
4478
|
+
active: panelPinned,
|
|
4479
|
+
onClick: () => poolActions.setSetting('panelPinned', !panelPinned),
|
|
4480
|
+
}),
|
|
4025
4481
|
h(
|
|
4026
4482
|
'button',
|
|
4027
4483
|
{ type: 'button', className: 'pp-x', title: translate('panel.close'), 'aria-label': translate('panel.close'), onClick: () => ui.set({ open: false }) },
|
|
@@ -4033,6 +4489,7 @@ window.__ModuleLoader__.load({
|
|
|
4033
4489
|
{ className: 'pp-bar', style: { padding: '8px 12px 2px' } },
|
|
4034
4490
|
h(TabBar, {
|
|
4035
4491
|
tabs: buildTabs(state.categories, workspaces.items, state.settings, currentWorkspaceId),
|
|
4492
|
+
counts: tabCounts,
|
|
4036
4493
|
active: tab,
|
|
4037
4494
|
...tabHandlers((next) => {
|
|
4038
4495
|
setSettingsOpen(false);
|
|
@@ -4082,6 +4539,16 @@ window.__ModuleLoader__.load({
|
|
|
4082
4539
|
},
|
|
4083
4540
|
})
|
|
4084
4541
|
: null,
|
|
4542
|
+
captureOpen
|
|
4543
|
+
? h(CaptureMenu, {
|
|
4544
|
+
groups: captureGroups,
|
|
4545
|
+
onPick: (group) => {
|
|
4546
|
+
setCaptureOpen(false);
|
|
4547
|
+
captureDraft(group);
|
|
4548
|
+
},
|
|
4549
|
+
onCancel: () => setCaptureOpen(false),
|
|
4550
|
+
})
|
|
4551
|
+
: null,
|
|
4085
4552
|
h(
|
|
4086
4553
|
'div',
|
|
4087
4554
|
{ className: 'pp-list', ref: listRef },
|
|
@@ -4116,19 +4583,19 @@ window.__ModuleLoader__.load({
|
|
|
4116
4583
|
h(
|
|
4117
4584
|
'div',
|
|
4118
4585
|
{ className: 'pp-panel-dock' },
|
|
4119
|
-
|
|
4586
|
+
notice
|
|
4120
4587
|
? h(
|
|
4121
4588
|
'div',
|
|
4122
|
-
{ className: 'pp-status pp-status-float', 'data-kind':
|
|
4123
|
-
h('span', null,
|
|
4124
|
-
|
|
4589
|
+
{ className: 'pp-status pp-status-float', role: 'status', 'aria-live': 'polite', 'data-kind': notice.kind || 'info' },
|
|
4590
|
+
h('span', null, notice.text),
|
|
4591
|
+
notice.undo
|
|
4125
4592
|
? h(
|
|
4126
4593
|
'button',
|
|
4127
4594
|
{
|
|
4128
4595
|
type: 'button',
|
|
4129
4596
|
className: 'pp-link',
|
|
4130
4597
|
onClick: () => {
|
|
4131
|
-
|
|
4598
|
+
notice.undo();
|
|
4132
4599
|
},
|
|
4133
4600
|
},
|
|
4134
4601
|
translate('status.undo'),
|
|
@@ -4137,119 +4604,26 @@ window.__ModuleLoader__.load({
|
|
|
4137
4604
|
)
|
|
4138
4605
|
: null,
|
|
4139
4606
|
!settingsOpen
|
|
4140
|
-
?
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
: h(
|
|
4157
|
-
'div',
|
|
4158
|
-
{ className: 'pp-page-foot' },
|
|
4159
|
-
h(
|
|
4160
|
-
'div',
|
|
4161
|
-
{ className: 'pp-foot-head' },
|
|
4162
|
-
h(
|
|
4163
|
-
'button',
|
|
4164
|
-
{
|
|
4165
|
-
type: 'button',
|
|
4166
|
-
className: 'pp-queue-toggle',
|
|
4167
|
-
title: translate('tray.collapseTitle'),
|
|
4168
|
-
'aria-label': translate('tray.collapseTitle'),
|
|
4169
|
-
'aria-expanded': 'true',
|
|
4170
|
-
onClick: () => poolActions.setSetting('queueCollapsed', true),
|
|
4171
|
-
},
|
|
4172
|
-
h('span', { className: 'pp-queue-toggle-icon' }, icon('chevronDown')),
|
|
4173
|
-
),
|
|
4174
|
-
h('span', { className: 'pp-foot-title' }, translate('tray.title')),
|
|
4175
|
-
h('span', { className: 'pp-hint' }, translate('tray.selected', { n: tray.length })),
|
|
4176
|
-
queue.length > 0 ? h('span', { className: 'pp-hint' }, translate('tray.queue', { n: queue.length })) : null,
|
|
4177
|
-
h('span', { className: 'pp-grow' }),
|
|
4178
|
-
tray.length > 0 ? h('button', { type: 'button', className: 'pp-link', onClick: () => setConfirmClear(true) }, translate('tray.clear')) : null,
|
|
4179
|
-
tray.length > 0
|
|
4180
|
-
? h('button', { type: 'button', className: 'pp-primary', disabled: busy, onClick: release }, translate('tray.release'))
|
|
4181
|
-
: null,
|
|
4182
|
-
),
|
|
4183
|
-
h(
|
|
4184
|
-
'div',
|
|
4185
|
-
{ className: tray.length === 0 ? 'pp-tray pp-tray-empty' : 'pp-tray' },
|
|
4186
|
-
tray.length === 0
|
|
4187
|
-
? h('div', { className: 'pp-hint' }, translate('tray.empty'))
|
|
4188
|
-
: tray.map((entry, index) => {
|
|
4189
|
-
if (trayEditing && trayEditing.key === entry.key) {
|
|
4190
|
-
return h(
|
|
4191
|
-
'div',
|
|
4192
|
-
{ key: entry.key, className: 'pp-edit', style: { margin: '4px 0' } },
|
|
4193
|
-
h(MentionField, {
|
|
4194
|
-
value: trayEditing.body,
|
|
4195
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
4196
|
-
rows: 4,
|
|
4197
|
-
autoFocus: true,
|
|
4198
|
-
sessionId: props.sessionId,
|
|
4199
|
-
onChange: (event) => setTrayEditing((current) => (current ? { ...current, body: event.target.value } : current)),
|
|
4200
|
-
onPasteImages: pasteTrayImages,
|
|
4201
|
-
onKeyDown: (event) => {
|
|
4202
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
4203
|
-
event.preventDefault();
|
|
4204
|
-
saveTrayEdit();
|
|
4205
|
-
}
|
|
4206
|
-
},
|
|
4207
|
-
}),
|
|
4208
|
-
h(ImagePicker, {
|
|
4209
|
-
images: trayEditing.images || [],
|
|
4210
|
-
onChange: (images) => setTrayEditing((current) => (current ? { ...current, images } : current)),
|
|
4211
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
4212
|
-
onOpen: openImage,
|
|
4213
|
-
}),
|
|
4214
|
-
h(
|
|
4215
|
-
'div',
|
|
4216
|
-
{ className: 'pp-edit-actions' },
|
|
4217
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: () => setTrayEditing(null) }, translate('row.cancel')),
|
|
4218
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: saveTrayEdit }, translate('row.save')),
|
|
4219
|
-
),
|
|
4220
|
-
);
|
|
4221
|
-
}
|
|
4222
|
-
return h(
|
|
4223
|
-
'div',
|
|
4224
|
-
{ key: entry.key, className: 'pp-chip' },
|
|
4225
|
-
h('span', { className: 'pp-chip-n' }, String(index + 1) + '.'),
|
|
4226
|
-
h('div', { className: 'pp-chip-t', title: entry.body }, entry.body),
|
|
4227
|
-
h(ImageStrip, { images: entry.images, compact: true, max: 4, onOpen: openImage }),
|
|
4228
|
-
h(
|
|
4229
|
-
'div',
|
|
4230
|
-
{ className: 'pp-chip-actions' },
|
|
4231
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.moveTray(entry.key, -1) }),
|
|
4232
|
-
h(IconButton, {
|
|
4233
|
-
name: 'down',
|
|
4234
|
-
label: translate('row.down'),
|
|
4235
|
-
disabled: index === tray.length - 1,
|
|
4236
|
-
onClick: () => poolActions.moveTray(entry.key, 1),
|
|
4237
|
-
}),
|
|
4238
|
-
h(IconButton, {
|
|
4239
|
-
name: 'edit',
|
|
4240
|
-
label: translate('row.edit'),
|
|
4241
|
-
onClick: () => setTrayEditing({ key: entry.key, body: entry.body || '', images: normalizeImages(entry.images) }),
|
|
4242
|
-
}),
|
|
4243
|
-
h(IconButton, { name: 'copy', label: translate('tray.duplicate'), onClick: () => poolActions.duplicateTray(entry.key) }),
|
|
4244
|
-
h(IconButton, { name: 'close', label: translate('tray.remove'), onClick: () => setPendingRemove(entry) }),
|
|
4245
|
-
),
|
|
4246
|
-
);
|
|
4247
|
-
}),
|
|
4248
|
-
),
|
|
4249
|
-
)
|
|
4607
|
+
? renderTrayCard({
|
|
4608
|
+
entries: tray,
|
|
4609
|
+
queuePending: queue.length,
|
|
4610
|
+
collapsed: queueCollapsed,
|
|
4611
|
+
busy,
|
|
4612
|
+
sessionId: props.sessionId,
|
|
4613
|
+
editing: trayEditing,
|
|
4614
|
+
setEditing: setTrayEditing,
|
|
4615
|
+
onSaveEdit: saveTrayEdit,
|
|
4616
|
+
onPasteImages: pasteTrayImages,
|
|
4617
|
+
onClear: () => setConfirmClear(true),
|
|
4618
|
+
onRelease: release,
|
|
4619
|
+
onRemove: setPendingRemove,
|
|
4620
|
+
onOpenImage: openImage,
|
|
4621
|
+
onError: (text) => flash({ kind: 'error', text }),
|
|
4622
|
+
})
|
|
4250
4623
|
: null,
|
|
4251
4624
|
),
|
|
4252
4625
|
h(ImageLightbox, { preview, onClose: closeImage }),
|
|
4626
|
+
renderReleaseOverlay({ state: releaseInfo, onStop: requestReleaseStop }),
|
|
4253
4627
|
);
|
|
4254
4628
|
}
|
|
4255
4629
|
|
|
@@ -4288,13 +4662,17 @@ window.__ModuleLoader__.load({
|
|
|
4288
4662
|
// The composer trigger names itself, and switches to the accent colour once
|
|
4289
4663
|
// something is queued so the pending count is hard to miss.
|
|
4290
4664
|
'.pp-trigger{gap:6px;padding:0 9px;border:1px solid transparent}' +
|
|
4665
|
+
'.pp-trigger[disabled]{opacity:.55;cursor:not-allowed}' +
|
|
4291
4666
|
'.pp-trigger-label{white-space:nowrap}' +
|
|
4292
4667
|
'.pp-trigger[data-queued="true"]{border-color:var(--pp-accent-line);background:var(--pp-accent-soft);color:var(--pp-accent);font-weight:600}' +
|
|
4293
4668
|
'.pp-trigger[data-queued="true"]:hover{background:color-mix(in srgb,var(--pp-accent) 20%,transparent);color:var(--pp-accent)}' +
|
|
4294
4669
|
'.pp-trigger[data-queued="true"] .pp-badge{border-color:var(--pp-accent);background:var(--pp-accent);color:var(--pp-on-accent);font-weight:600}' +
|
|
4295
|
-
'.pp-panel{position:absolute;left:auto;right:0;bottom:0;margin:0;max-width:min(920px,100%);z-index:40;display:flex;flex-direction:column;--pp-h:min(70vh,720px,var(--pp-room,100vh));height:var(--pp-h);max-height:var(--pp-h);border:1px solid var(--pp-line);border-radius:var(--dsw-radius-panel,12px);background:var(--dsw-alias-bg-base,var(--pp-surface-2));box-shadow:var(--dsw-elevation-soft,0 10px 30px rgba(0,0,0,.16));overflow:hidden;overflow:clip;font-size:13px;line-height:1.5;color:var(--pp-ink);text-align:left}' +
|
|
4670
|
+
'.pp-panel{position:absolute;left:auto;right:0;bottom:0;margin:0;width:min(var(--pp-w,920px),100%);max-width:min(var(--pp-w,920px),100%);z-index:40;display:flex;flex-direction:column;--pp-h:min(70vh,720px,var(--pp-room,100vh));height:var(--pp-h);max-height:var(--pp-h);border:1px solid var(--pp-line);border-radius:var(--dsw-radius-panel,12px);background:var(--dsw-alias-bg-base,var(--pp-surface-2));box-shadow:var(--dsw-elevation-soft,0 10px 30px rgba(0,0,0,.16));overflow:hidden;overflow:clip;font-size:13px;line-height:1.5;color:var(--pp-ink);text-align:left}' +
|
|
4296
4671
|
// The grip above the header resizes the panel; a long queue may keep half the list.
|
|
4297
4672
|
'.pp-panel-grip{flex:none;display:flex;align-items:center;justify-content:center;height:11px;cursor:ns-resize;touch-action:none}' +
|
|
4673
|
+
'.pp-panel-grip-x{position:absolute;left:0;top:0;bottom:0;width:8px;z-index:5;display:flex;align-items:center;justify-content:center;cursor:ew-resize;touch-action:none}' +
|
|
4674
|
+
'.pp-grip-bar-x{width:3px;height:44px;border-radius:2px;background:var(--pp-line-2);opacity:0;transition:opacity .12s ease}' +
|
|
4675
|
+
'.pp-panel-grip-x:hover .pp-grip-bar-x,.pp-panel-grip-x:active .pp-grip-bar-x{opacity:1;background:var(--pp-accent)}' +
|
|
4298
4676
|
'.pp-grip-bar{width:44px;height:4px;border-radius:2px;background:var(--pp-line-2);transition:background .12s ease}' +
|
|
4299
4677
|
'.pp-panel-grip:hover .pp-grip-bar{background:var(--pp-accent)}' +
|
|
4300
4678
|
// flex:none keeps the card at its content height (or its cap) instead of
|
|
@@ -4310,9 +4688,6 @@ window.__ModuleLoader__.load({
|
|
|
4310
4688
|
// the tray sizes to its content and only shrinks (then scrolls) at the cap.
|
|
4311
4689
|
'.pp-panel .pp-page-foot .pp-tray{max-height:none;min-height:0;flex:0 1 auto}' +
|
|
4312
4690
|
'.pp-panel .pp-foot-head{flex:none}' +
|
|
4313
|
-
'.pp-head{display:flex;align-items:center;gap:8px;padding:10px 12px 6px}' +
|
|
4314
|
-
'.pp-head-title{font-weight:600;font-size:13px}' +
|
|
4315
|
-
'.pp-head-count{color:var(--pp-ink-2);font-size:11px;font-variant-numeric:tabular-nums}' +
|
|
4316
4691
|
'.pp-grow{flex:1;min-width:0}' +
|
|
4317
4692
|
'.pp-x{width:22px;height:22px;border:0;border-radius:6px;background:transparent;color:var(--pp-ink-2);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;font-size:12px;line-height:1}' +
|
|
4318
4693
|
'.pp-x:hover{background:var(--pp-hover);color:var(--pp-ink)}' +
|
|
@@ -4320,16 +4695,24 @@ window.__ModuleLoader__.load({
|
|
|
4320
4695
|
'.pp-tab{height:24px;padding:0 9px;border-radius:7px;border:1px solid transparent;background:transparent;color:var(--pp-ink-2);font:inherit;font-size:12px;cursor:pointer}' +
|
|
4321
4696
|
'.pp-tab:hover{background:var(--pp-hover)}' +
|
|
4322
4697
|
'.pp-tab[data-active="true"]{border-color:var(--pp-accent);background:var(--pp-accent-soft);color:var(--pp-accent);font-weight:600}' +
|
|
4698
|
+
'.pp-tab-count{margin-left:5px;padding:0 5px;vertical-align:1px;border-radius:999px;background:color-mix(in srgb, currentColor 12%, transparent);color:inherit;font-size:10px;font-weight:600;line-height:16px;height:16px;display:inline-flex;align-items:center}' +
|
|
4323
4699
|
'.pp-tab-add{padding:0 7px;color:var(--pp-ink-2)}' +
|
|
4324
4700
|
'.pp-tab-addwrap{display:inline-flex;align-items:center}' +
|
|
4325
4701
|
'.pp-tab-sep{flex:none;width:1px;height:16px;margin:0 7px;background:color-mix(in srgb, var(--pp-ink-2) 45%, transparent)}' +
|
|
4326
|
-
'.pp-tab-x{margin-left:4px;padding:0 2px;border-radius:4px;font-size:11px;line-height:1;color:var(--pp-ink-2)}' +
|
|
4702
|
+
'.pp-tab-x{margin-left:4px;padding:0 2px;border-radius:4px;font-size:11px;line-height:1;color:var(--pp-ink-2);cursor:pointer}' +
|
|
4703
|
+
'.pp-tab-x:focus-visible{outline:2px solid var(--pp-accent);outline-offset:1px}' +
|
|
4327
4704
|
'.pp-tab-x:hover{color:var(--pp-danger)}' +
|
|
4328
4705
|
'.pp-tab-input{height:24px;width:110px;padding:0 7px;border:1px solid var(--pp-accent);border-radius:7px;background:var(--dsw-alias-bg-base);color:inherit;font:inherit;font-size:12px;outline:none}' +
|
|
4706
|
+
'.pp-release-mask{position:absolute;inset:0;z-index:60;display:flex;align-items:center;justify-content:center;padding:16px;background:color-mix(in srgb,var(--pp-ink) 28%,transparent)}' +
|
|
4707
|
+
'.pp-release-card{width:100%;max-width:300px;display:flex;flex-direction:column;align-items:center;gap:10px;padding:16px 18px;border:1px solid var(--pp-line);border-radius:12px;background:var(--pp-surface-2);box-shadow:0 18px 48px rgba(0,0,0,.24);text-align:center}' +
|
|
4708
|
+
'.pp-release-title{font-weight:600;font-size:13px}' +
|
|
4709
|
+
'.pp-release-count{font-size:12px;color:var(--pp-ink-2);font-variant-numeric:tabular-nums}' +
|
|
4329
4710
|
'.pp-modal{position:absolute;inset:0;z-index:50;display:flex;align-items:center;justify-content:center;padding:16px;background:color-mix(in srgb,var(--pp-ink) 22%,transparent)}' +
|
|
4330
4711
|
'.pp-modal-card{width:100%;max-width:400px;display:flex;flex-direction:column;gap:14px;padding:16px 18px;border:1px solid var(--pp-line);border-radius:12px;background:var(--pp-surface-2);box-shadow:0 18px 48px rgba(0,0,0,.24)}' +
|
|
4331
4712
|
'.pp-modal-text{font-size:13px;line-height:1.65;color:var(--pp-ink)}' +
|
|
4332
4713
|
'.pp-modal-actions{display:flex;justify-content:flex-end;gap:8px}' +
|
|
4714
|
+
'.pp-capture-options{display:flex;flex-direction:column;gap:6px;max-height:280px;overflow:auto}' +
|
|
4715
|
+
'.pp-capture-option{justify-content:flex-start;height:auto;min-height:26px;padding:5px 9px;text-align:left;white-space:normal}' +
|
|
4333
4716
|
'.pp-mini{height:24px;padding:0 9px;border-radius:7px;border:1px solid var(--pp-line);background:transparent;color:var(--pp-ink);font:inherit;font-size:12px;cursor:pointer;white-space:nowrap}' +
|
|
4334
4717
|
'.pp-mini:hover{background:var(--pp-hover)}' +
|
|
4335
4718
|
'.pp-set-btn{display:inline-flex;align-items:center;gap:5px;padding:0 9px}' +
|
|
@@ -4362,16 +4745,11 @@ window.__ModuleLoader__.load({
|
|
|
4362
4745
|
'.pp-about-row{display:flex;gap:10px;padding:2px 0;font-size:12px;color:var(--pp-ink);min-width:0}' +
|
|
4363
4746
|
'.pp-about-key{flex:none;width:60px;color:var(--pp-ink-2)}' +
|
|
4364
4747
|
'.pp-about-row a{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
|
|
4365
|
-
'.pp-set-line{display:flex;align-items:center;gap:12px;padding:4px 0}' +
|
|
4366
4748
|
'.pp-set-ws{display:flex;align-items:center;gap:8px;padding:4px 0;cursor:pointer;min-width:0}' +
|
|
4367
4749
|
'.pp-set-ws input{margin:0;accent-color:var(--pp-accent);cursor:pointer}' +
|
|
4368
4750
|
'.pp-set-ws-name{font-size:12px;color:var(--pp-ink);white-space:nowrap}' +
|
|
4369
4751
|
'.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}' +
|
|
4370
4752
|
'.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}' +
|
|
4371
|
-
'.pp-set-name{min-width:78px;font-size:12px;color:var(--pp-ink)}' +
|
|
4372
|
-
'.pp-set-modes{display:flex;flex-wrap:wrap;gap:16px}' +
|
|
4373
|
-
'.pp-set-inline{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--pp-ink);cursor:pointer}' +
|
|
4374
|
-
'.pp-set-inline input{margin:0;accent-color:var(--pp-accent);cursor:pointer}' +
|
|
4375
4753
|
'.pp-set-label{font-size:12px;color:var(--pp-ink-2);margin:2px 0 4px}' +
|
|
4376
4754
|
'.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)}' +
|
|
4377
4755
|
'.pp-set-card .pp-set-label{margin:0 0 6px;font-size:12px;font-weight:600;color:var(--pp-ink)}' +
|
|
@@ -4408,10 +4786,8 @@ window.__ModuleLoader__.load({
|
|
|
4408
4786
|
'.pp-page-item .pp-actions{opacity:.35}' +
|
|
4409
4787
|
'.pp-page-item:hover .pp-actions{opacity:1}' +
|
|
4410
4788
|
'.pp-empty{padding:22px 16px;color:var(--pp-ink-2);text-align:center;font-size:12px}' +
|
|
4411
|
-
'.pp-group{display:flex;align-items:center;gap:6px;padding:10px 8px 4px;font-size:11px;font-weight:500;color:var(--pp-ink-2);letter-spacing:.02em}' +
|
|
4412
4789
|
'.pp-row{display:flex;align-items:flex-start;gap:8px;padding:7px 8px;border-radius:8px}' +
|
|
4413
4790
|
'.pp-row:hover{background:var(--pp-hover)}' +
|
|
4414
|
-
'.pp-check{margin:2px 0 0;accent-color:var(--pp-accent);cursor:pointer;flex:none}' +
|
|
4415
4791
|
'.pp-toggle{width:26px;height:26px;flex:none;margin-top:-1px;border:0;border-radius:6px;background:transparent;color:var(--pp-ink-2);cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0}' +
|
|
4416
4792
|
'.pp-toggle:hover{background:var(--pp-hover);color:var(--pp-ink)}' +
|
|
4417
4793
|
'.pp-toggle[data-selected="true"]{color:var(--pp-accent)}' +
|
|
@@ -4465,10 +4841,8 @@ window.__ModuleLoader__.load({
|
|
|
4465
4841
|
'.pp-primary:disabled{opacity:.5;cursor:default}' +
|
|
4466
4842
|
'.pp-link{border:0;background:transparent;color:var(--pp-ink-2);font:inherit;font-size:11px;cursor:pointer;padding:0;text-decoration:underline;text-underline-offset:2px}' +
|
|
4467
4843
|
'.pp-link:hover{color:var(--pp-ink)}' +
|
|
4468
|
-
'.pp-foot{border-top:1px solid var(--pp-line);padding:8px 12px 10px;display:flex;flex-direction:column;gap:6px;background:var(--pp-queue-bg)}' +
|
|
4469
4844
|
'.pp-foot-head{display:flex;align-items:center;gap:6px}' +
|
|
4470
4845
|
'.pp-page-foot .pp-foot-head{margin:-10px -12px 0;padding:8px 12px;border-radius:9px 9px 0 0;background:var(--pp-queue-head-bg)}' +
|
|
4471
|
-
'.pp-foot .pp-foot-head{margin:-8px -12px 0;padding:8px 12px;background:var(--pp-queue-head-bg)}' +
|
|
4472
4846
|
'.pp-foot-title{font-size:12px;font-weight:600;color:var(--pp-ink)}' +
|
|
4473
4847
|
'.pp-tray{display:flex;flex-direction:column;gap:6px;max-height:260px;overflow-y:auto}' +
|
|
4474
4848
|
'.pp-foot .pp-tray{max-height:min(40vh,220px)}' +
|
|
@@ -4532,6 +4906,9 @@ window.__ModuleLoader__.load({
|
|
|
4532
4906
|
bindOptional(['conversation'], (target) => {
|
|
4533
4907
|
conversationFace = serviceOf(target, 'conversation');
|
|
4534
4908
|
});
|
|
4909
|
+
bindOptional(['sessions'], (target) => {
|
|
4910
|
+
sessionsFace = serviceOf(target, 'sessions');
|
|
4911
|
+
});
|
|
4535
4912
|
if (ctx.locale && typeof ctx.locale.register === 'function' && typeof ctx.locale.bind === 'function') {
|
|
4536
4913
|
ctx.effect(() => ctx.locale.register(NS, { zh: ZH, en: EN }));
|
|
4537
4914
|
translate = ctx.locale.bind(NS);
|