dsh-prompt-pool 1.0.3 → 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 +988 -714
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -7,14 +7,7 @@ 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';
|
|
@@ -26,7 +19,7 @@ window.__ModuleLoader__.load({
|
|
|
26
19
|
const NATIVE_TAB_ID = 'dsh-prompt-pool';
|
|
27
20
|
const NATIVE_TAB_KIND = 'prompt-pool';
|
|
28
21
|
/** Shown in the settings about card; keep in step with plugin/package.json. */
|
|
29
|
-
const PLUGIN_VERSION = '1.0
|
|
22
|
+
const PLUGIN_VERSION = '1.1.0';
|
|
30
23
|
const PLUGIN_AUTHOR = 'GanttShen';
|
|
31
24
|
/** Replace once the public repository exists; the row hides while it is empty. */
|
|
32
25
|
const PLUGIN_REPO = 'https://github.com/Ganttfly/dsh-prompt-pool';
|
|
@@ -45,6 +38,8 @@ window.__ModuleLoader__.load({
|
|
|
45
38
|
* running past it.
|
|
46
39
|
*/
|
|
47
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 };
|
|
48
43
|
|
|
49
44
|
/**
|
|
50
45
|
* Top of the nearest ancestor that clips its overflow — the pane the panel
|
|
@@ -72,12 +67,13 @@ window.__ModuleLoader__.load({
|
|
|
72
67
|
'panel.capture': '存草稿',
|
|
73
68
|
'panel.captureHint': '把输入框里的内容复制一份存进池子(图片附件一起存);输入框里的字会保留',
|
|
74
69
|
'panel.resize': '拖动调整高度,双击还原',
|
|
75
|
-
'panel.
|
|
70
|
+
'panel.resizeWidth': '拖动调整宽度,双击还原',
|
|
71
|
+
'panel.pin': '钉住面板',
|
|
72
|
+
'panel.unpin': '取消钉住',
|
|
73
|
+
'panel.empty': '池子是空的。写一句,然后点「存草稿」。',
|
|
76
74
|
'panel.emptyTab': '这一栏还没有内容。',
|
|
77
75
|
'tab.all': '全部',
|
|
78
76
|
'tab.oftenuse': '常用',
|
|
79
|
-
'tab.workspace': '工作区',
|
|
80
|
-
'tab.currentWorkspace': '当前工作区',
|
|
81
77
|
'ws.none': '没有可用的工作区',
|
|
82
78
|
'ws.empty': '这个工作区还没有条目',
|
|
83
79
|
'tab.note': '便签',
|
|
@@ -95,37 +91,30 @@ window.__ModuleLoader__.load({
|
|
|
95
91
|
'group.untitled': '(未命名)',
|
|
96
92
|
'mention.loading': '正在读取…',
|
|
97
93
|
'mention.empty': '没有匹配项',
|
|
98
|
-
'mention.
|
|
94
|
+
'mention.noSessionTag': '无会话',
|
|
95
|
+
'mention.directory': '目录',
|
|
99
96
|
'mention.noSkillService': '读不到技能目录(remote 服务未绑定)',
|
|
100
|
-
'mention.noDirectoryService': '读不到目录服务(uiWorkspace 未绑定)',
|
|
101
97
|
'mention.noSessionService': '读不到会话服务(sessions 未绑定)',
|
|
102
98
|
'mention.sessionClosed': '会话未打开,无法读取技能目录',
|
|
103
99
|
'mention.failed': '读取失败',
|
|
104
100
|
'mention.timeout': '读取超时:宿主没有响应(可能没有活跃会话)',
|
|
105
101
|
'row.insert': '插入到输入框',
|
|
106
102
|
'row.select': '加入待发送队列',
|
|
107
|
-
'row.copy': '复制内容',
|
|
108
103
|
'row.duplicate': '复制一份,追加到池子末尾',
|
|
109
104
|
'page.title': '提示池',
|
|
110
105
|
'tab.description': '暂存、编辑、编排你的提示词,按住顺序一次性释放',
|
|
111
106
|
'page.count': '共 {n} 条',
|
|
112
107
|
'page.search': '搜索标题或内容…',
|
|
113
|
-
'page.empty': '还没有内容。点右上角「+
|
|
108
|
+
'page.empty': '还没有内容。点右上角「+ 提示词」开始。',
|
|
114
109
|
'page.emptyOftenuse': '还没有常用条目。把条目的「分组」改成「常用」即可。',
|
|
115
110
|
'page.noMatch': '没有匹配的条目。',
|
|
116
|
-
'page.trayReady': '已选 {n} 条 · 去对话释放',
|
|
117
|
-
'page.gotoConversation': '去对话',
|
|
118
111
|
'status.noComposer': '没有可用的输入框:请先打开一个对话页签',
|
|
119
112
|
'status.releaseSent': '已交给输入框,按顺序排队中',
|
|
120
|
-
'status.copied': '已复制',
|
|
121
|
-
'status.copyFailed': '复制失败',
|
|
122
113
|
'status.savedToPool': '已保存',
|
|
123
|
-
'sidebar.label': '提示池',
|
|
124
114
|
'settings.nav': '提示池',
|
|
125
115
|
'settings.open': '提示池设置',
|
|
126
116
|
'settings.button': '设置',
|
|
127
117
|
'settings.tab.order': '分组',
|
|
128
|
-
'settings.display': '分组怎么显示',
|
|
129
118
|
'settings.table': '分组的顺序与显示',
|
|
130
119
|
'settings.tableHint': '箭头调整先后顺序;右侧三列决定这一组怎么显示。',
|
|
131
120
|
'settings.tableGroup': '分组',
|
|
@@ -148,27 +137,14 @@ window.__ModuleLoader__.load({
|
|
|
148
137
|
'settings.about': '插件信息',
|
|
149
138
|
'settings.aboutAuthor': '作者',
|
|
150
139
|
'settings.aboutRepo': '仓库',
|
|
151
|
-
'settings.tab.display': '展示',
|
|
152
|
-
'settings.customNested': '自定义分组折叠成一个 Tab',
|
|
153
|
-
'settings.customNestedHint': '分组多时打开:Tab 行只保留一个「自定义」,组内用横排胶囊切换。',
|
|
154
140
|
'settings.workspaceCard': '工作区如何展示',
|
|
155
141
|
'settings.workspacesVisible': '显示哪些工作区',
|
|
156
142
|
'settings.workspacesCurrent': '当前',
|
|
157
143
|
'settings.workspacesEmpty': '还没有读到工作区列表。打开一次提示池页面后,这里会列出全部工作区。',
|
|
158
|
-
'settings.leading': '哪一组排在前面',
|
|
159
|
-
'settings.leading.workspace': '工作区',
|
|
160
|
-
'settings.leading.custom': '自定义分组',
|
|
161
|
-
'settings.leading.builtin': '内置分组',
|
|
162
|
-
'settings.leadingHint': '「全部」始终在最前;这里决定它后面先出现哪一组,另外两组按固定顺序跟随。',
|
|
163
|
-
'settings.reload': '重新加载界面',
|
|
164
|
-
'settings.reloadHint': '插件代码更新后,界面不会自动换新。点这里重新加载(比重启应用快)。',
|
|
165
144
|
'settings.title': '提示池',
|
|
166
|
-
'settings.desc': '
|
|
167
|
-
'settings.workspaceTabs': '在工作区 Tab 中列出全部工作区',
|
|
168
|
-
'settings.workspaceTabsHint': '「工作区」Tab 里用横向胶囊切换工作区;关掉后只保留当前工作区。',
|
|
145
|
+
'settings.desc': '控制分组顺序、显示方式和工作区 Tab。改动立即生效。',
|
|
169
146
|
'settings.currentWorkspaceTab': '当前工作区排在最前',
|
|
170
147
|
'settings.currentWorkspaceTabHint': '当前会话所属的工作区固定排第一;其余按原顺序。',
|
|
171
|
-
'settings.label': '提示池',
|
|
172
148
|
'row.edit': '编辑',
|
|
173
149
|
'row.delete': '删除',
|
|
174
150
|
'row.deleteTitle': '删除这条提示词',
|
|
@@ -194,7 +170,6 @@ window.__ModuleLoader__.load({
|
|
|
194
170
|
'row.familyCustom': '自定义',
|
|
195
171
|
'row.familyWorkspace': '工作区分组',
|
|
196
172
|
'tab.familyBuiltin': '内置分组',
|
|
197
|
-
'row.categoryLabel': '自定义分组',
|
|
198
173
|
'row.classification': '分组',
|
|
199
174
|
'page.new': '提示词',
|
|
200
175
|
'row.noCategory': '未分组',
|
|
@@ -211,15 +186,14 @@ window.__ModuleLoader__.load({
|
|
|
211
186
|
'tray.removeConfirm': '「{title}」会从待发送队列移出;这条如果在队列里改过,改动不会保留。',
|
|
212
187
|
'tray.removeAction': '移出',
|
|
213
188
|
'tray.duplicate': '复制一份,追加到末尾',
|
|
214
|
-
'tray.hint': '释放后会按这个顺序排队,当前这轮结束后自动接着执行。',
|
|
215
189
|
'tray.queue': '队列中 {n}',
|
|
216
190
|
'tray.collapseTitle': '收起待发送队列',
|
|
217
191
|
'tray.expandTitle': '展开待发送队列',
|
|
218
|
-
'confirm.title': '将按此顺序排队 {n} 条:',
|
|
219
|
-
'confirm.ok': '确认释放',
|
|
220
|
-
'confirm.cancel': '再想想',
|
|
221
192
|
'status.saved': '已存入池子',
|
|
222
193
|
'status.savedPartial': '已存入池子,但这 {n} 个附件没有一起保存',
|
|
194
|
+
'status.savedTo': '已存入「{group}」',
|
|
195
|
+
'status.savedPartialTo': '已存入「{group}」,但 {n} 个附件没有保存',
|
|
196
|
+
'capture.title': '存到哪个分组?',
|
|
223
197
|
'status.storageFailed': '保存失败:浏览器存储不可写(可能已满)。改动只在当前页面有效。',
|
|
224
198
|
'status.nothing': '草稿是空的,先写点什么',
|
|
225
199
|
'status.emptyBody': '内容不能是空的',
|
|
@@ -233,6 +207,14 @@ window.__ModuleLoader__.load({
|
|
|
233
207
|
'status.deleted': '已删除「{title}」',
|
|
234
208
|
'status.cleared': '已清空 {n} 条待发送',
|
|
235
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': '提交到队列失败',
|
|
236
218
|
'status.releasing': '正在释放 {n} 条…',
|
|
237
219
|
};
|
|
238
220
|
|
|
@@ -244,12 +226,13 @@ window.__ModuleLoader__.load({
|
|
|
244
226
|
'panel.capture': 'Save draft',
|
|
245
227
|
'panel.captureHint': 'Copy the composer draft into the pool; the composer keeps its text',
|
|
246
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',
|
|
247
232
|
'panel.empty': 'The pool is empty. Write something, then press Save draft.',
|
|
248
233
|
'panel.emptyTab': 'Nothing in this tab yet.',
|
|
249
234
|
'tab.all': 'All',
|
|
250
235
|
'tab.oftenuse': 'Frequent',
|
|
251
|
-
'tab.workspace': 'Workspaces',
|
|
252
|
-
'tab.currentWorkspace': 'Current workspace',
|
|
253
236
|
'ws.none': 'No workspaces available',
|
|
254
237
|
'ws.empty': 'No items in this workspace yet',
|
|
255
238
|
'tab.note': 'Notes',
|
|
@@ -267,37 +250,30 @@ window.__ModuleLoader__.load({
|
|
|
267
250
|
'group.untitled': '(untitled)',
|
|
268
251
|
'mention.loading': 'Loading…',
|
|
269
252
|
'mention.empty': 'No matches',
|
|
270
|
-
'mention.
|
|
253
|
+
'mention.noSessionTag': 'no session',
|
|
254
|
+
'mention.directory': 'folder',
|
|
271
255
|
'mention.noSkillService': 'Skill catalog unavailable (remote service not bound)',
|
|
272
|
-
'mention.noDirectoryService': 'Directory service unavailable (uiWorkspace not bound)',
|
|
273
256
|
'mention.noSessionService': 'Session service unavailable (sessions not bound)',
|
|
274
257
|
'mention.sessionClosed': 'The session is not open, so the catalog is unavailable',
|
|
275
258
|
'mention.failed': 'Failed to load',
|
|
276
259
|
'mention.timeout': 'Timed out: the host did not answer (no live session?)',
|
|
277
260
|
'row.insert': 'Insert into the composer',
|
|
278
261
|
'row.select': 'Add to the send queue',
|
|
279
|
-
'row.copy': 'Copy the text',
|
|
280
262
|
'row.duplicate': 'Duplicate and append to the pool',
|
|
281
263
|
'page.title': 'Prompt pool',
|
|
282
264
|
'tab.description': 'Stage, edit and arrange prompts, then release them in order',
|
|
283
265
|
'page.count': '{n} items',
|
|
284
266
|
'page.search': 'Search title or text…',
|
|
285
|
-
'page.empty': 'Nothing yet. Use “+
|
|
267
|
+
'page.empty': 'Nothing yet. Use “+ Prompt” in the top right.',
|
|
286
268
|
'page.emptyOftenuse': 'Nothing here yet. Set an item’s group to Frequent.',
|
|
287
269
|
'page.noMatch': 'No matching item.',
|
|
288
|
-
'page.trayReady': '{n} selected · release in a conversation',
|
|
289
|
-
'page.gotoConversation': 'Open the conversation',
|
|
290
270
|
'status.noComposer': 'No composer available: open a conversation tab first',
|
|
291
271
|
'status.releaseSent': 'Handed to the composer; queuing in order',
|
|
292
|
-
'status.copied': 'Copied',
|
|
293
|
-
'status.copyFailed': 'Copy failed',
|
|
294
272
|
'status.savedToPool': 'Saved',
|
|
295
|
-
'sidebar.label': 'Prompt pool',
|
|
296
273
|
'settings.nav': 'Prompt pool',
|
|
297
274
|
'settings.open': 'Prompt pool settings',
|
|
298
275
|
'settings.button': 'Settings',
|
|
299
276
|
'settings.tab.order': 'Groups',
|
|
300
|
-
'settings.display': 'How groups show up',
|
|
301
277
|
'settings.table': 'Group order and display',
|
|
302
278
|
'settings.tableHint': 'Use the arrows to reorder; the three columns decide how each family shows up.',
|
|
303
279
|
'settings.tableGroup': 'Group',
|
|
@@ -320,27 +296,14 @@ window.__ModuleLoader__.load({
|
|
|
320
296
|
'settings.about': 'Plugin info',
|
|
321
297
|
'settings.aboutAuthor': 'Author',
|
|
322
298
|
'settings.aboutRepo': 'Repository',
|
|
323
|
-
'settings.tab.display': 'Display',
|
|
324
|
-
'settings.customNested': 'Fold custom groups into one tab',
|
|
325
|
-
'settings.customNestedHint': 'Useful once you have many groups: one “Custom” tab keeps them as chips inside.',
|
|
326
299
|
'settings.workspaceCard': 'How workspaces appear',
|
|
327
300
|
'settings.workspacesVisible': 'Workspaces to show',
|
|
328
301
|
'settings.workspacesCurrent': 'current',
|
|
329
302
|
'settings.workspacesEmpty': 'No workspace roster yet. Open the prompt pool page once and every workspace will be listed here.',
|
|
330
|
-
'settings.leading': 'Which group comes first',
|
|
331
|
-
'settings.leading.workspace': 'Workspaces',
|
|
332
|
-
'settings.leading.custom': 'Custom groups',
|
|
333
|
-
'settings.leading.builtin': 'Built-in groups',
|
|
334
|
-
'settings.leadingHint': '"All" always leads; this picks which group follows it, the other two keep their fixed order.',
|
|
335
|
-
'settings.reload': 'Reload the UI',
|
|
336
|
-
'settings.reloadHint': 'A plugin code change does not swap the running UI. Use this instead of restarting the app.',
|
|
337
303
|
'settings.title': 'Prompt pool',
|
|
338
|
-
'settings.desc': 'Controls how the
|
|
339
|
-
'settings.workspaceTabs': 'List every workspace in the Workspaces tab',
|
|
340
|
-
'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.',
|
|
341
305
|
'settings.currentWorkspaceTab': 'Put the current workspace first',
|
|
342
306
|
'settings.currentWorkspaceTabHint': 'The workspace owning this session stays first; the rest keep their order.',
|
|
343
|
-
'settings.label': 'Prompt pool',
|
|
344
307
|
'row.edit': 'Edit',
|
|
345
308
|
'row.delete': 'Delete',
|
|
346
309
|
'row.deleteTitle': 'Delete this prompt',
|
|
@@ -366,7 +329,6 @@ window.__ModuleLoader__.load({
|
|
|
366
329
|
'row.familyCustom': 'Custom',
|
|
367
330
|
'row.familyWorkspace': 'Workspace groups',
|
|
368
331
|
'tab.familyBuiltin': 'Built-in groups',
|
|
369
|
-
'row.categoryLabel': 'Custom',
|
|
370
332
|
'row.classification': 'Group',
|
|
371
333
|
'page.new': 'Prompt',
|
|
372
334
|
'row.noCategory': 'Ungrouped',
|
|
@@ -383,15 +345,14 @@ window.__ModuleLoader__.load({
|
|
|
383
345
|
'tray.removeConfirm': '{title} will be removed from the send queue. Edits made to this queued copy are lost.',
|
|
384
346
|
'tray.removeAction': 'Remove',
|
|
385
347
|
'tray.duplicate': 'Duplicate and append to the end',
|
|
386
|
-
'tray.hint': 'Released items queue up in this order and run as soon as the current turn ends.',
|
|
387
348
|
'tray.queue': '{n} in queue',
|
|
388
349
|
'tray.collapseTitle': 'Collapse the send queue',
|
|
389
350
|
'tray.expandTitle': 'Expand the send queue',
|
|
390
|
-
'confirm.title': 'Queue {n} in this order:',
|
|
391
|
-
'confirm.ok': 'Queue them',
|
|
392
|
-
'confirm.cancel': 'Not yet',
|
|
393
351
|
'status.saved': 'Saved to the pool',
|
|
394
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?',
|
|
395
356
|
'status.storageFailed': 'Could not save: browser storage is unwritable (possibly full). Changes last only for this page.',
|
|
396
357
|
'status.nothing': 'The composer is empty',
|
|
397
358
|
'status.emptyBody': 'The content cannot be empty',
|
|
@@ -405,6 +366,14 @@ window.__ModuleLoader__.load({
|
|
|
405
366
|
'status.deleted': 'Deleted this item',
|
|
406
367
|
'status.cleared': 'Cleared {n} queued items',
|
|
407
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',
|
|
408
377
|
'status.releasing': 'Releasing {n}…',
|
|
409
378
|
};
|
|
410
379
|
|
|
@@ -474,6 +443,25 @@ window.__ModuleLoader__.load({
|
|
|
474
443
|
*/
|
|
475
444
|
const storageState = createStore({ failed: false });
|
|
476
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
|
+
|
|
477
465
|
function uid() {
|
|
478
466
|
try {
|
|
479
467
|
return crypto.randomUUID();
|
|
@@ -972,8 +960,58 @@ window.__ModuleLoader__.load({
|
|
|
972
960
|
];
|
|
973
961
|
}
|
|
974
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
|
+
|
|
975
1012
|
/** Shared confirm modal: backdrop click and Escape both cancel. */
|
|
976
1013
|
function ConfirmModal(props) {
|
|
1014
|
+
const cardRef = useRef(null);
|
|
977
1015
|
useEffect(() => {
|
|
978
1016
|
const onKeyDown = (event) => {
|
|
979
1017
|
if (event.key !== 'Escape') return;
|
|
@@ -985,6 +1023,32 @@ window.__ModuleLoader__.load({
|
|
|
985
1023
|
return () => window.removeEventListener('keydown', onKeyDown, true);
|
|
986
1024
|
}, [props.onCancel]);
|
|
987
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
|
+
|
|
988
1052
|
return h(
|
|
989
1053
|
'div',
|
|
990
1054
|
{
|
|
@@ -995,13 +1059,13 @@ window.__ModuleLoader__.load({
|
|
|
995
1059
|
},
|
|
996
1060
|
h(
|
|
997
1061
|
'div',
|
|
998
|
-
{ 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 },
|
|
999
1063
|
h('div', { className: 'pp-modal-text' }, props.text),
|
|
1000
1064
|
h(
|
|
1001
1065
|
'div',
|
|
1002
1066
|
{ className: 'pp-modal-actions' },
|
|
1003
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: props.onCancel }, props.cancelText),
|
|
1004
|
-
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),
|
|
1005
1069
|
),
|
|
1006
1070
|
),
|
|
1007
1071
|
);
|
|
@@ -1092,11 +1156,18 @@ window.__ModuleLoader__.load({
|
|
|
1092
1156
|
{
|
|
1093
1157
|
className: 'pp-tab-x',
|
|
1094
1158
|
role: 'button',
|
|
1159
|
+
tabIndex: 0,
|
|
1095
1160
|
title: translate('tab.delete'),
|
|
1096
1161
|
onClick: (event) => {
|
|
1097
1162
|
event.stopPropagation();
|
|
1098
1163
|
if (props.onDelete) props.onDelete(workspace.id);
|
|
1099
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
|
+
},
|
|
1100
1171
|
},
|
|
1101
1172
|
'×',
|
|
1102
1173
|
)
|
|
@@ -1292,6 +1363,19 @@ window.__ModuleLoader__.load({
|
|
|
1292
1363
|
|
|
1293
1364
|
const ui = createStore({ open: false });
|
|
1294
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
|
+
|
|
1295
1379
|
/**
|
|
1296
1380
|
* Live workspace directory: derived (never persisted) and published by
|
|
1297
1381
|
* whichever view can read the workspace snapshot, so one tab appears per
|
|
@@ -1365,6 +1449,13 @@ window.__ModuleLoader__.load({
|
|
|
1365
1449
|
const value = Number(settings.panelHeight);
|
|
1366
1450
|
return Number.isFinite(value) && value > 0 ? Math.round(value) : 0;
|
|
1367
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,
|
|
1368
1459
|
orderExplicit: settings.orderExplicit === true,
|
|
1369
1460
|
order: (() => {
|
|
1370
1461
|
const stored = Array.isArray(settings.order) ? settings.order.filter((name) => leaders.indexOf(name) >= 0) : [];
|
|
@@ -1392,6 +1483,50 @@ window.__ModuleLoader__.load({
|
|
|
1392
1483
|
];
|
|
1393
1484
|
}
|
|
1394
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
|
+
|
|
1395
1530
|
/** One family's tab block: hidden / one folded tab / one tab per group. */
|
|
1396
1531
|
function displayBlock(family, groups, settings) {
|
|
1397
1532
|
const mode = normalizeSettings(settings).display[family];
|
|
@@ -1466,7 +1601,8 @@ window.__ModuleLoader__.load({
|
|
|
1466
1601
|
mutate((state) => ({ ...state, items: [...state.items, item] }));
|
|
1467
1602
|
return item;
|
|
1468
1603
|
},
|
|
1469
|
-
/** 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) {
|
|
1470
1606
|
mutate((state) => {
|
|
1471
1607
|
const found = state.items.find((item) => item.id === id);
|
|
1472
1608
|
if (!found) return null;
|
|
@@ -1616,6 +1752,335 @@ window.__ModuleLoader__.load({
|
|
|
1616
1752
|
return useSyncExternalStore(storageState.subscribe, storageState.get, storageState.get);
|
|
1617
1753
|
}
|
|
1618
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
|
+
|
|
1619
2084
|
function useUiState() {
|
|
1620
2085
|
return useSyncExternalStore(ui.subscribe, ui.get, ui.get);
|
|
1621
2086
|
}
|
|
@@ -1697,6 +2162,14 @@ window.__ModuleLoader__.load({
|
|
|
1697
2162
|
h('path', { d: 'M2.6 6.2h10.8M2.6 9.6h10.8M2.6 13h6' }),
|
|
1698
2163
|
h('path', { d: 'M11.6 2.4v4.4M9.4 4.6h4.4' }),
|
|
1699
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
|
+
);
|
|
1700
2173
|
default:
|
|
1701
2174
|
return null;
|
|
1702
2175
|
}
|
|
@@ -1728,6 +2201,7 @@ window.__ModuleLoader__.load({
|
|
|
1728
2201
|
useLocaleTick();
|
|
1729
2202
|
const state = usePoolState();
|
|
1730
2203
|
const view = useUiState();
|
|
2204
|
+
const release = useReleaseState();
|
|
1731
2205
|
const label = translate('button.label');
|
|
1732
2206
|
const count = state.tray.length;
|
|
1733
2207
|
const queued = count > 0;
|
|
@@ -1745,12 +2219,16 @@ window.__ModuleLoader__.load({
|
|
|
1745
2219
|
'data-pp-trigger': 'true',
|
|
1746
2220
|
'data-open': view.open ? 'true' : 'false',
|
|
1747
2221
|
'data-queued': queued ? 'true' : 'false',
|
|
2222
|
+
disabled: release.active,
|
|
1748
2223
|
title: hint,
|
|
1749
2224
|
'aria-label': hint,
|
|
1750
2225
|
'aria-haspopup': 'dialog',
|
|
1751
2226
|
'aria-expanded': view.open ? 'true' : 'false',
|
|
1752
2227
|
onMouseDown: (event) => event.preventDefault(),
|
|
1753
|
-
onClick: () =>
|
|
2228
|
+
onClick: () => {
|
|
2229
|
+
if (release.active) return;
|
|
2230
|
+
ui.set({ open: !ui.get().open });
|
|
2231
|
+
},
|
|
1754
2232
|
},
|
|
1755
2233
|
icon('pool'),
|
|
1756
2234
|
h('span', { className: 'pp-trigger-label' }, label),
|
|
@@ -2040,6 +2518,7 @@ window.__ModuleLoader__.load({
|
|
|
2040
2518
|
});
|
|
2041
2519
|
}
|
|
2042
2520
|
const active = props.active === tab.id;
|
|
2521
|
+
const count = props.counts && typeof props.counts[tab.id] === 'number' ? props.counts[tab.id] : 0;
|
|
2043
2522
|
return h(
|
|
2044
2523
|
'button',
|
|
2045
2524
|
{
|
|
@@ -2052,17 +2531,27 @@ window.__ModuleLoader__.load({
|
|
|
2052
2531
|
onDoubleClick: tab.category ? () => setRenaming({ id: tab.id, name: tab.label, original: tab.label }) : undefined,
|
|
2053
2532
|
},
|
|
2054
2533
|
tab.label,
|
|
2534
|
+
count > 0 && tab.id !== 'all'
|
|
2535
|
+
? h('span', { className: 'pp-tab-count' }, String(count))
|
|
2536
|
+
: null,
|
|
2055
2537
|
tab.category && active
|
|
2056
2538
|
? h(
|
|
2057
2539
|
'span',
|
|
2058
2540
|
{
|
|
2059
2541
|
className: 'pp-tab-x',
|
|
2060
2542
|
role: 'button',
|
|
2543
|
+
tabIndex: 0,
|
|
2061
2544
|
title: translate('tab.delete'),
|
|
2062
2545
|
onClick: (event) => {
|
|
2063
2546
|
event.stopPropagation();
|
|
2064
2547
|
props.onDelete(tab.id);
|
|
2065
2548
|
},
|
|
2549
|
+
onKeyDown: (event) => {
|
|
2550
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
2551
|
+
event.preventDefault();
|
|
2552
|
+
event.stopPropagation();
|
|
2553
|
+
props.onDelete(tab.id);
|
|
2554
|
+
},
|
|
2066
2555
|
},
|
|
2067
2556
|
'×',
|
|
2068
2557
|
)
|
|
@@ -2143,6 +2632,7 @@ window.__ModuleLoader__.load({
|
|
|
2143
2632
|
useLocaleTick();
|
|
2144
2633
|
const state = usePoolState();
|
|
2145
2634
|
const storage = useStorageState();
|
|
2635
|
+
const releaseInfo = useReleaseState();
|
|
2146
2636
|
const queueCollapsed = state.settings && state.settings.queueCollapsed === true;
|
|
2147
2637
|
const workspaces = useWorkspaceDir();
|
|
2148
2638
|
const sessionHint = useSessionDir().sessionId;
|
|
@@ -2161,15 +2651,21 @@ window.__ModuleLoader__.load({
|
|
|
2161
2651
|
return pool.length > 0 ? pool[pool.length - 1] : '';
|
|
2162
2652
|
})();
|
|
2163
2653
|
const activeSessionId = pageSessionId || sessionHint || workspaceSession || '';
|
|
2164
|
-
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
|
+
};
|
|
2165
2662
|
const [query, setQuery] = useState('');
|
|
2166
|
-
const [editing, setEditing] = useState(null);
|
|
2167
|
-
const [trayEditing, setTrayEditing] = useState(null);
|
|
2168
2663
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
2169
2664
|
const [pendingCategory, setPendingCategory] = useState(null);
|
|
2170
2665
|
const [confirmClear, setConfirmClear] = useState(false);
|
|
2171
2666
|
const [pendingDelete, setPendingDelete] = useState(null);
|
|
2172
2667
|
const [pendingRemove, setPendingRemove] = useState(null);
|
|
2668
|
+
const [captureOpen, setCaptureOpen] = useState(false);
|
|
2173
2669
|
const [wsSelected, setWsSelected] = useState('');
|
|
2174
2670
|
const [customPick, setCustomPick] = useState('');
|
|
2175
2671
|
const [builtinPick, setBuiltinPick] = useState('');
|
|
@@ -2182,6 +2678,13 @@ window.__ModuleLoader__.load({
|
|
|
2182
2678
|
statusTimer.current = window.setTimeout(() => setStatus(null), 5000);
|
|
2183
2679
|
}, []);
|
|
2184
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]);
|
|
2185
2688
|
// A failed write outranks a transient toast: the change is not saved.
|
|
2186
2689
|
const notice = status || (storage.failed ? { kind: 'error', text: translate('status.storageFailed') } : null);
|
|
2187
2690
|
const trayRef = useRef(null);
|
|
@@ -2276,23 +2779,6 @@ window.__ModuleLoader__.load({
|
|
|
2276
2779
|
}
|
|
2277
2780
|
};
|
|
2278
2781
|
|
|
2279
|
-
const saveTrayEdit = () => {
|
|
2280
|
-
if (!trayEditing) return;
|
|
2281
|
-
if (!trayEditing.body.trim() && !(trayEditing.images && trayEditing.images.length)) {
|
|
2282
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
2283
|
-
return;
|
|
2284
|
-
}
|
|
2285
|
-
poolActions.patchTray(trayEditing.key, { body: trayEditing.body, images: trayEditing.images || [] });
|
|
2286
|
-
setTrayEditing(null);
|
|
2287
|
-
};
|
|
2288
|
-
|
|
2289
|
-
const pasteTrayImages = (files) => {
|
|
2290
|
-
const key = trayEditing && trayEditing.key;
|
|
2291
|
-
appendImageAssets(files, trayEditing && trayEditing.images ? trayEditing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
2292
|
-
setTrayEditing((current) => (current && current.key === key ? { ...current, images } : current));
|
|
2293
|
-
});
|
|
2294
|
-
};
|
|
2295
|
-
|
|
2296
2782
|
const sendToComposer = async (command, okText, onSuccess) => {
|
|
2297
2783
|
let result;
|
|
2298
2784
|
try {
|
|
@@ -2314,11 +2800,35 @@ window.__ModuleLoader__.load({
|
|
|
2314
2800
|
flash({ kind: 'error', text });
|
|
2315
2801
|
};
|
|
2316
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
|
+
|
|
2317
2827
|
/** The page cannot read the composer, so the mounted panel performs it. */
|
|
2318
|
-
const captureDraft = () => {
|
|
2828
|
+
const captureDraft = (group) => {
|
|
2319
2829
|
let result;
|
|
2320
2830
|
try {
|
|
2321
|
-
result = bridge.request({ type: 'capture' });
|
|
2831
|
+
result = bridge.request({ type: 'capture', group });
|
|
2322
2832
|
} catch (error) {
|
|
2323
2833
|
result = { ok: false, reason: String((error && error.message) || error) };
|
|
2324
2834
|
}
|
|
@@ -2326,9 +2836,18 @@ window.__ModuleLoader__.load({
|
|
|
2326
2836
|
(value) => {
|
|
2327
2837
|
if (value && value.ok) {
|
|
2328
2838
|
const skipped = Number(value.skipped) || 0;
|
|
2839
|
+
const label = typeof value.label === 'string' ? value.label : '';
|
|
2329
2840
|
flash(skipped > 0
|
|
2330
|
-
? {
|
|
2331
|
-
|
|
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
|
+
});
|
|
2332
2851
|
return;
|
|
2333
2852
|
}
|
|
2334
2853
|
const reason = value && value.reason;
|
|
@@ -2338,29 +2857,6 @@ window.__ModuleLoader__.load({
|
|
|
2338
2857
|
);
|
|
2339
2858
|
};
|
|
2340
2859
|
|
|
2341
|
-
const save = () => {
|
|
2342
|
-
if (!editing) return;
|
|
2343
|
-
if (!editing.body.trim() && (!editing.images || editing.images.length === 0)) {
|
|
2344
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
2345
|
-
return;
|
|
2346
|
-
}
|
|
2347
|
-
poolActions.patch(editing.id, {
|
|
2348
|
-
group: editing.group,
|
|
2349
|
-
title: editing.title.trim(),
|
|
2350
|
-
body: editing.body,
|
|
2351
|
-
images: editing.images || [],
|
|
2352
|
-
});
|
|
2353
|
-
setEditing(null);
|
|
2354
|
-
flash({ kind: 'ok', text: translate('status.savedToPool') });
|
|
2355
|
-
};
|
|
2356
|
-
|
|
2357
|
-
const pasteImages = (files) => {
|
|
2358
|
-
const id = editing && editing.id;
|
|
2359
|
-
appendImageAssets(files, editing && editing.images ? editing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
2360
|
-
setEditing((current) => (current && current.id === id ? { ...current, images } : current));
|
|
2361
|
-
});
|
|
2362
|
-
};
|
|
2363
|
-
|
|
2364
2860
|
/** The confirmed delete: drop the item, then offer the same undo as the panel. */
|
|
2365
2861
|
const removeItem = (item, text) => {
|
|
2366
2862
|
const index = pool.get().items.findIndex((entry) => entry.id === item.id);
|
|
@@ -2402,132 +2898,36 @@ window.__ModuleLoader__.load({
|
|
|
2402
2898
|
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
2403
2899
|
};
|
|
2404
2900
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
setEditing
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
onChange: (event) => setEditing({ ...editing, body: event.target.value }),
|
|
2436
|
-
onPasteImages: pasteImages,
|
|
2437
|
-
onKeyDown: (event) => {
|
|
2438
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
2439
|
-
event.preventDefault();
|
|
2440
|
-
save();
|
|
2441
|
-
}
|
|
2442
|
-
},
|
|
2443
|
-
}),
|
|
2444
|
-
h(ImagePicker, {
|
|
2445
|
-
images: editing.images || [],
|
|
2446
|
-
onChange: (images) => setEditing((current) => (current ? { ...current, images } : current)),
|
|
2447
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
2448
|
-
onOpen: openImage,
|
|
2449
|
-
}),
|
|
2450
|
-
h(
|
|
2451
|
-
'div',
|
|
2452
|
-
{ className: 'pp-edit-actions' },
|
|
2453
|
-
h(
|
|
2454
|
-
'select',
|
|
2455
|
-
{
|
|
2456
|
-
className: 'pp-input',
|
|
2457
|
-
style: { width: 'auto', maxWidth: '220px' },
|
|
2458
|
-
value: groupOf(editing),
|
|
2459
|
-
'aria-label': translate('row.classification'),
|
|
2460
|
-
onChange: (event) => setEditing(withGroup(editing, event.target.value)),
|
|
2461
|
-
},
|
|
2462
|
-
h(
|
|
2463
|
-
'optgroup',
|
|
2464
|
-
{ label: translate('row.familyBuiltin') },
|
|
2465
|
-
h('option', { value: BUILTIN_GROUP.oftenuse }, translate('group.oftenuse')),
|
|
2466
|
-
h('option', { value: BUILTIN_GROUP.note }, translate('group.note')),
|
|
2467
|
-
h('option', { value: BUILTIN_GROUP.template }, translate('group.template')),
|
|
2468
|
-
),
|
|
2469
|
-
workspaces.items.length > 0
|
|
2470
|
-
? h(
|
|
2471
|
-
'optgroup',
|
|
2472
|
-
{ label: translate('row.familyWorkspace') },
|
|
2473
|
-
workspaces.items.map((workspace) => h('option', { key: workspace.id, value: 'workspace:' + workspace.workspaceId }, workspace.name)),
|
|
2474
|
-
)
|
|
2475
|
-
: null,
|
|
2476
|
-
state.categories.length > 0
|
|
2477
|
-
? h(
|
|
2478
|
-
'optgroup',
|
|
2479
|
-
{ label: translate('row.familyCustom') },
|
|
2480
|
-
state.categories.map((category) => h('option', { key: category.id, value: 'custom:' + category.id }, category.name)),
|
|
2481
|
-
)
|
|
2482
|
-
: null,
|
|
2483
|
-
),
|
|
2484
|
-
h('span', { className: 'pp-grow' }),
|
|
2485
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: cancelEdit }, translate('row.cancel')),
|
|
2486
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: save }, translate('row.save')),
|
|
2487
|
-
),
|
|
2488
|
-
);
|
|
2489
|
-
}
|
|
2490
|
-
return h(
|
|
2491
|
-
'div',
|
|
2492
|
-
{ key: item.id, className: 'pp-row pp-page-item' },
|
|
2493
|
-
h(IconButton, {
|
|
2494
|
-
name: 'insert',
|
|
2495
|
-
label: translate('row.insert'),
|
|
2496
|
-
onClick: () => sendToComposer(
|
|
2497
|
-
{ type: 'insert', text: item.body, images: normalizeImages(item.images) },
|
|
2498
|
-
item.body.trim() ? translate('status.inserted') : translate('image.inserted'),
|
|
2499
|
-
() => {
|
|
2500
|
-
if (!normalizeSettings(state.settings).keepAfterInsert) removeItem(item, translate('status.insertedAndRemoved'));
|
|
2501
|
-
},
|
|
2502
|
-
),
|
|
2503
|
-
}),
|
|
2504
|
-
h(TrayAdd, { label: translate('row.select'), onClick: () => queueItem(item) }),
|
|
2505
|
-
h(
|
|
2506
|
-
'div',
|
|
2507
|
-
{ className: 'pp-main', onClick: () => setEditing({ id: item.id, group: groupOf(item), title: item.title, body: item.body, images: normalizeImages(item.images) }) },
|
|
2508
|
-
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')),
|
|
2509
|
-
item.body.trim() === (item.title || '').trim() ? null : h('div', { className: 'pp-body' }, item.body),
|
|
2510
|
-
h(ImageStrip, { images: item.images, compact: true, onOpen: openImage }),
|
|
2511
|
-
),
|
|
2512
|
-
tab === 'all'
|
|
2513
|
-
? h('span', { className: 'pp-tag' }, clipLabel(groupLabelOf(item, state.categories, workspaces.items)))
|
|
2514
|
-
: null,
|
|
2515
|
-
h(
|
|
2516
|
-
'div',
|
|
2517
|
-
{ className: 'pp-actions' },
|
|
2518
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.move(item.id, -1) }),
|
|
2519
|
-
h(IconButton, {
|
|
2520
|
-
name: 'down',
|
|
2521
|
-
label: translate('row.down'),
|
|
2522
|
-
disabled: index === items.length - 1,
|
|
2523
|
-
onClick: () => poolActions.move(item.id, 1),
|
|
2524
|
-
}),
|
|
2525
|
-
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) }) }),
|
|
2526
|
-
h(IconButton, { name: 'copy', label: translate('row.duplicate'), onClick: () => poolActions.duplicateItem(item.id) }),
|
|
2527
|
-
h(IconButton, { name: 'trash', label: translate('row.delete'), danger: true, onClick: () => setPendingDelete(item) }),
|
|
2528
|
-
),
|
|
2529
|
-
);
|
|
2530
|
-
};
|
|
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
|
+
});
|
|
2531
2931
|
|
|
2532
2932
|
// A folded family renders its groups as chips inside one tab.
|
|
2533
2933
|
const customGroups = state.categories.map((category) => ({ id: 'custom:' + category.id, name: category.name }));
|
|
@@ -2536,11 +2936,8 @@ window.__ModuleLoader__.load({
|
|
|
2536
2936
|
: customGroups.length > 0
|
|
2537
2937
|
? customGroups[0].id
|
|
2538
2938
|
: '';
|
|
2539
|
-
const customCounts =
|
|
2540
|
-
|
|
2541
|
-
const group = groupOf(item);
|
|
2542
|
-
if (familyOf(group) === 'custom') customCounts[group] = (customCounts[group] || 0) + 1;
|
|
2543
|
-
}
|
|
2939
|
+
const customCounts = groupCounts(state.items, 'custom');
|
|
2940
|
+
const builtinCounts = groupCounts(state.items, 'builtin');
|
|
2544
2941
|
const builtinList = builtinGroups();
|
|
2545
2942
|
const builtinActive = builtinList.some((entry) => entry.id === builtinPick) ? builtinPick : builtinList[0].id;
|
|
2546
2943
|
const nestedView =
|
|
@@ -2569,7 +2966,7 @@ window.__ModuleLoader__.load({
|
|
|
2569
2966
|
rail: builtinList,
|
|
2570
2967
|
activeId: builtinActive,
|
|
2571
2968
|
onSelect: setBuiltinPick,
|
|
2572
|
-
counts:
|
|
2969
|
+
counts: builtinCounts,
|
|
2573
2970
|
emptyText: translate('panel.emptyTab'),
|
|
2574
2971
|
scoped: state.items.filter((item) => groupOf(item) === builtinActive),
|
|
2575
2972
|
}
|
|
@@ -2589,17 +2986,19 @@ window.__ModuleLoader__.load({
|
|
|
2589
2986
|
className: 'pp-search',
|
|
2590
2987
|
value: query,
|
|
2591
2988
|
placeholder: translate('page.search'),
|
|
2989
|
+
'aria-label': translate('page.search'),
|
|
2592
2990
|
onChange: (event) => setQuery(event.target.value),
|
|
2593
2991
|
}),
|
|
2594
2992
|
h('button', { type: 'button', className: 'pp-mini', onClick: create }, '+ ', translate('page.new')),
|
|
2595
|
-
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')),
|
|
2596
2994
|
h(SettingsButton, { active: settingsOpen, onClick: () => setSettingsOpen(!settingsOpen) }),
|
|
2597
2995
|
),
|
|
2598
2996
|
h(
|
|
2599
2997
|
'div',
|
|
2600
2998
|
{ className: 'pp-bar', style: { padding: '8px 12px 2px' } },
|
|
2601
2999
|
h(TabBar, {
|
|
2602
|
-
tabs:
|
|
3000
|
+
tabs: tabs,
|
|
3001
|
+
counts: tabCounts,
|
|
2603
3002
|
active: tab,
|
|
2604
3003
|
...tabHandlers((next) => {
|
|
2605
3004
|
setSettingsOpen(false);
|
|
@@ -2649,6 +3048,16 @@ window.__ModuleLoader__.load({
|
|
|
2649
3048
|
},
|
|
2650
3049
|
})
|
|
2651
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,
|
|
2652
3061
|
h(
|
|
2653
3062
|
'div',
|
|
2654
3063
|
{ className: 'pp-page-body', ref: pageListRef },
|
|
@@ -2686,7 +3095,7 @@ window.__ModuleLoader__.load({
|
|
|
2686
3095
|
notice
|
|
2687
3096
|
? h(
|
|
2688
3097
|
'div',
|
|
2689
|
-
{ className: 'pp-status pp-status-float', 'data-kind': notice.kind || 'info' },
|
|
3098
|
+
{ className: 'pp-status pp-status-float', role: 'status', 'aria-live': 'polite', 'data-kind': notice.kind || 'info' },
|
|
2690
3099
|
h('span', null, notice.text),
|
|
2691
3100
|
notice.undo
|
|
2692
3101
|
? h(
|
|
@@ -2704,132 +3113,26 @@ window.__ModuleLoader__.load({
|
|
|
2704
3113
|
)
|
|
2705
3114
|
: null,
|
|
2706
3115
|
settingsOpen
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
)
|
|
2724
|
-
: h(
|
|
2725
|
-
'div',
|
|
2726
|
-
{ className: 'pp-page-foot' },
|
|
2727
|
-
h(
|
|
2728
|
-
'div',
|
|
2729
|
-
{ className: 'pp-foot-head' },
|
|
2730
|
-
h(
|
|
2731
|
-
'button',
|
|
2732
|
-
{
|
|
2733
|
-
type: 'button',
|
|
2734
|
-
className: 'pp-queue-toggle',
|
|
2735
|
-
title: translate('tray.collapseTitle'),
|
|
2736
|
-
'aria-label': translate('tray.collapseTitle'),
|
|
2737
|
-
'aria-expanded': 'true',
|
|
2738
|
-
onClick: () => poolActions.setSetting('queueCollapsed', true),
|
|
2739
|
-
},
|
|
2740
|
-
h('span', { className: 'pp-queue-toggle-icon' }, icon('chevronDown')),
|
|
2741
|
-
),
|
|
2742
|
-
h('span', { className: 'pp-foot-title' }, translate('tray.title')),
|
|
2743
|
-
h('span', { className: 'pp-hint' }, translate('tray.selected', { n: state.tray.length })),
|
|
2744
|
-
queuePending > 0 ? h('span', { className: 'pp-hint' }, translate('tray.queue', { n: queuePending })) : null,
|
|
2745
|
-
h('span', { className: 'pp-grow' }),
|
|
2746
|
-
state.tray.length > 0
|
|
2747
|
-
? h('button', { type: 'button', className: 'pp-link', onClick: () => setConfirmClear(true) }, translate('tray.clear'))
|
|
2748
|
-
: null,
|
|
2749
|
-
state.tray.length > 0
|
|
2750
|
-
? h(
|
|
2751
|
-
'button',
|
|
2752
|
-
{ type: 'button', className: 'pp-primary', onClick: () => sendToComposer({ type: 'release' }, translate('status.releaseSent')) },
|
|
2753
|
-
translate('tray.release'),
|
|
2754
|
-
)
|
|
2755
|
-
: null,
|
|
2756
|
-
),
|
|
2757
|
-
state.tray.length === 0
|
|
2758
|
-
? h(
|
|
2759
|
-
'div',
|
|
2760
|
-
{ className: 'pp-tray pp-tray-empty', ref: trayRef },
|
|
2761
|
-
h('div', { className: 'pp-hint' }, translate('tray.empty')),
|
|
2762
|
-
)
|
|
2763
|
-
: h(
|
|
2764
|
-
'div',
|
|
2765
|
-
{
|
|
2766
|
-
className: 'pp-tray',
|
|
2767
|
-
ref: trayRef,
|
|
2768
|
-
},
|
|
2769
|
-
state.tray.map((entry, index) => {
|
|
2770
|
-
if (trayEditing && trayEditing.key === entry.key) {
|
|
2771
|
-
return h(
|
|
2772
|
-
'div',
|
|
2773
|
-
{ key: entry.key, className: 'pp-edit', style: { margin: '4px 0' } },
|
|
2774
|
-
h(MentionField, {
|
|
2775
|
-
value: trayEditing.body,
|
|
2776
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
2777
|
-
rows: 4,
|
|
2778
|
-
autoFocus: true,
|
|
2779
|
-
sessionId: activeSessionId,
|
|
2780
|
-
onChange: (event) => setTrayEditing((current) => (current ? { ...current, body: event.target.value } : current)),
|
|
2781
|
-
onPasteImages: pasteTrayImages,
|
|
2782
|
-
onKeyDown: (event) => {
|
|
2783
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
2784
|
-
event.preventDefault();
|
|
2785
|
-
saveTrayEdit();
|
|
2786
|
-
}
|
|
2787
|
-
},
|
|
2788
|
-
}),
|
|
2789
|
-
h(ImagePicker, {
|
|
2790
|
-
images: trayEditing.images || [],
|
|
2791
|
-
onChange: (images) => setTrayEditing((current) => (current ? { ...current, images } : current)),
|
|
2792
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
2793
|
-
onOpen: openImage,
|
|
2794
|
-
}),
|
|
2795
|
-
h(
|
|
2796
|
-
'div',
|
|
2797
|
-
{ className: 'pp-edit-actions' },
|
|
2798
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: () => setTrayEditing(null) }, translate('row.cancel')),
|
|
2799
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: saveTrayEdit }, translate('row.save')),
|
|
2800
|
-
),
|
|
2801
|
-
);
|
|
2802
|
-
}
|
|
2803
|
-
return h(
|
|
2804
|
-
'div',
|
|
2805
|
-
{ key: entry.key, className: 'pp-chip' },
|
|
2806
|
-
h('span', { className: 'pp-chip-n' }, String(index + 1) + '.'),
|
|
2807
|
-
h('div', { className: 'pp-chip-t', title: entry.body }, entry.body),
|
|
2808
|
-
h(ImageStrip, { images: entry.images, compact: true, max: 4, onOpen: openImage }),
|
|
2809
|
-
h(
|
|
2810
|
-
'div',
|
|
2811
|
-
{ className: 'pp-chip-actions' },
|
|
2812
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.moveTray(entry.key, -1) }),
|
|
2813
|
-
h(IconButton, {
|
|
2814
|
-
name: 'down',
|
|
2815
|
-
label: translate('row.down'),
|
|
2816
|
-
disabled: index === state.tray.length - 1,
|
|
2817
|
-
onClick: () => poolActions.moveTray(entry.key, 1),
|
|
2818
|
-
}),
|
|
2819
|
-
h(IconButton, {
|
|
2820
|
-
name: 'edit',
|
|
2821
|
-
label: translate('row.edit'),
|
|
2822
|
-
onClick: () => setTrayEditing({ key: entry.key, body: entry.body || '', images: normalizeImages(entry.images) }),
|
|
2823
|
-
}),
|
|
2824
|
-
h(IconButton, { name: 'copy', label: translate('tray.duplicate'), onClick: () => poolActions.duplicateTray(entry.key) }),
|
|
2825
|
-
h(IconButton, { name: 'close', label: translate('tray.remove'), onClick: () => setPendingRemove(entry) }),
|
|
2826
|
-
),
|
|
2827
|
-
);
|
|
2828
|
-
}),
|
|
2829
|
-
),
|
|
2830
|
-
),
|
|
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
|
+
}),
|
|
2831
3133
|
h(ImageLightbox, { preview, onClose: closeImage }),
|
|
2832
3134
|
),
|
|
3135
|
+
renderReleaseOverlay({ state: releaseInfo, onStop: () => bridge.request({ type: 'stop' }) }),
|
|
2833
3136
|
);
|
|
2834
3137
|
}
|
|
2835
3138
|
|
|
@@ -3165,7 +3468,7 @@ window.__ModuleLoader__.load({
|
|
|
3165
3468
|
setActive(0);
|
|
3166
3469
|
};
|
|
3167
3470
|
|
|
3168
|
-
const sessionTag = () => (props.sessionId ? 'session=' + String(props.sessionId).slice(-8) : '
|
|
3471
|
+
const sessionTag = () => (props.sessionId ? 'session=' + String(props.sessionId).slice(-8) : translate('mention.noSessionTag'));
|
|
3169
3472
|
|
|
3170
3473
|
const openFor = (value, caret) => {
|
|
3171
3474
|
const before = String(value || '').slice(0, caret);
|
|
@@ -3224,7 +3527,7 @@ window.__ModuleLoader__.load({
|
|
|
3224
3527
|
window.clearTimeout(timer);
|
|
3225
3528
|
setItems([]);
|
|
3226
3529
|
setNote(
|
|
3227
|
-
translate('mention.failed') + '
|
|
3530
|
+
translate('mention.failed') + ': ' + String((error && error.message) || error).slice(0, 90) + ' · ' + sessionTag(),
|
|
3228
3531
|
);
|
|
3229
3532
|
return;
|
|
3230
3533
|
}
|
|
@@ -3241,7 +3544,7 @@ window.__ModuleLoader__.load({
|
|
|
3241
3544
|
setItems([]);
|
|
3242
3545
|
const message = String((error && error.message) || error).slice(0, 90);
|
|
3243
3546
|
setNote(
|
|
3244
|
-
(abort.signal.aborted ? translate('mention.timeout') : translate('mention.failed') + '
|
|
3547
|
+
(abort.signal.aborted ? translate('mention.timeout') : translate('mention.failed') + ': ' + message) +
|
|
3245
3548
|
' · ' +
|
|
3246
3549
|
sessionTag(),
|
|
3247
3550
|
);
|
|
@@ -3256,7 +3559,7 @@ window.__ModuleLoader__.load({
|
|
|
3256
3559
|
workspace
|
|
3257
3560
|
.listDirectory(undefined)
|
|
3258
3561
|
.then((listing) => {
|
|
3259
|
-
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);
|
|
3260
3563
|
})
|
|
3261
3564
|
.catch(() => apply([], query));
|
|
3262
3565
|
};
|
|
@@ -3277,7 +3580,7 @@ window.__ModuleLoader__.load({
|
|
|
3277
3580
|
openFor(event.target.value, event.target.selectionStart || 0);
|
|
3278
3581
|
} catch (error) {
|
|
3279
3582
|
setItems([]);
|
|
3280
|
-
setNote(translate('mention.failed') + '
|
|
3583
|
+
setNote(translate('mention.failed') + ': ' + String((error && error.message) || error).slice(0, 90));
|
|
3281
3584
|
}
|
|
3282
3585
|
},
|
|
3283
3586
|
onPaste: (event) => {
|
|
@@ -3374,6 +3677,7 @@ window.__ModuleLoader__.load({
|
|
|
3374
3677
|
useLocaleTick();
|
|
3375
3678
|
const state = usePoolState();
|
|
3376
3679
|
const storage = useStorageState();
|
|
3680
|
+
const releaseInfo = useReleaseState();
|
|
3377
3681
|
const view = useUiState();
|
|
3378
3682
|
const workspaces = useWorkspaceDir();
|
|
3379
3683
|
const sessionHint = useSessionDir().sessionId;
|
|
@@ -3428,8 +3732,6 @@ window.__ModuleLoader__.load({
|
|
|
3428
3732
|
|
|
3429
3733
|
const [tab, setTab] = useState('all');
|
|
3430
3734
|
const [query, setQuery] = useState('');
|
|
3431
|
-
const [editing, setEditing] = useState(null);
|
|
3432
|
-
const [trayEditing, setTrayEditing] = useState(null);
|
|
3433
3735
|
const [settingsOpen, setSettingsOpen] = useState(false);
|
|
3434
3736
|
const [pendingCategory, setPendingCategory] = useState(null);
|
|
3435
3737
|
const [wsSelected, setWsSelected] = useState('');
|
|
@@ -3438,6 +3740,7 @@ window.__ModuleLoader__.load({
|
|
|
3438
3740
|
const [confirmClear, setConfirmClear] = useState(false);
|
|
3439
3741
|
const [pendingDelete, setPendingDelete] = useState(null);
|
|
3440
3742
|
const [pendingRemove, setPendingRemove] = useState(null);
|
|
3743
|
+
const [captureOpen, setCaptureOpen] = useState(false);
|
|
3441
3744
|
const [status, setStatus] = useState(null);
|
|
3442
3745
|
const [busy, setBusy] = useState(false);
|
|
3443
3746
|
const { preview, openImage, closeImage } = useImagePreview();
|
|
@@ -3450,6 +3753,9 @@ window.__ModuleLoader__.load({
|
|
|
3450
3753
|
}, []);
|
|
3451
3754
|
useEffect(() => () => window.clearTimeout(statusTimer.current), []);
|
|
3452
3755
|
|
|
3756
|
+
const { editing, setEditing, startEdit, save, cancelEdit, pasteImages } = usePoolEditor(flash);
|
|
3757
|
+
const { trayEditing, setTrayEditing, saveTrayEdit, pasteTrayImages } = useTrayEditor(flash);
|
|
3758
|
+
|
|
3453
3759
|
// A failed write outranks a transient toast: the change is not saved.
|
|
3454
3760
|
const notice = status || (storage.failed ? { kind: 'error', text: translate('status.storageFailed') } : null);
|
|
3455
3761
|
|
|
@@ -3462,13 +3768,21 @@ window.__ModuleLoader__.load({
|
|
|
3462
3768
|
};
|
|
3463
3769
|
|
|
3464
3770
|
const panelRef = useRef(null);
|
|
3771
|
+
const panelChrome = normalizeSettings(state.settings);
|
|
3465
3772
|
|
|
3466
3773
|
// The panel can be dragged taller or shorter; 0 means the CSS default.
|
|
3467
3774
|
const [dragHeight, setDragHeight] = useState(0);
|
|
3468
|
-
const panelHeight = dragHeight ||
|
|
3775
|
+
const panelHeight = dragHeight || panelChrome.panelHeight;
|
|
3469
3776
|
const panelHeightRef = useRef(panelHeight);
|
|
3470
3777
|
panelHeightRef.current = panelHeight;
|
|
3471
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
|
+
|
|
3472
3786
|
// Room from the top of the pane that clips the panel down to the panel's
|
|
3473
3787
|
// own bottom edge. The overlay anchors that bottom edge to the composer,
|
|
3474
3788
|
// and a new session puts the composer mid-page, so the panel is capped by
|
|
@@ -3532,8 +3846,44 @@ window.__ModuleLoader__.load({
|
|
|
3532
3846
|
poolActions.setSetting('panelHeight', 0);
|
|
3533
3847
|
};
|
|
3534
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
|
+
|
|
3535
3885
|
useEffect(() => {
|
|
3536
|
-
if (!view.open) return undefined;
|
|
3886
|
+
if (!view.open || panelPinned) return undefined;
|
|
3537
3887
|
const onPointerDown = (event) => {
|
|
3538
3888
|
const target = event.target;
|
|
3539
3889
|
if (!(target instanceof Element)) return;
|
|
@@ -3543,12 +3893,12 @@ window.__ModuleLoader__.load({
|
|
|
3543
3893
|
};
|
|
3544
3894
|
document.addEventListener('pointerdown', onPointerDown, true);
|
|
3545
3895
|
return () => document.removeEventListener('pointerdown', onPointerDown, true);
|
|
3546
|
-
}, [view.open]);
|
|
3896
|
+
}, [view.open, panelPinned]);
|
|
3547
3897
|
|
|
3548
3898
|
useEffect(() => {
|
|
3549
3899
|
if (!view.open || preview) return undefined;
|
|
3550
3900
|
const onKey = (event) => {
|
|
3551
|
-
if (event.key !== 'Escape') return;
|
|
3901
|
+
if (event.key !== 'Escape' || captureOpen) return;
|
|
3552
3902
|
if (editing) {
|
|
3553
3903
|
setEditing(null);
|
|
3554
3904
|
} else {
|
|
@@ -3559,7 +3909,7 @@ window.__ModuleLoader__.load({
|
|
|
3559
3909
|
};
|
|
3560
3910
|
window.addEventListener('keydown', onKey, true);
|
|
3561
3911
|
return () => window.removeEventListener('keydown', onKey, true);
|
|
3562
|
-
}, [view.open, editing, preview]);
|
|
3912
|
+
}, [view.open, editing, preview, captureOpen]);
|
|
3563
3913
|
|
|
3564
3914
|
const rail = workspaceRail(workspaces.items, state.settings, currentWorkspaceId);
|
|
3565
3915
|
const wsActive = rail.some((entry) => entry.id === wsSelected) ? wsSelected : rail.length > 0 ? rail[0].id : '';
|
|
@@ -3592,18 +3942,79 @@ window.__ModuleLoader__.load({
|
|
|
3592
3942
|
actions.setDraft(text);
|
|
3593
3943
|
};
|
|
3594
3944
|
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
if (list.length === 0) return 0;
|
|
3598
|
-
if (!actions || typeof actions.addAttachments !== 'function') throw new Error(translate('image.insertFailed'));
|
|
3599
|
-
const api = conversationFace || serviceOf(pluginCtx, 'conversation');
|
|
3600
|
-
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) => {
|
|
3601
3947
|
const files = [];
|
|
3602
|
-
for (const image of
|
|
3948
|
+
for (const image of normalizeImages(images)) {
|
|
3603
3949
|
const blob = await getImageBlob(image.id);
|
|
3604
3950
|
if (!blob) throw new Error(translate('image.missing'));
|
|
3605
3951
|
files.push(new File([blob], image.name || 'image', { type: image.type || blob.type || 'image/png' }));
|
|
3606
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'));
|
|
3607
4018
|
const drafts = api.createDrafts(props.sessionId, files);
|
|
3608
4019
|
if (!Array.isArray(drafts) || drafts.length !== files.length) throw new Error(translate('image.insertFailed'));
|
|
3609
4020
|
try {
|
|
@@ -3648,23 +4059,6 @@ window.__ModuleLoader__.load({
|
|
|
3648
4059
|
}
|
|
3649
4060
|
};
|
|
3650
4061
|
|
|
3651
|
-
const saveTrayEdit = () => {
|
|
3652
|
-
if (!trayEditing) return;
|
|
3653
|
-
if (!trayEditing.body.trim() && !(trayEditing.images && trayEditing.images.length)) {
|
|
3654
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
3655
|
-
return;
|
|
3656
|
-
}
|
|
3657
|
-
poolActions.patchTray(trayEditing.key, { body: trayEditing.body, images: trayEditing.images || [] });
|
|
3658
|
-
setTrayEditing(null);
|
|
3659
|
-
};
|
|
3660
|
-
|
|
3661
|
-
const pasteTrayImages = (files) => {
|
|
3662
|
-
const key = trayEditing && trayEditing.key;
|
|
3663
|
-
appendImageAssets(files, trayEditing && trayEditing.images ? trayEditing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
3664
|
-
setTrayEditing((current) => (current && current.key === key ? { ...current, images } : current));
|
|
3665
|
-
});
|
|
3666
|
-
};
|
|
3667
|
-
|
|
3668
4062
|
/** The composer's draft attachments as descriptors, when the host exposes them. */
|
|
3669
4063
|
const resolveAttachments = () => {
|
|
3670
4064
|
const api = conversationFace || serviceOf(pluginCtx, 'conversation');
|
|
@@ -3677,12 +4071,22 @@ window.__ModuleLoader__.load({
|
|
|
3677
4071
|
}
|
|
3678
4072
|
};
|
|
3679
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
|
+
|
|
3680
4083
|
/**
|
|
3681
4084
|
* Copies the composer content into the pool; the composer keeps its text.
|
|
3682
4085
|
* Attached images come along (their browser files are copied into the pool's
|
|
3683
4086
|
* image store); other files have no local copy to keep, so they are counted.
|
|
3684
4087
|
*/
|
|
3685
|
-
const captureDraft = async () => {
|
|
4088
|
+
const captureDraft = async (groupArg) => {
|
|
4089
|
+
const group = typeof groupArg === 'string' && familyOf(groupArg) ? groupArg : BUILTIN_GROUP.note;
|
|
3686
4090
|
const text = draftRef.current;
|
|
3687
4091
|
if (!text || !text.trim()) {
|
|
3688
4092
|
flash({ kind: 'error', text: translate('status.nothing') });
|
|
@@ -3697,7 +4101,7 @@ window.__ModuleLoader__.load({
|
|
|
3697
4101
|
}
|
|
3698
4102
|
const item = {
|
|
3699
4103
|
id: uid(),
|
|
3700
|
-
group
|
|
4104
|
+
group,
|
|
3701
4105
|
title: draftTitle(text, occurrenceRef.current),
|
|
3702
4106
|
body: text,
|
|
3703
4107
|
images: normalizeImages(stored),
|
|
@@ -3705,13 +4109,14 @@ window.__ModuleLoader__.load({
|
|
|
3705
4109
|
updatedAt: Date.now(),
|
|
3706
4110
|
};
|
|
3707
4111
|
poolActions.add(item);
|
|
3708
|
-
// The copy lands in
|
|
4112
|
+
// The copy lands in the chosen group, which a folded/workspace tab may not show.
|
|
3709
4113
|
if (!matchesTab(item, tab)) setTab('all');
|
|
3710
4114
|
const skipped = others.length + (images.length - item.images.length);
|
|
4115
|
+
const label = groupLabelOf(item, state.categories, workspaces.items);
|
|
3711
4116
|
flash(skipped > 0
|
|
3712
|
-
? { kind: 'info', text: translate('status.
|
|
3713
|
-
: { kind: 'ok', text: translate('status.
|
|
3714
|
-
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 };
|
|
3715
4120
|
};
|
|
3716
4121
|
|
|
3717
4122
|
const newItem = () => {
|
|
@@ -3733,43 +4138,6 @@ window.__ModuleLoader__.load({
|
|
|
3733
4138
|
setEditing({ id: item.id, group, title: '', body: '', images: [] });
|
|
3734
4139
|
};
|
|
3735
4140
|
|
|
3736
|
-
/**
|
|
3737
|
-
* Cancel drops an item the editor created and never saved, so no empty
|
|
3738
|
-
* row is left behind; an existing item keeps its stored content.
|
|
3739
|
-
*/
|
|
3740
|
-
const cancelEdit = () => {
|
|
3741
|
-
const current = editing;
|
|
3742
|
-
setEditing(null);
|
|
3743
|
-
if (!current) return;
|
|
3744
|
-
const stored = pool.get().items.find((item) => item.id === current.id);
|
|
3745
|
-
discardUnsavedImages(current, stored);
|
|
3746
|
-
if (stored && !stored.body.trim() && !(stored.images && stored.images.length > 0)) poolActions.remove(stored.id);
|
|
3747
|
-
};
|
|
3748
|
-
|
|
3749
|
-
const startEdit = (item) => setEditing({ id: item.id, group: groupOf(item), title: item.title, body: item.body, images: normalizeImages(item.images) });
|
|
3750
|
-
|
|
3751
|
-
const saveEdit = () => {
|
|
3752
|
-
if (!editing) return;
|
|
3753
|
-
if (!editing.body.trim() && (!editing.images || editing.images.length === 0)) {
|
|
3754
|
-
flash({ kind: 'error', text: translate('status.emptyBody') });
|
|
3755
|
-
return;
|
|
3756
|
-
}
|
|
3757
|
-
poolActions.patch(editing.id, {
|
|
3758
|
-
group: editing.group,
|
|
3759
|
-
title: editing.title.trim(),
|
|
3760
|
-
body: editing.body,
|
|
3761
|
-
images: editing.images || [],
|
|
3762
|
-
});
|
|
3763
|
-
setEditing(null);
|
|
3764
|
-
};
|
|
3765
|
-
|
|
3766
|
-
const pasteImages = (files) => {
|
|
3767
|
-
const id = editing && editing.id;
|
|
3768
|
-
appendImageAssets(files, editing && editing.images ? editing.images : [], (text) => flash({ kind: 'error', text })).then((images) => {
|
|
3769
|
-
setEditing((current) => (current && current.id === id ? { ...current, images } : current));
|
|
3770
|
-
});
|
|
3771
|
-
};
|
|
3772
|
-
|
|
3773
4141
|
const deleteItem = (item, text) => {
|
|
3774
4142
|
const index = pool.get().items.findIndex((entry) => entry.id === item.id);
|
|
3775
4143
|
poolActions.remove(item.id);
|
|
@@ -3795,26 +4163,54 @@ window.__ModuleLoader__.load({
|
|
|
3795
4163
|
if (busyRef.current) return;
|
|
3796
4164
|
const entries = state.tray.slice();
|
|
3797
4165
|
if (entries.length === 0) return;
|
|
3798
|
-
|
|
4166
|
+
const direct = resolveDirectQueue();
|
|
4167
|
+
if (!direct && draftRef.current.trim() !== '') {
|
|
3799
4168
|
flash({ kind: 'error', text: translate('status.draftBusy') });
|
|
3800
4169
|
return;
|
|
3801
4170
|
}
|
|
3802
4171
|
busyRef.current = true;
|
|
3803
4172
|
setBusy(true);
|
|
4173
|
+
releaseCancel = false;
|
|
4174
|
+
releaseState.set({ active: true, sent: 0, total: entries.length, stopping: false });
|
|
3804
4175
|
setStatus({ kind: 'info', text: translate('status.releasing', { n: entries.length }) });
|
|
3805
4176
|
let sent = 0;
|
|
4177
|
+
let canceled = false;
|
|
4178
|
+
let failed = false;
|
|
3806
4179
|
// Keys finished by this run; the queue is filtered by key afterwards so
|
|
3807
4180
|
// rows queued (or removed) meanwhile are not overwritten.
|
|
3808
4181
|
const done = [];
|
|
3809
4182
|
try {
|
|
3810
4183
|
for (const entry of entries) {
|
|
4184
|
+
if (releaseCancel) {
|
|
4185
|
+
canceled = true;
|
|
4186
|
+
break;
|
|
4187
|
+
}
|
|
3811
4188
|
const body = typeof entry.body === 'string' ? entry.body : '';
|
|
3812
4189
|
const images = normalizeImages(entry.images);
|
|
3813
4190
|
if (!body.trim() && images.length === 0) {
|
|
3814
4191
|
done.push(entry.key);
|
|
3815
4192
|
continue;
|
|
3816
4193
|
}
|
|
3817
|
-
|
|
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);
|
|
3818
4214
|
if (!clear) break;
|
|
3819
4215
|
try {
|
|
3820
4216
|
if (images.length > 0) await addImages(images);
|
|
@@ -3827,14 +4223,10 @@ window.__ModuleLoader__.load({
|
|
|
3827
4223
|
const pendingBefore = pendingRef.current.length;
|
|
3828
4224
|
try {
|
|
3829
4225
|
setDraft(body);
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
// Wait until the editor really holds this occurrence before submitting it.
|
|
3835
|
-
const loaded = await waitFor(() => draftRef.current.trim() === body.trim(), 2500);
|
|
3836
|
-
if (!loaded) break;
|
|
3837
|
-
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.
|
|
3838
4230
|
actions.submit();
|
|
3839
4231
|
} catch (error) {
|
|
3840
4232
|
flash({ kind: 'error', text: String((error && error.message) || error) });
|
|
@@ -3844,134 +4236,68 @@ window.__ModuleLoader__.load({
|
|
|
3844
4236
|
() =>
|
|
3845
4237
|
(queueRef.current.length > queuedBefore || pendingRef.current.length > pendingBefore) &&
|
|
3846
4238
|
draftRef.current.trim() === '',
|
|
3847
|
-
|
|
4239
|
+
RELEASE_WAIT.accept,
|
|
3848
4240
|
);
|
|
3849
4241
|
if (!accepted) {
|
|
3850
4242
|
// The first send of an idle session becomes the live turn, not a queue row.
|
|
3851
4243
|
if (!(sent === 0 && draftRef.current.trim() === '')) break;
|
|
3852
4244
|
}
|
|
3853
|
-
await waitFor(() => phaseRef.current === 'plain',
|
|
4245
|
+
await waitFor(() => phaseRef.current === 'plain', RELEASE_WAIT.plain);
|
|
3854
4246
|
sent += 1;
|
|
3855
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
|
+
}
|
|
3856
4253
|
}
|
|
3857
4254
|
} catch (error) {
|
|
3858
4255
|
flash({ kind: 'error', text: String((error && error.message) || error) });
|
|
3859
4256
|
} finally {
|
|
3860
4257
|
busyRef.current = false;
|
|
3861
4258
|
setBusy(false);
|
|
4259
|
+
releaseState.set({ active: false, sent, total: entries.length, stopping: false });
|
|
4260
|
+
releaseCancel = false;
|
|
3862
4261
|
}
|
|
3863
4262
|
poolActions.removeTrayKeys(done);
|
|
3864
|
-
|
|
3865
|
-
sent
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
return h(
|
|
3874
|
-
'div',
|
|
3875
|
-
{ key: item.id, className: 'pp-edit' },
|
|
3876
|
-
h('input', {
|
|
3877
|
-
className: 'pp-input',
|
|
3878
|
-
value: editing.title,
|
|
3879
|
-
placeholder: translate('row.titlePlaceholder'),
|
|
3880
|
-
onChange: (event) => setEditing({ ...editing, title: event.target.value }),
|
|
3881
|
-
}),
|
|
3882
|
-
h(MentionField, {
|
|
3883
|
-
value: editing.body,
|
|
3884
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
3885
|
-
rows: 4,
|
|
3886
|
-
autoFocus: true,
|
|
3887
|
-
sessionId: props.sessionId,
|
|
3888
|
-
onChange: (event) => setEditing({ ...editing, body: event.target.value }),
|
|
3889
|
-
onPasteImages: pasteImages,
|
|
3890
|
-
onKeyDown: (event) => {
|
|
3891
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
3892
|
-
event.preventDefault();
|
|
3893
|
-
saveEdit();
|
|
3894
|
-
}
|
|
3895
|
-
},
|
|
3896
|
-
}),
|
|
3897
|
-
h(ImagePicker, {
|
|
3898
|
-
images: editing.images || [],
|
|
3899
|
-
onChange: (images) => setEditing((current) => (current ? { ...current, images } : current)),
|
|
3900
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
3901
|
-
onOpen: openImage,
|
|
3902
|
-
}),
|
|
3903
|
-
h(
|
|
3904
|
-
'div',
|
|
3905
|
-
{ className: 'pp-edit-actions' },
|
|
3906
|
-
h(
|
|
3907
|
-
'select',
|
|
3908
|
-
{
|
|
3909
|
-
className: 'pp-input',
|
|
3910
|
-
style: { width: 'auto', maxWidth: '220px' },
|
|
3911
|
-
value: groupOf(editing),
|
|
3912
|
-
'aria-label': translate('row.classification'),
|
|
3913
|
-
onChange: (event) => setEditing(withGroup(editing, event.target.value)),
|
|
3914
|
-
},
|
|
3915
|
-
h(
|
|
3916
|
-
'optgroup',
|
|
3917
|
-
{ label: translate('row.familyBuiltin') },
|
|
3918
|
-
h('option', { value: BUILTIN_GROUP.oftenuse }, translate('group.oftenuse')),
|
|
3919
|
-
h('option', { value: BUILTIN_GROUP.note }, translate('group.note')),
|
|
3920
|
-
h('option', { value: BUILTIN_GROUP.template }, translate('group.template')),
|
|
3921
|
-
),
|
|
3922
|
-
workspaces.items.length > 0
|
|
3923
|
-
? h(
|
|
3924
|
-
'optgroup',
|
|
3925
|
-
{ label: translate('row.familyWorkspace') },
|
|
3926
|
-
workspaces.items.map((workspace) => h('option', { key: workspace.id, value: 'workspace:' + workspace.workspaceId }, workspace.name)),
|
|
3927
|
-
)
|
|
3928
|
-
: null,
|
|
3929
|
-
state.categories.length > 0
|
|
3930
|
-
? h(
|
|
3931
|
-
'optgroup',
|
|
3932
|
-
{ label: translate('row.familyCustom') },
|
|
3933
|
-
state.categories.map((category) => h('option', { key: category.id, value: 'custom:' + category.id }, category.name)),
|
|
3934
|
-
)
|
|
3935
|
-
: null,
|
|
3936
|
-
),
|
|
3937
|
-
h('span', { className: 'pp-grow' }),
|
|
3938
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: cancelEdit }, translate('row.cancel')),
|
|
3939
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: saveEdit }, translate('row.save')),
|
|
3940
|
-
),
|
|
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 }) },
|
|
3941
4272
|
);
|
|
3942
4273
|
}
|
|
3943
|
-
return h(
|
|
3944
|
-
'div',
|
|
3945
|
-
{ key: item.id, className: 'pp-row pp-page-item' },
|
|
3946
|
-
h(IconButton, { name: 'insert', label: translate('row.insert'), onClick: () => insertItem(item) }),
|
|
3947
|
-
h(TrayAdd, { label: translate('row.select'), onClick: () => queueItem(item) }),
|
|
3948
|
-
h(
|
|
3949
|
-
'div',
|
|
3950
|
-
{ className: 'pp-main', title: translate('row.insert'), onClick: () => insertItem(item) },
|
|
3951
|
-
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')),
|
|
3952
|
-
item.body.trim() === (item.title || '').trim() ? null : h('div', { className: 'pp-body' }, item.body),
|
|
3953
|
-
h(ImageStrip, { images: item.images, compact: true, onOpen: openImage }),
|
|
3954
|
-
),
|
|
3955
|
-
tab === 'all'
|
|
3956
|
-
? h('span', { className: 'pp-tag' }, clipLabel(groupLabelOf(item, state.categories, workspaces.items)))
|
|
3957
|
-
: null,
|
|
3958
|
-
h(
|
|
3959
|
-
'div',
|
|
3960
|
-
{ className: 'pp-actions' },
|
|
3961
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.move(item.id, -1) }),
|
|
3962
|
-
h(IconButton, {
|
|
3963
|
-
name: 'down',
|
|
3964
|
-
label: translate('row.down'),
|
|
3965
|
-
disabled: index === items.length - 1,
|
|
3966
|
-
onClick: () => poolActions.move(item.id, 1),
|
|
3967
|
-
}),
|
|
3968
|
-
h(IconButton, { name: 'edit', label: translate('row.edit'), onClick: () => startEdit(item) }),
|
|
3969
|
-
h(IconButton, { name: 'copy', label: translate('row.duplicate'), onClick: () => poolActions.duplicateItem(item.id) }),
|
|
3970
|
-
h(IconButton, { name: 'trash', label: translate('row.delete'), danger: true, onClick: () => setPendingDelete(item) }),
|
|
3971
|
-
),
|
|
3972
|
-
);
|
|
3973
4274
|
};
|
|
3974
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
|
+
|
|
3975
4301
|
const tray = state.tray;
|
|
3976
4302
|
const queueCollapsed = normalizeSettings(state.settings).queueCollapsed;
|
|
3977
4303
|
|
|
@@ -4009,11 +4335,18 @@ window.__ModuleLoader__.load({
|
|
|
4009
4335
|
api.release();
|
|
4010
4336
|
return { ok: true };
|
|
4011
4337
|
}
|
|
4338
|
+
if (command.type === 'stop') {
|
|
4339
|
+
return { ok: requestReleaseStop() };
|
|
4340
|
+
}
|
|
4012
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
|
+
}
|
|
4013
4345
|
if (command.type === 'capture') {
|
|
4014
4346
|
// The capture is async (it copies attachments), so the answer is a promise;
|
|
4015
4347
|
// reading `.ok` off it always failed and reported an empty composer.
|
|
4016
|
-
|
|
4348
|
+
const group = typeof command.group === 'string' ? command.group : '';
|
|
4349
|
+
return Promise.resolve(api.capture(group)).then(
|
|
4017
4350
|
(result) => (result && result.ok ? result : { ok: false, reason: (result && result.reason) || 'empty' }),
|
|
4018
4351
|
(error) => ({ ok: false, reason: String((error && error.message) || error) }),
|
|
4019
4352
|
);
|
|
@@ -4025,6 +4358,8 @@ window.__ModuleLoader__.load({
|
|
|
4025
4358
|
if (!view.open) return null;
|
|
4026
4359
|
|
|
4027
4360
|
const panelCount = state.items.length;
|
|
4361
|
+
const captureGroups = captureChoices(state.categories, workspaces.items, currentWorkspaceId, state.settings);
|
|
4362
|
+
const tabCounts = tabCountsOf(state.items);
|
|
4028
4363
|
|
|
4029
4364
|
// A folded family renders its groups as chips inside one tab.
|
|
4030
4365
|
const customGroups = state.categories.map((category) => ({ id: 'custom:' + category.id, name: category.name }));
|
|
@@ -4033,11 +4368,8 @@ window.__ModuleLoader__.load({
|
|
|
4033
4368
|
: customGroups.length > 0
|
|
4034
4369
|
? customGroups[0].id
|
|
4035
4370
|
: '';
|
|
4036
|
-
const customCounts =
|
|
4037
|
-
|
|
4038
|
-
const group = groupOf(item);
|
|
4039
|
-
if (familyOf(group) === 'custom') customCounts[group] = (customCounts[group] || 0) + 1;
|
|
4040
|
-
}
|
|
4371
|
+
const customCounts = groupCounts(state.items, 'custom');
|
|
4372
|
+
const builtinCounts = groupCounts(state.items, 'builtin');
|
|
4041
4373
|
const builtinList = builtinGroups();
|
|
4042
4374
|
const builtinActive = builtinList.some((entry) => entry.id === builtinPick) ? builtinPick : builtinList[0].id;
|
|
4043
4375
|
const nestedView =
|
|
@@ -4066,7 +4398,7 @@ window.__ModuleLoader__.load({
|
|
|
4066
4398
|
rail: builtinList,
|
|
4067
4399
|
activeId: builtinActive,
|
|
4068
4400
|
onSelect: setBuiltinPick,
|
|
4069
|
-
counts:
|
|
4401
|
+
counts: builtinCounts,
|
|
4070
4402
|
emptyText: translate('panel.emptyTab'),
|
|
4071
4403
|
scoped: state.items.filter((item) => groupOf(item) === builtinActive),
|
|
4072
4404
|
}
|
|
@@ -4084,6 +4416,7 @@ window.__ModuleLoader__.load({
|
|
|
4084
4416
|
panelStyle.height = size;
|
|
4085
4417
|
panelStyle.maxHeight = 'none';
|
|
4086
4418
|
}
|
|
4419
|
+
if (panelWidth) panelStyle['--pp-w'] = panelWidth + 'px';
|
|
4087
4420
|
|
|
4088
4421
|
return h(
|
|
4089
4422
|
'div',
|
|
@@ -4109,6 +4442,19 @@ window.__ModuleLoader__.load({
|
|
|
4109
4442
|
},
|
|
4110
4443
|
h('span', { className: 'pp-grip-bar' }),
|
|
4111
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
|
+
),
|
|
4112
4458
|
// Same header and tab strip as the sidebar page, so both views read alike.
|
|
4113
4459
|
h(
|
|
4114
4460
|
'div',
|
|
@@ -4120,11 +4466,18 @@ window.__ModuleLoader__.load({
|
|
|
4120
4466
|
className: 'pp-search',
|
|
4121
4467
|
value: query,
|
|
4122
4468
|
placeholder: translate('page.search'),
|
|
4469
|
+
'aria-label': translate('page.search'),
|
|
4123
4470
|
onChange: (event) => setQuery(event.target.value),
|
|
4124
4471
|
}),
|
|
4125
4472
|
h('button', { type: 'button', className: 'pp-mini', onClick: newItem }, '+ ', translate('page.new')),
|
|
4126
|
-
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')),
|
|
4127
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
|
+
}),
|
|
4128
4481
|
h(
|
|
4129
4482
|
'button',
|
|
4130
4483
|
{ type: 'button', className: 'pp-x', title: translate('panel.close'), 'aria-label': translate('panel.close'), onClick: () => ui.set({ open: false }) },
|
|
@@ -4136,6 +4489,7 @@ window.__ModuleLoader__.load({
|
|
|
4136
4489
|
{ className: 'pp-bar', style: { padding: '8px 12px 2px' } },
|
|
4137
4490
|
h(TabBar, {
|
|
4138
4491
|
tabs: buildTabs(state.categories, workspaces.items, state.settings, currentWorkspaceId),
|
|
4492
|
+
counts: tabCounts,
|
|
4139
4493
|
active: tab,
|
|
4140
4494
|
...tabHandlers((next) => {
|
|
4141
4495
|
setSettingsOpen(false);
|
|
@@ -4185,6 +4539,16 @@ window.__ModuleLoader__.load({
|
|
|
4185
4539
|
},
|
|
4186
4540
|
})
|
|
4187
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,
|
|
4188
4552
|
h(
|
|
4189
4553
|
'div',
|
|
4190
4554
|
{ className: 'pp-list', ref: listRef },
|
|
@@ -4222,7 +4586,7 @@ window.__ModuleLoader__.load({
|
|
|
4222
4586
|
notice
|
|
4223
4587
|
? h(
|
|
4224
4588
|
'div',
|
|
4225
|
-
{ className: 'pp-status pp-status-float', 'data-kind': notice.kind || 'info' },
|
|
4589
|
+
{ className: 'pp-status pp-status-float', role: 'status', 'aria-live': 'polite', 'data-kind': notice.kind || 'info' },
|
|
4226
4590
|
h('span', null, notice.text),
|
|
4227
4591
|
notice.undo
|
|
4228
4592
|
? h(
|
|
@@ -4240,119 +4604,26 @@ window.__ModuleLoader__.load({
|
|
|
4240
4604
|
)
|
|
4241
4605
|
: null,
|
|
4242
4606
|
!settingsOpen
|
|
4243
|
-
?
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
: h(
|
|
4260
|
-
'div',
|
|
4261
|
-
{ className: 'pp-page-foot' },
|
|
4262
|
-
h(
|
|
4263
|
-
'div',
|
|
4264
|
-
{ className: 'pp-foot-head' },
|
|
4265
|
-
h(
|
|
4266
|
-
'button',
|
|
4267
|
-
{
|
|
4268
|
-
type: 'button',
|
|
4269
|
-
className: 'pp-queue-toggle',
|
|
4270
|
-
title: translate('tray.collapseTitle'),
|
|
4271
|
-
'aria-label': translate('tray.collapseTitle'),
|
|
4272
|
-
'aria-expanded': 'true',
|
|
4273
|
-
onClick: () => poolActions.setSetting('queueCollapsed', true),
|
|
4274
|
-
},
|
|
4275
|
-
h('span', { className: 'pp-queue-toggle-icon' }, icon('chevronDown')),
|
|
4276
|
-
),
|
|
4277
|
-
h('span', { className: 'pp-foot-title' }, translate('tray.title')),
|
|
4278
|
-
h('span', { className: 'pp-hint' }, translate('tray.selected', { n: tray.length })),
|
|
4279
|
-
queue.length > 0 ? h('span', { className: 'pp-hint' }, translate('tray.queue', { n: queue.length })) : null,
|
|
4280
|
-
h('span', { className: 'pp-grow' }),
|
|
4281
|
-
tray.length > 0 ? h('button', { type: 'button', className: 'pp-link', onClick: () => setConfirmClear(true) }, translate('tray.clear')) : null,
|
|
4282
|
-
tray.length > 0
|
|
4283
|
-
? h('button', { type: 'button', className: 'pp-primary', disabled: busy, onClick: release }, translate('tray.release'))
|
|
4284
|
-
: null,
|
|
4285
|
-
),
|
|
4286
|
-
h(
|
|
4287
|
-
'div',
|
|
4288
|
-
{ className: tray.length === 0 ? 'pp-tray pp-tray-empty' : 'pp-tray' },
|
|
4289
|
-
tray.length === 0
|
|
4290
|
-
? h('div', { className: 'pp-hint' }, translate('tray.empty'))
|
|
4291
|
-
: tray.map((entry, index) => {
|
|
4292
|
-
if (trayEditing && trayEditing.key === entry.key) {
|
|
4293
|
-
return h(
|
|
4294
|
-
'div',
|
|
4295
|
-
{ key: entry.key, className: 'pp-edit', style: { margin: '4px 0' } },
|
|
4296
|
-
h(MentionField, {
|
|
4297
|
-
value: trayEditing.body,
|
|
4298
|
-
placeholder: translate('row.bodyPlaceholder'),
|
|
4299
|
-
rows: 4,
|
|
4300
|
-
autoFocus: true,
|
|
4301
|
-
sessionId: props.sessionId,
|
|
4302
|
-
onChange: (event) => setTrayEditing((current) => (current ? { ...current, body: event.target.value } : current)),
|
|
4303
|
-
onPasteImages: pasteTrayImages,
|
|
4304
|
-
onKeyDown: (event) => {
|
|
4305
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'Enter') {
|
|
4306
|
-
event.preventDefault();
|
|
4307
|
-
saveTrayEdit();
|
|
4308
|
-
}
|
|
4309
|
-
},
|
|
4310
|
-
}),
|
|
4311
|
-
h(ImagePicker, {
|
|
4312
|
-
images: trayEditing.images || [],
|
|
4313
|
-
onChange: (images) => setTrayEditing((current) => (current ? { ...current, images } : current)),
|
|
4314
|
-
onError: (text) => flash({ kind: 'error', text }),
|
|
4315
|
-
onOpen: openImage,
|
|
4316
|
-
}),
|
|
4317
|
-
h(
|
|
4318
|
-
'div',
|
|
4319
|
-
{ className: 'pp-edit-actions' },
|
|
4320
|
-
h('button', { type: 'button', className: 'pp-mini', onClick: () => setTrayEditing(null) }, translate('row.cancel')),
|
|
4321
|
-
h('button', { type: 'button', className: 'pp-primary', onClick: saveTrayEdit }, translate('row.save')),
|
|
4322
|
-
),
|
|
4323
|
-
);
|
|
4324
|
-
}
|
|
4325
|
-
return h(
|
|
4326
|
-
'div',
|
|
4327
|
-
{ key: entry.key, className: 'pp-chip' },
|
|
4328
|
-
h('span', { className: 'pp-chip-n' }, String(index + 1) + '.'),
|
|
4329
|
-
h('div', { className: 'pp-chip-t', title: entry.body }, entry.body),
|
|
4330
|
-
h(ImageStrip, { images: entry.images, compact: true, max: 4, onOpen: openImage }),
|
|
4331
|
-
h(
|
|
4332
|
-
'div',
|
|
4333
|
-
{ className: 'pp-chip-actions' },
|
|
4334
|
-
h(IconButton, { name: 'up', label: translate('row.up'), disabled: index === 0, onClick: () => poolActions.moveTray(entry.key, -1) }),
|
|
4335
|
-
h(IconButton, {
|
|
4336
|
-
name: 'down',
|
|
4337
|
-
label: translate('row.down'),
|
|
4338
|
-
disabled: index === tray.length - 1,
|
|
4339
|
-
onClick: () => poolActions.moveTray(entry.key, 1),
|
|
4340
|
-
}),
|
|
4341
|
-
h(IconButton, {
|
|
4342
|
-
name: 'edit',
|
|
4343
|
-
label: translate('row.edit'),
|
|
4344
|
-
onClick: () => setTrayEditing({ key: entry.key, body: entry.body || '', images: normalizeImages(entry.images) }),
|
|
4345
|
-
}),
|
|
4346
|
-
h(IconButton, { name: 'copy', label: translate('tray.duplicate'), onClick: () => poolActions.duplicateTray(entry.key) }),
|
|
4347
|
-
h(IconButton, { name: 'close', label: translate('tray.remove'), onClick: () => setPendingRemove(entry) }),
|
|
4348
|
-
),
|
|
4349
|
-
);
|
|
4350
|
-
}),
|
|
4351
|
-
),
|
|
4352
|
-
)
|
|
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
|
+
})
|
|
4353
4623
|
: null,
|
|
4354
4624
|
),
|
|
4355
4625
|
h(ImageLightbox, { preview, onClose: closeImage }),
|
|
4626
|
+
renderReleaseOverlay({ state: releaseInfo, onStop: requestReleaseStop }),
|
|
4356
4627
|
);
|
|
4357
4628
|
}
|
|
4358
4629
|
|
|
@@ -4391,13 +4662,17 @@ window.__ModuleLoader__.load({
|
|
|
4391
4662
|
// The composer trigger names itself, and switches to the accent colour once
|
|
4392
4663
|
// something is queued so the pending count is hard to miss.
|
|
4393
4664
|
'.pp-trigger{gap:6px;padding:0 9px;border:1px solid transparent}' +
|
|
4665
|
+
'.pp-trigger[disabled]{opacity:.55;cursor:not-allowed}' +
|
|
4394
4666
|
'.pp-trigger-label{white-space:nowrap}' +
|
|
4395
4667
|
'.pp-trigger[data-queued="true"]{border-color:var(--pp-accent-line);background:var(--pp-accent-soft);color:var(--pp-accent);font-weight:600}' +
|
|
4396
4668
|
'.pp-trigger[data-queued="true"]:hover{background:color-mix(in srgb,var(--pp-accent) 20%,transparent);color:var(--pp-accent)}' +
|
|
4397
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}' +
|
|
4398
|
-
'.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}' +
|
|
4399
4671
|
// The grip above the header resizes the panel; a long queue may keep half the list.
|
|
4400
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)}' +
|
|
4401
4676
|
'.pp-grip-bar{width:44px;height:4px;border-radius:2px;background:var(--pp-line-2);transition:background .12s ease}' +
|
|
4402
4677
|
'.pp-panel-grip:hover .pp-grip-bar{background:var(--pp-accent)}' +
|
|
4403
4678
|
// flex:none keeps the card at its content height (or its cap) instead of
|
|
@@ -4413,9 +4688,6 @@ window.__ModuleLoader__.load({
|
|
|
4413
4688
|
// the tray sizes to its content and only shrinks (then scrolls) at the cap.
|
|
4414
4689
|
'.pp-panel .pp-page-foot .pp-tray{max-height:none;min-height:0;flex:0 1 auto}' +
|
|
4415
4690
|
'.pp-panel .pp-foot-head{flex:none}' +
|
|
4416
|
-
'.pp-head{display:flex;align-items:center;gap:8px;padding:10px 12px 6px}' +
|
|
4417
|
-
'.pp-head-title{font-weight:600;font-size:13px}' +
|
|
4418
|
-
'.pp-head-count{color:var(--pp-ink-2);font-size:11px;font-variant-numeric:tabular-nums}' +
|
|
4419
4691
|
'.pp-grow{flex:1;min-width:0}' +
|
|
4420
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}' +
|
|
4421
4693
|
'.pp-x:hover{background:var(--pp-hover);color:var(--pp-ink)}' +
|
|
@@ -4423,16 +4695,24 @@ window.__ModuleLoader__.load({
|
|
|
4423
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}' +
|
|
4424
4696
|
'.pp-tab:hover{background:var(--pp-hover)}' +
|
|
4425
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}' +
|
|
4426
4699
|
'.pp-tab-add{padding:0 7px;color:var(--pp-ink-2)}' +
|
|
4427
4700
|
'.pp-tab-addwrap{display:inline-flex;align-items:center}' +
|
|
4428
4701
|
'.pp-tab-sep{flex:none;width:1px;height:16px;margin:0 7px;background:color-mix(in srgb, var(--pp-ink-2) 45%, transparent)}' +
|
|
4429
|
-
'.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}' +
|
|
4430
4704
|
'.pp-tab-x:hover{color:var(--pp-danger)}' +
|
|
4431
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}' +
|
|
4432
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)}' +
|
|
4433
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)}' +
|
|
4434
4712
|
'.pp-modal-text{font-size:13px;line-height:1.65;color:var(--pp-ink)}' +
|
|
4435
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}' +
|
|
4436
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}' +
|
|
4437
4717
|
'.pp-mini:hover{background:var(--pp-hover)}' +
|
|
4438
4718
|
'.pp-set-btn{display:inline-flex;align-items:center;gap:5px;padding:0 9px}' +
|
|
@@ -4465,16 +4745,11 @@ window.__ModuleLoader__.load({
|
|
|
4465
4745
|
'.pp-about-row{display:flex;gap:10px;padding:2px 0;font-size:12px;color:var(--pp-ink);min-width:0}' +
|
|
4466
4746
|
'.pp-about-key{flex:none;width:60px;color:var(--pp-ink-2)}' +
|
|
4467
4747
|
'.pp-about-row a{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}' +
|
|
4468
|
-
'.pp-set-line{display:flex;align-items:center;gap:12px;padding:4px 0}' +
|
|
4469
4748
|
'.pp-set-ws{display:flex;align-items:center;gap:8px;padding:4px 0;cursor:pointer;min-width:0}' +
|
|
4470
4749
|
'.pp-set-ws input{margin:0;accent-color:var(--pp-accent);cursor:pointer}' +
|
|
4471
4750
|
'.pp-set-ws-name{font-size:12px;color:var(--pp-ink);white-space:nowrap}' +
|
|
4472
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}' +
|
|
4473
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}' +
|
|
4474
|
-
'.pp-set-name{min-width:78px;font-size:12px;color:var(--pp-ink)}' +
|
|
4475
|
-
'.pp-set-modes{display:flex;flex-wrap:wrap;gap:16px}' +
|
|
4476
|
-
'.pp-set-inline{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--pp-ink);cursor:pointer}' +
|
|
4477
|
-
'.pp-set-inline input{margin:0;accent-color:var(--pp-accent);cursor:pointer}' +
|
|
4478
4753
|
'.pp-set-label{font-size:12px;color:var(--pp-ink-2);margin:2px 0 4px}' +
|
|
4479
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)}' +
|
|
4480
4755
|
'.pp-set-card .pp-set-label{margin:0 0 6px;font-size:12px;font-weight:600;color:var(--pp-ink)}' +
|
|
@@ -4511,10 +4786,8 @@ window.__ModuleLoader__.load({
|
|
|
4511
4786
|
'.pp-page-item .pp-actions{opacity:.35}' +
|
|
4512
4787
|
'.pp-page-item:hover .pp-actions{opacity:1}' +
|
|
4513
4788
|
'.pp-empty{padding:22px 16px;color:var(--pp-ink-2);text-align:center;font-size:12px}' +
|
|
4514
|
-
'.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}' +
|
|
4515
4789
|
'.pp-row{display:flex;align-items:flex-start;gap:8px;padding:7px 8px;border-radius:8px}' +
|
|
4516
4790
|
'.pp-row:hover{background:var(--pp-hover)}' +
|
|
4517
|
-
'.pp-check{margin:2px 0 0;accent-color:var(--pp-accent);cursor:pointer;flex:none}' +
|
|
4518
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}' +
|
|
4519
4792
|
'.pp-toggle:hover{background:var(--pp-hover);color:var(--pp-ink)}' +
|
|
4520
4793
|
'.pp-toggle[data-selected="true"]{color:var(--pp-accent)}' +
|
|
@@ -4568,10 +4841,8 @@ window.__ModuleLoader__.load({
|
|
|
4568
4841
|
'.pp-primary:disabled{opacity:.5;cursor:default}' +
|
|
4569
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}' +
|
|
4570
4843
|
'.pp-link:hover{color:var(--pp-ink)}' +
|
|
4571
|
-
'.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)}' +
|
|
4572
4844
|
'.pp-foot-head{display:flex;align-items:center;gap:6px}' +
|
|
4573
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)}' +
|
|
4574
|
-
'.pp-foot .pp-foot-head{margin:-8px -12px 0;padding:8px 12px;background:var(--pp-queue-head-bg)}' +
|
|
4575
4846
|
'.pp-foot-title{font-size:12px;font-weight:600;color:var(--pp-ink)}' +
|
|
4576
4847
|
'.pp-tray{display:flex;flex-direction:column;gap:6px;max-height:260px;overflow-y:auto}' +
|
|
4577
4848
|
'.pp-foot .pp-tray{max-height:min(40vh,220px)}' +
|
|
@@ -4635,6 +4906,9 @@ window.__ModuleLoader__.load({
|
|
|
4635
4906
|
bindOptional(['conversation'], (target) => {
|
|
4636
4907
|
conversationFace = serviceOf(target, 'conversation');
|
|
4637
4908
|
});
|
|
4909
|
+
bindOptional(['sessions'], (target) => {
|
|
4910
|
+
sessionsFace = serviceOf(target, 'sessions');
|
|
4911
|
+
});
|
|
4638
4912
|
if (ctx.locale && typeof ctx.locale.register === 'function' && typeof ctx.locale.bind === 'function') {
|
|
4639
4913
|
ctx.effect(() => ctx.locale.register(NS, { zh: ZH, en: EN }));
|
|
4640
4914
|
translate = ctx.locale.bind(NS);
|