dsh-gallery 0.14.0 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -119,19 +119,21 @@ function normalizeAnnotation(a) {
119
119
  }
120
120
  /** 单图请求超时,避免一张卡死的图拖住整面板。 */
121
121
  const RAW_TIMEOUT_MS = 15000
122
+ /** 列表请求超时:宿主忙时给「重试」入口,不永远停在「正在扫描…」。 */
123
+ const HOST_TIMEOUT_MS = 12000
122
124
  /** 同一时刻最多几个缩略图在解码。 */
123
125
  const MAX_CONCURRENT = 4
124
126
  /** 查看器缩放上限与单次滚轮步进。 */
125
127
  const MAX_ZOOM = 8
126
128
  const ZOOM_STEP = 0.35
127
129
  /** 自动刷新间隔(毫秒)。 */
128
- const AUTO_REFRESH_MS = 5000
130
+ const AUTO_REFRESH_MS = 15000
129
131
  /** 文本预览最大字符数。 */
130
132
  const MAX_TEXT_CHARS = 200000
131
133
  const NS = 'dshGallery'
132
134
  /** 插件自己的 context;侧栏入口按钮需要它来开 tab。 */
133
135
  const ctxRef = { current: null }
134
-
136
+
135
137
  /** 中英字典(拆分自 client.js L54-L379)。 */
136
138
 
137
139
  const zh = {
@@ -158,35 +160,88 @@ function normalizeAnnotation(a) {
158
160
  scopeLogEmpty: '本对话的会话记录为空',
159
161
  subCount: '{shown} / {total} 条',
160
162
  // ===== 资产分类(三色边框)=====
161
- catFinal: '最终',
162
- catInput: '输入',
163
- catIntermediate: '中间',
163
+ catFinal: '成稿',
164
+ catInput: '素材',
165
+ catIntermediate: '过程稿',
164
166
  catUnknown: '未归类',
165
- catLegendFinal: '最终交付物',
166
- catLegendInput: '输入素材',
167
- catLegendIntermediate: '中间产物',
167
+ catLegendFinal: '成稿·待定',
168
+ catLegendInput: '素材',
169
+ catLegendIntermediate: '过程稿',
168
170
  catLegendUnknown: '未归类',
171
+ // v0.14.2 手动标签:表态层下线后的替代入口
172
+ labelEdit: '改标签',
173
+ labelEditHint: '手动调整这张图的产出标签;改过的标签刷新 / 重启都保留',
174
+ labelDialogTitle: '调整产出标签',
175
+ labelDialogBatchTitle: '批量调整产出标签',
176
+ labelCurrent: '当前标签',
177
+ labelNew: '改为',
178
+ labelAuto: '自动判定',
179
+ labelManual: '手动',
180
+ labelCatFinal: '定稿',
181
+ labelCatInput: '素材',
182
+ labelCatIntermediate: '过程稿',
183
+ labelCatUnknown: '未归类',
184
+ labelDirection: '调整方向(可选)',
185
+ labelDirectionPlaceholder: '例如:门头往左挪、配色偏冷,其余不变',
186
+ labelAddToBasket: '同时加入反馈篮',
187
+ labelAddToBasketHint: '取消勾选则只改标签、不生成反馈;反馈仍需人工审核后发送',
188
+ labelReset: '恢复自动判定',
189
+ labelApply: '应用',
190
+ labelBatch: '批量改标签',
191
+ labelSaved: '标签已更新',
192
+ labelSavedNoFeedback: '标签已更新(未加入反馈篮)',
193
+ labelCtxReset: '恢复自动标签',
194
+ catFilterFinal: '定稿',
169
195
  annotEnter: '标注',
170
196
  annotExit: '退出标注',
171
197
  annotNotePrompt: '这块要改什么?(可留空)',
172
198
  annotNotePlaceholder: '例如:沙发位置偏了 / 色调太暖',
173
199
  annotNoNote: '(无说明)',
174
- annotHint: '拖拽画框标出要改的位置,说明会写进决策草稿',
200
+ annotHint: '按住拖拽圈一处,或点两下(起点→终点);可连续圈多处,保存后自动进反馈篮',
175
201
  annotCount: '批注 {n} 处',
176
- catFilterFinalConfirmed: '最终交付·已确认',
177
- catFilterFinalPending: '最终交付·待确认',
202
+ annotPendingTag: '待保存',
203
+ annotPendingHint: '黄色亮框就是刚圈的位置;写完点「保存并生效」,也可以直接在图上继续圈下一处(这处会先自动存档)',
204
+ annotStartTag: '再点一下定终点',
205
+ batchModeEnter: '批量选择',
206
+ batchModeExit: '退出批量',
207
+ batchModeEnterHint: '批量模式:直接点卡片即可选中/取消(此时点卡片不会打开大图),选好后批量改标签',
208
+ batchModeExitHint: '退出批量模式并清空已选',
209
+ cardConfirm: '✓ 定稿',
210
+ cardConfirmed: '✓ 已定稿',
211
+ cardConfirmHint: '把这张定为「已定稿」(只写标记,不动文件,也不发送消息)',
212
+ cardUnconfirmHint: '清除表态,回到机器预判的阶段',
213
+ catFilterFinalConfirmed: '✓ 已定稿',
214
+ catFilterFinalPending: '成稿·待定',
215
+ catFilterRevise: '↩ 要重做',
216
+ catFilterArchive: '◇ 留档',
178
217
  filterShowHint: '点击显示「{label}」',
179
218
  filterHideHint: '点击隐藏「{label}」',
180
- confirmBadgeLabel: '已确认',
181
- confirmBadgeHint: '这张已定为最终版(判断已锁住,刷新/重启都保留)',
182
- batchSelect: '选中以批量处理',
219
+ filterEmptyHint: '当前筛选下没有可显示的文件,点上方标签可重新显示',
220
+ confirmBadgeLabel: '已定稿',
221
+ confirmBadgeHint: '这张已由人定为「已定稿」(判断已锁住,刷新/重启都保留)',
222
+ verdictBadgeDeliver: '已定稿',
223
+ verdictBadgeRevise: '要重做',
224
+ verdictBadgeArchive: '留档',
225
+ verdictDeliver: '✓ 已定稿',
226
+ verdictRevise: '↩ 要重做',
227
+ verdictArchive: '◇ 留档',
228
+ verdictDeliverHint: '定为最终可交付(只写标记,不动文件)',
229
+ verdictReviseHint: '这张要重做 / 打回(只写标记,不动文件)',
230
+ verdictArchiveHint: '留作备用、不参与交付(只写标记,不动文件)',
231
+ verdictBadgeHint: '人的结论优先于机器预判;刷新 / 重启都保留',
232
+ batchSelect: '点击卡片即可选中(也可点这个勾)',
183
233
  batchUnselect: '取消选中',
184
- batchBarTitle: '已选 {n} 个',
185
- batchConfirm: '确认',
186
- batchUnconfirm: '取消确认',
234
+ batchBarTitle: '已选 {n} 个 · 批量设为',
235
+ batchConfirm: '✓ 已定稿',
236
+ batchUnconfirm: '清除表态',
237
+ batchSetRevise: '↩ 要重做',
238
+ batchSetArchive: '◇ 留档',
187
239
  batchClearMark: '清除标记',
188
240
  batchClearSelection: '取消选择',
189
- batchHintConfirm: '把选中卡片标为「已确认」(只改标记,不碰文件)',
241
+ batchHintConfirm: '把选中卡片定为「已定稿」(只改标记,不碰文件)',
242
+ batchHintRevise: '把选中卡片标为「要重做」(只改标记,不碰文件)',
243
+ batchHintArchive: '把选中卡片标为「留档」(只改标记,不碰文件)',
244
+ batchHintClearVerdict: '清掉选中的表态,回到机器预判的阶段(只改标记,不碰文件)',
190
245
  batchHintClearMark: '清掉选中卡片的标记(只改标记,不碰文件)',
191
246
  discardEntry: '清掉废稿({n})',
192
247
  discardEntryHint: '删除所有标过「不要这张」的文件 —— 永久删除,不进回收站',
@@ -204,16 +259,29 @@ function normalizeAnnotation(a) {
204
259
  scanModeExit: '退出批量',
205
260
  shownOfTotal: '已显示 {shown} / 共 {total}',
206
261
 
207
- catLegendHint: '边框颜色代表资产类型;「未归类」是会话记录里查不到归属的历史文件',
262
+ catLegendHint: '产出状态角标:素材 / 过程稿 / 定稿 / 未归类。手动改过的以手动为准,刷新、重启都保留',
208
263
  // ===== 全局按对话分组 =====
209
264
  groupCount: '{count} 个',
210
- groupFinal: '最终 {n}',
211
- groupInput: '输入 {n}',
212
- groupIntermediate: '中间 {n}',
265
+ groupFinal: '成稿 {n}',
266
+ groupInput: '素材 {n}',
267
+ groupIntermediate: '过程稿 {n}',
213
268
  groupUnknown: '未归类 {n}',
214
269
  groupTruncated: '仅显示最近 {shown} 个,共 {total} 个',
215
270
  groupHistoryTitle: '历史资产',
216
271
  groupCurrentBadge: '当前对话',
272
+ // 资产 → 会话(01)与归档/删除标注(02)
273
+ groupOpenSession: '打开对话',
274
+ groupOpenTip: '切换到「{title}」——这批资产所属的对话',
275
+ groupOpenDone: '已切到该对话',
276
+ groupOpenMissed: '列表里没找到,已复制会话 ID',
277
+ groupOpenArchived: '会话已归档,不能直接打开',
278
+ groupStateArchived: '已归档',
279
+ groupStateDeleted: '会话已删除',
280
+ groupStateCannotReopen: '无法重建对话',
281
+ groupStateHintArchived: '宿主标记该对话已归档;仍可点「打开对话」尝试切回,打不开会自动改标「无法重建对话」。',
282
+ groupStateHintDeleted: '会话已删除 · 无法重建对话,只保留资产。',
283
+ groupStateRebuildHint: '列表里找不到该对话,无法重建对话,只保留资产。',
284
+ listTimeout: '扫描超时了,点「重试」再来一次(宿主正忙时会这样)',
217
285
  groupHistoryHint: '这些文件在会话记录里查不到归属对话',
218
286
  groupUnassigned: '未归属对话',
219
287
  groupFiles: '{n} 个文件',
@@ -283,11 +351,11 @@ function normalizeAnnotation(a) {
283
351
  mediaOpenExternal: '用系统播放器打开',
284
352
  mediaBlobSeekHint: '载入完成后可拖动进度条(宿主转发时丢了 Content-Length,直链无法 seek)',
285
353
  mediaOpenFolder: '打开所在文件夹',
286
- ctxMarkSection: '标记(进反馈篮)',
354
+ ctxMarkSection: '结论 / 反馈',
287
355
  ctxMarkApprove: '通过',
288
356
  ctxMarkReject: '不要这张',
289
- ctxMarkFinalize: '定为最终版',
290
- ctxMarkUnconfirm: '取消确认',
357
+ ctxMarkFinalize: '✓ 已定稿(只记结论)',
358
+ ctxMarkUnconfirm: '清除表态',
291
359
  ctxMarkRedo: '单维重做',
292
360
  ctxMarkRegen: '选择性重生成',
293
361
  ctxMarkReference: '设为参照',
@@ -299,11 +367,18 @@ function normalizeAnnotation(a) {
299
367
  feedbackBasketToggleN: '反馈篮 · {n} 条',
300
368
  feedbackBasketToggleHint: '打开/关闭反馈篮,可在此生成决策草稿',
301
369
  feedbackBasketTitleN: '反馈篮 · {n} 条',
302
- feedbackBasketEmpty: '还没有标记任何条目。在卡片上右键选择动作即可加入。',
370
+ feedbackBasketEmpty: '还没有可发的条目。在卡片上右键选择动作,或在图片上框选批注,都会进这里。',
303
371
  feedbackTargetSession: '将发往会话:{title}',
304
372
  feedbackForeignWarn: '有 {n} 条来自其他会话,不能一起提交(请先切到那个会话)。',
305
373
  feedbackForeignWarnShort: '含其他会话的条目,已禁用提交',
306
374
  feedbackEdit: '编辑',
375
+ // 框选批注(归到「反馈」这一侧:说明文字进反馈篮、随草稿发出)
376
+ feedbackClearHint: '清空篮子里的全部条目:反馈条目与批注一起清(已改的标签不受影响,也不删文件)',
377
+ feedbackAnnotTag: '批注',
378
+ feedbackAnnotRegion: '区域 左{x}% 上{y}% · 宽{w}% 高{h}%',
379
+ feedbackAnnotNoNote: '(未填说明,按框选区域改)',
380
+ feedbackFrameFrom: '取自《{name}》{timecode} 帧',
381
+ feedbackAnnotHint: '{n} 条框选批注会随反馈一起发出,序号与草稿里的 Annotation N 一一对应',
307
382
  feedbackEditTitle: '编辑:{name}',
308
383
  feedbackReasonLabel: '理由(可选)',
309
384
  feedbackChangeOnlyLabel: '只改(逗号分隔,可选)',
@@ -332,8 +407,10 @@ function normalizeAnnotation(a) {
332
407
  mediaTooBigHint: '该文件 {size},超过面板内播放上限。用系统播放器打开可立即拖动查看。',
333
408
  mediaBlobReady: '已载入,可拖动进度条',
334
409
  mediaGrabFrame: '截取当前帧',
335
- mediaGrabFrameHint: '把当前播放位置的画面存成 PNG 图片',
410
+ mediaGrabFrameHint: '把当前播放位置存成 PNG,自动放进当前对话资产,不用选保存位置',
336
411
  mediaGrabFrameOk: '已保存:{name}',
412
+ mediaGrabFrameSaving: '正在保存截帧…',
413
+ mediaGrabFrameSaved: '已存入当前对话资产:{name}(第 {timecode} 帧)',
337
414
  mediaGrabFrameFailed: '截帧失败:{message}',
338
415
  mediaGrabFrameNoVideo: '只有视频可以截帧',
339
416
  mediaNoPreview: '浏览器无法解码该格式',
@@ -400,35 +477,88 @@ function normalizeAnnotation(a) {
400
477
  scopeLogEmpty: 'This chat’s session log is empty',
401
478
  subCount: '{shown} of {total}',
402
479
  // Asset categories (colored borders)
403
- catFinal: 'Final',
404
- catInput: 'Input',
405
- catIntermediate: 'Interim',
480
+ catFinal: 'Draft',
481
+ catInput: 'Source',
482
+ catIntermediate: 'WIP',
406
483
  catUnknown: 'Unclassified',
407
- catLegendFinal: 'Final deliverable',
408
- catLegendInput: 'Input material',
409
- catLegendIntermediate: 'Interim product',
484
+ catLegendFinal: 'Draft · pending',
485
+ catLegendInput: 'Source',
486
+ catLegendIntermediate: 'WIP',
410
487
  catLegendUnknown: 'Unclassified',
488
+ // v0.14.2 manual labels (replaces the retired verdict layer)
489
+ labelEdit: 'Edit label',
490
+ labelEditHint: 'Override the detected asset stage; manual labels survive refresh and restart',
491
+ labelDialogTitle: 'Adjust asset label',
492
+ labelDialogBatchTitle: 'Adjust labels in batch',
493
+ labelCurrent: 'Current',
494
+ labelNew: 'Change to',
495
+ labelAuto: 'Auto-detected',
496
+ labelManual: 'Manual',
497
+ labelCatFinal: 'Final',
498
+ labelCatInput: 'Source',
499
+ labelCatIntermediate: 'WIP',
500
+ labelCatUnknown: 'Unclassified',
501
+ labelDirection: 'Direction (optional)',
502
+ labelDirectionPlaceholder: 'e.g. move the sign left, cooler palette, keep the rest',
503
+ labelAddToBasket: 'Also add to feedback basket',
504
+ labelAddToBasketHint: 'Uncheck to only change the label; feedback still needs your review before sending',
505
+ labelReset: 'Back to auto-detected',
506
+ labelApply: 'Apply',
507
+ labelBatch: 'Edit labels in batch',
508
+ labelSaved: 'Label updated',
509
+ labelSavedNoFeedback: 'Label updated (no feedback added)',
510
+ labelCtxReset: 'Reset to auto label',
511
+ catFilterFinal: 'Final',
411
512
  annotEnter: 'Annotate',
412
513
  annotExit: 'Exit annotate',
413
514
  annotNotePrompt: 'What should change here? (optional)',
414
515
  annotNotePlaceholder: 'e.g. sofa position is off / color is too warm',
415
516
  annotNoNote: '(no note)',
416
- annotHint: 'Drag to box the area that needs changes; notes go into the decision draft',
517
+ annotHint: 'Drag to box an area, or click twice (start → end). Box as many as you like — saved notes go straight into the feedback basket',
417
518
  annotCount: '{n} annotation(s)',
418
- catFilterFinalConfirmed: 'Final · confirmed',
419
- catFilterFinalPending: 'Final · pending',
519
+ annotPendingTag: 'Pending',
520
+ annotPendingHint: 'The yellow box is the area you just marked. Add a note and click Save, or keep boxing more areas (this one is stored first).',
521
+ annotStartTag: 'Click again to set the end',
522
+ batchModeEnter: 'Batch select',
523
+ batchModeExit: 'Exit batch',
524
+ batchModeEnterHint: 'Batch mode: click any card to select/deselect (clicking no longer opens the viewer), then edit labels in batch',
525
+ batchModeExitHint: 'Leave batch mode and clear the selection',
526
+ cardConfirm: '✓ Finalize',
527
+ cardConfirmed: '✓ Finalized',
528
+ cardConfirmHint: 'Mark this as finalized (marks only; no file changes, no message sent)',
529
+ cardUnconfirmHint: 'Clear the verdict and fall back to the machine-guessed stage',
530
+ catFilterFinalConfirmed: '✓ Finalized',
531
+ catFilterFinalPending: 'Draft · pending',
532
+ catFilterRevise: '↩ Rework',
533
+ catFilterArchive: '◇ Archive',
420
534
  filterShowHint: 'Click to show "{label}"',
421
535
  filterHideHint: 'Click to hide "{label}"',
422
- confirmBadgeLabel: 'Confirmed',
423
- confirmBadgeHint: 'Marked as final (the decision is persisted across refresh and restart)',
424
- batchSelect: 'Select for batch actions',
536
+ filterEmptyHint: 'Nothing to show under the current filters. Click a label above to show it again.',
537
+ confirmBadgeLabel: 'Finalized',
538
+ confirmBadgeHint: 'A human finalized this (the decision persists across refresh and restart)',
539
+ verdictBadgeDeliver: 'Finalized',
540
+ verdictBadgeRevise: 'Rework',
541
+ verdictBadgeArchive: 'Archive',
542
+ verdictDeliver: '✓ Finalized',
543
+ verdictRevise: '↩ Rework',
544
+ verdictArchive: '◇ Archive',
545
+ verdictDeliverHint: 'Mark as ready to deliver (marks only, files untouched)',
546
+ verdictReviseHint: 'Mark as rework / send back (marks only, files untouched)',
547
+ verdictArchiveHint: 'Keep as backup, not for delivery (marks only, files untouched)',
548
+ verdictBadgeHint: 'Human verdict outranks the machine-guessed stage; persists across refresh and restart',
549
+ batchSelect: 'Click the card to select (or click this box)',
425
550
  batchUnselect: 'Deselect',
426
- batchBarTitle: '{n} selected',
427
- batchConfirm: 'Confirm',
428
- batchUnconfirm: 'Unconfirm',
551
+ batchBarTitle: '{n} selected · set to',
552
+ batchConfirm: '✓ Finalized',
553
+ batchUnconfirm: 'Clear verdict',
554
+ batchSetRevise: '↩ Rework',
555
+ batchSetArchive: '◇ Archive',
429
556
  batchClearMark: 'Clear marks',
430
557
  batchClearSelection: 'Clear selection',
431
- batchHintConfirm: 'Mark selected cards as confirmed (marks only, files untouched)',
558
+ batchHintConfirm: 'Mark selected cards as finalized (marks only, files untouched)',
559
+ batchHintRevise: 'Mark selected cards as rework (marks only, files untouched)',
560
+ batchHintArchive: 'Mark selected cards as archive (marks only, files untouched)',
561
+ batchHintClearVerdict: 'Clear the verdict on selected cards (marks only, files untouched)',
432
562
  batchHintClearMark: 'Clear marks on selected cards (marks only, files untouched)',
433
563
  discardEntry: 'Delete discarded ({n})',
434
564
  discardEntryHint: 'Permanently delete every file marked "reject" — bypasses the recycle bin',
@@ -446,16 +576,29 @@ function normalizeAnnotation(a) {
446
576
  scanModeExit: 'Exit selection',
447
577
  shownOfTotal: '{shown} of {total} shown',
448
578
 
449
- catLegendHint: 'Border color shows the asset type; “Unclassified” means the session logs have no record of it',
579
+ catLegendHint: 'Asset stage: source / WIP / final / unclassified. Manual overrides win and persist across restarts',
450
580
  // Grouped by conversation (global view)
451
581
  groupCount: '{count} files',
452
- groupFinal: 'Final {n}',
453
- groupInput: 'Input {n}',
454
- groupIntermediate: 'Interim {n}',
582
+ groupFinal: 'Draft {n}',
583
+ groupInput: 'Source {n}',
584
+ groupIntermediate: 'WIP {n}',
455
585
  groupUnknown: 'Unclassified {n}',
456
586
  groupTruncated: 'Showing latest {shown} of {total}',
457
587
  groupHistoryTitle: 'Older assets',
458
588
  groupCurrentBadge: 'This chat',
589
+ // Assets to chat (01) and archived / deleted badges (02)
590
+ groupOpenSession: 'Open chat',
591
+ groupOpenTip: 'Switch to the chat that owns these assets: {title}',
592
+ groupOpenDone: 'Switched',
593
+ groupOpenMissed: 'Not in the list — session ID copied',
594
+ groupOpenArchived: 'Archived chat cannot be opened',
595
+ groupStateArchived: 'Archived',
596
+ groupStateDeleted: 'Chat deleted',
597
+ groupStateCannotReopen: 'Chat cannot be rebuilt',
598
+ groupStateHintArchived: 'The host marks this chat as archived. You can still try "Open chat"; if it fails, it will be marked as unrebuildable.',
599
+ groupStateHintDeleted: 'Chat deleted · cannot be rebuilt; assets are kept as-is.',
600
+ groupStateRebuildHint: 'Chat not found in the list and cannot be rebuilt; assets are kept as-is.',
601
+ listTimeout: 'Scan timed out — tap Retry (the host may be busy)',
459
602
  groupHistoryHint: 'These files have no conversation recorded in the session logs',
460
603
  groupUnassigned: 'No conversation',
461
604
  groupFiles: '{n} files',
@@ -523,11 +666,11 @@ function normalizeAnnotation(a) {
523
666
  mediaOpenExternal: 'Open in system player',
524
667
  mediaBlobSeekHint: 'Seeking works once loaded (the desktop shell drops Content-Length, so a direct link cannot seek)',
525
668
  mediaOpenFolder: 'Open containing folder',
526
- ctxMarkSection: 'Mark (to feedback basket)',
669
+ ctxMarkSection: 'Verdict / feedback',
527
670
  ctxMarkApprove: 'Approve',
528
671
  ctxMarkReject: 'Reject',
529
- ctxMarkFinalize: 'Finalize',
530
- ctxMarkUnconfirm: 'Unconfirm',
672
+ ctxMarkFinalize: '✓ Finalize (verdict only)',
673
+ ctxMarkUnconfirm: 'Clear verdict',
531
674
  ctxMarkRedo: 'Redo one dimension',
532
675
  ctxMarkRegen: 'Regenerate selection',
533
676
  ctxMarkReference: 'Set as reference',
@@ -539,11 +682,18 @@ function normalizeAnnotation(a) {
539
682
  feedbackBasketToggleN: 'Basket · {n}',
540
683
  feedbackBasketToggleHint: 'Toggle the feedback basket to generate a draft',
541
684
  feedbackBasketTitleN: 'Feedback basket · {n} item(s)',
542
- feedbackBasketEmpty: 'Nothing marked yet. Right-click a card and pick an action.',
685
+ feedbackBasketEmpty: 'Nothing to send yet. Right-click a card for an action, or box an area on an image — both land here.',
543
686
  feedbackTargetSession: 'Will be sent to session: {title}',
544
687
  feedbackForeignWarn: '{n} item(s) belong to another session and cannot be sent together.',
545
688
  feedbackForeignWarnShort: 'Contains items from another session — submit disabled',
546
689
  feedbackEdit: 'Edit',
690
+ // Boxed notes (feedback side: the note text goes into the basket and the draft)
691
+ feedbackClearHint: 'Clear every feedback item and annotation (labels stay; no files touched)',
692
+ feedbackAnnotTag: 'Note',
693
+ feedbackAnnotRegion: 'region left {x}% top {y}% · {w}%×{h}%',
694
+ feedbackAnnotNoNote: '(no note — change the boxed area)',
695
+ feedbackFrameFrom: 'From "{name}" at frame {timecode}',
696
+ feedbackAnnotHint: '{n} boxed note(s) will be sent with this feedback, numbered to match `Annotation N` in the draft',
547
697
  feedbackEditTitle: 'Edit: {name}',
548
698
  feedbackReasonLabel: 'Reason (optional)',
549
699
  feedbackChangeOnlyLabel: 'Only change (comma separated, optional)',
@@ -572,8 +722,10 @@ function normalizeAnnotation(a) {
572
722
  mediaTooBigHint: 'This file is {size}, over the in-panel limit. Open it in the system player to seek right away.',
573
723
  mediaBlobReady: 'Loaded — seeking available',
574
724
  mediaGrabFrame: 'Save current frame',
575
- mediaGrabFrameHint: 'Save the frame at the current play position as a PNG',
725
+ mediaGrabFrameHint: 'Save the current frame as PNG into this chat assets (no file dialog)',
576
726
  mediaGrabFrameOk: 'Saved: {name}',
727
+ mediaGrabFrameSaving: 'Saving frame...',
728
+ mediaGrabFrameSaved: 'Saved to this chat: {name} (frame {timecode})',
577
729
  mediaGrabFrameFailed: 'Frame grab failed: {message}',
578
730
  mediaGrabFrameNoVideo: 'Only video can be grabbed',
579
731
  mediaNoPreview: 'The browser cannot decode this format',
@@ -613,9 +765,20 @@ function normalizeAnnotation(a) {
613
765
  scanned: 'Scanned {dirs} folders',
614
766
  capped: 'Scan limit reached; results may be incomplete',
615
767
  }
616
-
768
+
617
769
  /** 格式化 / 图片压缩 / 并发限流工具。 */
618
770
 
771
+ /**
772
+ * 焦点是否落在可输入控件里。
773
+ * 查看器的全局快捷键(左右切图 / 数字缩放 / o 切原图 / Esc 退出)必须给打字让位,
774
+ * 否则在批注输入框里按方向键或输入字母就会切图、缩放、关掉大图。
775
+ */
776
+ function isTypingTarget(target) {
777
+ if (target === null || target === undefined) return false
778
+ if (typeof target.closest !== 'function') return false
779
+ return target.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]') !== null
780
+ }
781
+
619
782
  /** 极简模板替换:字典里只有 {name} 占位。 */
620
783
  function format(template, values) {
621
784
  return String(template).replace(/\{(\w+)\}/g, (whole, key) => {
@@ -642,15 +805,45 @@ function normalizeAnnotation(a) {
642
805
 
643
806
  /** POST 到 Host 私有路由,统一把失败转成可展示的错误。 */
644
807
  async function callHost(op, payload, signal) {
645
- const response = await fetch(ROUTE, {
646
- method: 'POST',
647
- credentials: 'same-origin',
648
- headers: { 'content-type': 'application/json' },
649
- body: JSON.stringify({ op, ...(payload ?? {}) }),
650
- signal,
651
- })
652
- if (!response.ok) throw new Error(`HTTP ${response.status}`)
653
- return response.json()
808
+ // 宿主忙(例如切进一个超长对话)时 fetch 可能一直挂着;旧实现没有超时,
809
+ // 面板就永远停在「正在扫描…」。列表给 12 秒硬上限,其它操作给 60 秒,
810
+ // 避免误伤删除 / 批处理这类本来就慢的请求。
811
+ const timeout = new AbortController()
812
+ const timer = setTimeout(() => timeout.abort(), op === 'list' ? HOST_TIMEOUT_MS : 60000)
813
+ let onExternalAbort = null
814
+ let merged
815
+ if (typeof AbortSignal.any === 'function') {
816
+ merged = signal ? AbortSignal.any([signal, timeout.signal]) : timeout.signal
817
+ } else {
818
+ merged = timeout.signal
819
+ onExternalAbort = () => timeout.abort()
820
+ if (signal) {
821
+ if (signal.aborted) timeout.abort()
822
+ else signal.addEventListener('abort', onExternalAbort, { once: true })
823
+ }
824
+ }
825
+ try {
826
+ const response = await fetch(ROUTE, {
827
+ method: 'POST',
828
+ credentials: 'same-origin',
829
+ headers: { 'content-type': 'application/json' },
830
+ body: JSON.stringify({ op, ...(payload ?? {}) }),
831
+ signal: merged,
832
+ })
833
+ if (!response.ok) throw new Error(`HTTP ${response.status}`)
834
+ return await response.json()
835
+ } catch (error) {
836
+ // 组件卸载造成的取消仍按 AbortError 交给上层忽略;只有自己的超时转成可读错误
837
+ if (timeout.signal.aborted && !signal?.aborted) {
838
+ const err = new Error('request timeout')
839
+ err.code = 'gallery-timeout'
840
+ throw err
841
+ }
842
+ throw error
843
+ } finally {
844
+ clearTimeout(timer)
845
+ if (onExternalAbort !== null && signal) signal.removeEventListener('abort', onExternalAbort)
846
+ }
654
847
  }
655
848
 
656
849
  /**
@@ -793,7 +986,7 @@ function normalizeAnnotation(a) {
793
986
  }
794
987
 
795
988
  /** 面板内的样式:只用宿主 theme token,深色/浅色自动跟随。 */
796
-
989
+
797
990
  /** 面板内的样式(内容来自 styles.css,构建时内联)。 */
798
991
  const CSS = `.dg-root {
799
992
  display: flex;
@@ -1058,6 +1251,8 @@ function normalizeAnnotation(a) {
1058
1251
  gap: 10px;
1059
1252
  }
1060
1253
  .dg-card {
1254
+ box-sizing: border-box;
1255
+ width: 100%;
1061
1256
  display: flex;
1062
1257
  flex-direction: column;
1063
1258
  gap: 0;
@@ -1079,20 +1274,34 @@ function normalizeAnnotation(a) {
1079
1274
  输入 = 灰蓝、中间 = 橙色、最终 = 绿色。
1080
1275
  边框加粗到 2px 以便一眼分辨。 */
1081
1276
  .dg-card { position: relative; }
1082
- .dg-cat-final { border: 2px solid #1A936F; }
1083
- .dg-cat-input { border: 2px solid #8A8F99; }
1084
- .dg-cat-intermediate { border: 2px solid #D48806; }
1085
- .dg-cat-unknown { border: 2px solid #C8CDD6; }
1086
- .dg-cat-final:hover { border-color: #157A5C; }
1087
- .dg-cat-input:hover { border-color: #6B7079; }
1088
- .dg-cat-intermediate:hover { border-color: #B36F05; }
1089
- .dg-cat-unknown:hover { border-color: #A8AEB8; }
1090
-
1091
- /* 角标:贴在缩略图右上角 */
1277
+
1278
+ /* 边框统一画在 .dg-cardWrap 的伪元素上(v0.14.2):
1279
+ 原来用 outline 画在卡片子元素上,卡片宽度与网格格不一致时会外扩、压到邻卡。
1280
+ 伪元素 inset:0 + box-sizing:border-box 永远严格贴合网格格,缩放/焦点都不跑偏。 */
1281
+ .dg-cardWrap::after {
1282
+ content: '';
1283
+ position: absolute;
1284
+ inset: 0;
1285
+ border: 2px solid transparent;
1286
+ border-radius: 8px;
1287
+ box-sizing: border-box;
1288
+ pointer-events: none;
1289
+ z-index: 6;
1290
+ }
1291
+ .dg-cardWrap[data-gallery-bucket="final"]::after { border-color: #4a9d5f; }
1292
+ /* v0.14.2:表态层下线,「已确认 / 待确认」两态合并为单一「定稿」 */
1293
+ .dg-cardWrap[data-gallery-bucket="revise"]::after { border-color: #d4693c; }
1294
+ .dg-cardWrap[data-gallery-bucket="archive"]::after { border-color: #6f8fb5; }
1295
+ .dg-cardWrap[data-gallery-bucket="input"]::after { border-color: #8A8F99; }
1296
+ .dg-cardWrap[data-gallery-bucket="intermediate"]::after { border-color: #D48806; }
1297
+ .dg-cardWrap[data-gallery-bucket="unknown"]::after { border-color: #C8CDD6; }
1298
+ .dg-cardWrap.dg-cardChecked::after { border-color: #4a7cff !important; border-style: solid !important; }
1299
+
1300
+ /* 阶段角标:贴左上(与结论角标同位置,二者互斥);右上留给三个表态按钮 */
1092
1301
  .dg-catBadge {
1093
1302
  position: absolute;
1094
1303
  top: 6px;
1095
- right: 6px;
1304
+ left: 6px;
1096
1305
  z-index: 2;
1097
1306
  padding: 2px 7px;
1098
1307
  border-radius: 9px;
@@ -1130,6 +1339,8 @@ function normalizeAnnotation(a) {
1130
1339
  .dg-legendSwatch-final { background: #1A936F; }
1131
1340
  .dg-legendSwatch-input { background: #8A8F99; }
1132
1341
  .dg-legendSwatch-intermediate { background: #D48806; }
1342
+ .dg-legendSwatch-revise { background: #d4693c; }
1343
+ .dg-legendSwatch-archive { background: #6f8fb5; }
1133
1344
  .dg-legendSwatch-unknown { background: #8C93A0; }
1134
1345
 
1135
1346
  /* ===== 分组(全局按对话)===== */
@@ -1196,6 +1407,108 @@ function normalizeAnnotation(a) {
1196
1407
  background: var(--dsw-alias-brand-primary);
1197
1408
  }
1198
1409
  .dg-groupCurrent .dg-groupTitle { font-weight: 700; }
1410
+
1411
+ /* ---------- v0.14.2 手动标签:卡片入口 + 调整弹窗 ---------- */
1412
+ /* 沿用表态按钮原来的右上角位置,不新增角标,避免与左上角的阶段角标打架。 */
1413
+ .dg-labelBtn {
1414
+ position: absolute; top: 4px; right: 4px; z-index: 3;
1415
+ min-width: 22px; height: 22px; padding: 0 6px;
1416
+ border-radius: 6px; border: 1px solid rgba(255,255,255,.45);
1417
+ background: rgba(20,20,20,.72); color: #fff;
1418
+ font-size: 11px; line-height: 20px; cursor: pointer; opacity: .55;
1419
+ }
1420
+ .dg-cardWrap:hover .dg-labelBtn { opacity: 1; }
1421
+ .dg-labelBtn:hover { border-color: #fff; transform: scale(1.06); }
1422
+ .dg-labelBtnManual { background: #8a6520; border-color: #e2b968; opacity: .95; }
1423
+ .dg-cardSelectable .dg-labelBtn { display: none; }
1424
+
1425
+ .dg-labelLayer {
1426
+ position: fixed; inset: 0; z-index: 60;
1427
+ display: flex; align-items: center; justify-content: center;
1428
+ background: rgba(0,0,0,.55);
1429
+ }
1430
+ /* 弹窗内一律写死色值:宿主主题变量在这一层解析不稳,
1431
+ 实测「取消 / 应用」和未选中的标签按钮会糊进背景里看不清。 */
1432
+ .dg-labelDialog {
1433
+ width: min(420px, 92vw); max-height: 86vh; overflow: auto;
1434
+ padding: 16px; border-radius: 10px;
1435
+ background: #262b33;
1436
+ color: #f2f5f8;
1437
+ box-shadow: 0 12px 40px rgba(0,0,0,.6);
1438
+ }
1439
+ .dg-labelDialog .dg-labelHead,
1440
+ .dg-labelDialog .dg-labelRow,
1441
+ .dg-labelDialog .dg-labelCheck { color: #f2f5f8; }
1442
+ .dg-labelHead { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
1443
+ .dg-labelRow { margin: 10px 0; font-size: 12px; }
1444
+ .dg-labelChoices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
1445
+ .dg-labelChoice {
1446
+ padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
1447
+ background: #3a4451; border: 1px solid #8b9aab; color: #f2f5f8; font-weight: 600;
1448
+ }
1449
+ .dg-labelChoice:hover { background: #4b5867; border-color: #d2dce7; }
1450
+ .dg-labelChoiceOn,
1451
+ .dg-labelChoiceOn:hover {
1452
+ background: #2f8f57; border-color: #8ce0b0; color: #fff;
1453
+ box-shadow: 0 0 0 1px rgba(140,224,176,.35);
1454
+ }
1455
+ .dg-labelTextarea { width: 100%; box-sizing: border-box; min-height: 62px; resize: vertical; }
1456
+ /* 宿主 .dg-input 是白底,在深色弹窗里要压过去 */
1457
+ .dg-labelDialog .dg-input {
1458
+ background: #1c2129; color: #f2f5f8; border: 1px solid #6d7c8d;
1459
+ }
1460
+ .dg-labelDialog .dg-input::placeholder { color: #9aa8b8; opacity: 1; }
1461
+ .dg-labelCheck { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
1462
+ .dg-labelActions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
1463
+ /* 取消 / 恢复自动 / 应用:不依赖宿主 dg-btn 的主题色 */
1464
+ .dg-labelActions .dg-btn {
1465
+ background: #3a4451; border: 1px solid #8b9aab; color: #f2f5f8; font-weight: 600;
1466
+ }
1467
+ .dg-labelActions .dg-btn:hover { background: #4b5867; border-color: #d2dce7; color: #fff; }
1468
+ .dg-labelActions .dg-primaryBtn,
1469
+ .dg-labelActions .dg-primaryBtn:hover {
1470
+ background: #2f8f57; border-color: #8ce0b0; color: #fff; font-weight: 700;
1471
+ box-shadow: 0 0 0 1px rgba(140,224,176,.3);
1472
+ }
1473
+ .dg-labelActions .dg-btn:disabled { opacity: .6; }
1474
+ .dg-labelHint { font-size: 11px; color: #c4ced9; line-height: 1.5; }
1475
+ .dg-groupStateBadge {
1476
+ flex: 0 0 auto;
1477
+ padding: 1px 7px;
1478
+ border-radius: 9px;
1479
+ font-size: 10px;
1480
+ font-weight: 600;
1481
+ line-height: 1.6;
1482
+ white-space: nowrap;
1483
+ color: var(--dsw-alias-label-secondary);
1484
+ background: var(--dsw-alias-bg-layer-1);
1485
+ border: 1px solid var(--dsw-alias-border-l1);
1486
+ }
1487
+ .dg-groupStateBadge-warn {
1488
+ color: var(--dsw-alias-label-primary);
1489
+ background: color-mix(in srgb, #E8A33D 16%, var(--dsw-alias-bg-layer-2));
1490
+ border-color: color-mix(in srgb, #E8A33D 40%, transparent);
1491
+ }
1492
+ .dg-groupStateHint { border-top: 0; }
1493
+ .dg-groupActions {
1494
+ display: flex;
1495
+ align-items: center;
1496
+ flex-wrap: wrap;
1497
+ gap: 8px;
1498
+ padding: 7px 11px;
1499
+ background: var(--dsw-alias-bg-layer-1);
1500
+ border-bottom: 1px solid var(--dsw-alias-border-l1);
1501
+ }
1502
+ .dg-groupOpenWrap { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
1503
+ .dg-openSession { flex: 0 0 auto; }
1504
+ .dg-groupOpenNote {
1505
+ font-size: 11px;
1506
+ color: var(--dsw-alias-label-secondary);
1507
+ white-space: nowrap;
1508
+ overflow: hidden;
1509
+ text-overflow: ellipsis;
1510
+ max-width: 160px;
1511
+ }
1199
1512
  .dg-groupDate {
1200
1513
  flex: 0 0 auto;
1201
1514
  font-size: 11px;
@@ -1525,7 +1838,7 @@ function normalizeAnnotation(a) {
1525
1838
  flex: 0 0 auto;
1526
1839
  }
1527
1840
  .dg-viewerTitle { flex: 1 1 auto; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
1528
- .dg-viewerBody { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 10px 42px 10px 10px; }
1841
+ .dg-viewerBody { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 10px 42px 10px 10px; }
1529
1842
  .dg-viewerBody img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
1530
1843
  .dg-viewerLayer { position: absolute; inset: 0; z-index: 30; background: var(--dsw-specific-sidebar-fill, #111); display: flex; flex-direction: column; }
1531
1844
  .dg-viewerLayer .dg-viewer { flex: 1 1 auto; min-height: 0; }
@@ -1846,6 +2159,29 @@ function normalizeAnnotation(a) {
1846
2159
  }
1847
2160
  .dg-feedbackAction { flex: 0 0 auto; color: #8fb6ff; font-weight: 600; }
1848
2161
  .dg-feedbackName { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e8eaed; }
2162
+
2163
+ /* 框选批注条目(v0.14.3):黄调 + 左侧竖线,和「表态行」一眼分开 */
2164
+ .dg-feedbackAnnotItem {
2165
+ position: relative; align-items: center; flex-wrap: wrap;
2166
+ padding: 8px 44px 8px 6px;
2167
+ background: rgba(255, 209, 102, 0.05);
2168
+ border-left: 2px solid rgba(255, 209, 102, 0.5);
2169
+ }
2170
+ .dg-feedbackAnnotItem .dg-feedbackNo { background: #8a6d1f; color: #ffe6a3; }
2171
+ .dg-feedbackActionAnnot { color: #ffd166; }
2172
+ .dg-feedbackRegion { flex: 0 0 auto; color: #c8b071; font-size: 11px; }
2173
+ .dg-feedbackAnnotItem .dg-feedbackNote {
2174
+ flex: 1 1 100%; margin-top: 4px;
2175
+ color: #e8eaed; font-size: 12px; line-height: 1.45;
2176
+ white-space: pre-wrap; word-break: break-word;
2177
+ }
2178
+ .dg-feedbackAnnotItem .dg-feedbackOps { position: absolute; right: 6px; top: 8px; }
2179
+ /* 批注提示条:让用户明确「框选说明会跟着发出去」 */
2180
+ .dg-feedbackAnnotHint {
2181
+ padding: 7px 14px; font-size: 11px; color: #ffd166;
2182
+ background: rgba(255, 209, 102, 0.08);
2183
+ border-bottom: 1px solid rgba(255, 209, 102, 0.22);
2184
+ }
1849
2185
  .dg-feedbackDim { flex: 0 0 auto; color: #a9b1bd; font-size: 11px; }
1850
2186
  .dg-feedbackOps { flex: 0 0 auto; display: flex; gap: 4px; }
1851
2187
 
@@ -1917,25 +2253,60 @@ function normalizeAnnotation(a) {
1917
2253
 
1918
2254
  /* 卡片包装层 + 确认角标 + 多选框 */
1919
2255
  .dg-cardWrap { position: relative; }
1920
- .dg-cardConfirmed > :first-child { outline: 2px solid #4a9d5f; outline-offset: -2px; }
1921
- .dg-cardChecked > :first-child { outline: 2px solid #4a7cff; outline-offset: -2px; }
1922
- .dg-confirmBadge {
1923
- position: absolute; top: 6px; left: 6px; z-index: 3;
1924
- display: inline-flex; align-items: center; gap: 3px;
1925
- padding: 1px 6px; border-radius: 9px;
1926
- background: #4a9d5f; color: #fff; font-size: 10px; font-weight: 600;
1927
- pointer-events: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
1928
- }
2256
+ /* 结论角标(左上):人的表态,优先于右上角的机器预判角标 */
2257
+ .dg-verdictBadge {
2258
+ position: absolute; top: 6px; left: 6px; z-index: 5;
2259
+ display: inline-flex; align-items: center;
2260
+ padding: 1px 7px; border-radius: 9px;
2261
+ color: #fff; font-size: 10px; font-weight: 700;
2262
+ pointer-events: none; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
2263
+ }
2264
+ .dg-verdict-deliver { background: #4a9d5f; }
2265
+ .dg-verdict-revise { background: #d4693c; }
2266
+ .dg-verdict-archive { background: #6f8fb5; }
2267
+ /* 有结论时,右上角「机器预判」角标让位,避免两层标签并排打架 */
2268
+ .dg-cardWrap[data-gallery-verdict="deliver"] .dg-catBadge,
2269
+ .dg-cardWrap[data-gallery-verdict="revise"] .dg-catBadge,
2270
+ .dg-cardWrap[data-gallery-verdict="archive"] .dg-catBadge { display: none; }
2271
+
2272
+ /* 三种表态按钮:右上角一排,当前结论高亮,再点一次取消 */
2273
+ .dg-verdictOps {
2274
+ position: absolute; top: 6px; right: 6px; z-index: 5;
2275
+ display: inline-flex; gap: 3px;
2276
+ }
2277
+ .dg-verdictBtn {
2278
+ width: 20px; height: 20px; padding: 0;
2279
+ display: inline-flex; align-items: center; justify-content: center;
2280
+ border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.55);
2281
+ background: rgba(20, 26, 32, 0.78); color: #e8eaed;
2282
+ font-size: 11px; line-height: 1; font-weight: 700;
2283
+ cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
2284
+ }
2285
+ .dg-verdictBtn:hover { border-color: #fff; transform: scale(1.08); }
2286
+ .dg-verdictBtn-deliver.dg-verdictOn { background: #4a9d5f; border-color: #9fe3bd; color: #fff; }
2287
+ .dg-verdictBtn-revise.dg-verdictOn { background: #d4693c; border-color: #ffb494; color: #fff; }
2288
+ .dg-verdictBtn-archive.dg-verdictOn { background: #6f8fb5; border-color: #c3d6ea; color: #fff; }
2289
+ /* 多选框(v0.14.3):尺寸保持原样 20px —— 点选主要靠整卡,勾选框只做状态指示;
2290
+ 位置放右上(批量模式下三个单张表态按钮已收起,不冲突),避免压住底部文件名。 */
1929
2291
  .dg-cardCheck {
1930
- position: absolute; top: 6px; right: 6px; z-index: 4;
1931
- width: 20px; height: 20px; border-radius: 4px;
1932
- border: 1.5px solid rgba(255, 255, 255, 0.65);
1933
- background: rgba(0, 0, 0, 0.45); color: #fff;
1934
- font-size: 12px; line-height: 1; cursor: pointer;
2292
+ position: absolute; top: 6px; right: 6px; z-index: 7;
2293
+ width: 20px; height: 20px; border-radius: 5px;
2294
+ border: 1.5px solid rgba(255, 255, 255, 0.7);
2295
+ background: rgba(0, 0, 0, 0.5); color: #fff;
2296
+ font-size: 12px; line-height: 1; font-weight: 700; cursor: pointer;
1935
2297
  display: flex; align-items: center; justify-content: center;
2298
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
2299
+ }
2300
+ .dg-cardCheck:hover { border-color: #fff; background: rgba(0, 0, 0, 0.75); }
2301
+ .dg-cardCheckOn { background: #4a7cff; border-color: #cfe0ff; }
2302
+ /* 批量模式:整张卡片都可点,给明确的可点提示 */
2303
+ .dg-cardSelectable, .dg-cardSelectable .dg-card { cursor: cell; }
2304
+ .dg-cardSelectable:hover::after { border-color: #8fa9ff !important; border-style: solid !important; }
2305
+ /* 已选中:加一层蓝色蒙层,隔一米也看得出来选没选 */
2306
+ .dg-cardWrap.dg-cardChecked::before {
2307
+ content: ''; position: absolute; inset: 0; z-index: 3;
2308
+ background: rgba(74, 124, 255, 0.18); border-radius: 8px; pointer-events: none;
1936
2309
  }
1937
- .dg-cardCheck:hover { border-color: #fff; background: rgba(0, 0, 0, 0.7); }
1938
- .dg-cardCheckOn { background: #4a7cff; border-color: #4a7cff; }
1939
2310
 
1940
2311
  /* 批量操作条 */
1941
2312
  .dg-batchBar {
@@ -1984,7 +2355,7 @@ function normalizeAnnotation(a) {
1984
2355
 
1985
2356
  /* 批注列表 */
1986
2357
  .dg-annotList {
1987
- position: absolute; left: 8px; bottom: 8px; z-index: 5;
2358
+ position: absolute; left: 8px; top: 8px; z-index: 5;
1988
2359
  max-width: 300px; max-height: 40%; overflow: auto;
1989
2360
  background: rgba(27, 30, 36, 0.95); border: 1px solid rgba(255, 255, 255, 0.16);
1990
2361
  border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
@@ -1994,9 +2365,9 @@ function normalizeAnnotation(a) {
1994
2365
  .dg-annotIndex { color: #8fb6ff; font-weight: 600; }
1995
2366
  .dg-annotText { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1996
2367
 
1997
- /* 批注输入框 */
2368
+ /* 批注输入框:贴底居中,别挡住刚圈出来的框 */
1998
2369
  .dg-annotEditor {
1999
- position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6;
2370
+ position: absolute; left: 50%; bottom: 14px; top: auto; transform: translateX(-50%); z-index: 6;
2000
2371
  width: min(340px, 80%); background: #1b1e24; color: #e8eaed;
2001
2372
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; padding: 10px;
2002
2373
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
@@ -2009,8 +2380,28 @@ function normalizeAnnotation(a) {
2009
2380
  }
2010
2381
  .dg-annotInput:focus { outline: 2px solid #4a7cff; outline-offset: -1px; }
2011
2382
  .dg-annotEditorOps { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
2383
+
2384
+
2385
+ /* ---------- v0.14.1:表态入口 / 防重叠 / 批注弹窗可辨识 ---------- */
2386
+
2387
+ /* 卡片包装层不许被长文件名撑破网格列 */
2388
+ .dg-cardWrap { min-width: 0; }
2389
+
2390
+ /* 批量模式(v0.14.3):
2391
+ 勾选框放大到 30px 并放到右上——不压底部文件名/尺寸/时间;此时单张表态按钮收起
2392
+ (批量条的三种表态就是它的替代),避免「整卡点选」与「点小圆钮」互相误触。 */
2393
+ .dg-cardSelectable .dg-verdictOps { display: none; }
2394
+
2395
+ /* 「保存并生效」必须一眼看得见、和编辑器背景分开 */
2396
+ .dg-annotEditorOps .dg-annotSave {
2397
+ background: #4a7cff !important; color: #fff !important;
2398
+ border-color: #86a9ff !important; font-weight: 600;
2399
+ box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2), 0 2px 8px rgba(74, 124, 255, 0.5);
2400
+ }
2401
+ .dg-annotEditorOps .dg-annotSave:hover:not(:disabled) { background: #6a92ff !important; }
2402
+ .dg-annotPendingHint { font-size: 11px; color: #ffd166; margin: -2px 0 8px; }
2012
2403
  `
2013
-
2404
+
2014
2405
 
2015
2406
  /**
2016
2407
  * 复制文本到剪贴板。优先 Clipboard API,失败回退 execCommand。
@@ -2081,199 +2472,237 @@ function normalizeAnnotation(a) {
2081
2472
  * 挂在卡片上,位置跟随鼠标;点外部或按 Esc 关闭。
2082
2473
  * 删除需要二次确认(走 ConfirmDialog)。
2083
2474
  */
2084
-
2085
- /**
2086
- * 反馈契约 v1 —— 纯函数,Host 与 Client 双端复用。
2087
- *
2088
- * 由 scripts/build.mjs 沿用 protocol.js 的做法:
2089
- * · 剥掉 export 注入 client bundle
2090
- * · 生成 host/feedback-text.js 供 Host 侧 import
2091
- *
2092
- * 设计原则(调研结论,见 docs/migration.md 与调研报告):
2093
- * 1. 反馈是**契约**不是自由文本:带锚点(relPath)、动作类型、理由、目标会话。
2094
- * 2. **攒批 + 一次发送**:多条标记合成一条消息,不逐条发。
2095
- * 3. **人确认闸门**:本模块只负责「产出草稿文本」,发送由用户在 composer 里点。
2096
- * 4. **显式 changeOnly / keep**:生成类工作流实证「只改 X、其余锁死」远好于「再改改」。
2097
- * 5. 逐条用 `Annotation N:` 编号,便于模型逐条回应(参考 dsh-quote-annotate-pro 契约)。
2098
- */
2099
-
2100
- /** 首版 6 个动作。值即契约里的 action 字符串,不要随意改(已写进 marks 文件)。 */
2101
- const ACTIONS = [
2102
- 'approve',
2103
- 'reject',
2104
- 'finalize',
2105
- 'redo-one-dim',
2106
- 'regenerate-selected',
2107
- 'set-reference',
2108
- ]
2109
-
2110
- /** 动作 → 中文动词(生成草稿正文用)。 */
2111
- const ACTION_LABELS_ZH = {
2112
- approve: '通过',
2113
- reject: '不要这张',
2114
- finalize: '定为最终版',
2115
- 'redo-one-dim': '单维重做',
2116
- 'regenerate-selected': '选择性重生成',
2117
- 'set-reference': '设为参照',
2118
- }
2119
-
2120
- /** 动作 → 英文动词。 */
2121
- const ACTION_LABELS_EN = {
2122
- approve: 'approve',
2123
- reject: 'reject',
2124
- finalize: 'finalize',
2125
- 'redo-one-dim': 'redo one dimension',
2126
- 'regenerate-selected': 'regenerate',
2127
- 'set-reference': 'set as reference',
2128
- }
2129
-
2130
- /** 契约版本。检查项会核对。 */
2131
- const SCHEMA = 1
2132
-
2133
- /** 来源标识。 */
2134
- const SOURCE = 'dsh-gallery'
2135
-
2136
- /** 常用「只改」维度候选(给 UI 做快捷输入,不是强制枚举)。 */
2137
- const CHANGE_CANDIDATES = [
2138
- '色调', '亮度', '材质', '构图', '透视', '比例', '文字', '光线', '风格', '细节',
2139
- ]
2140
-
2141
- /** 常用的「锁死」项候选。 */
2142
- const KEEP_CANDIDATES = [
2143
- '构图', '人物位置', '主体比例', '透视角度', '文字内容', '整体风格', '配色基调',
2144
- ]
2145
-
2146
- /**
2147
- * 构造一条反馈项。
2148
- * @param item - { relPath, category, action, reason?, changeOnly?, keep?, preserve?, region?, params? }
2149
- * @returns 规范化后的 feedback item
2150
- */
2151
- function makeItem(item) {
2152
- const out = {
2153
- relPath: String(item?.relPath ?? ''),
2154
- category: String(item?.category ?? 'unknown'),
2155
- action: ACTIONS.includes(item?.action) ? item.action : 'approve',
2156
- }
2157
- if (typeof item?.reason === 'string' && item.reason.trim() !== '') out.reason = item.reason.trim()
2158
- if (Array.isArray(item?.changeOnly) && item.changeOnly.length > 0) {
2159
- out.changeOnly = item.changeOnly.map((x) => String(x)).filter((x) => x !== '')
2160
- }
2161
- if (Array.isArray(item?.keep) && item.keep.length > 0) {
2162
- out.keep = item.keep.map((x) => String(x)).filter((x) => x !== '')
2163
- }
2164
- if (Array.isArray(item?.preserve) && item.preserve.length > 0) {
2165
- out.preserve = item.preserve.map((x) => String(x)).filter((x) => x !== '')
2166
- }
2167
- if (item?.region !== undefined && item.region !== null) out.region = item.region
2168
- if (item?.params !== undefined && item.params !== null) out.params = item.params
2169
- return out
2170
- }
2171
-
2172
- /**
2173
- * 构造一份反馈草稿(契约对象)。
2174
- * @param args - { sessionId, items, status? }
2175
- */
2176
- function makeFeedback(args) {
2177
- return {
2178
- schema: SCHEMA,
2179
- source: SOURCE,
2180
- sessionId: String(args?.sessionId ?? ''),
2181
- status: args?.status === 'sent' ? 'sent' : 'draft',
2182
- items: (Array.isArray(args?.items) ? args.items : []).map(makeItem),
2183
- createdAt: typeof args?.createdAt === 'number' ? args.createdAt : Date.now(),
2184
- }
2185
- }
2186
-
2187
- /** 文件名取路径末段。 */
2188
- function baseName(relPath) {
2189
- const s = String(relPath ?? '')
2190
- const i = s.lastIndexOf('/')
2191
- return i >= 0 ? s.slice(i + 1) : s
2192
- }
2193
-
2194
- /**
2195
- * 把契约渲染成**人类与模型都能读的草稿正文**。
2196
- *
2197
- * 关键要求(调研结论 4):每条必须同时写「只改 X」与「其余锁死」,
2198
- * 否则模型容易把整张重画。
2199
- *
2200
- * @param feedback - makeFeedback() 的产物
2201
- * @param options - { locale?: 'zh'|'en', targetSessionTitle?: string }
2202
- * @returns 纯文本(可直接 setDraft 进 composer)
2203
- */
2204
- function renderFeedbackText(feedback, options) {
2205
- const locale = options?.locale === 'en' ? 'en' : 'zh'
2206
- const labels = locale === 'en' ? ACTION_LABELS_EN : ACTION_LABELS_ZH
2207
- const items = Array.isArray(feedback?.items) ? feedback.items : []
2208
-
2209
- if (items.length === 0) {
2210
- return locale === 'en'
2211
- ? '(No items in the feedback basket.)'
2212
- : '(反馈篮里还没有条目。)'
2213
- }
2214
-
2215
- const lines = []
2216
- if (locale === 'en') {
2217
- lines.push(`[Feedback from dsh-gallery · ${items.length} item(s)]`)
2218
- lines.push('')
2219
- lines.push('Reply item by item using the `Annotation N:` prefix, so each decision maps to one annotation.')
2220
- lines.push('')
2221
- } else {
2222
- lines.push(`【产出画廊反馈 · 共 ${items.length} 条】`)
2223
- lines.push('')
2224
- lines.push('请按 `Annotation 1:`、`Annotation 2:` … 逐条回应,让每条决定都对应到一个批注。')
2225
- lines.push('')
2226
- }
2227
-
2228
- items.forEach((item, idx) => {
2229
- const n = idx + 1
2230
- const name = baseName(item.relPath)
2231
- const verb = labels[item.action] ?? item.action
2232
- lines.push(`Annotation ${n}:${verb} —— ${name}`)
2233
- lines.push(`${locale === 'en' ? 'Path' : '路径'}:${item.relPath}`)
2234
- if (item.reason !== undefined) {
2235
- lines.push(`${locale === 'en' ? 'Reason' : '理由'}:${item.reason}`)
2236
- }
2237
- if (Array.isArray(item.changeOnly) && item.changeOnly.length > 0) {
2238
- lines.push(locale === 'en'
2239
- ? `changeOnly: ${item.changeOnly.join(' / ')}`
2240
- : `只改:${item.changeOnly.join(' / ')}`)
2241
- }
2242
- if (Array.isArray(item.keep) && item.keep.length > 0) {
2243
- lines.push(locale === 'en'
2244
- ? `keep locked: ${item.keep.join(' / ')}`
2245
- : `锁死(其余不动):${item.keep.join(' / ')}`)
2246
- }
2247
- if (Array.isArray(item.preserve) && item.preserve.length > 0) {
2248
- lines.push(locale === 'en'
2249
- ? `preserve: ${item.preserve.join(' / ')}`
2250
- : `保留:${item.preserve.join(' / ')}`)
2251
- }
2252
- if (item.region !== undefined && item.region !== null) {
2253
- lines.push(`${locale === 'en' ? 'Region' : '区域'}:${JSON.stringify(item.region)}`)
2254
- }
2255
- if (item.params !== undefined && item.params !== null) {
2256
- lines.push(`${locale === 'en' ? 'Params' : '参数'}:${JSON.stringify(item.params)}`)
2257
- }
2258
- lines.push('')
2259
- })
2260
-
2261
- // 收口指令:把「锁死」原则再强调一次(防模型整张重画)
2262
- if (locale === 'en') {
2263
- lines.push('Unless an annotation says otherwise, keep everything else unchanged — do not regenerate wholesale.')
2264
- } else {
2265
- lines.push('除上述明确要改的部分外,其余全部保持原样,不要整张重做。')
2266
- }
2267
-
2268
- return lines.join('\n')
2269
- }
2270
-
2271
- /**
2272
- * 把契约序列化成 JSON(导出 / 落盘 / 审计用,与渲染同一个 shape)。
2273
- */
2274
- function serializeFeedback(feedback) {
2275
- return JSON.stringify(feedback, null, 2)
2276
- }
2475
+
2476
+ /**
2477
+ * 反馈契约 v1 —— 纯函数,Host 与 Client 双端复用。
2478
+ *
2479
+ * 由 scripts/build.mjs 沿用 protocol.js 的做法:
2480
+ * · 剥掉 export 注入 client bundle
2481
+ * · 生成 host/feedback-text.js 供 Host 侧 import
2482
+ *
2483
+ * 设计原则(调研结论,见 docs/migration.md 与调研报告):
2484
+ * 1. 反馈是**契约**不是自由文本:带锚点(relPath)、动作类型、理由、目标会话。
2485
+ * 2. **攒批 + 一次发送**:多条标记合成一条消息,不逐条发。
2486
+ * 3. **人确认闸门**:本模块只负责「产出草稿文本」,发送由用户在 composer 里点。
2487
+ * 4. **显式 changeOnly / keep**:生成类工作流实证「只改 X、其余锁死」远好于「再改改」。
2488
+ * 5. 逐条用 `Annotation N:` 编号,便于模型逐条回应(参考 dsh-quote-annotate-pro 契约)。
2489
+ */
2490
+
2491
+ /** 动作契约。值即写进 marks 文件的 action 字符串,不要随意改(兼容历史数据)。 */
2492
+ const ACTIONS = [
2493
+ 'approve',
2494
+ 'reject',
2495
+ 'finalize',
2496
+ 'redo-one-dim',
2497
+ 'regenerate-selected',
2498
+ 'set-reference',
2499
+ // v0.14.2 手动调整标签的三条反馈语义(旧 6 个保留以兼容历史 marks)
2500
+ 'finalize-asset',
2501
+ 'reject-delivery',
2502
+ 'set-label',
2503
+ ]
2504
+
2505
+ /** 动作 → 中文动词(生成草稿正文用)。 */
2506
+ const ACTION_LABELS_ZH = {
2507
+ approve: '通过',
2508
+ reject: '不要这张',
2509
+ finalize: '已定稿',
2510
+ 'redo-one-dim': '单维重做',
2511
+ 'regenerate-selected': '选择性重生成',
2512
+ 'set-reference': '设为参照',
2513
+ 'finalize-asset': '终止枚举,以此图为定稿',
2514
+ 'reject-delivery': '交付不合格',
2515
+ 'set-label': '调整产出标签',
2516
+ }
2517
+
2518
+ /** 动作 → 英文动词。 */
2519
+ const ACTION_LABELS_EN = {
2520
+ approve: 'approve',
2521
+ reject: 'reject',
2522
+ finalize: 'deliver',
2523
+ 'redo-one-dim': 'redo one dimension',
2524
+ 'regenerate-selected': 'regenerate',
2525
+ 'set-reference': 'set as reference',
2526
+ 'finalize-asset': 'Stop enumerating; this asset is final',
2527
+ 'reject-delivery': 'Delivery rejected',
2528
+ 'set-label': 'Adjust asset label',
2529
+ }
2530
+
2531
+ /** 契约版本。检查项会核对。 */
2532
+ const SCHEMA = 1
2533
+
2534
+ /** 来源标识。 */
2535
+ const SOURCE = 'dsh-gallery'
2536
+
2537
+ /** 常用「只改」维度候选(给 UI 做快捷输入,不是强制枚举)。 */
2538
+ const CHANGE_CANDIDATES = [
2539
+ '色调', '亮度', '材质', '构图', '透视', '比例', '文字', '光线', '风格', '细节',
2540
+ ]
2541
+
2542
+ /** 常用的「锁死」项候选。 */
2543
+ const KEEP_CANDIDATES = [
2544
+ '构图', '人物位置', '主体比例', '透视角度', '文字内容', '整体风格', '配色基调',
2545
+ ]
2546
+
2547
+ /**
2548
+ * 构造一条反馈项。
2549
+ * @param item - { relPath, category, action, reason?, changeOnly?, keep?, preserve?, region?, params? }
2550
+ * @returns 规范化后的 feedback item
2551
+ */
2552
+ function makeItem(item) {
2553
+ const out = {
2554
+ relPath: String(item?.relPath ?? ''),
2555
+ category: String(item?.category ?? 'unknown'),
2556
+ action: ACTIONS.includes(item?.action) ? item.action : 'approve',
2557
+ }
2558
+ if (typeof item?.reason === 'string' && item.reason.trim() !== '') out.reason = item.reason.trim()
2559
+ if (Array.isArray(item?.changeOnly) && item.changeOnly.length > 0) {
2560
+ out.changeOnly = item.changeOnly.map((x) => String(x)).filter((x) => x !== '')
2561
+ }
2562
+ if (Array.isArray(item?.keep) && item.keep.length > 0) {
2563
+ out.keep = item.keep.map((x) => String(x)).filter((x) => x !== '')
2564
+ }
2565
+ if (Array.isArray(item?.preserve) && item.preserve.length > 0) {
2566
+ out.preserve = item.preserve.map((x) => String(x)).filter((x) => x !== '')
2567
+ }
2568
+ if (item?.region !== undefined && item.region !== null) out.region = item.region
2569
+ if (item?.params !== undefined && item.params !== null) out.params = item.params
2570
+ // v0.14.3 截帧来源:随草稿一起带出,模型才知道反馈针对的是哪一帧
2571
+ if (item?.frameOf !== undefined && item?.frameOf !== null && typeof item.frameOf === 'object') {
2572
+ out.frameOf = {
2573
+ videoName: String(item.frameOf.videoName ?? ''),
2574
+ videoRelPath: String(item.frameOf.videoRelPath ?? ''),
2575
+ timecode: String(item.frameOf.timecode ?? ''),
2576
+ frameMs: Number(item.frameOf.frameMs) || 0,
2577
+ }
2578
+ }
2579
+ return out
2580
+ }
2581
+
2582
+ /**
2583
+ * 构造一份反馈草稿(契约对象)。
2584
+ * @param args - { sessionId, items, status? }
2585
+ */
2586
+ function makeFeedback(args) {
2587
+ return {
2588
+ schema: SCHEMA,
2589
+ source: SOURCE,
2590
+ sessionId: String(args?.sessionId ?? ''),
2591
+ status: args?.status === 'sent' ? 'sent' : 'draft',
2592
+ items: (Array.isArray(args?.items) ? args.items : []).map(makeItem),
2593
+ createdAt: typeof args?.createdAt === 'number' ? args.createdAt : Date.now(),
2594
+ }
2595
+ }
2596
+
2597
+ /** 文件名取路径末段。 */
2598
+ function baseName(relPath) {
2599
+ const s = String(relPath ?? '')
2600
+ const i = s.lastIndexOf('/')
2601
+ return i >= 0 ? s.slice(i + 1) : s
2602
+ }
2603
+
2604
+ /**
2605
+ * 把契约渲染成**人类与模型都能读的草稿正文**。
2606
+ *
2607
+ * 关键要求(调研结论 4):每条必须同时写「只改 X」与「其余锁死」,
2608
+ * 否则模型容易把整张重画。
2609
+ *
2610
+ * @param feedback - makeFeedback() 的产物
2611
+ * @param options - { locale?: 'zh'|'en', targetSessionTitle?: string }
2612
+ * @returns 纯文本(可直接 setDraft 进 composer)
2613
+ */
2614
+ function renderFeedbackText(feedback, options) {
2615
+ const locale = options?.locale === 'en' ? 'en' : 'zh'
2616
+ const labels = locale === 'en' ? ACTION_LABELS_EN : ACTION_LABELS_ZH
2617
+ const items = Array.isArray(feedback?.items) ? feedback.items : []
2618
+
2619
+ if (items.length === 0) {
2620
+ return locale === 'en'
2621
+ ? '(No items in the feedback basket.)'
2622
+ : '(反馈篮里还没有条目。)'
2623
+ }
2624
+
2625
+ const lines = []
2626
+ if (locale === 'en') {
2627
+ lines.push(`[Feedback from dsh-gallery · ${items.length} item(s)]`)
2628
+ lines.push('')
2629
+ lines.push('Reply item by item using the `Annotation N:` prefix, so each decision maps to one annotation.')
2630
+ lines.push('')
2631
+ } else {
2632
+ lines.push(`【产出画廊反馈 · 共 ${items.length} 条】`)
2633
+ lines.push('')
2634
+ lines.push('请按 `Annotation 1:`、`Annotation 2:` … 逐条回应,让每条决定都对应到一个批注。')
2635
+ lines.push('')
2636
+ }
2637
+
2638
+ items.forEach((item, idx) => {
2639
+ const n = idx + 1
2640
+ const name = baseName(item.relPath)
2641
+ const hasRegion = item.region !== undefined && item.region !== null
2642
+ // 带框选区域的条目来自「框选批注」:动词写清楚是「只改这个框里的东西」,
2643
+ // 比抽象动作名(单维重做)更贴近用户真正想说的话。
2644
+ const verb = hasRegion
2645
+ ? (locale === 'en' ? 'Change the boxed area only' : '按框选区域修改')
2646
+ : (labels[item.action] ?? item.action)
2647
+ lines.push(`Annotation ${n}:${verb} —— ${name}`)
2648
+ lines.push(`${locale === 'en' ? 'Path' : '路径'}:${item.relPath}`)
2649
+ if (item.frameOf !== undefined && item.frameOf !== null) {
2650
+ const f = item.frameOf
2651
+ lines.push(locale === 'en'
2652
+ ? `Frame source: taken from "${f.videoName}" at ${f.timecode} (${f.frameMs} ms)`
2653
+ : `帧来源:取自视频《${f.videoName}》${f.timecode}(第 ${f.frameMs} 毫秒)`)
2654
+ }
2655
+ if (item.reason !== undefined) {
2656
+ lines.push(`${locale === 'en' ? 'Reason' : '理由'}:${item.reason}`)
2657
+ }
2658
+ if (Array.isArray(item.changeOnly) && item.changeOnly.length > 0) {
2659
+ lines.push(locale === 'en'
2660
+ ? `changeOnly: ${item.changeOnly.join(' / ')}`
2661
+ : `只改:${item.changeOnly.join(' / ')}`)
2662
+ }
2663
+ if (Array.isArray(item.keep) && item.keep.length > 0) {
2664
+ lines.push(locale === 'en'
2665
+ ? `keep locked: ${item.keep.join(' / ')}`
2666
+ : `锁死(其余不动):${item.keep.join(' / ')}`)
2667
+ }
2668
+ if (Array.isArray(item.preserve) && item.preserve.length > 0) {
2669
+ lines.push(locale === 'en'
2670
+ ? `preserve: ${item.preserve.join(' / ')}`
2671
+ : `保留:${item.preserve.join(' / ')}`)
2672
+ }
2673
+ if (hasRegion) {
2674
+ // 人话百分比,别丢 JSON 给模型看:左上角 + 宽高,相对整张图
2675
+ const pct = (v) => {
2676
+ const num = Number(v)
2677
+ return Number.isFinite(num) ? Math.round(Math.max(0, Math.min(1, num)) * 100) : 0
2678
+ }
2679
+ const r = item.region
2680
+ lines.push(locale === 'en'
2681
+ ? `Region: left ${pct(r.x)}%, top ${pct(r.y)}%, width ${pct(r.w)}%, height ${pct(r.h)}% (relative to the whole image)`
2682
+ : `区域:左 ${pct(r.x)}%、上 ${pct(r.y)}%,宽 ${pct(r.w)}%、高 ${pct(r.h)}%(相对整张图)`)
2683
+ }
2684
+ if (item.params !== undefined && item.params !== null) {
2685
+ lines.push(`${locale === 'en' ? 'Params' : '参数'}:${JSON.stringify(item.params)}`)
2686
+ }
2687
+ lines.push('')
2688
+ })
2689
+
2690
+ // 收口指令:把「锁死」原则再强调一次(防模型整张重画)
2691
+ if (locale === 'en') {
2692
+ lines.push('Unless an annotation says otherwise, keep everything else unchanged — do not regenerate wholesale.')
2693
+ } else {
2694
+ lines.push('除上述明确要改的部分外,其余全部保持原样,不要整张重做。')
2695
+ }
2696
+
2697
+ return lines.join('\n')
2698
+ }
2699
+
2700
+ /**
2701
+ * 把契约序列化成 JSON(导出 / 落盘 / 审计用,与渲染同一个 shape)。
2702
+ */
2703
+ function serializeFeedback(feedback) {
2704
+ return JSON.stringify(feedback, null, 2)
2705
+ }
2277
2706
 
2278
2707
 
2279
2708
  /**
@@ -2296,10 +2725,14 @@ function serializeFeedback(feedback) {
2296
2725
  const FEEDBACK_ACTIONS_UI = [
2297
2726
  { id: 'approve', labelZh: '通过', labelEn: 'Approve', icon: '✓' },
2298
2727
  { id: 'reject', labelZh: '不要这张', labelEn: 'Reject', icon: '✕' },
2299
- { id: 'finalize', labelZh: '定为最终版', labelEn: 'Finalize', icon: '★' },
2728
+ { id: 'finalize', labelZh: '已定稿', labelEn: 'Deliver', icon: '★' },
2300
2729
  { id: 'redo-one-dim', labelZh: '单维重做', labelEn: 'Redo one dim', icon: '↻' },
2301
2730
  { id: 'regenerate-selected', labelZh: '选择性重生成', labelEn: 'Regenerate', icon: '⟳' },
2302
2731
  { id: 'set-reference', labelZh: '设为参照', labelEn: 'Set reference', icon: '◎' },
2732
+ // v0.14.2 手动改标签进反馈篮后的三种显示(旧 6 个保留兼容历史数据)
2733
+ { id: 'finalize-asset', labelZh: '终止枚举·定为定稿', labelEn: 'Stop & finalize', icon: '★' },
2734
+ { id: 'reject-delivery', labelZh: '交付不合格', labelEn: 'Delivery rejected', icon: '✕' },
2735
+ { id: 'set-label', labelZh: '调整标签', labelEn: 'Adjust label', icon: '✎' },
2303
2736
  ]
2304
2737
 
2305
2738
  /**
@@ -2531,6 +2964,49 @@ function serializeFeedback(feedback) {
2531
2964
  : { ok: false, via: 'failed', reason: 'all-dom-paths-failed-copy-failed' }
2532
2965
  }
2533
2966
 
2967
+ /**
2968
+ * 把「卡片行」展开成契约条目(v0.14.3):
2969
+ * · 卡片有表态 → 一条(动作 + 理由 + 只改/锁死)
2970
+ * · 卡片有批注 → 每条批注各一条,带 `region`(框选位置),动作固定为「按区域改」
2971
+ *
2972
+ * 为什么把批注展开成独立条目而不是塞进理由:
2973
+ * 草稿要按 `Annotation N:` 逐条编号,模型也得逐条回应;
2974
+ * 一张图三处批注 = 三条指令,混成一段会丢掉「哪条对哪个框」的对应关系。
2975
+ */
2976
+ function expandFeedbackItems(list) {
2977
+ const out = []
2978
+ for (const it of Array.isArray(list) ? list : []) {
2979
+ const mark = it.mark
2980
+ if (mark !== undefined && mark !== null) {
2981
+ out.push({
2982
+ relPath: it.relPath,
2983
+ category: it.category ?? 'unknown',
2984
+ action: mark.action ?? 'approve',
2985
+ reason: mark.reason,
2986
+ changeOnly: mark.changeOnly,
2987
+ keep: mark.keep,
2988
+ preserve: mark.preserve,
2989
+ // 截帧来源随草稿带出(v0.14.3)
2990
+ frameOf: it.frameOf,
2991
+ })
2992
+ }
2993
+ const annots = Array.isArray(it.annotations) ? it.annotations : []
2994
+ for (const a of annots) {
2995
+ const note = typeof a?.note === 'string' ? a.note.trim() : ''
2996
+ out.push({
2997
+ relPath: it.relPath,
2998
+ category: it.category ?? 'unknown',
2999
+ // 卡已被判「不要这张」时,批注也沿用打回;否则是「只改这个框」
3000
+ action: mark?.action === 'reject' ? 'reject' : 'redo-one-dim',
3001
+ reason: note === '' ? undefined : note,
3002
+ region: { x: a.x, y: a.y, w: a.w, h: a.h },
3003
+ frameOf: it.frameOf,
3004
+ })
3005
+ }
3006
+ }
3007
+ return out
3008
+ }
3009
+
2534
3010
  /**
2535
3011
  * 反馈篮:一个受控组件,管理条目列表 + 生成草稿。
2536
3012
  *
@@ -2545,7 +3021,8 @@ function serializeFeedback(feedback) {
2545
3021
  * @param onSubmitDraft - 生成草稿后的回调(用于提示)
2546
3022
  */
2547
3023
  function FeedbackBasket({ t, items, currentSessionId, targetSessionTitle,
2548
- onClose, onRemove, onEdit, onClear, onEditSave }) {
3024
+ onClose, onRemove, onEdit, onClear, onEditSave,
3025
+ onRemoveAnnotation, onClearAll }) {
2549
3026
  // 语言判断:用 t 探测一个已知键 —— 命中中文就按 zh 渲染,否则 en。
2550
3027
  // (不引入 detectLocale,插件没有这个工具函数)
2551
3028
  const [locale] = React.useState(() => {
@@ -2556,6 +3033,21 @@ function serializeFeedback(feedback) {
2556
3033
  })
2557
3034
  const [busy, setBusy] = React.useState(false)
2558
3035
  const [notice, setNotice] = React.useState(null)
3036
+
3037
+ /**
3038
+ * 展示行:一条表态 + 每条批注各占一行(v0.14.3)。
3039
+ * 顺序必须与 expandFeedbackItems() 完全一致 —— 界面上的序号就是草稿里的 `Annotation N`。
3040
+ */
3041
+ const rows = React.useMemo(() => {
3042
+ const out = []
3043
+ for (const it of Array.isArray(items) ? items : []) {
3044
+ if (it.mark !== undefined && it.mark !== null) out.push({ kind: 'mark', it })
3045
+ const annots = Array.isArray(it.annotations) ? it.annotations : []
3046
+ for (const a of annots) out.push({ kind: 'annot', it, a })
3047
+ }
3048
+ return out
3049
+ }, [items])
3050
+ const annotCount = rows.filter((r) => r.kind === 'annot').length
2559
3051
  // 编辑弹窗:正在编辑的条目 + 三个字段的草稿值
2560
3052
  const [editing, setEditing] = React.useState(null)
2561
3053
  const [editReason, setEditReason] = React.useState('')
@@ -2592,7 +3084,7 @@ function serializeFeedback(feedback) {
2592
3084
  // 历史会话判定:条目归属会话与当前会话不同 → 禁止提交
2593
3085
  const foreignItems = items.filter((it) => it.sessionId !== undefined
2594
3086
  && it.sessionId !== '' && currentSessionId !== '' && it.sessionId !== currentSessionId)
2595
- const canSubmit = items.length > 0 && foreignItems.length === 0 && busy === false
3087
+ const canSubmit = rows.length > 0 && foreignItems.length === 0 && busy === false
2596
3088
 
2597
3089
  /** 生成草稿并写进 composer(不发送)。 */
2598
3090
  const generateDraft = React.useCallback(async () => {
@@ -2602,15 +3094,7 @@ function serializeFeedback(feedback) {
2602
3094
  try {
2603
3095
  const feedback = makeFeedback({
2604
3096
  sessionId: currentSessionId,
2605
- items: items.map((it) => ({
2606
- relPath: it.relPath,
2607
- category: it.category ?? 'unknown',
2608
- action: it.mark?.action ?? 'approve',
2609
- reason: it.mark?.reason,
2610
- changeOnly: it.mark?.changeOnly,
2611
- keep: it.mark?.keep,
2612
- preserve: it.mark?.preserve,
2613
- })),
3097
+ items: expandFeedbackItems(items),
2614
3098
  })
2615
3099
  const text = renderFeedbackText(feedback, { locale, targetSessionTitle })
2616
3100
  const result = await writeDraftToComposer(text, currentSessionId)
@@ -2642,7 +3126,7 @@ function serializeFeedback(feedback) {
2642
3126
  }, [
2643
3127
  h('div', { className: 'dg-feedbackHead', key: 'head' }, [
2644
3128
  h('span', { className: 'dg-feedbackTitle', key: 'title' },
2645
- format(t('feedbackBasketTitleN'), { n: items.length }),
3129
+ format(t('feedbackBasketTitleN'), { n: rows.length }),
2646
3130
  ),
2647
3131
  h('button', {
2648
3132
  type: 'button', className: 'dg-btn', key: 'close',
@@ -2662,24 +3146,81 @@ function serializeFeedback(feedback) {
2662
3146
  format(t('feedbackForeignWarn'), { n: foreignItems.length }))
2663
3147
  : null,
2664
3148
 
2665
- items.length === 0
3149
+ // 批注提示:让用户明确知道框选说明会跟着反馈一起发出去
3150
+ annotCount > 0
3151
+ ? h('div', { className: 'dg-feedbackAnnotHint', key: 'annotHint', 'data-gallery-feedback-annot-hint': annotCount },
3152
+ format(t('feedbackAnnotHint'), { n: annotCount }))
3153
+ : null,
3154
+
3155
+ rows.length === 0
2666
3156
  ? h('p', { className: 'dg-status', key: 'empty' }, t('feedbackBasketEmpty'))
2667
3157
  : h('ul', { className: 'dg-feedbackList', key: 'list' },
2668
- items.map((it, idx) => {
3158
+ rows.map((row, idx) => {
3159
+ const it = row.it
3160
+ const fileName = it.relPath.split('/').pop() ?? it.relPath
3161
+ const rowKey = `${it.relPath}:${row.kind}:${row.kind === 'annot' ? row.a.id : 'mark'}`
3162
+ // ① 批注行:位置 + 说明,只有删除(说明在查看器里改)
3163
+ if (row.kind === 'annot') {
3164
+ const a = row.a
3165
+ const pct = (v) => {
3166
+ const num = Number(v)
3167
+ return Number.isFinite(num) ? Math.round(Math.max(0, Math.min(1, num)) * 100) : 0
3168
+ }
3169
+ return h('li', {
3170
+ className: 'dg-feedbackItem dg-feedbackAnnotItem',
3171
+ key: rowKey,
3172
+ 'data-gallery-feedback-annot-item': a.id,
3173
+ 'data-gallery-feedback-no': idx + 1,
3174
+ }, [
3175
+ h('span', { className: 'dg-feedbackNo', key: 'n' }, String(idx + 1)),
3176
+ h('span', { className: 'dg-feedbackAction dg-feedbackActionAnnot', key: 'a' }, t('feedbackAnnotTag')),
3177
+ h('span', { className: 'dg-feedbackName', key: 'name', title: it.relPath }, fileName),
3178
+ // 截帧条目:写明来自哪段视频的哪一帧,避免多条反馈混淆
3179
+ it.frameOf !== undefined && it.frameOf !== null
3180
+ ? h('span', { className: 'dg-feedbackDim', key: 'frame', 'data-gallery-feedback-frame': it.frameOf.timecode },
3181
+ format(t('feedbackFrameFrom'), {
3182
+ name: it.frameOf.videoName ?? '',
3183
+ timecode: it.frameOf.timecode ?? '',
3184
+ }))
3185
+ : null,
3186
+ h('span', { className: 'dg-feedbackDim dg-feedbackRegion', key: 'r' },
3187
+ format(t('feedbackAnnotRegion'), { x: pct(a.x), y: pct(a.y), w: pct(a.w), h: pct(a.h) })),
3188
+ h('span', { className: 'dg-feedbackNote', key: 'note' },
3189
+ (typeof a.note === 'string' && a.note.trim() !== '') ? a.note : t('feedbackAnnotNoNote')),
3190
+ h('span', { className: 'dg-feedbackOps', key: 'ops' }, [
3191
+ h('button', {
3192
+ type: 'button', className: 'dg-btn dg-btnSmall', key: 'del',
3193
+ title: t('delete'),
3194
+ 'data-gallery-feedback-remove-annot': a.id,
3195
+ onClick: () => {
3196
+ if (typeof onRemoveAnnotation === 'function') onRemoveAnnotation(it.relPath, a.id)
3197
+ },
3198
+ }, '✕'),
3199
+ ]),
3200
+ ])
3201
+ }
3202
+ // ② 表态行:动作 + 理由/只改,可编辑可删
2669
3203
  const actionDef = FEEDBACK_ACTIONS_UI.find((a) => a.id === it.mark?.action)
2670
3204
  const label = actionDef === undefined
2671
3205
  ? (it.mark?.action ?? '')
2672
3206
  : (locale === 'en' ? actionDef.labelEn : actionDef.labelZh)
2673
3207
  return h('li', {
2674
3208
  className: 'dg-feedbackItem',
2675
- key: it.relPath,
3209
+ key: rowKey,
2676
3210
  'data-gallery-feedback-item': it.relPath,
2677
3211
  'data-gallery-feedback-no': idx + 1,
2678
3212
  }, [
2679
3213
  h('span', { className: 'dg-feedbackNo', key: 'n' }, String(idx + 1)),
2680
3214
  h('span', { className: 'dg-feedbackAction', key: 'a' }, label),
2681
- h('span', { className: 'dg-feedbackName', key: 'name', title: it.relPath },
2682
- it.relPath.split('/').pop() ?? it.relPath),
3215
+ h('span', { className: 'dg-feedbackName', key: 'name', title: it.relPath }, fileName),
3216
+ // 截帧条目:写明来自哪段视频的哪一帧,避免多条反馈混淆
3217
+ it.frameOf !== undefined && it.frameOf !== null
3218
+ ? h('span', { className: 'dg-feedbackDim', key: 'frame', 'data-gallery-feedback-frame': it.frameOf.timecode },
3219
+ format(t('feedbackFrameFrom'), {
3220
+ name: it.frameOf.videoName ?? '',
3221
+ timecode: it.frameOf.timecode ?? '',
3222
+ }))
3223
+ : null,
2683
3224
  (it.mark?.changeOnly !== undefined && it.mark.changeOnly.length > 0)
2684
3225
  ? h('span', { className: 'dg-feedbackDim', key: 'co' },
2685
3226
  `${t('feedbackChangeOnly')}:${it.mark.changeOnly.join('/')}`)
@@ -2767,10 +3308,12 @@ function serializeFeedback(feedback) {
2767
3308
 
2768
3309
  h('div', { className: 'dg-feedbackActions', key: 'actions' }, [
2769
3310
  h('button', {
2770
- type: 'button', className: 'dg-btn', key: 'clear',
3311
+ type: 'button', className: 'dg-btn dg-dangerBtn', key: 'clear',
2771
3312
  'data-gallery-feedback-clear': true,
2772
- disabled: busy || items.length === 0,
2773
- onClick: onClear,
3313
+ title: t('feedbackClearHint'),
3314
+ disabled: busy || rows.length === 0,
3315
+ // 「清空」要连批注一起清,否则批注留在图上、篮子里却空了
3316
+ onClick: typeof onClearAll === 'function' ? onClearAll : onClear,
2774
3317
  }, t('feedbackClear')),
2775
3318
  h('button', {
2776
3319
  type: 'button', className: 'dg-btn dg-primaryBtn', key: 'submit',
@@ -2783,14 +3326,14 @@ function serializeFeedback(feedback) {
2783
3326
  // 禁用时直接把原因写在按钮上,不只靠悬停 title
2784
3327
  : foreignItems.length > 0
2785
3328
  ? t('feedbackBlockedForeign')
2786
- : items.length === 0
3329
+ : rows.length === 0
2787
3330
  ? t('feedbackBlockedEmpty')
2788
3331
  : t('feedbackGenerateDraft')),
2789
3332
  ]),
2790
3333
  ]),
2791
3334
  ])
2792
3335
  }
2793
-
3336
+
2794
3337
  function ContextMenu({ t, x, y, item, actions, onClose }) {
2795
3338
  const menuRef = React.useRef(null)
2796
3339
  const [pos, setPos] = React.useState({ left: x, top: y })
@@ -2861,35 +3404,118 @@ function serializeFeedback(feedback) {
2861
3404
  entry('reveal', t('ctxReveal'), '📂', () => actions.onReveal()),
2862
3405
  entry('copy', t('ctxCopy'), '⧉', () => actions.onCopy()),
2863
3406
  entry('delete', t('ctxDelete'), '🗑', () => actions.onDelete(), true),
2864
- // ---- 反馈标记(S3-a):6 个动作,选中后进反馈篮,不直接发送 ----
2865
- actions.onMark !== undefined
2866
- ? h('div', { className: 'dg-ctxDivider', key: 'markDivider' }, t('ctxMarkSection'))
2867
- : null,
2868
- actions.onMark !== undefined
2869
- ? entry('mark-approve', t('ctxMarkApprove'), '✓', () => actions.onMark('approve'))
2870
- : null,
2871
- actions.onMark !== undefined
2872
- ? entry('mark-reject', t('ctxMarkReject'), '✕', () => actions.onMark('reject'))
2873
- : null,
2874
- actions.onMark !== undefined
2875
- ? entry('mark-finalize', t('ctxMarkFinalize'), '★', () => actions.onMark('finalize'))
3407
+ // ---- v0.14.2 手动标签:表态层已下线,只留「改标签 / 恢复自动」两个入口 ----
3408
+ actions.onEditLabel !== undefined
3409
+ ? h('div', { className: 'dg-ctxDivider', key: 'labelDivider' }, t('labelEdit'))
2876
3410
  : null,
2877
- // v0.13.7:已确认的卡片给出「取消确认」,退回待确认
2878
- actions.onUnconfirm !== undefined && actions.confirmed === true
2879
- ? entry('mark-unconfirm', t('ctxMarkUnconfirm'), '☆', () => actions.onUnconfirm())
3411
+ actions.onEditLabel !== undefined
3412
+ ? entry('label-edit', t('labelEdit'), '✎', () => actions.onEditLabel())
2880
3413
  : null,
2881
- actions.onMark !== undefined
2882
- ? entry('mark-redo', t('ctxMarkRedo'), '↻', () => actions.onMark('redo-one-dim'))
2883
- : null,
2884
- actions.onMark !== undefined
2885
- ? entry('mark-regen', t('ctxMarkRegen'), '⟳', () => actions.onMark('regenerate-selected'))
2886
- : null,
2887
- actions.onMark !== undefined
2888
- ? entry('mark-ref', t('ctxMarkReference'), '◎', () => actions.onMark('set-reference'))
3414
+ actions.onResetLabel !== undefined
3415
+ ? entry('label-reset', t('labelCtxReset'), '↺', () => actions.onResetLabel())
2889
3416
  : null,
2890
3417
  ]))
2891
3418
  }
2892
3419
 
3420
+ /**
3421
+ * v0.14.2 手动调整产出标签弹窗。
3422
+ *
3423
+ * 三件事一次做完,但决定权全在人:
3424
+ * ① 选新标签(素材 / 过程稿 / 定稿)
3425
+ * ② 可选填「调整方向」
3426
+ * ③ 可选「同时加入反馈篮」——默认勾上,可取消
3427
+ * 弹窗绝不发送任何消息;反馈只进篮子,等人审核合并后再发。
3428
+ */
3429
+ function LabelDialog({ t, item, batchCount, currentCategory, isManual,
3430
+ onCancel, onApply, onReset }) {
3431
+ const [next, setNext] = React.useState(
3432
+ ['input', 'intermediate', 'final'].includes(currentCategory) ? currentCategory : 'final',
3433
+ )
3434
+ const [direction, setDirection] = React.useState('')
3435
+ const [addToBasket, setAddToBasket] = React.useState(true)
3436
+
3437
+ React.useEffect(() => {
3438
+ const onKey = (event) => {
3439
+ if (event.key === 'Escape') { event.preventDefault(); onCancel() }
3440
+ }
3441
+ window.addEventListener('keydown', onKey)
3442
+ return () => window.removeEventListener('keydown', onKey)
3443
+ }, [onCancel])
3444
+
3445
+ const catName = (c) => c === 'final' ? t('labelCatFinal')
3446
+ : c === 'input' ? t('labelCatInput')
3447
+ : c === 'intermediate' ? t('labelCatIntermediate') : t('labelCatUnknown')
3448
+ const isBatch = Number(batchCount) > 1
3449
+ const choices = [
3450
+ { id: 'final', label: t('labelCatFinal') },
3451
+ { id: 'intermediate', label: t('labelCatIntermediate') },
3452
+ { id: 'input', label: t('labelCatInput') },
3453
+ ]
3454
+
3455
+ return h('div', {
3456
+ className: 'dg-labelLayer', key: 'labelLayer', onClick: onCancel,
3457
+ }, [
3458
+ h('div', {
3459
+ className: 'dg-labelDialog', key: 'dlg',
3460
+ 'data-gallery-label-dialog': true,
3461
+ onClick: (event) => event.stopPropagation(),
3462
+ }, [
3463
+ h('div', { className: 'dg-labelHead', key: 'head' },
3464
+ isBatch ? `${t('labelDialogBatchTitle')} · ${batchCount}` : t('labelDialogTitle')),
3465
+ h('div', { className: 'dg-labelRow', key: 'file' },
3466
+ isBatch ? format(t('batchBarTitle'), { n: batchCount }) : (item?.name ?? '')),
3467
+ h('div', { className: 'dg-labelRow', key: 'cur' },
3468
+ `${t('labelCurrent')}:${catName(currentCategory)}(${isManual ? t('labelManual') : t('labelAuto')})`),
3469
+ h('div', { className: 'dg-labelRow', key: 'new' }, [
3470
+ h('span', { key: 'l' }, t('labelNew')),
3471
+ h('div', { className: 'dg-labelChoices', key: 'cs' },
3472
+ choices.map((c) => h('button', {
3473
+ type: 'button', key: c.id,
3474
+ className: `dg-labelChoice${next === c.id ? ' dg-labelChoiceOn' : ''}`,
3475
+ 'data-gallery-label-choice': c.id,
3476
+ 'data-gallery-label-choice-on': next === c.id ? '1' : '0',
3477
+ onClick: () => setNext(c.id),
3478
+ }, c.label))),
3479
+ ]),
3480
+ h('label', { className: 'dg-labelRow', key: 'dir' }, [
3481
+ h('div', { key: 'l' }, t('labelDirection')),
3482
+ h('textarea', {
3483
+ className: 'dg-input dg-labelTextarea', key: 'in', rows: 2,
3484
+ value: direction, placeholder: t('labelDirectionPlaceholder'),
3485
+ 'data-gallery-label-direction': true,
3486
+ onChange: (event) => setDirection(event.target.value),
3487
+ }),
3488
+ ]),
3489
+ h('label', { className: 'dg-labelCheck', key: 'chk' }, [
3490
+ h('input', {
3491
+ type: 'checkbox', key: 'cb', checked: addToBasket,
3492
+ 'data-gallery-label-add-basket': addToBasket ? '1' : '0',
3493
+ onChange: (event) => setAddToBasket(event.target.checked),
3494
+ }),
3495
+ h('span', { key: 's' }, t('labelAddToBasket')),
3496
+ ]),
3497
+ h('div', { className: 'dg-labelHint', key: 'hint' }, t('labelAddToBasketHint')),
3498
+ h('div', { className: 'dg-labelActions', key: 'acts' }, [
3499
+ isManual && !isBatch
3500
+ ? h('button', {
3501
+ type: 'button', className: 'dg-btn', key: 'reset',
3502
+ 'data-gallery-label-reset': true,
3503
+ onClick: () => onReset(),
3504
+ }, t('labelReset'))
3505
+ : null,
3506
+ h('button', {
3507
+ type: 'button', className: 'dg-btn', key: 'cancel', onClick: onCancel,
3508
+ }, t('cancel')),
3509
+ h('button', {
3510
+ type: 'button', className: 'dg-btn dg-primaryBtn', key: 'apply',
3511
+ 'data-gallery-label-apply': true,
3512
+ onClick: () => onApply({ category: next, direction: direction.trim(), addToBasket }),
3513
+ }, t('labelApply')),
3514
+ ]),
3515
+ ]),
3516
+ ])
3517
+ }
3518
+
2893
3519
  /** 删除确认弹窗:删除不可逆,必须二次确认。 */
2894
3520
  function ConfirmDialog({ t, name, busy, onCancel, onConfirm }) {
2895
3521
  React.useEffect(() => {
@@ -2936,7 +3562,7 @@ function serializeFeedback(feedback) {
2936
3562
  * 抽帧是**懒加载**的(进入视口才做),否则一页几十个视频会同时解码把面板卡死。
2937
3563
  * 音频没有画面,只显示音符图标。
2938
3564
  */
2939
-
3565
+
2940
3566
  function MediaCard({ item, t, absPath, onPlay, onContextMenu }) {
2941
3567
  const isVideo = item.mediaType === 'video'
2942
3568
  const [thumb, setThumb] = React.useState(null)
@@ -3099,7 +3725,7 @@ function serializeFeedback(feedback) {
3099
3725
  *
3100
3726
  * 因此不再需要 blob 方案,也不再需要 60MB 分档 —— 任意大小都能播。
3101
3727
  */
3102
- function MediaPlayer({ item, t, onClose }) {
3728
+ function MediaPlayer({ item, t, onClose, sessionId, sessionTitle, sessionCreatedAt, onSaved }) {
3103
3729
  const isVideo = item.mediaType === 'video'
3104
3730
  const videoRef = React.useRef(null)
3105
3731
  const blobUrlRef = React.useRef(null)
@@ -3205,9 +3831,14 @@ function serializeFeedback(feedback) {
3205
3831
  }, [item.relPath, t])
3206
3832
 
3207
3833
  /**
3208
- * 截取当前帧存成 PNG。
3209
- * 同一来源(同协议同端口)才能 canvas toBlob,否则 canvas 被 taint。
3210
- * 我们的媒体路由与页面同源,所以可用。
3834
+ * 截取当前帧 → 交给 Host 直接写进「当前对话资产」(v0.14.3)。
3835
+ *
3836
+ * 旧实现用 <a download> 触发浏览器下载:弹系统保存框、文件落在「下载」目录,
3837
+ * 画廊扫描不到,也就没法对这一帧框选批注、写进反馈篮。
3838
+ * 现在只把 PNG 的 base64 交给 Host,由它写到源视频同目录(扫描范围内),
3839
+ * 并登记「来源视频 + 帧时间 + 所属对话」,刷新后仍在当前对话分组里。
3840
+ *
3841
+ * 同源要求不变:媒体路由与页面同源,canvas 才不会被 taint。
3211
3842
  */
3212
3843
  const grabFrame = React.useCallback(() => {
3213
3844
  const v = videoRef.current
@@ -3226,32 +3857,45 @@ function serializeFeedback(feedback) {
3226
3857
  if (c2d === null) throw new Error('no 2d context')
3227
3858
  c2d.drawImage(v, 0, 0, w, h)
3228
3859
 
3229
- const sec = Math.floor(v.currentTime || 0)
3230
- const hh = String(Math.floor(sec / 3600)).padStart(2, '0')
3231
- const mm = String(Math.floor((sec % 3600) / 60)).padStart(2, '0')
3232
- const ss = String(sec % 60).padStart(2, '0')
3233
- const base = (item.name ?? 'frame').replace(/\.[^.]+$/, '')
3234
- const fname = `${base}_${hh}-${mm}-${ss}.png`
3860
+ // 精确到毫秒:同一秒内连截多帧也能分清先后
3861
+ const frameMs = Math.max(0, Math.round((v.currentTime || 0) * 1000))
3862
+ setGrabNotice({ kind: 'ok', text: t('mediaGrabFrameSaving') })
3235
3863
 
3236
- canvas.toBlob((blob) => {
3864
+ canvas.toBlob(async (blob) => {
3237
3865
  if (blob === null) {
3238
3866
  setGrabNotice({ kind: 'failed', text: format(t('mediaGrabFrameFailed'), { message: 'toBlob null' }) })
3239
3867
  return
3240
3868
  }
3241
- const u = URL.createObjectURL(blob)
3242
- const a = document.createElement('a')
3243
- a.href = u
3244
- a.download = fname
3245
- document.body.appendChild(a)
3246
- a.click()
3247
- document.body.removeChild(a)
3248
- setTimeout(() => URL.revokeObjectURL(u), 1000)
3249
- setGrabNotice({ kind: 'ok', text: format(t('mediaGrabFrameOk'), { name: fname }) })
3869
+ try {
3870
+ const dataUrl = await new Promise((resolve, reject) => {
3871
+ const fr = new FileReader()
3872
+ fr.onload = () => resolve(String(fr.result))
3873
+ fr.onerror = () => reject(fr.error ?? new Error('FileReader failed'))
3874
+ fr.readAsDataURL(blob)
3875
+ })
3876
+ const payload = await callHost('saveFrame', {
3877
+ path: item.relPath,
3878
+ data: dataUrl.slice(dataUrl.indexOf(',') + 1),
3879
+ frameMs,
3880
+ sessionId: sessionId ?? '',
3881
+ sessionTitle: sessionTitle ?? '',
3882
+ sessionCreatedAt: sessionCreatedAt ?? 0,
3883
+ })
3884
+ if (payload?.ok === false) throw new Error(payload?.error?.message ?? 'saveFrame failed')
3885
+ setGrabNotice({
3886
+ kind: 'ok',
3887
+ text: format(t('mediaGrabFrameSaved'), { name: payload?.name ?? '', timecode: payload?.timecode ?? '' }),
3888
+ })
3889
+ // 立刻重扫:新资产出现在当前对话组,可马上点开批注 / 进反馈篮
3890
+ if (typeof onSaved === 'function') onSaved(payload)
3891
+ } catch (error) {
3892
+ setGrabNotice({ kind: 'failed', text: format(t('mediaGrabFrameFailed'), { message: String(error?.message ?? error) }) })
3893
+ }
3250
3894
  }, 'image/png')
3251
3895
  } catch (error) {
3252
3896
  setGrabNotice({ kind: 'failed', text: format(t('mediaGrabFrameFailed'), { message: String(error?.message ?? error) }) })
3253
3897
  }
3254
- }, [item.name, t])
3898
+ }, [item.relPath, sessionId, sessionTitle, sessionCreatedAt, onSaved, t])
3255
3899
 
3256
3900
  React.useEffect(() => {
3257
3901
  if (grabNotice === null) return undefined
@@ -3388,7 +4032,7 @@ function serializeFeedback(feedback) {
3388
4032
  * 媒体直链:GET /api/dsh-gallery/media?path=<relPath>
3389
4033
  * 带 mtime 作为缓存破坏参数(文件被覆盖后浏览器不会用旧缓存)。
3390
4034
  */
3391
-
4035
+
3392
4036
  function mediaUrlOf(relPath, mtime) {
3393
4037
  const stamp = typeof mtime === 'number' ? mtime : 0
3394
4038
  return MEDIA_ROUTE + '?path=' + encodeURIComponent(relPath) + '&v=' + stamp
@@ -3584,7 +4228,7 @@ ${absPath}
3584
4228
  }
3585
4229
 
3586
4230
  /** 文本类扩展名(仅用于判断,不再在插件内渲染)。 */
3587
-
4231
+
3588
4232
  const TEXT_EXTS = new Set([
3589
4233
  '.md', '.markdown', '.txt', '.log', '.json', '.jsonl', '.csv', '.tsv',
3590
4234
  '.yaml', '.yml', '.xml', '.toml', '.ini', '.cfg', '.conf',
@@ -3850,6 +4494,8 @@ ${absPath}
3850
4494
  * 放大状态下左键是用来拖图的,松手后若真的移动过就不算点击。
3851
4495
  */
3852
4496
  const onClickBody = (event) => {
4497
+ // 标注模式下点图只用于画框,不能顺手把大图关掉(老板 20:32 指出的冲突)
4498
+ if (annotActive) return
3853
4499
  event.preventDefault()
3854
4500
  if (lastDragMoved.current === true) {
3855
4501
  lastDragMoved.current = false
@@ -3926,6 +4572,9 @@ ${absPath}
3926
4572
  // 远程控制下键盘比鼠标精确,是主要操作方式。
3927
4573
  React.useEffect(() => {
3928
4574
  const onKey = (event) => {
4575
+ // 正在输入(批注说明等)时,所有查看器快捷键让位:
4576
+ // 左右键要能移动光标、字母 o/0/+/- 要能当文字输入,Esc 只取消编辑
4577
+ if (isTypingTarget(event.target)) return
3929
4578
  const key = event.key
3930
4579
  if (key === 'Escape') {
3931
4580
  event.preventDefault()
@@ -4212,23 +4861,44 @@ ${absPath}
4212
4861
  * 用户填一个绝对路径 → Host 校验 → 写入运行时配置 → 立即生效(不重启)。
4213
4862
  * 也可以点「恢复默认」,回到自动探测的结果。
4214
4863
  */
4215
-
4864
+
4216
4865
  /**
4217
- * 框选批注层(v0.14.0)—— 在查看器图片上圈出「哪儿不对」。
4866
+ * 框选批注层(v0.14.2)—— 在查看器图片上圈出「哪儿不对」。
4218
4867
  *
4219
4868
  * 设计要点:
4220
4869
  * · 坐标全部归一化(0–1,相对图片宽高),见 shared/protocol.js 的 ANNOTATION_* 契约
4221
4870
  * · SVG 覆盖在图片之上;不干扰查看器原有的缩放/平移(只有「批注模式」下才接管指针)
4222
- * · 拖拽画矩形 → 立刻弹出输入框写说明 → 存进批注列表
4223
- * · 已存在的批注按归一化坐标还原绘制,缩放/换屏都不失真
4871
+ * · 拖拽画矩形 → 亮框**一直留着**直到保存/取消 → 输入框写说明 → 存进批注列表
4872
+ * · 已存在的批注按归一化坐标还原绘制,带编号,缩放/换屏都不失真
4224
4873
  * · 批注不发送任何东西;出口是与决策草稿同一通道(见 05-feedback.js)
4874
+ *
4875
+ * v0.14.1 修:
4876
+ * ① 局部变量 h 遮蔽 React.createElement(画框直接崩面板)→ 全部改名 boxH
4877
+ * ② 拖完松手就把草稿框清掉,图上没有任何边界标志 → 草稿保留到保存/取消
4878
+ * ③ 输入框里按方向键/字母被查看器全局快捷键抢走 → 本层拦事件 + 查看器侧判焦点
4879
+ * ④ 放大状态下查看器 pointerdown 会捕获指针,弹窗里的按钮点不动 → 弹窗拦冒泡
4880
+ *
4881
+ * v0.14.2 修:
4882
+ * ⑤ 弹窗开着时第二处按不下:改为一按下就先把当前草稿存档,可连续圈多处
4883
+ * ⑥ 只认「按住拖拽」:补「点两下」定义矩形(点起点 → 点终点),两种习惯都能用
4225
4884
  */
4226
4885
 
4227
4886
  function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, stageRef }) {
4228
4887
  const [draft, setDraft] = React.useState(null)
4229
4888
  const [editing, setEditing] = React.useState(null)
4889
+ /** 已点下第一下、等第二下定终点时的起点(归一化坐标)。 */
4890
+ const [pendingStart, setPendingStart] = React.useState(null)
4230
4891
  const svgRef = React.useRef(null)
4231
4892
 
4893
+ /** 退出标注模式时清掉未保存的草稿,避免输入框/虚线框残留。 */
4894
+ React.useEffect(() => {
4895
+ if (active) return undefined
4896
+ setDraft(null)
4897
+ setEditing(null)
4898
+ setPendingStart(null)
4899
+ return undefined
4900
+ }, [active])
4901
+
4232
4902
  /** 客户坐标 → 归一化(相对 SVG 的实际渲染盒) */
4233
4903
  const toNorm = (event) => {
4234
4904
  const el = svgRef.current
@@ -4241,50 +4911,129 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4241
4911
  }
4242
4912
  }
4243
4913
 
4914
+ const rectFrom = (p0, p1) => ({
4915
+ x: Math.min(p0.x, p1.x),
4916
+ y: Math.min(p0.y, p1.y),
4917
+ w: Math.abs(p1.x - p0.x),
4918
+ h: Math.abs(p1.y - p0.y),
4919
+ })
4920
+
4921
+ /** 太小当成误点,不产生批注(避免满屏碎框)。 */
4922
+ const isValidBox = (box) => box.w >= 0.01 && box.h >= 0.01
4923
+
4924
+ const clearPending = () => {
4925
+ setDraft(null)
4926
+ setEditing(null)
4927
+ setPendingStart(null)
4928
+ }
4929
+
4930
+ /**
4931
+ * 把正在编辑的草稿直接存档(说明可留空)。
4932
+ * 用于「弹窗还开着就在图上圈下一处」:不丢当前这处,也不卡住下一处。
4933
+ */
4934
+ const commitEditing = () => {
4935
+ if (editing === null) return
4936
+ const normalized = normalizeAnnotation(editing)
4937
+ if (normalized !== null) onAdd(normalized)
4938
+ setEditing(null)
4939
+ }
4940
+
4941
+ const beginEdit = (box) => {
4942
+ // draft 的形态必须是 {x0,y0,x1,y1}(绘制层按这四个角算框),
4943
+ // 不能直接塞 {x,y,w,h},否则 Math.min(undefined) → NaN%,框画不出来。
4944
+ setDraft({ x0: box.x, y0: box.y, x1: box.x + box.w, y1: box.y + box.h })
4945
+ setEditing({ shape: 'rect', ...box, note: '', frameMs: frameMs ?? null })
4946
+ setPendingStart(null)
4947
+ }
4948
+
4244
4949
  const onPointerDown = (event) => {
4245
4950
  if (!active) return
4246
- // 只响应主键;左键拖拽画框
4951
+ // 放大状态下查看器会在 pointerdown 里 setPointerCapture;这里必须拦住冒泡,
4952
+ // 否则弹窗内的输入框/按钮会被「拖图」逻辑抢走,表现为点击无反应。
4953
+ event.stopPropagation()
4247
4954
  if (event.button !== 0) return
4248
4955
  const p = toNorm(event)
4249
4956
  if (p === null) return
4250
4957
  event.preventDefault()
4251
- event.stopPropagation()
4252
4958
  try { event.currentTarget.setPointerCapture(event.pointerId) } catch { /* 忽略 */ }
4959
+
4960
+ // 上一处还在输入 → 先存档,第二处才按得下去(v0.14.2 ⑤)
4961
+ if (editing !== null) commitEditing()
4962
+
4963
+ // 已经点过第一下 → 这一下当终点,直接成框(v0.14.2 ⑥)
4964
+ if (pendingStart !== null) {
4965
+ const box = rectFrom(pendingStart, p)
4966
+ if (isValidBox(box)) {
4967
+ beginEdit(box)
4968
+ } else {
4969
+ // 两次点到同一处:把起点挪到新位置,继续等第二下
4970
+ setPendingStart(p)
4971
+ setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
4972
+ }
4973
+ return
4974
+ }
4975
+
4976
+ setPendingStart(p)
4253
4977
  setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
4254
4978
  }
4255
4979
 
4256
4980
  const onPointerMove = (event) => {
4257
- if (draft === null) return
4981
+ if (!active || draft === null || editing !== null) return
4982
+ event.stopPropagation()
4258
4983
  const p = toNorm(event)
4259
4984
  if (p === null) return
4260
4985
  event.preventDefault()
4261
- event.stopPropagation()
4262
4986
  setDraft((d) => (d === null ? null : { ...d, x1: p.x, y1: p.y }))
4263
4987
  }
4264
4988
 
4265
4989
  const finishDraft = (event) => {
4266
- if (draft === null) return
4990
+ if (draft === null || editing !== null) return
4267
4991
  event.preventDefault()
4268
4992
  event.stopPropagation()
4269
- const x = Math.min(draft.x0, draft.x1)
4270
- const y = Math.min(draft.y0, draft.y1)
4271
- const w = Math.abs(draft.x1 - draft.x0)
4272
- const h = Math.abs(draft.y1 - draft.y0)
4273
- setDraft(null)
4274
- // 太小当成误点,不产生批注(避免满屏碎框)
4275
- if (w < 0.01 || h < 0.01) return
4276
- setEditing({ shape: 'rect', x, y, w, h, note: '', frameMs: frameMs ?? null })
4993
+ const box = rectFrom({ x: draft.x0, y: draft.y0 }, { x: draft.x1, y: draft.y1 })
4994
+ if (!isValidBox(box)) {
4995
+ // 只是点了一下、还没拖:保留起点,等第二下点终点(v0.14.2 ⑥)
4996
+ setPendingStart({ x: draft.x0, y: draft.y0 })
4997
+ setDraft(null)
4998
+ return
4999
+ }
5000
+ // 草稿框不清:输入框弹出期间,图上必须仍然看得见刚才圈的位置
5001
+ beginEdit(box)
4277
5002
  }
4278
5003
 
4279
5004
  const saveEditing = () => {
4280
5005
  if (editing === null) return
4281
5006
  const normalized = normalizeAnnotation(editing)
4282
5007
  if (normalized !== null) onAdd(normalized)
4283
- setEditing(null)
5008
+ clearPending()
5009
+ }
5010
+
5011
+ /**
5012
+ * 双层描边矩形:白色外线 + 彩色内线。
5013
+ * vectorEffect=non-scaling-stroke 让线宽固定为屏幕像素,缩放时既不糊也不粗得离谱。
5014
+ */
5015
+ const rectPair = (key, a, color, dashed) => {
5016
+ const box = {
5017
+ x: (a.x * 100) + '%', y: (a.y * 100) + '%',
5018
+ width: (a.w * 100) + '%', height: (a.h * 100) + '%',
5019
+ rx: 3,
5020
+ }
5021
+ const dash = dashed ? { strokeDasharray: '7 5' } : {}
5022
+ return h('g', { key }, [
5023
+ h('rect', {
5024
+ ...box, key: 'outer', fill: 'none', stroke: '#ffffff', strokeWidth: 4,
5025
+ vectorEffect: 'non-scaling-stroke', opacity: 0.92, ...dash,
5026
+ }),
5027
+ h('rect', {
5028
+ ...box, key: 'inner',
5029
+ fill: dashed ? 'rgba(255, 209, 102, 0.20)' : 'rgba(74, 124, 255, 0.18)',
5030
+ stroke: color, strokeWidth: 2, vectorEffect: 'non-scaling-stroke', ...dash,
5031
+ }),
5032
+ ])
4284
5033
  }
4285
5034
 
4286
5035
  // ---- 绘制已有批注 ----
4287
- const shapes = (annotations ?? []).map((a) => {
5036
+ const shapes = (annotations ?? []).map((a, idx) => {
4288
5037
  if (a.shape === 'text') {
4289
5038
  return h('g', { key: a.id }, [
4290
5039
  h('circle', {
@@ -4298,46 +5047,64 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4298
5047
  }, a.note || ''),
4299
5048
  ])
4300
5049
  }
4301
- // rect / arrow 都先按矩形画(arrow 后续可细化),带说明文字
5050
+ // rect / arrow 都先按矩形画(arrow 后续可细化),带编号与说明文字
4302
5051
  return h('g', { key: a.id }, [
4303
- h('rect', {
4304
- key: 'r',
5052
+ rectPair('r', a, '#4a7cff', false),
5053
+ h('text', {
5054
+ key: 'n',
4305
5055
  x: (a.x * 100) + '%', y: (a.y * 100) + '%',
4306
- width: (a.w * 100) + '%', height: (a.h * 100) + '%',
4307
- fill: 'rgba(74, 124, 255, 0.14)', stroke: '#4a7cff', strokeWidth: 2,
4308
- rx: 3,
4309
- }),
4310
- a.note !== ''
4311
- ? h('text', {
4312
- key: 'n',
4313
- x: (a.x * 100) + '%', y: (a.y * 100) + '%',
4314
- dx: 4, dy: -6, fill: '#fff', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
4315
- style: { paintOrder: 'stroke' },
4316
- }, a.note)
4317
- : null,
5056
+ dx: 4, dy: -6, fill: '#fff', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
5057
+ style: { paintOrder: 'stroke' },
5058
+ }, `#${idx + 1}${a.note !== '' ? ' ' + a.note : ''}`),
4318
5059
  ])
4319
5060
  })
4320
5061
 
4321
- // ---- 正在画的框 ----
4322
- const draftShape = draft === null ? null : (() => {
4323
- const x = Math.min(draft.x0, draft.x1)
4324
- const y = Math.min(draft.y0, draft.y1)
4325
- const w = Math.abs(draft.x1 - draft.x0)
4326
- const h = Math.abs(draft.y1 - draft.y0)
4327
- return h('rect', {
4328
- key: 'draft',
4329
- x: (x * 100) + '%', y: (y * 100) + '%',
4330
- width: (w * 100) + '%', height: (h * 100) + '%',
4331
- fill: 'rgba(74, 124, 255, 0.22)', stroke: '#4a7cff', strokeWidth: 2, strokeDasharray: '5 3',
4332
- })
4333
- })()
5062
+ // ---- 正在画的框 / 已点下的起点(保存前一直可见)----
5063
+ const draftShape = draft !== null
5064
+ ? (() => {
5065
+ const x = Math.min(draft.x0, draft.x1)
5066
+ const y = Math.min(draft.y0, draft.y1)
5067
+ const w = Math.abs(draft.x1 - draft.x0)
5068
+ const boxH = Math.abs(draft.y1 - draft.y0)
5069
+ return h('g', { key: 'draft' }, [
5070
+ rectPair('box', { x, y, w, h: boxH }, '#ffd166', true),
5071
+ h('text', {
5072
+ key: 'tag', x: (x * 100) + '%', y: (y * 100) + '%',
5073
+ dx: 4, dy: -6, fill: '#ffe08a', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
5074
+ style: { paintOrder: 'stroke' },
5075
+ }, t('annotPendingTag')),
5076
+ ])
5077
+ })()
5078
+ : (pendingStart !== null
5079
+ ? h('g', { key: 'startPoint' }, [
5080
+ h('circle', {
5081
+ cx: (pendingStart.x * 100) + '%', cy: (pendingStart.y * 100) + '%', r: 5,
5082
+ fill: '#ffd166', stroke: '#000', strokeWidth: 1.5,
5083
+ }),
5084
+ h('text', {
5085
+ x: (pendingStart.x * 100) + '%', y: (pendingStart.y * 100) + '%',
5086
+ dx: 9, dy: 4, fill: '#ffe08a', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
5087
+ style: { paintOrder: 'stroke' },
5088
+ }, t('annotStartTag')),
5089
+ ])
5090
+ : null)
5091
+
5092
+ /** 弹窗与批注列表:一律拦住指针/点击冒泡,别让查看器抢事件。 */
5093
+ const blockViewer = {
5094
+ onPointerDown: (e) => e.stopPropagation(),
5095
+ onPointerUp: (e) => e.stopPropagation(),
5096
+ onClick: (e) => e.stopPropagation(),
5097
+ onContextMenu: (e) => { e.preventDefault(); e.stopPropagation() },
5098
+ }
4334
5099
 
4335
5100
  const editor = editing === null ? null : h('div', {
4336
5101
  className: 'dg-annotEditor',
4337
5102
  key: 'editor',
4338
5103
  'data-gallery-annot-editor': true,
5104
+ ...blockViewer,
4339
5105
  }, [
4340
5106
  h('div', { className: 'dg-annotEditorHead', key: 'h' }, t('annotNotePrompt')),
5107
+ h('div', { className: 'dg-annotPendingHint', key: 'p' }, t('annotPendingHint')),
4341
5108
  h('input', {
4342
5109
  type: 'text',
4343
5110
  key: 'inp',
@@ -4349,42 +5116,52 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4349
5116
  maxLength: 500,
4350
5117
  onChange: (e) => setEditing((cur) => (cur === null ? null : { ...cur, note: e.target.value })),
4351
5118
  onKeyDown: (e) => {
5119
+ // 方向键/字母键属于输入内容,不能被查看器的全局快捷键截走
5120
+ e.stopPropagation()
4352
5121
  if (e.key === 'Enter') { e.preventDefault(); saveEditing() }
4353
- if (e.key === 'Escape') { e.preventDefault(); setEditing(null) }
5122
+ if (e.key === 'Escape') { e.preventDefault(); clearPending() }
4354
5123
  },
4355
5124
  }),
4356
5125
  h('div', { className: 'dg-annotEditorOps', key: 'o' }, [
4357
- h('button', { type: 'button', className: 'dg-btn dg-btnSmall', key: 'c', onClick: () => setEditing(null) }, t('cancel')),
4358
5126
  h('button', {
4359
- type: 'button', className: 'dg-btn dg-btnSmall dg-primaryBtn', key: 's',
4360
- 'data-gallery-annot-save': true, onClick: saveEditing,
5127
+ type: 'button', className: 'dg-btn dg-btnSmall', key: 'c',
5128
+ onClick: (e) => { e.stopPropagation(); e.preventDefault(); clearPending() },
5129
+ }, t('cancel')),
5130
+ h('button', {
5131
+ type: 'button', className: 'dg-btn dg-btnSmall dg-annotSave', key: 's',
5132
+ 'data-gallery-annot-save': true,
5133
+ onClick: (e) => { e.stopPropagation(); e.preventDefault(); saveEditing() },
4361
5134
  }, t('save')),
4362
5135
  ]),
4363
5136
  ])
4364
5137
 
4365
5138
  const list = (annotations ?? []).length === 0 ? null : h('div', {
4366
5139
  className: 'dg-annotList', key: 'list', 'data-gallery-annot-list': true,
4367
- }, (annotations ?? []).map((a) => h('div', {
5140
+ ...blockViewer,
5141
+ }, (annotations ?? []).map((a, idx) => h('div', {
4368
5142
  className: 'dg-annotItem', key: a.id, 'data-gallery-annot-id': a.id,
4369
5143
  }, [
4370
- h('span', { className: 'dg-annotIndex', key: 'i' }, '#'),
5144
+ h('span', { className: 'dg-annotIndex', key: 'i' }, `#${idx + 1}`),
4371
5145
  h('span', { className: 'dg-annotText', key: 't' }, a.note || t('annotNoNote')),
4372
5146
  h('button', {
4373
5147
  type: 'button', className: 'dg-btn dg-btnSmall dg-btnIcon', key: 'x',
4374
5148
  title: t('delete'), 'data-gallery-annot-remove': a.id,
4375
- onClick: () => onRemove(a.id),
5149
+ onClick: (e) => { e.stopPropagation(); e.preventDefault(); onRemove(a.id) },
4376
5150
  }, '✕'),
4377
5151
  ])))
4378
5152
 
4379
- return h('div', { className: 'dg-annotWrap', key: 'annot', style: { position: 'absolute', inset: 0 } }, [
5153
+ return h('div', {
5154
+ className: 'dg-annotWrap', key: 'annot',
5155
+ style: { position: 'absolute', inset: 0, zIndex: 3 },
5156
+ }, [
4380
5157
  h('svg', {
4381
5158
  key: 'svg',
4382
5159
  ref: svgRef,
4383
5160
  className: `dg-annotSvg${active ? ' dg-annotActive' : ''}`,
4384
5161
  'data-gallery-annot-svg': true,
4385
5162
  'data-gallery-annot-active': active ? '1' : '0',
4386
- viewBox: '0 0 100 100',
4387
- preserveAspectRatio: 'none',
5163
+ // 不设 viewBox:坐标本来就是百分比(相对 SVG 视口),去掉 viewBox 后
5164
+ // 线宽与字号按屏幕像素计算,否则 12 号字会被放大成几十像素、盖住整张图。
4388
5165
  style: {
4389
5166
  position: 'absolute', inset: 0, width: '100%', height: '100%',
4390
5167
  pointerEvents: active ? 'auto' : 'none',
@@ -4393,13 +5170,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4393
5170
  onPointerDown,
4394
5171
  onPointerMove,
4395
5172
  onPointerUp: finishDraft,
4396
- onPointerCancel: () => setDraft(null),
5173
+ onPointerCancel: () => { setDraft(null); setPendingStart(null) },
5174
+ onClick: active ? (event) => { event.preventDefault(); event.stopPropagation() } : undefined,
5175
+ onContextMenu: active ? (event) => { event.preventDefault(); event.stopPropagation() } : undefined,
4397
5176
  }, [draftShape, ...shapes]),
4398
5177
  list,
4399
5178
  editor,
4400
5179
  ])
4401
5180
  }
4402
-
5181
+
4403
5182
  function SettingsPanel({ t, onClose, onSaved }) {
4404
5183
  const [loading, setLoading] = React.useState(true)
4405
5184
  const [info, setInfo] = React.useState(null)
@@ -4654,8 +5433,167 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4654
5433
  ])
4655
5434
  }
4656
5435
 
5436
+ /**
5437
+ * 资产 → 会话窗口(01,纯 DOM 路线)。
5438
+ *
5439
+ * 宿主会话列表是渐进渲染(watermark):不活跃的旧会话行不在 DOM 里。
5440
+ * 宿主自己提供 `overflow:*`(展开其余会话)与 `workspace:*`(展开折叠工作区),
5441
+ * 找不到目标时先替用户展开,等 React 更新后再找,最后点目标行。
5442
+ * 只操作宿主公开 DOM:不 inject 任何服务、不碰私有 RPC、不发消息。
5443
+ * @returns {Promise<{ok:boolean, reason?:string, expanded?:number}>}
5444
+ */
5445
+ async function openSessionById(sessionId) {
5446
+ const id = String(sessionId ?? '')
5447
+ if (id === '' || id === '__history__') return { ok: false, reason: 'no-id' }
5448
+ const wanted = 'session:' + id
5449
+ const allRows = () => Array.from(document.querySelectorAll('[data-row-key]'))
5450
+ const findRow = () => allRows().find((el) => el.getAttribute('data-row-key') === wanted) ?? null
5451
+ const tick = () => new Promise((resolve) => setTimeout(resolve, 120))
5452
+ // 每轮最多展开一个入口,16 轮封顶(宿主行为变化时不空转)
5453
+ for (let round = 0; round < 16; round += 1) {
5454
+ const row = findRow()
5455
+ if (row !== null) {
5456
+ // 行在就点,能不能切过去由点击结果说话。
5457
+ // 旧版一见 aria-description 就判「归档、禁止打开」,但宿主会给普通行也挂描述,
5458
+ // 于是能打开的对话被误标成打不开(老板 2026-11-10 反馈的 bug)。
5459
+ try { row.scrollIntoView({ block: 'nearest' }) } catch { /* 滚动失败不影响打开 */ }
5460
+ row.click()
5461
+ return { ok: true, expanded: round }
5462
+ }
5463
+ const overflow = allRows().find((el) =>
5464
+ (el.getAttribute('data-row-key') || '').startsWith('overflow:'))
5465
+ if (overflow !== undefined) { overflow.click(); await tick(); continue }
5466
+ const folded = allRows().find((el) =>
5467
+ (el.getAttribute('data-row-key') || '').startsWith('workspace:')
5468
+ && el.getAttribute('aria-expanded') === 'false')
5469
+ if (folded !== undefined) { folded.click(); await tick(); continue }
5470
+ break
5471
+ }
5472
+ return { ok: false, reason: 'not-found' }
5473
+ }
5474
+
5475
+ /**
5476
+ * 会话状态标注(02)——只标注,不排序、不改变分组显示范围,
5477
+ * 也不取消「打开对话」入口:能不能切回以点击实测为准。
5478
+ */
5479
+ const GROUP_STATE_LABEL = {
5480
+ archived: ['groupStateArchived', 'groupStateHintArchived'],
5481
+ }
5482
+
5483
+ /** 归一化左侧会话标题:去掉尾部「(2)」「3 天前」这类宿主附加文字。 */
5484
+ function normalizeSessionTitle(raw) {
5485
+ return String(raw ?? '')
5486
+ .replace(/\s+/g, ' ')
5487
+ .replace(/[((]\s*\d+\s*[))]\s*$/, '')
5488
+ .replace(/\s*\d+\s*(天|小时|分钟|周|个月|年)前\s*$/, '')
5489
+ .trim()
5490
+ .toLowerCase()
5491
+ }
5492
+
5493
+ /**
5494
+ * 左侧会话列表此刻的快照:会话 ID + 可见标题。
5495
+ *
5496
+ * 宿主是渐进渲染,折叠在「其余会话」里的行不在 DOM,光靠 ID 查行会漏判;
5497
+ * 所以连标题一起收,并按归一化名比对(画廊的「Chief (2)」≈ 左侧的「Chief」)。
5498
+ */
5499
+ function readSidebarSessions() {
5500
+ const ids = new Set()
5501
+ const titles = new Set()
5502
+ try {
5503
+ for (const el of document.querySelectorAll('[data-row-key]')) {
5504
+ const key = el.getAttribute('data-row-key') || ''
5505
+ if (key.startsWith('session:')) ids.add(key.slice('session:'.length))
5506
+ for (const raw of [el.getAttribute('title'), el.getAttribute('aria-label'), (el.textContent || '').trim()]) {
5507
+ const norm = normalizeSessionTitle(String(raw ?? '').slice(0, 80))
5508
+ if (norm !== '' && norm.length <= 80) titles.add(norm)
5509
+ }
5510
+ }
5511
+ } catch { /* 读不到就没有快照,交给实测裁决 */ }
5512
+ return { ids, titles }
5513
+ }
5514
+
5515
+ /** 这个对话此刻是否还出现在左侧列表里(同 ID 或同名,含带序号的旧会话)。 */
5516
+ function sessionVisibleInSidebar(group, sidebar) {
5517
+ if (sidebar === null || sidebar === undefined) return false
5518
+ const sid = String(group.sessionId ?? '')
5519
+ if (sid !== '' && sidebar.ids.has(sid)) return true
5520
+ const title = normalizeSessionTitle(group.title ?? '')
5521
+ if (title === '') return false
5522
+ if (sidebar.titles.has(title)) return true
5523
+ // 行文本常带「3 天前」「📌」等尾巴,做一次前缀兜底
5524
+ for (const t of sidebar.titles) {
5525
+ if (t.startsWith(title) || title.startsWith(t)) return true
5526
+ }
5527
+ return false
5528
+ }
5529
+
5530
+ /**
5531
+ * 状态标注(02):只标注、不排序、不裁剪,且绝不顶替「实测能否打开」。
5532
+ *
5533
+ * 裁决顺序(老板 2026-11-10 定的口径):
5534
+ * ① 点过「打开对话」且成功 → 一律不标
5535
+ * ② 左侧列表里还看得见这个对话 → 一律不标(宁可少标,保证能跳回去)
5536
+ * ③ 实测打不开 → 标「无法重建对话」
5537
+ * ④ 宿主官方归档字段命中、且左侧确实找不到 → 只标「已归档」,仍保留打开入口
5538
+ */
5539
+ function groupStateBadge(group, t, openResult, sidebar) {
5540
+ if (group.isCurrent === true || group.isHistory === true) return null
5541
+ if (openResult === 'ok') return null
5542
+ if (sessionVisibleInSidebar(group, sidebar)) return null
5543
+ if (openResult === 'failed') {
5544
+ return {
5545
+ label: t('groupStateCannotReopen'),
5546
+ hint: t('groupStateRebuildHint'),
5547
+ className: 'dg-groupStateBadge dg-groupStateBadge-warn',
5548
+ state: 'unreachable',
5549
+ }
5550
+ }
5551
+ const entry = GROUP_STATE_LABEL[group.sessionState]
5552
+ if (entry === undefined) return null
5553
+ return {
5554
+ label: t(entry[0]),
5555
+ hint: t(entry[1]),
5556
+ className: 'dg-groupStateBadge',
5557
+ state: group.sessionState,
5558
+ }
5559
+ }
5560
+
5561
+ /** 分组展开后的「打开对话」按钮:成功/失败都给一句可见反馈,不弹窗。 */
5562
+ function GroupOpenButton({ t, sessionId, title, onResult }) {
5563
+ const [note, setNote] = React.useState('')
5564
+ const timerRef = React.useRef(null)
5565
+ React.useEffect(() => () => {
5566
+ if (timerRef.current !== null) clearTimeout(timerRef.current)
5567
+ }, [])
5568
+ const show = (text) => {
5569
+ setNote(text)
5570
+ if (timerRef.current !== null) clearTimeout(timerRef.current)
5571
+ timerRef.current = setTimeout(() => setNote(''), 3200)
5572
+ }
5573
+ const onClick = async () => {
5574
+ const r = await openSessionById(sessionId)
5575
+ onResult?.(sessionId, r)
5576
+ if (r.ok) show(t('groupOpenDone'))
5577
+ else if (r.reason === 'archived') show(t('groupOpenArchived'))
5578
+ else {
5579
+ await copyText(sessionId)
5580
+ show(t('groupOpenMissed'))
5581
+ }
5582
+ }
5583
+ return h('span', { className: 'dg-groupOpenWrap' }, [
5584
+ h('button', {
5585
+ type: 'button',
5586
+ className: 'dg-btn dg-btnSmall dg-openSession',
5587
+ 'data-gallery-open-session': sessionId,
5588
+ title: format(t('groupOpenTip'), { title: title || sessionId }),
5589
+ onClick,
5590
+ }, t('groupOpenSession')),
5591
+ note === '' ? null : h('span', { className: 'dg-groupOpenNote', key: 'n' }, note),
5592
+ ])
5593
+ }
5594
+
4657
5595
  /** 画廊正文:Header(刷新)+ 网格 + 面板内放大。 */
4658
-
5596
+
4659
5597
  function GalleryBody(props) {
4660
5598
  const { t, sessionId } = props
4661
5599
  const [view, setView] = React.useState({ status: 'loading' })
@@ -4685,11 +5623,25 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4685
5623
  const [settingsOpen, setSettingsOpen] = React.useState(false)
4686
5624
  // 全局分组:哪些组是展开的(键是 sessionId 或 '__history__')
4687
5625
  const [openGroups, setOpenGroups] = React.useState(new Set())
5626
+ /**
5627
+ * 「打开对话」的实测结论:sid → 'ok' | 'failed'。
5628
+ * 它比 Host 的归档字段优先级更高:点得开就撤掉一切标注,点不开才标无法重建。
5629
+ */
5630
+ const [openResults, setOpenResults] = React.useState(() => new Map())
5631
+ const reportOpenResult = React.useCallback((sid, r) => {
5632
+ setOpenResults((prev) => {
5633
+ const nextState = r.ok === true ? 'ok' : 'failed'
5634
+ if (prev.get(sid) === nextState) return prev
5635
+ const next = new Map(prev)
5636
+ next.set(sid, nextState)
5637
+ return next
5638
+ })
5639
+ }, [])
4688
5640
  // 分组默认展开只做一次:当前对话组优先,没有则展开第一个。
4689
5641
  // 用 ref 记住「已初始化」,否则用户手动收起后每次渲染又被强制展开。
4690
5642
  const groupsInitRef = React.useRef(false)
4691
- // 全局分组:哪些组显示了中间产物
4692
- const [showInterim, setShowInterim] = React.useState({})
5643
+ // v0.14.3:组内「隐藏 / 显示中间产物」按钮已移除。
5644
+ // 过程稿的显隐只由顶部「过程稿」开关决定,不再有第二套开关。
4693
5645
  /**
4694
5646
  * 分类显隐开关(v0.13.7)。
4695
5647
  *
@@ -4697,15 +5649,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4697
5649
  * 理由:用户若忘了自己关过哪一类,会以为文件丢了 —— 每次从全显示开始最不容易误解。
4698
5650
  *
4699
5651
  * 键:
4700
- * finalConfirmed —— 最终交付·已确认(确认态,见 3.2)
4701
- * finalPending —— 最终交付·待确认
5652
+ * final —— 定稿
5653
+ * input / intermediate / unknown —— 素材 / 过程稿 / 未归类(手动覆写后按新标签归类)
4702
5654
  * input —— 输入素材
4703
5655
  * intermediate —— 中间产物(与组内开关同源)
4704
5656
  * unknown —— 未归类
4705
5657
  */
5658
+ // v0.14.2:表态层下线,只剩 4 个原生标签(定稿 / 素材 / 过程稿 / 未归类)
4706
5659
  const [categoryFilter, setCategoryFilter] = React.useState({
4707
- finalConfirmed: true,
4708
- finalPending: true,
5660
+ final: true,
4709
5661
  input: true,
4710
5662
  intermediate: true,
4711
5663
  unknown: true,
@@ -4732,16 +5684,17 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4732
5684
  return next
4733
5685
  })
4734
5686
  }, [])
4735
- const toggleInterim = React.useCallback((key) => {
4736
- setShowInterim((prev) => ({ ...prev, [key]: !prev[key] }))
4737
- }, [])
5687
+ // 组内中间产物开关已并入顶部分类筛选(v0.14.3)。
4738
5688
  // 右键菜单:{ item, absPath, x, y }
4739
5689
  const [ctxMenu, setCtxMenu] = React.useState(null)
4740
5690
  // 删除确认:{ item, busy }
4741
5691
  const [deleteTarget, setDeleteTarget] = React.useState(null)
4742
- // ---- 反馈标记(S3-a)----
4743
- // marks: { [relPath]: { action, reason?, changeOnly?, keep? } }
5692
+ // ---- v0.14.2:反馈篮条目(marks,一次性)与手动标签(labels,持久)分开 ----
5693
+ // 两者绝不能共用一份:从反馈篮删掉一条,不该把已经定好的标签一起撤销。
4744
5694
  const [marks, setMarks] = React.useState({})
5695
+ const [labels, setLabels] = React.useState({})
5696
+ // 改标签弹窗:null | { item, paths, category }
5697
+ const [labelDialog, setLabelDialog] = React.useState(null)
4745
5698
  // 反馈篮是否打开
4746
5699
  const [basketOpen, setBasketOpen] = React.useState(false)
4747
5700
  // 编辑中的条目(null 表示不编辑)
@@ -4750,49 +5703,38 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4750
5703
  const bodyScrollRef = React.useRef(null)
4751
5704
  const savedScrollRef = React.useRef(null)
4752
5705
 
4753
- // 首次挂载时拉取已有标记(持久化在 dsh-gallery-marks.json)
5706
+ // 首次挂载:分别拉反馈条目与手动标签覆写
4754
5707
  React.useEffect(() => {
4755
5708
  let alive = true
4756
5709
  callHost('getMarks', {})
4757
5710
  .then((payload) => {
4758
- if (!alive) return
4759
- if (payload?.ok === false) return
4760
- if (payload !== null && typeof payload.marks === 'object' && payload.marks !== null) {
4761
- setMarks(payload.marks)
4762
- }
5711
+ if (!alive || payload?.ok === false) return
5712
+ if (payload?.marks !== null && typeof payload?.marks === 'object') setMarks(payload.marks)
4763
5713
  })
4764
5714
  .catch((error) => console.warn('dsh-gallery: getMarks 失败', error))
5715
+ callHost('getLabels', {})
5716
+ .then((payload) => {
5717
+ if (!alive || payload?.ok === false) return
5718
+ if (payload?.labels !== null && typeof payload?.labels === 'object') setLabels(payload.labels)
5719
+ })
5720
+ .catch((error) => console.warn('dsh-gallery: getLabels 失败', error))
4765
5721
  return () => { alive = false }
4766
5722
  }, [])
4767
5723
 
4768
- /**
4769
- * 给某卡片设标记 → 进反馈篮。
4770
- * 只改本地状态 + 落盘 marks,**绝不发送任何消息**。
4771
- */
4772
- /**
4773
- * 卡片的「确认态」—— 唯一真源是 marks 里的 confirmed 字段(v0.13.7)。
4774
- *
4775
- * **数据边界(最要紧)**:确认态只读标记文件,绝不读 / 写自动分类。
4776
- * 分类是机器猜的、会随 5 秒刷新变;判断是人给的、必须留得住。
4777
- */
4778
- const isConfirmed = React.useCallback((relPath) => {
4779
- return marks[relPath]?.confirmed === true
4780
- }, [marks])
5724
+ /** 手动标签覆写:只读独立 labels 文件,与反馈篮条目互不影响。 */
5725
+ const manualLabelOf = React.useCallback((relPath) => labels[relPath] ?? null, [labels])
4781
5726
 
4782
5727
  /**
4783
- * 卡片的分类分组(用于顶部开关筛选):
4784
- * finalConfirmed / finalPending / input / intermediate / unknown
4785
- *
4786
- * 注意「最终交付」拆两态:靠确认态区分,不靠自动分类的 final。
4787
- * 一张 final 的卡片若没确认 → finalPending;确认了 → finalConfirmed。
5728
+ * 顶部分类开关用的分组键。
5729
+ * v0.14.2:表态层下线;Host 扫描时已把手动标签覆写进 file.category,
5730
+ * 所以这里只按最终标签走,不再有「确认 / 要重做 / 留档」这些桶。
4788
5731
  */
4789
5732
  const bucketOf = React.useCallback((file) => {
4790
- if (isConfirmed(file.relPath)) return 'finalConfirmed'
4791
- if (file.category === 'final') return 'finalPending'
5733
+ if (file.category === 'final') return 'final'
4792
5734
  if (file.category === 'input') return 'input'
4793
5735
  if (file.category === 'intermediate') return 'intermediate'
4794
5736
  return 'unknown'
4795
- }, [isConfirmed])
5737
+ }, [])
4796
5738
 
4797
5739
  /** 切一个分类的显隐。 */
4798
5740
  const toggleCategory = React.useCallback((key) => {
@@ -4809,67 +5751,105 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4809
5751
  })
4810
5752
  }, [])
4811
5753
 
4812
- /** 批量:确认 / 取消确认 / 清除标记(只改标记,不碰磁盘)。 */
4813
- const batchMark = React.useCallback(async (action) => {
5754
+ /** 打开单张「改标签」弹窗。 */
5755
+ const openLabelDialog = React.useCallback((item) => {
5756
+ setLabelDialog({ item, paths: [item.relPath], category: item.category ?? 'unknown' })
5757
+ }, [])
5758
+
5759
+ /** 批量改标签:把当前选中的卡片一起交给同一个弹窗。 */
5760
+ const openBatchLabelDialog = React.useCallback(() => {
4814
5761
  const paths = [...selected]
4815
5762
  if (paths.length === 0) return
4816
- const updates = paths.map((p) => ({
4817
- path: p,
4818
- // 确认:保留原有 action,加 confirmed:true
4819
- // 取消确认:去掉 confirmed
4820
- // 清除:整条删掉
4821
- mark: action === 'clear'
4822
- ? null
4823
- : action === 'confirm'
4824
- ? { ...(marks[p] ?? { action: 'finalize' }), confirmed: true }
4825
- : (() => {
4826
- const cur = marks[p]
4827
- if (cur === undefined) return null
4828
- const next = { ...cur }
4829
- delete next.confirmed
4830
- // 若原来只为确认而建的 finalize 标记,取消后整条删掉
4831
- if (next.action === 'finalize' && Object.keys(next).filter((k) => k !== 'action' && k !== 'markedAt').length === 0) {
4832
- return null
4833
- }
4834
- return next
4835
- })(),
4836
- }))
4837
- // 本地先行(乐观更新)
4838
- setMarks((prev) => {
4839
- const next = { ...prev }
4840
- for (const u of updates) {
4841
- if (u.mark === null) delete next[u.path]
4842
- else next[u.path] = u.mark
5763
+ const flat = Array.isArray(data?.items) ? data.items : []
5764
+ const grouped = Array.isArray(data?.groups)
5765
+ ? data.groups.flatMap((gr) => Array.isArray(gr.files) ? gr.files : [])
5766
+ : []
5767
+ const first = flat.find((it) => it.relPath === paths[0])
5768
+ ?? grouped.find((it) => it.relPath === paths[0])
5769
+ setLabelDialog({ item: first ?? null, paths, category: first?.category ?? 'unknown' })
5770
+ }, [selected])
5771
+
5772
+ /**
5773
+ * 手动改标签的主逻辑(v0.14.2)。
5774
+ *
5775
+ * ① 写 labels(持久)→ Host 清列表缓存 → 重扫,角标 / 筛选 / 分组统计一起跟着变;
5776
+ * ② 可选写一条反馈进篮子(一次性),按 from→to 选语义:
5777
+ * 过程稿 → 定稿 = 「终止枚举,以此图为定稿」
5778
+ * 定稿 → 其它 = 「交付不合格」+ 调整方向
5779
+ * 其它 = 「调整产出标签」+ from→to + 调整方向
5780
+ * 全程**不发送任何消息**;反馈由人在篮子里审核合并后手动发。
5781
+ */
5782
+ const applyLabelChange = React.useCallback(async ({ category, direction, addToBasket }) => {
5783
+ const dlg = labelDialog
5784
+ if (dlg === null || !['input', 'intermediate', 'final'].includes(category)) return
5785
+ const catName = (c) => c === 'final' ? t('labelCatFinal')
5786
+ : c === 'input' ? t('labelCatInput')
5787
+ : c === 'intermediate' ? t('labelCatIntermediate') : t('labelCatUnknown')
5788
+ // 全局分组视图的卡片在 groups[].files 里,不能只查平铺的 data.items
5789
+ const flat = Array.isArray(data?.items) ? data.items : []
5790
+ const grouped = Array.isArray(data?.groups)
5791
+ ? data.groups.flatMap((gr) => Array.isArray(gr.files) ? gr.files : [])
5792
+ : []
5793
+ const findItem = (rp) => flat.find((it) => it.relPath === rp)
5794
+ ?? grouped.find((it) => it.relPath === rp)
5795
+
5796
+ const labelUpdates = []
5797
+ const markUpdates = []
5798
+ for (const relPath of dlg.paths) {
5799
+ const from = findItem(relPath)?.category ?? dlg.category ?? 'unknown'
5800
+ labelUpdates.push({ path: relPath, label: { category, from } })
5801
+ if (!addToBasket) continue
5802
+ let action = 'set-label'
5803
+ if (from === 'intermediate' && category === 'final') action = 'finalize-asset'
5804
+ else if (from === 'final' && category !== 'final') action = 'reject-delivery'
5805
+ let reason = ''
5806
+ if (action === 'reject-delivery') reason = direction
5807
+ else if (action === 'set-label') {
5808
+ reason = `${t('labelEdit')}:${catName(from)} → ${catName(category)}`
5809
+ if (direction !== '') reason += `;${t('labelDirection')}:${direction}`
4843
5810
  }
5811
+ markUpdates.push({
5812
+ path: relPath,
5813
+ mark: {
5814
+ action, category, from,
5815
+ ...(reason !== '' ? { reason } : {}),
5816
+ markedAt: Date.now(),
5817
+ },
5818
+ })
5819
+ }
5820
+
5821
+ // 乐观更新:标签覆写与反馈条目先落到本地
5822
+ setLabels((prev) => {
5823
+ const next = { ...prev }
5824
+ for (const u of labelUpdates) next[u.path] = u.label
4844
5825
  return next
4845
5826
  })
4846
- try {
4847
- const payload = await callHost('marksBatch', { updates })
4848
- if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
4849
- if (payload?.marks !== undefined) setMarks(payload.marks)
4850
- } catch (error) {
4851
- console.warn('dsh-gallery: 批量标记失败', error)
5827
+ if (markUpdates.length > 0) {
5828
+ setMarks((prev) => {
5829
+ const next = { ...prev }
5830
+ for (const u of markUpdates) next[u.path] = u.mark
5831
+ return next
5832
+ })
5833
+ setBasketOpen(true)
4852
5834
  }
4853
- setSelected(new Set())
4854
- }, [selected, marks, t])
4855
-
4856
- const doMark = React.useCallback(async (item, action, extra) => {
4857
- /**
4858
- * v0.13.7:`finalize` = 「定为最终版」要写成**持久确认态**。
4859
- *
4860
- * confirmed 字段是唯一真源:存进 marks 文件,刷新 / 重扫 / 切会话 / 重启都在。
4861
- * **绝不回写自动分类** —— 分类是机器猜的会变,判断是人给的必须留得住。
4862
- */
4863
- const mark = { action, ...(extra ?? {}), ...(action === 'finalize' ? { confirmed: true } : {}) }
4864
- setMarks((prev) => ({ ...prev, [item.relPath]: mark }))
4865
- setBasketOpen(true)
4866
5835
  try {
4867
- const payload = await callHost('marks', { path: item.relPath, mark })
4868
- if (payload?.ok === false) throw new Error(payload?.error?.message ?? t('errorTitle'))
5836
+ const lp = await callHost('setLabelsBatch', { updates: labelUpdates })
5837
+ if (lp?.ok === false) throw new Error(lp?.error?.message ?? t('errorTitle'))
5838
+ if (lp?.labels !== undefined) setLabels(lp.labels)
5839
+ if (markUpdates.length > 0) {
5840
+ const mp = await callHost('marksBatch', { updates: markUpdates })
5841
+ if (mp?.ok === false) throw new Error(mp?.error?.message ?? t('errorTitle'))
5842
+ if (mp?.marks !== undefined) setMarks(mp.marks)
5843
+ }
4869
5844
  } catch (error) {
4870
- console.warn('dsh-gallery: 标记落盘失败', error)
5845
+ console.warn('dsh-gallery: 改标签落盘失败', error)
4871
5846
  }
4872
- }, [t])
5847
+ setLabelDialog(null)
5848
+ setSelected(new Set())
5849
+ setBatchMode(false)
5850
+ // refresh 定义在本函数之后:不放进依赖数组,实际调用时早已初始化
5851
+ void refresh()
5852
+ }, [labelDialog, t])
4873
5853
 
4874
5854
  /**
4875
5855
  * 更新一条标记的附加字段(理由 / 只改 / 锁死)。
@@ -4892,28 +5872,29 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4892
5872
  }
4893
5873
  }, [])
4894
5874
 
4895
- /** 取消确认(v0.13.7):把 confirmed 去掉,退回「待确认」。 */
4896
- const unconfirmOne = React.useCallback(async (relPath) => {
4897
- const cur = marks[relPath]
4898
- if (cur === undefined) return
4899
- const next = { ...cur }
4900
- delete next.confirmed
4901
- const cleaned = (next.action === 'finalize' &&
4902
- Object.keys(next).filter((k) => k !== 'action' && k !== 'markedAt').length === 0)
4903
- ? null
4904
- : next
4905
- setMarks((prev) => {
4906
- const n = { ...prev }
4907
- if (cleaned === null) delete n[relPath]
4908
- else n[relPath] = cleaned
4909
- return n
5875
+ /** 恢复自动判定:只删 labels 覆写,不动反馈篮里的任何条目。 */
5876
+ const resetLabels = React.useCallback(async () => {
5877
+ const dlg = labelDialog
5878
+ if (dlg === null) return
5879
+ const paths = dlg.paths
5880
+ setLabels((prev) => {
5881
+ const next = { ...prev }
5882
+ for (const p of paths) delete next[p]
5883
+ return next
4910
5884
  })
4911
5885
  try {
4912
- await callHost('marks', { path: relPath, mark: cleaned })
5886
+ await callHost('setLabelsBatch', {
5887
+ updates: paths.map((p) => ({ path: p, label: null })),
5888
+ })
4913
5889
  } catch (error) {
4914
- console.warn('dsh-gallery: 取消确认失败', error)
5890
+ console.warn('dsh-gallery: 恢复自动标签失败', error)
4915
5891
  }
4916
- }, [marks])
5892
+ setLabelDialog(null)
5893
+ void refresh()
5894
+ }, [labelDialog])
5895
+
5896
+ // v0.14.2:表态层的「确认 / 取消确认 / 单张表态」回调已整体移除,
5897
+ // 人的判断现在直接落在标签上(labels 覆写),表达走反馈篮。
4917
5898
 
4918
5899
  /** 加一条批注(v0.14.0)。 */
4919
5900
  const addAnnotation = React.useCallback((item, annot) => {
@@ -4938,6 +5919,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
4938
5919
  })
4939
5920
  }, [])
4940
5921
 
5922
+ /** 删一条批注(按 relPath,反馈篮用;查看器走带 item 的那个)。 */
5923
+ const removeAnnotationById = React.useCallback((relPath, id) => {
5924
+ setAnnotations((prev) => {
5925
+ const cur = prev[relPath] ?? []
5926
+ const next = cur.filter((a) => a.id !== id)
5927
+ const out = { ...prev }
5928
+ if (next.length === 0) delete out[relPath]
5929
+ else out[relPath] = next
5930
+ return out
5931
+ })
5932
+ }, [])
5933
+
4941
5934
  /** 取某文件的批注列表(给查看器用)。 */
4942
5935
  const annotationsOf = React.useCallback((item) => {
4943
5936
  return annotations[item.relPath] ?? []
@@ -5099,7 +6092,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5099
6092
  setView({ status: 'ready', data: await load(undefined, kind, scope, page) })
5100
6093
  } catch (error) {
5101
6094
  if (error?.name === 'AbortError') return
5102
- setView({ status: 'failed', message: String(error?.message ?? error) })
6095
+ setView({ status: 'failed', message: error?.code === 'gallery-timeout' ? t('listTimeout') : String(error?.message ?? error) })
5103
6096
  } finally {
5104
6097
  setRefreshing(false)
5105
6098
  }
@@ -5113,7 +6106,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5113
6106
  if (alive) setView({ status: 'ready', data })
5114
6107
  })
5115
6108
  .catch((error) => {
5116
- if (alive && error?.name !== 'AbortError') setView({ status: 'failed', message: String(error?.message ?? error) })
6109
+ if (alive && error?.name !== 'AbortError') setView({ status: 'failed', message: error?.code === 'gallery-timeout' ? t('listTimeout') : String(error?.message ?? error) })
5117
6110
  })
5118
6111
  return () => {
5119
6112
  alive = false
@@ -5140,6 +6133,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5140
6133
  React.useEffect(() => {
5141
6134
  if (viewer === null) return undefined
5142
6135
  const onKey = (event) => {
6136
+ // 批注输入框里按 Esc 只取消编辑,不能把整个查看器关掉
6137
+ if (isTypingTarget(event.target)) return
5143
6138
  if (event.key === 'Escape') {
5144
6139
  event.preventDefault()
5145
6140
  setViewer(null)
@@ -5151,6 +6146,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5151
6146
 
5152
6147
  const data = view.status === 'ready' ? view.data : null
5153
6148
  const items = data?.items ?? []
6149
+ /**
6150
+ * 顶部分类筛选后的可见条目(v0.14.3)。
6151
+ * 「当前对话」等非分组视图此前直接渲染 items,点了「定稿 / 素材 / 过程稿」
6152
+ * 只有按钮变色、卡片不动 —— 这里统一按开关裁一遍,两个视图行为一致。
6153
+ * items 本身保持全量:分类计数、反馈篮、批量操作不随筛选丢失。
6154
+ */
6155
+ const visibleItems = React.useMemo(
6156
+ () => items.filter((it) => categoryFilter[bucketOf(it)] !== false),
6157
+ [items, categoryFilter, bucketOf])
5154
6158
  // 右键菜单的回调要在不重建依赖的前提下读到最新的列表,所以同步到 ref
5155
6159
  const itemsRef = React.useRef(items)
5156
6160
  itemsRef.current = items
@@ -5215,7 +6219,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5215
6219
  h('span', { className: 'dg-sub', key: 'sub' },
5216
6220
  data === null
5217
6221
  ? (view.status === 'failed' ? t('errorTitle') : t('loading'))
5218
- : format(t('subCount'), { shown: items.length, total: data.total })),
6222
+ : format(t('subCount'), { shown: visibleItems.length, total: data.total })),
5219
6223
  ]),
5220
6224
  scopeSwitch,
5221
6225
  // 图片 / 文件 / 音视频 三画廊切换(v0.10.1)
@@ -5242,6 +6246,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5242
6246
  onClick: () => { setKind('media'); setPage(1); setViewer(null) },
5243
6247
  }, t('kindMedia')),
5244
6248
  ]),
6249
+ // 批量选择入口(v0.14.1 修 v0.13.7 死锁):此前没有任何 setBatchMode(true) 调用
6250
+ h('button', {
6251
+ type: 'button',
6252
+ className: `dg-btn${batchMode ? ' dg-btnActive' : ''}`,
6253
+ key: 'batchMode',
6254
+ 'data-gallery-batch-mode': batchMode ? '1' : '0',
6255
+ title: batchMode ? t('batchModeExitHint') : t('batchModeEnterHint'),
6256
+ onClick: () => setBatchMode((v) => {
6257
+ if (v) setSelected(new Set())
6258
+ return !v
6259
+ }),
6260
+ }, batchMode ? t('batchModeExit') : t('batchModeEnter')),
5245
6261
  settingsBtn,
5246
6262
  h('button', {
5247
6263
  type: 'button',
@@ -5256,7 +6272,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5256
6272
  // 分类图例:告诉用户三种边框颜色代表什么(只在有数据时显示)
5257
6273
  // 「未归类」只有在确实存在这类文件时才显示,避免图例噪音
5258
6274
  // 反馈篮独立入口(S3-a):关闭后能重新打开,不必再标记一张卡
5259
- const markedCount = Object.keys(marks).length
6275
+ // 计数取「表态 ∪ 批注」并集:只有框选批注、没表态的卡也算一条待发反馈
6276
+ const markedCount = new Set([...Object.keys(marks), ...Object.keys(annotations)]).size
5260
6277
  const basketToggle = h('button', {
5261
6278
  type: 'button',
5262
6279
  className: 'dg-btn dg-basketToggle',
@@ -5275,29 +6292,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5275
6292
  * v0.13.7:确认态计数来自 marks,不来自自动分类。
5276
6293
  */
5277
6294
  const catCounts = React.useMemo(() => {
5278
- const c = { finalConfirmed: 0, finalPending: 0, input: 0, intermediate: 0, unknown: 0 }
6295
+ // v0.14.2:只数 4 个原生标签,表态层已下线
6296
+ const c = { final: 0, input: 0, intermediate: 0, unknown: 0 }
5279
6297
  for (const it of items) {
5280
6298
  const b = bucketOf(it)
5281
6299
  if (Object.prototype.hasOwnProperty.call(c, b)) c[b] += 1
5282
6300
  }
5283
6301
  return c
5284
6302
  }, [items, bucketOf])
5285
- const confirmedCount = catCounts.finalConfirmed
5286
- const pendingCount = catCounts.finalPending
6303
+ const finalCount = catCounts.final
5287
6304
  const inputCount = catCounts.input
5288
6305
  const interimCount = catCounts.intermediate
5289
6306
  const unknownCount = catCounts.unknown
5290
6307
 
5291
- /** 按当前开关过滤后的可见文件数(供「已显示 N / 共 M」)。 */
5292
- const visibleStats = React.useMemo(() => {
5293
- let shown = 0
5294
- let total = 0
5295
- for (const it of items) {
5296
- total += 1
5297
- if (categoryFilter[bucketOf(it)] !== false) shown += 1
5298
- }
5299
- return { shown, total }
5300
- }, [items, categoryFilter, bucketOf])
6308
+ // 「已显示 N / 共 M」直接取 visibleItems.length(定义见上方),不再另算一遍。
5301
6309
 
5302
6310
  const hasUnknown = data !== null && Array.isArray(data.groups) &&
5303
6311
  data.groups.some((gr) => (gr.counts?.unknown ?? 0) > 0)
@@ -5330,12 +6338,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5330
6338
 
5331
6339
  const legend = data !== null && items.length > 0
5332
6340
  ? h('div', { className: 'dg-legend', key: 'legend', 'data-gallery-filterbar': true }, [
5333
- // 最终交付 · 已确认
5334
- filterToggle('finalConfirmed', t('catFilterFinalConfirmed'),
5335
- 'dg-legendSwatch-final', confirmedCount, true),
5336
- // 最终交付 · 待确认
5337
- filterToggle('finalPending', t('catFilterFinalPending'),
5338
- 'dg-legendSwatch-final dg-legendSwatchPending', pendingCount, true),
6341
+ // v0.14.2:只留原生标签四个开关;手动改过的标签 Host 已覆写,直接按新标签归类
6342
+ filterToggle('final', t('catFilterFinal'),
6343
+ 'dg-legendSwatch-final', finalCount, true),
5339
6344
  filterToggle('input', t('catLegendInput'), 'dg-legendSwatch-input', inputCount, true),
5340
6345
  filterToggle('intermediate', t('catLegendIntermediate'), 'dg-legendSwatch-intermediate', interimCount, true),
5341
6346
  hasUnknown
@@ -5353,22 +6358,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5353
6358
  ? h('div', { className: 'dg-batchBar', key: 'batchBar', 'data-gallery-batch-bar': true }, [
5354
6359
  h('span', { className: 'dg-batchCount', key: 'n' }, format(t('batchBarTitle'), { n: selectedCount })),
5355
6360
  h('div', { className: 'dg-batchOps', key: 'ops' }, [
6361
+ // v0.14.2:批量表态整体换成「批量改标签」,语义与单张弹窗完全一致
5356
6362
  h('button', {
5357
- type: 'button', className: 'dg-btn dg-btnSmall', key: 'confirm',
5358
- 'data-gallery-batch-confirm': true,
5359
- title: t('batchHintConfirm'),
5360
- onClick: () => { void batchMark('confirm') },
5361
- }, t('batchConfirm')),
5362
- h('button', {
5363
- type: 'button', className: 'dg-btn dg-btnSmall', key: 'unconfirm',
5364
- 'data-gallery-batch-unconfirm': true,
5365
- onClick: () => { void batchMark('unconfirm') },
5366
- }, t('batchUnconfirm')),
6363
+ type: 'button', className: 'dg-btn dg-btnSmall dg-primaryBtn', key: 'label',
6364
+ 'data-gallery-batch-label': true,
6365
+ title: t('labelEditHint'),
6366
+ onClick: () => openBatchLabelDialog(),
6367
+ }, t('labelBatch')),
5367
6368
  h('button', {
5368
6369
  type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearmark',
5369
6370
  'data-gallery-batch-clear': true,
5370
6371
  title: t('batchHintClearMark'),
5371
- onClick: () => { void batchMark('clear') },
6372
+ onClick: () => { void clearMarks(); setSelected(new Set()) },
5372
6373
  }, t('batchClearMark')),
5373
6374
  h('button', {
5374
6375
  type: 'button', className: 'dg-btn dg-btnSmall', key: 'clearSel',
@@ -5538,52 +6539,71 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5538
6539
  // 全局模式 + 有分组数据 → 按对话分组渲染(可折叠)
5539
6540
  const useGroups = scope === 'global' && Array.isArray(data.groups) && data.groups.length > 0
5540
6541
 
5541
- if (useGroups) {
5542
- /**
5543
- * 卡片包装层(v0.13.7):给任意卡片加「确认角标」+「批量多选框」。
5544
- *
5545
- * 为什么不改三个卡片组件:Card / FileCard / MediaCard 各自有复杂的内部结构,
5546
- * 在它们外面套一层 absolute 定位的 overlay 最省事,也不会影响既有交互
5547
- * (右键、点击预览、拖拽都不受影响,因为我们只加 pointer-events 可控的子元素)。
5548
- */
5549
- const wrapCard = (node, item, key) => {
5550
- const confirmed = isConfirmed(item.relPath)
5551
- const checked = selected.has(item.relPath)
5552
- const showCheckbox = selectMode || checked
5553
- return h('div', {
5554
- className: `dg-cardWrap${confirmed ? ' dg-cardConfirmed' : ''}${checked ? ' dg-cardChecked' : ''}`,
5555
- key: key + ':wrap',
5556
- 'data-gallery-card-wrap': item.relPath,
5557
- 'data-gallery-confirmed': confirmed ? '1' : '0',
5558
- }, [
5559
- node,
5560
- // 确认角标(只在确认态出现,与自动分色边框区分开)
5561
- confirmed
5562
- ? h('div', {
5563
- className: 'dg-confirmBadge',
5564
- key: 'badge',
5565
- 'data-gallery-confirm-badge': true,
5566
- title: t('confirmBadgeHint'),
5567
- }, [h('span', { key: 'i' }, '✓'), h('span', { key: 'l' }, t('confirmBadgeLabel'))])
5568
- : null,
5569
- // 多选框(批量模式下常显,或已选中时显示)
5570
- showCheckbox
5571
- ? h('button', {
5572
- type: 'button',
5573
- className: `dg-cardCheck${checked ? ' dg-cardCheckOn' : ''}`,
5574
- key: 'check',
5575
- 'data-gallery-card-check': item.relPath,
5576
- title: checked ? t('batchUnselect') : t('batchSelect'),
5577
- onClick: (e) => {
5578
- e.stopPropagation()
5579
- e.preventDefault()
5580
- toggleSelect(item.relPath)
5581
- },
5582
- }, checked ? '✓' : '')
5583
- : null,
5584
- ])
5585
- }
6542
+ /** 卡片包装层(v0.14.2):手动标签入口 + 批量多选框。表态层已下线。 */
6543
+ const wrapCard = (node, item, key) => {
6544
+ const bucket = bucketOf(item)
6545
+ const checked = selected.has(item.relPath)
6546
+ const showCheckbox = selectMode || checked
6547
+ const manual = manualLabelOf(item.relPath)
6548
+ const isManual = manual !== null && manual !== undefined
6549
+ return h('div', {
6550
+ className: `dg-cardWrap${checked ? ' dg-cardChecked' : ''}${selectMode ? ' dg-cardSelectable' : ''}`,
6551
+ key: key + ':wrap',
6552
+ 'data-gallery-card-wrap': item.relPath,
6553
+ 'data-gallery-bucket': bucket,
6554
+ 'data-gallery-label-manual': isManual ? '1' : '0',
6555
+ 'data-gallery-category': item.category || '',
6556
+ /**
6557
+ * 批量模式下整张卡片都能点(v0.14.3):
6558
+ * 点卡片任意位置 = 选中/取消,不再打开大图 / 侧栏预览 / 播放器。
6559
+ * 只放行卡片上的按钮(三种表态、多选框),它们有自己的语义。
6560
+ * 用 capture 而不是改每个 Card 的 onOpen:三种卡片(图片/文件/音视频)
6561
+ * 与分组视图、当前对话视图共用这一层,一处生效。
6562
+ */
6563
+ onClickCapture: selectMode
6564
+ ? (event) => {
6565
+ const target = event.target
6566
+ if (target !== null && target !== undefined && typeof target.closest === 'function') {
6567
+ if (target.closest('[data-gallery-label-edit],[data-gallery-card-check]') !== null) return
6568
+ }
6569
+ event.preventDefault()
6570
+ event.stopPropagation()
6571
+ toggleSelect(item.relPath)
6572
+ }
6573
+ : undefined,
6574
+ }, [
6575
+ node,
6576
+ // 右上「改标签」:手动设定过的用琥珀色区分,hover 时完全显现。
6577
+ // 不再放独立角标,避免和卡片左上角的阶段角标抢位置。
6578
+ h('button', {
6579
+ type: 'button', key: 'labelEdit',
6580
+ className: `dg-labelBtn${isManual ? ' dg-labelBtnManual' : ''}`,
6581
+ 'data-gallery-label-edit': item.relPath,
6582
+ title: t('labelEditHint'),
6583
+ onClick: (e) => {
6584
+ e.stopPropagation(); e.preventDefault()
6585
+ openLabelDialog(item)
6586
+ },
6587
+ }, '✎'),
6588
+ // 多选框(批量模式下常显,或已选中时显示)
6589
+ showCheckbox
6590
+ ? h('button', {
6591
+ type: 'button',
6592
+ className: `dg-cardCheck${checked ? ' dg-cardCheckOn' : ''}`,
6593
+ key: 'check',
6594
+ 'data-gallery-card-check': item.relPath,
6595
+ title: checked ? t('batchUnselect') : t('batchSelect'),
6596
+ onClick: (e) => {
6597
+ e.stopPropagation()
6598
+ e.preventDefault()
6599
+ toggleSelect(item.relPath)
6600
+ },
6601
+ }, checked ? '✓' : '')
6602
+ : null,
6603
+ ])
6604
+ }
5586
6605
 
6606
+ if (useGroups) {
5587
6607
  const cardFor = (item, groupKey, listForViewer) => {
5588
6608
  // 分组里的文件也走同一套卡片组件
5589
6609
  const enriched = {
@@ -5648,32 +6668,17 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5648
6668
  }), item, `${groupKey}:${item.relPath}`)
5649
6669
  }
5650
6670
 
6671
+ // 左侧会话列表快照只取一次:宿主渐进渲染,折叠行不在 DOM,
6672
+ // 因此按「ID + 归一化标题」双重判定,而不是逐组查行是否存在。
6673
+ const sidebarSnapshot = readSidebarSessions()
5651
6674
  const groupNodes = data.groups.map((group, gi) => {
5652
6675
  const groupKey = group.sessionId ?? '__history__'
5653
6676
  const isOpen = openGroups.has(groupKey)
5654
- // 组内中间产物的显隐:
5655
- // - 当前对话:**默认显示**(用户刚做完的就是要看过程,可选收起)
5656
- // - 其他对话 / 历史资产:**默认隐藏**(避免别人调试图淹没列表)
5657
- // 用户手动切换后,以 showInterim 里记录的为准(true=显示 / false=隐藏)。
5658
- // 组内「显示中间产物」与顶部「中间产物」开关**同源**(v0.13.7):
5659
- // 顶部开关关掉 → 全局都不显示中间产物;
5660
- // 顶部开着 + 组内开关 → 由组内决定(默认当前对话显示、历史隐藏)。
5661
- // 不搞两套打架的开关。
5662
- const interimDefault = group.isCurrent === true
5663
- const stored = showInterim[groupKey]
5664
- const groupWantsIntermediate = stored === undefined ? interimDefault : stored
5665
- const globalAllowsIntermediate = categoryFilter.intermediate !== false
5666
- const showIntermediate = groupWantsIntermediate && globalAllowsIntermediate
5667
-
5668
- // 分类开关过滤:按 bucketOf 判断该文件属哪一类,再查开关
5669
- const visibleFiles = group.files.filter((f) => {
5670
- const bucket = bucketOf(f)
5671
- if (categoryFilter[bucket] === false) return false
5672
- // 中间产物额外受组内开关控制(上面已算好)
5673
- if (f.category === 'intermediate' && !showIntermediate) return false
5674
- return true
5675
- })
5676
- const hiddenCount = group.files.length - visibleFiles.length
6677
+ // v0.14.3:过程稿显隐只认顶部「过程稿」开关,组内不再第二套开关。
6678
+ // 顶部开 → 所有组的过程稿都显示;顶部关 → 全部隐藏。
6679
+ // 分类开关过滤:按 bucketOf 判断该文件属哪一类,再查开关。
6680
+ const visibleFiles = group.files.filter(
6681
+ (f) => categoryFilter[bucketOf(f)] !== false)
5677
6682
 
5678
6683
  const chips = []
5679
6684
  if (group.counts.final > 0) {
@@ -5690,6 +6695,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5690
6695
  }
5691
6696
 
5692
6697
  const headKey = group.sessionId ?? '__history__'
6698
+ // 状态徽标:折叠时也能看见;只标注、不排序、不裁剪分组。
6699
+ const stateBadge = groupStateBadge(group, t, openResults.get(headKey), sidebarSnapshot)
6700
+ // 「打开对话」一律保留:标注只是提示,不能顶替实测。
6701
+ // 带「已归档」徽标的组也能点,点得开就自动撤标,点不开才改标无法重建。
6702
+ const canOpenSession = !group.isHistory && group.isCurrent !== true && !!group.sessionId
6703
+ // v0.14.3:组内「隐藏 / 显示中间产物」按钮已去掉,统一用顶部筛选。
5693
6704
  return h('div', {
5694
6705
  className: `dg-group${group.isHistory ? ' dg-groupHistory' : ''}${group.isCurrent ? ' dg-groupCurrent' : ''}`,
5695
6706
  key: `g:${headKey}`,
@@ -5707,6 +6718,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5707
6718
  group.isCurrent === true
5708
6719
  ? h('span', { className: 'dg-groupCurrentBadge', key: 'cur', 'data-gallery-current-badge': true }, t('groupCurrentBadge'))
5709
6720
  : null,
6721
+ stateBadge === null
6722
+ ? null
6723
+ : h('span', {
6724
+ className: stateBadge.className,
6725
+ key: 'st',
6726
+ 'data-gallery-session-state': stateBadge.state,
6727
+ title: stateBadge.hint,
6728
+ }, stateBadge.label),
5710
6729
  h('span', { className: 'dg-groupTitle', key: 't' },
5711
6730
  group.isHistory ? t('groupHistoryTitle') : (group.title || t('groupUnassigned'))),
5712
6731
  h('span', { className: 'dg-groupDate', key: 'd' },
@@ -5718,19 +6737,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5718
6737
  group.isHistory
5719
6738
  ? h('div', { className: 'dg-groupHint', key: 'hint' }, t('groupHistoryHint'))
5720
6739
  : null,
5721
- // 只有该组确实存在中间产物时才给切换按钮:
5722
- // 否则「显示中间产物」点了也没东西可显示,按钮是死的。
5723
- (group.counts.intermediate ?? 0) > 0
5724
- ? h('div', { className: 'dg-groupHint', key: 'toggle' }, [
5725
- h('button', {
5726
- type: 'button',
5727
- className: 'dg-btn dg-btnSmall',
5728
- 'data-gallery-toggle-interim': headKey,
5729
- 'data-gallery-interim-shown': showIntermediate ? '1' : '0',
5730
- onClick: () => toggleInterim(headKey),
5731
- }, showIntermediate
5732
- ? format(t('groupHideIntermediate'), { n: group.counts.intermediate })
5733
- : format(t('groupShowIntermediate'), { n: hiddenCount })),
6740
+ stateBadge === null
6741
+ ? null
6742
+ : h('div', { className: 'dg-groupHint dg-groupStateHint', key: 'stateHint' }, stateBadge.hint),
6743
+ canOpenSession
6744
+ ? h('div', { className: 'dg-groupActions', key: 'actions' }, [
6745
+ h(GroupOpenButton, {
6746
+ key: 'open', t, sessionId: group.sessionId,
6747
+ title: group.title, onResult: reportOpenResult,
6748
+ }),
5734
6749
  ])
5735
6750
  : null,
5736
6751
  h('div', { className: 'dg-groupBody', key: 'body' }, [
@@ -5769,7 +6784,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5769
6784
  ])
5770
6785
  } else {
5771
6786
  // 音视频:卡片直接播放(不走图片查看器)
5772
- const mediaGridChildren = items.map((item) => h(MediaCard, {
6787
+ const mediaGridChildren = visibleItems.map((item) => wrapCard(h(MediaCard, {
5773
6788
  key: item.relPath,
5774
6789
  item,
5775
6790
  t,
@@ -5777,9 +6792,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5777
6792
  absPath: buildAbsPath(data === null ? '' : data.root, item.relPath),
5778
6793
  onPlay: (target) => setMediaPlaying(target),
5779
6794
  onContextMenu: openContextMenu,
5780
- }))
6795
+ }), item, item.relPath))
5781
6796
 
5782
- const gridChildren = items.map((item) => kind === 'file'
6797
+ const gridChildren = visibleItems.map((item) => wrapCard(kind === 'file'
5783
6798
  ? h(FileCard, {
5784
6799
  key: item.relPath,
5785
6800
  item,
@@ -5804,8 +6819,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5804
6819
  t,
5805
6820
  limiter: limiter.current,
5806
6821
  onContextMenu: openContextMenu,
5807
- onOpen: (opened, anchorEl) => openViewer(items.indexOf(opened), anchorEl, items),
5808
- }))
6822
+ onOpen: (opened, anchorEl) => openViewer(visibleItems.indexOf(opened), anchorEl, visibleItems),
6823
+ }), item, item.relPath))
5809
6824
  // 网格区外面包一层定位容器,右侧放滚动辅助列(无滚轮场景用)
5810
6825
  body = h('div', { className: 'dg-bodyWrap', key: 'bodyWrap' }, [
5811
6826
  h('div', {
@@ -5814,7 +6829,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5814
6829
  'data-gallery-body': true,
5815
6830
  ref: bodyScrollRef,
5816
6831
  }, [
5817
- h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}${kind === 'media' ? ' dg-mediaGrid' : ''}`, key: 'grid' }, kind === 'media' ? mediaGridChildren : gridChildren),
6832
+ (visibleItems.length > 0
6833
+ ? h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}${kind === 'media' ? ' dg-mediaGrid' : ''}`, key: 'grid' }, kind === 'media' ? mediaGridChildren : gridChildren)
6834
+ : h('div', { className: 'dg-groupEmpty', key: 'filterEmpty' }, t('filterEmptyHint'))),
5818
6835
  data.scan.capped
5819
6836
  ? h('div', { className: 'dg-more', key: 'capped' }, t('capped'))
5820
6837
  : null,
@@ -5872,11 +6889,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5872
6889
  : null
5873
6890
 
5874
6891
  // 音视频播放器层(v0.10.1)
6892
+ // 截帧要挂到当前对话:把当前组标题 / 创建时间一并传下去登记
5875
6893
  const mediaLayer = mediaPlaying !== null
5876
6894
  ? h(MediaPlayer, {
5877
6895
  key: 'mediaPlayer',
5878
6896
  item: mediaPlaying,
5879
6897
  t,
6898
+ sessionId: sessionId ?? '',
6899
+ sessionTitle: Array.isArray(data?.groups)
6900
+ ? (data.groups.find((g) => g.isCurrent)?.title ?? '')
6901
+ : '',
6902
+ sessionCreatedAt: Array.isArray(data?.groups)
6903
+ ? (data.groups.find((g) => g.isCurrent)?.createdAt ?? 0)
6904
+ : 0,
6905
+ onSaved: () => { void refresh() },
5880
6906
  onClose: () => setMediaPlaying(null),
5881
6907
  })
5882
6908
  : null
@@ -5891,8 +6917,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5891
6917
  })
5892
6918
  : null
5893
6919
 
5894
- // 反馈篮(S3-a):列出已标记条目 + 生成决策草稿
5895
- const markedList = Object.keys(marks).map((relPath) => {
6920
+ // 反馈篮(S3-a):列出已标记条目 + 带批注的卡片(v0.14.3 批注并入反馈)
6921
+ // 批注属于「反馈」这一侧:它不进 marks(不参与表态/筛选/落盘),
6922
+ // 但只要有批注,这张卡就出现在反馈篮里,草稿会按 Annotation N 逐条带出说明与框选区域。
6923
+ const feedbackPaths = Array.from(new Set([
6924
+ ...Object.keys(marks),
6925
+ ...Object.keys(annotations),
6926
+ ]))
6927
+ const markedList = feedbackPaths.map((relPath) => {
5896
6928
  // 从当前视图里找该条目,拿 category / sessionId
5897
6929
  const flat = (Array.isArray(data?.items) ? data.items : [])
5898
6930
  const groupsList = Array.isArray(data?.groups)
@@ -5904,7 +6936,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5904
6936
  relPath,
5905
6937
  category: found?.category ?? 'unknown',
5906
6938
  sessionId: found?.sessionId,
6939
+ frameOf: found?.frameOf,
5907
6940
  mark: marks[relPath],
6941
+ annotations: Array.isArray(annotations[relPath]) ? annotations[relPath] : [],
5908
6942
  }
5909
6943
  })
5910
6944
  const feedbackLayer = basketOpen && markedList.length >= 0
@@ -5923,6 +6957,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5923
6957
  onEdit: (it) => { setEditingItem(it) },
5924
6958
  onEditSave: (relPath, patch) => { void updateMark(relPath, patch) },
5925
6959
  onClear: () => { void clearMarks() },
6960
+ // 批注:属于反馈侧,删一条只动内存,不碰 marks
6961
+ onRemoveAnnotation: (relPath, annotId) => { removeAnnotationById(relPath, annotId) },
6962
+ // 「清空反馈篮」= 表态 + 批注一起清,否则批注留在图上、篮子却空了
6963
+ onClearAll: () => { void clearMarks(); setAnnotations({}) },
6964
+ })
6965
+ : null
6966
+
6967
+ // v0.14.2 改标签弹窗:单张与批量共用,应用后才落盘 + 重扫
6968
+ const labelLayer = labelDialog !== null
6969
+ ? h(LabelDialog, {
6970
+ key: 'labelLayer',
6971
+ t,
6972
+ item: labelDialog.item,
6973
+ batchCount: labelDialog.paths.length,
6974
+ currentCategory: labelDialog.category,
6975
+ isManual: labelDialog.paths.length === 1
6976
+ ? manualLabelOf(labelDialog.paths[0]) !== null
6977
+ : false,
6978
+ onCancel: () => setLabelDialog(null),
6979
+ onApply: (payload) => { void applyLabelChange(payload) },
6980
+ onReset: () => { void resetLabels() },
5926
6981
  })
5927
6982
  : null
5928
6983
 
@@ -5944,14 +6999,28 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5944
6999
  onReveal: () => { void doReveal(ctxMenu.item) },
5945
7000
  onCopy: () => { void copyText(ctxMenu.absPath) },
5946
7001
  onDelete: () => setDeleteTarget({ item: ctxMenu.item, busy: false }),
5947
- // 6 个反馈动作(S3-a):选中即进反馈篮,不发送
5948
- confirmed: marks[ctxMenu.item.relPath]?.confirmed === true,
5949
- onUnconfirm: () => { void unconfirmOne(ctxMenu.item.relPath) },
5950
- onMark: (action) => {
7002
+ // v0.14.2:改标签 / 恢复自动,表态层已下线
7003
+ onEditLabel: () => {
5951
7004
  const target = ctxMenu.item
5952
7005
  closeContextMenu()
5953
- void doMark(target, action)
7006
+ openLabelDialog(target)
5954
7007
  },
7008
+ ...(manualLabelOf(ctxMenu.item.relPath) !== null
7009
+ ? {
7010
+ onResetLabel: () => {
7011
+ const rp = ctxMenu.item.relPath
7012
+ closeContextMenu()
7013
+ setLabels((prev) => {
7014
+ const n = { ...prev }
7015
+ delete n[rp]
7016
+ return n
7017
+ })
7018
+ void callHost('setLabelsBatch', { updates: [{ path: rp, label: null }] })
7019
+ .then(() => { void refresh() })
7020
+ .catch((e) => console.warn('dsh-gallery: 恢复自动标签失败', e))
7021
+ },
7022
+ }
7023
+ : {}),
5955
7024
  },
5956
7025
  })
5957
7026
  : null
@@ -5983,6 +7052,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5983
7052
  ctxLayer,
5984
7053
  confirmLayer,
5985
7054
  feedbackLayer,
7055
+ labelLayer,
5986
7056
  ])
5987
7057
  }
5988
7058
 
@@ -5991,7 +7061,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
5991
7061
  * 左边「还有 X 张」说清总量分布,右边页码点击切页。
5992
7062
  * 单页时也渲染(只显示「共 N 张」),保持视觉稳定。
5993
7063
  */
5994
-
7064
+
5995
7065
  function Pager({ t, page, pageCount, pageSize, total, remaining, onGo }) {
5996
7066
  const start = total === 0 ? 0 : (page - 1) * pageSize + 1
5997
7067
  const end = Math.min(page * pageSize, total)
@@ -6200,7 +7270,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, frameMs, sta
6200
7270
  }
6201
7271
 
6202
7272
  /** tab 标题(chip / 浮动面板标题)。 */
6203
-
7273
+
6204
7274
  function GalleryTitle({ t }) {
6205
7275
  return h('span', { className: 'dg-title' }, t('type.label'))
6206
7276
  }