dsh-gallery 0.17.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -1,3 +1,4 @@
1
+ // __DSH_BUILD_FINGERPRINT__ {"v":1,"fragments":{"src/client/00-head.js":"c62f6d728d1cfdb5d64db41764171d5d6314d6cc","src/client/01-i18n.js":"5edcfb18abac018ead28772972035b66fcb73562","src/client/02-util.js":"af7867f3cd7313b4d54ff17b727516eca315313e","src/client/03-theme.js":"fe8a1ed10f3ee8ab59bdbdb3038f5bb95e01f0be","src/client/04-paths.js":"d2f85774e5d0888ce512c0fe35755978b6986b52","src/client/05-feedback.js":"a9a21378ff499e482ce52c3d45041eda86d2e39d","src/client/06-ctxmenu.js":"82c4d1ccff0312453a68ae63630e4514eb11b70f","src/client/07-media.js":"e2690a07c9735856e03aaaa901e8007da005da7a","src/client/08-cards.js":"bbff076268c827f846229d97064c972ae34f7740","src/client/09-viewer.js":"4a909e1ea1fa2380062c69013ede1ba794c4535d","src/client/10-annotate.js":"0dd07c4a4929b512739df62e91ed6eb201201fb9","src/client/11-settings.js":"c02bc78edf896050dee3bc4b26d311433cc33ade","src/client/12-body.js":"656b068d26229df902eaa5a436ddd8aa0921af49","src/client/13-chrome.js":"de082de1a9d1ffbaeb600fbf659dba059cca7973","src/client/14-entry.js":"5ce848d53bef377c53b97b6411614bd571ff775b"},"shared":{"src/shared/feedback-text.js":"1e7454d368685c938b970db7b1fe297fd4e60f68"},"styles":"c5e27291a1416843ce3ae8379e40dbc80bd561bf","builtAt":"2026-11-14T14:35:40.643Z","artifactSha1":"e1f883e2f40c5f925b047d31cc21d335da835a84"}
1
2
  window.__ModuleLoader__.load({
2
3
  id: 'dsh-gallery',
3
4
  factory(require) {
@@ -57,6 +58,9 @@ const ANNOTATION_SHAPES = ["rect", "arrow", "text"]
57
58
  *
58
59
  * 约束:x/y/w/h 必须落在 [0,1];越界由写入端 clamp。
59
60
  */
61
+ /** 全局分组视图:每组一次画多少张卡,点「再显示」按这个步长追加。 */
62
+ const GROUP_PAGE = 60
63
+
60
64
  const ANNOTATION_LIMITS = { min: 0, max: 1, maxNoteLength: 500, maxPerAsset: 50 }
61
65
 
62
66
  /** 把任意数值 clamp 到 [0,1](批注坐标写入前必须过一遍)。 */
@@ -102,7 +106,11 @@ function trimPlaybackDecision(now, inPoint, outPoint, opts) {
102
106
  /** 校验并规整一条批注;不合法返回 null。 */
103
107
  function normalizeAnnotation(a) {
104
108
  if (a === null || typeof a !== "object") return null
105
- const shape = ANNOTATION_SHAPES.includes(a.shape) ? a.shape : "rect"
109
+ // v0.17.x:'polygon' 是前端「不规则区域标记」专用形状,不进 Host 的动作契约,
110
+ // 因此只在这里特判放行,host/protocol.js 的 ANNOTATION_SHAPES 无需跟着改。
111
+ const shape = a.shape === "polygon"
112
+ ? "polygon"
113
+ : (ANNOTATION_SHAPES.includes(a.shape) ? a.shape : "rect")
106
114
  const note = typeof a.note === "string" ? a.note.slice(0, ANNOTATION_LIMITS.maxNoteLength) : ""
107
115
  const x = clamp01(a.x)
108
116
  const y = clamp01(a.y)
@@ -112,9 +120,19 @@ function normalizeAnnotation(a) {
112
120
  if (w > 0 && x + w > 1) w = 1 - x
113
121
  if (h > 0 && y + h > 1) h = 1 - y
114
122
  const frameMs = Number.isFinite(a.frameMs) ? Math.max(0, Math.floor(a.frameMs)) : null
123
+ // 顶点数写死 4–20,与 POLYGON_LIMITS 一致;这里不引用后面的常量,
124
+ // 免得离线把本函数单独抽出来跑时踩到暂时性死区。
125
+ const polygon = shape === "polygon" && Array.isArray(a.polygon)
126
+ && a.polygon.length >= 4 && a.polygon.length <= 20
127
+ && a.polygon.every((p) => Array.isArray(p) && p.length === 2
128
+ && Number.isFinite(p[0]) && Number.isFinite(p[1]))
129
+ ? a.polygon.map((p) => [clamp01(p[0]), clamp01(p[1])])
130
+ : null
131
+ const fillColor = typeof a.fillColor === "string" && a.fillColor !== "" ? a.fillColor : "green"
115
132
  return {
116
133
  id: typeof a.id === "string" && a.id !== "" ? a.id : ("a" + Math.random().toString(36).slice(2, 10)),
117
134
  shape, x, y, w, h, note, frameMs,
135
+ ...(polygon !== null ? { polygon, fillColor } : {}),
118
136
  }
119
137
  }
120
138
 
@@ -195,12 +213,16 @@ function maskAlphaAt(px, py, rect) {
195
213
  }
196
214
 
197
215
  /* ------------------------------------------------------------------ *
198
- * v0.14.6 右键多点选区(老板 2026-11-12 拍板):
199
- * 标记态下左键仍是矩形批注,右键逐点点击 4–20 个顶点,闭合成实心多边形。
200
- * 实测口径(见验证报告第九节):必须是「实心、贴合目标外接框」的块,
201
- * 描笔画的镂空线框 / 椭圆 / 大矩形都会出白底;多边形天然实心且面积可量。
216
+ * 多边形选区(v0.14.6 起;老板 2026-11-15 再定版):
217
+ * · 左键按住拖动 = 矩形批注(老行为,保留)
218
+ * · 左键**单击**逐点 = 不规则区域标记,闭合后直接进反馈篮(不生成遮罩文件)
219
+ * · 右键逐点 = 实心多边形填充选区,闭合后导出遮罩 + 彩色预览(老行为,保留)
220
+ * 两套多边形共用一组顶点,模式互斥;4–20 点,点回起点 / Enter / 面板按钮闭合。
221
+ * 实测口径(见验证报告第九节):遮罩必须实心贴合目标外接框,线框 / 椭圆会出白底。
202
222
  * ------------------------------------------------------------------ */
203
223
  const POLYGON_LIMITS = { min: 4, max: 20, closeRadius: 0.02, minArea: 0.0001 }
224
+ /** 左键按下后移动超过这个归一化距离才算「拖框」,否则算一次点击(区域顶点)。 */
225
+ const ANNOT_DRAG_THRESHOLD = 0.008
204
226
 
205
227
  /* ------------------------------------------------------------------ *
206
228
  * 选区纯色半透明填充(v0.14.7 引入;老板 2026-11-12 20:22 再定版):
@@ -558,6 +580,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
558
580
  scopeNotFound: '找不到本对话的会话记录',
559
581
  scopeLogEmpty: '本对话的会话记录为空',
560
582
  subCount: '{shown} / {total} 条',
583
+ subCountGroups: '共 {total} 条 · {groups} 个对话',
561
584
  // ===== 资产分类(三色边框)=====
562
585
  catFinal: '成稿',
563
586
  catInput: '素材',
@@ -597,7 +620,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
597
620
  annotNotePrompt: '这块要改什么?(可留空)',
598
621
  annotNotePlaceholder: '例如:沙发位置偏了 / 色调太暖',
599
622
  annotNoNote: '(无说明)',
600
- annotHint: '左键拖拽或点两下画矩形批注;右键逐点圈出 4–20 点的多边形,闭合后直接生成局部重绘遮罩',
623
+ annotHint: '左键按住拖动=矩形框选(可写说明);左键单击逐点圈不规则区域,闭合后=标记进反馈篮;右键逐点圈选=生成实心填充遮罩',
601
624
  annotCount: '批注 {n} 处',
602
625
  annotPendingTag: '待保存',
603
626
  annotPendingHint: '黄色亮框就是刚圈的位置;写完点「保存并生效」,也可以直接在图上继续圈下一处(这处会先自动存档)',
@@ -667,6 +690,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
667
690
  groupIntermediate: '过程稿 {n}',
668
691
  groupUnknown: '未归类 {n}',
669
692
  groupTruncated: '仅显示最近 {shown} 个,共 {total} 个',
693
+ groupShowMore: '再显示 {step} 张 · 已显示 {shown} / 共 {total}',
670
694
  groupHistoryTitle: '历史资产',
671
695
  groupCurrentBadge: '当前对话',
672
696
  // 资产 → 会话(01)与归档/删除标注(02)
@@ -798,8 +822,15 @@ async function encodeMaskPngBytes(imageData, width, height) {
798
822
  polyClear: '清空',
799
823
  polyTooFew: '至少 4 个点才能闭合',
800
824
  polyDegenerate: '选区面积太小(点几乎连成一条线),请重新围一圈',
825
+ // v0.17.x 左键单击逐点 → 不规则区域标记,闭合只进反馈篮、不生成文件
826
+ polyNoteTitle: '不规则区域标记',
827
+ polyNoteHint: '左键逐点点出要标的位置;点回起点、按 Enter 或点「闭合并加入反馈篮」即收工。说明可填可不填,顶点可左键拖动微调,Backspace 撤销一点,Escape 清空。',
828
+ polyNotePlaceholder: '这块要说什么?(可留空)',
829
+ polyNoteClose: '闭合并加入反馈篮',
830
+ polyNoteSaved: '已把这块区域加进反馈篮(没有生成遮罩文件)',
801
831
  feedbackMaskFrom: '已有遮罩:{name}',
802
832
  feedbackAnnotHint: '{n} 条框选批注会随反馈一起发出,序号与草稿里的 Annotation N 一一对应',
833
+ feedbackAnnotPolygonTag: '不规则区域 · {n} 点',
803
834
  feedbackEditTitle: '编辑:{name}',
804
835
  feedbackReasonLabel: '理由(可选)',
805
836
  feedbackChangeOnlyLabel: '只改(逗号分隔,可选)',
@@ -810,6 +841,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
810
841
  feedbackGenerating: '正在生成…',
811
842
  feedbackGenerateHint: '生成草稿并写入输入框,由你确认后手动发送',
812
843
  feedbackDraftReady: '草稿已写入输入框(未发送)。确认无误请自行发送。',
844
+ feedbackDraftAlreadyThere: '这张图已经在输入框里了,没有重复添加。',
813
845
  dblClickHint: '双击 = 把带路径信息写进输入框(不自动发送)',
814
846
  feedbackDraftInClipboard: '草稿已复制到剪贴板(输入框通道不可用),请手动粘贴。',
815
847
  feedbackDraftFailed: '生成草稿失败',
@@ -906,6 +938,10 @@ async function encodeMaskPngBytes(imageData, width, height) {
906
938
  cropSaved: '已裁剪:{name}(已加入「{target}」素材)',
907
939
  cropFailed: '裁剪失败:{message}',
908
940
  cropMinSize: '选区太小',
941
+ cropCoord: '坐标',
942
+ cropColor: '色值',
943
+ cropCopyColor: '按 Ctrl+C 复制色值',
944
+ cropCopied: '已复制 {hex}',
909
945
  trimEnter: '裁剪片段',
910
946
  trimExit: '退出裁剪',
911
947
  trimPreview: '从入点播放',
@@ -943,6 +979,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
943
979
  scopeNotFound: 'Cannot find this chat’s session log',
944
980
  scopeLogEmpty: 'This chat’s session log is empty',
945
981
  subCount: '{shown} of {total}',
982
+ subCountGroups: '{total} items · {groups} chats',
946
983
  // Asset categories (colored borders)
947
984
  catFinal: 'Draft',
948
985
  catInput: 'Source',
@@ -982,7 +1019,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
982
1019
  annotNotePrompt: 'What should change here? (optional)',
983
1020
  annotNotePlaceholder: 'e.g. sofa position is off / color is too warm',
984
1021
  annotNoNote: '(no note)',
985
- annotHint: 'Left-drag or click twice for a boxed note; right-click 4–20 vertices for a polygon selection that becomes an inpaint mask',
1022
+ annotHint: 'Left-drag = boxed note (optional text); left-click vertices = irregular area mark, close it to add to the feedback basket; right-click vertices = solid filled mask',
986
1023
  annotCount: '{n} annotation(s)',
987
1024
  annotPendingTag: 'Pending',
988
1025
  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).',
@@ -1052,6 +1089,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
1052
1089
  groupIntermediate: 'WIP {n}',
1053
1090
  groupUnknown: 'Unclassified {n}',
1054
1091
  groupTruncated: 'Showing latest {shown} of {total}',
1092
+ groupShowMore: 'Show {step} more · {shown} of {total}',
1055
1093
  groupHistoryTitle: 'Older assets',
1056
1094
  groupCurrentBadge: 'This chat',
1057
1095
  // Assets to chat (01) and archived / deleted badges (02)
@@ -1180,8 +1218,15 @@ async function encodeMaskPngBytes(imageData, width, height) {
1180
1218
  polyClear: 'Clear',
1181
1219
  polyTooFew: 'At least 4 points are needed',
1182
1220
  polyDegenerate: 'Selection area is too small — the points are nearly a line',
1221
+ // v0.17.x left-click vertices -> irregular area mark, goes to the feedback basket only
1222
+ polyNoteTitle: 'Irregular area mark',
1223
+ polyNoteHint: 'Left-click to add vertices; click the first point, press Enter, or use Close & add to basket. A note is optional; drag vertices to adjust, Backspace undoes one point, Escape clears.',
1224
+ polyNotePlaceholder: 'What should be said about this area? (optional)',
1225
+ polyNoteClose: 'Close & add to basket',
1226
+ polyNoteSaved: 'Area added to the feedback basket (no mask file created)',
1183
1227
  feedbackMaskFrom: 'Mask ready: {name}',
1184
1228
  feedbackAnnotHint: '{n} boxed note(s) will be sent with this feedback, numbered to match `Annotation N` in the draft',
1229
+ feedbackAnnotPolygonTag: 'Irregular area · {n} points',
1185
1230
  feedbackEditTitle: 'Edit: {name}',
1186
1231
  feedbackReasonLabel: 'Reason (optional)',
1187
1232
  feedbackChangeOnlyLabel: 'Only change (comma separated, optional)',
@@ -1192,6 +1237,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
1192
1237
  feedbackGenerating: 'Generating…',
1193
1238
  feedbackGenerateHint: 'Writes the draft into the composer; you confirm and send it yourself',
1194
1239
  feedbackDraftReady: 'Draft written into the composer (not sent). Review it and send when ready.',
1240
+ feedbackDraftAlreadyThere: 'This image is already in the composer; nothing was added twice.',
1195
1241
  dblClickHint: 'Double-click = write the asset path into the chat input (never auto-sends)',
1196
1242
  feedbackDraftInClipboard: 'Draft copied to clipboard (composer channel unavailable) — paste it manually.',
1197
1243
  feedbackDraftFailed: 'Could not generate the draft',
@@ -1286,6 +1332,10 @@ async function encodeMaskPngBytes(imageData, width, height) {
1286
1332
  cropSaved: 'Cropped: {name} (added to "{target}" assets)',
1287
1333
  cropFailed: 'Crop failed: {message}',
1288
1334
  cropMinSize: 'Selection too small',
1335
+ cropCoord: 'Position',
1336
+ cropColor: 'Color',
1337
+ cropCopyColor: 'Press Ctrl+C to copy the color',
1338
+ cropCopied: 'Copied {hex}',
1289
1339
  trimEnter: 'Trim clip',
1290
1340
  trimExit: 'Exit trim',
1291
1341
  trimPreview: 'Play from in',
@@ -3079,9 +3129,9 @@ async function encodeMaskPngBytes(imageData, width, height) {
3079
3129
  .dg-annotSvg.dg-annotActive { background: rgba(74, 124, 255, 0.04); }
3080
3130
  .dg-btnActive { background: #4a7cff !important; color: #fff !important; border-color: #4a7cff !important; }
3081
3131
 
3082
- /* 批注列表 */
3132
+ /* 批注列表。离边也统一 20px:原来 8px,跟右上提示条一高一低,看着歪。 */
3083
3133
  .dg-annotList {
3084
- position: absolute; left: 8px; top: 8px; z-index: 5;
3134
+ position: absolute; left: 20px; top: 20px; z-index: 5;
3085
3135
  max-width: 300px; max-height: 40%; overflow: auto;
3086
3136
  background: rgba(27, 30, 36, 0.95); border: 1px solid rgba(255, 255, 255, 0.16);
3087
3137
  border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
@@ -3091,23 +3141,28 @@ async function encodeMaskPngBytes(imageData, width, height) {
3091
3141
  .dg-annotIndex { color: #8fb6ff; font-weight: 600; }
3092
3142
  .dg-annotText { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
3093
3143
  .dg-annotItem .dg-btn { flex: 0 0 auto; }
3094
- /* 遮罩导出结果提示:避开左上批注列表与底部批注输入框,不受 svg 缩放平移影响 */
3144
+ /* 遮罩导出结果提示:避开左上批注列表与右下角确认框,不受 svg 缩放平移影响。
3145
+ 边距跟那三个确认框统一成 20px —— 整块界面只有一套网格。 */
3095
3146
  .dg-maskNotice {
3096
- position: absolute; right: 8px; top: 8px; z-index: 7;
3147
+ position: absolute; right: 20px; top: 20px; z-index: 7;
3097
3148
  max-width: min(360px, 70%); padding: 6px 10px; border-radius: 6px;
3098
3149
  font-size: 11px; line-height: 1.5; color: #e8eaed;
3099
3150
  background: rgba(27, 30, 36, 0.96); border: 1px solid rgba(255, 255, 255, 0.18);
3100
3151
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
3152
+ animation: dg-panelIn 0.14s ease-out;
3101
3153
  }
3102
3154
  .dg-maskNotice-ok { border-color: rgba(94, 214, 150, 0.65); }
3103
3155
  .dg-maskNotice-failed { border-color: rgba(255, 107, 107, 0.85); color: #ffd7d7; }
3104
3156
 
3105
- /* 批注输入框:贴底居中,别挡住刚圈出来的框 */
3157
+ /* 批注输入框(左键拖框选完的状态确认框)。位置口径同裁剪/多边形:
3158
+ 钉在右下角、离边 20px、宽 300、松手后淡入。
3159
+ 原来贴底居中 —— 框要是圈在画面下半部,正好被它压住,等于边看边被挡。 */
3106
3160
  .dg-annotEditor {
3107
- position: absolute; left: 50%; bottom: 14px; top: auto; transform: translateX(-50%); z-index: 6;
3108
- width: min(340px, 80%); background: #1b1e24; color: #e8eaed;
3161
+ position: absolute; right: 20px; bottom: 20px; left: auto; top: auto; transform: none; z-index: 6;
3162
+ width: 300px; max-width: calc(100% - 40px); background: #1b1e24; color: #e8eaed;
3109
3163
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px; padding: 10px;
3110
3164
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
3165
+ animation: dg-panelIn 0.14s ease-out;
3111
3166
  }
3112
3167
  .dg-annotEditorHead { font-size: 12px; font-weight: 600; margin-bottom: 8px; }
3113
3168
  .dg-annotInput {
@@ -3116,6 +3171,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
3116
3171
  font-size: 12px; font-family: inherit;
3117
3172
  }
3118
3173
  .dg-annotInput:focus { outline: 2px solid #4a7cff; outline-offset: -1px; }
3174
+ /* 深色底上浏览器默认的 placeholder 灰几乎看不见,跟 .dg-input 用同一个色 */
3175
+ .dg-annotInput::placeholder { color: #9aa8b8; opacity: 1; }
3119
3176
  .dg-annotEditorOps { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; }
3120
3177
 
3121
3178
 
@@ -3138,13 +3195,24 @@ async function encodeMaskPngBytes(imageData, width, height) {
3138
3195
  .dg-annotEditorOps .dg-annotSave:hover:not(:disabled) { background: #6a92ff !important; }
3139
3196
  .dg-annotPendingHint { font-size: 11px; color: #ffd166; margin: -2px 0 8px; }
3140
3197
 
3141
- /* v0.14.6 右键多边形选区操作条:贴右下,避开左上批注列表与底部矩形输入框 */
3198
+ /* 右下角确认框统一淡入:与裁剪面板那条同参(0.14s / 上移 6px),
3199
+ 三个「选完才问你要不要确认」的框出现的手感必须一模一样。 */
3200
+ @keyframes dg-panelIn {
3201
+ from { opacity: 0; transform: translateY(6px); }
3202
+ to { opacity: 1; transform: none; }
3203
+ }
3204
+
3205
+ /* v0.14.6 多边形选区操作条(区域标记 / 填充遮罩共用)。
3206
+ 位置口径 2026-11-16 统一:和裁剪确认面板一样钉在**窗口右下角**、
3207
+ 离右边和下边各 20px、宽 300 —— 原来贴 8/14,跟另外两个框错位,眼睛要重新找。
3208
+ 拖动顶点时整块让开(组件里按 polyDrag 门控),松手再淡入。 */
3142
3209
  .dg-polyPanel {
3143
- position: absolute; right: 8px; bottom: 14px; z-index: 6;
3144
- width: min(320px, 76%); box-sizing: border-box;
3210
+ position: absolute; right: 20px; bottom: 20px; z-index: 6;
3211
+ width: 300px; max-width: calc(100% - 40px); box-sizing: border-box;
3145
3212
  background: #1b1e24; color: #e8eaed;
3146
3213
  border: 1px solid rgba(94, 214, 150, 0.55); border-radius: 8px; padding: 10px;
3147
3214
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
3215
+ animation: dg-panelIn 0.14s ease-out;
3148
3216
  }
3149
3217
  .dg-polyPanelHead { font-size: 12px; font-weight: 600; color: #9fe1cb; margin-bottom: 6px; }
3150
3218
  .dg-polyPanelInfo { font-size: 11px; line-height: 1.5; word-break: break-all; }
@@ -3159,6 +3227,16 @@ async function encodeMaskPngBytes(imageData, width, height) {
3159
3227
  border-color: #1d9e75 !important; font-weight: 600;
3160
3228
  }
3161
3229
  .dg-polyPanelOps .dg-polyClose:disabled { opacity: 0.45; }
3230
+ .dg-polyPanel[data-gallery-poly-mode='note'] { border-color: rgba(255, 209, 102, 0.65); }
3231
+ .dg-polyPanel[data-gallery-poly-mode='note'] .dg-polyPanelHead { color: #ffe08a; }
3232
+ .dg-polyPanelNote { margin-top: 8px; }
3233
+ .dg-polyNoteInput {
3234
+ width: 100%; box-sizing: border-box; background: #10141b; color: #e8eaed;
3235
+ border: 1px solid rgba(255,255,255,0.22); border-radius: 4px;
3236
+ padding: 5px 7px; font-size: 11px; outline: none;
3237
+ }
3238
+ .dg-polyNoteInput:focus { border-color: #5ed696; }
3239
+ .dg-polyNoteInput::placeholder { color: #9aa8b8; opacity: 1; }
3162
3240
 
3163
3241
  /* v0.16.0 粘贴结果提示 */
3164
3242
  .dg-pasteNotice {
@@ -3171,38 +3249,72 @@ async function encodeMaskPngBytes(imageData, width, height) {
3171
3249
  .dg-pasteOk { border-color: rgba(94,214,150,0.6); }
3172
3250
  .dg-pasteFail { border-color: rgba(255,107,107,0.6); color: #ffd2d2; }
3173
3251
 
3174
- /* v0.16.0 图片裁剪层 + 微信式圆形放大镜
3252
+ /* v1.0.2 图片裁剪层:绿框 + 八向手柄 + 像素级取色放大镜(照老板给的参考图对齐)
3175
3253
  坐标系说明:裁剪框/放大镜都用 getBoundingClientRect 的**视口坐标**定位,
3176
3254
  所以这一层必须 fixed 铺满视口,absolute 会相对 stage 偏移导致框错位。 */
3177
3255
  .dg-cropLayer { position: fixed; inset: 0; z-index: 60; cursor: crosshair; }
3256
+ /* 框外不再压暗:参考图里整张图亮度不变,靠绿线与手柄识别边界 */
3178
3257
  .dg-cropRect {
3179
- position: absolute; border: 1px solid #6a92ff;
3180
- box-shadow: 0 0 0 9999px rgba(0,0,0,0.5); box-sizing: border-box;
3181
- cursor: move; background: rgba(106,146,255,0.06);
3258
+ position: absolute; border: 1px solid #00e676;
3259
+ box-sizing: border-box; cursor: move; background: transparent;
3182
3260
  }
3183
3261
  .dg-cropHandle {
3184
- position: absolute; width: 13px; height: 13px; background: #6a92ff;
3185
- border: 2px solid #fff; border-radius: 2px; box-sizing: border-box;
3262
+ position: absolute; width: 9px; height: 9px; background: #00e676;
3263
+ border: 1px solid rgba(0,0,0,0.65); border-radius: 1px; box-sizing: border-box;
3264
+ z-index: 2;
3186
3265
  }
3187
- .dg-cropHandleNW { left: -7px; top: -7px; cursor: nwse-resize; }
3188
- .dg-cropHandleNE { right: -7px; top: -7px; cursor: nesw-resize; }
3189
- .dg-cropHandleSW { left: -7px; bottom: -7px; cursor: nesw-resize; }
3190
- .dg-cropHandleSE { right: -7px; bottom: -7px; cursor: nwse-resize; }
3266
+ .dg-cropHandleNW { left: -5px; top: -5px; cursor: nwse-resize; }
3267
+ .dg-cropHandleNE { right: -5px; top: -5px; cursor: nesw-resize; }
3268
+ .dg-cropHandleSW { left: -5px; bottom: -5px; cursor: nesw-resize; }
3269
+ .dg-cropHandleSE { right: -5px; bottom: -5px; cursor: nwse-resize; }
3270
+ /* 四边中点:只沿一个轴拖,免得「只想收一下高度」却把宽度也带歪 */
3271
+ .dg-cropHandleN { left: 50%; top: -5px; margin-left: -5px; cursor: ns-resize; }
3272
+ .dg-cropHandleS { left: 50%; bottom: -5px; margin-left: -5px; cursor: ns-resize; }
3273
+ .dg-cropHandleW { left: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
3274
+ .dg-cropHandleE { right: -5px; top: 50%; margin-top: -5px; cursor: ew-resize; }
3275
+ /* 尺寸标签:贴在框左上角外侧,白字带阴影,深底浅底都看得清 */
3276
+ .dg-cropSize {
3277
+ position: absolute; padding: 1px 4px; border-radius: 3px;
3278
+ font-size: 11px; line-height: 1.4; font-variant-numeric: tabular-nums;
3279
+ color: #fff; background: rgba(0,0,0,0.42); text-shadow: 0 1px 2px rgba(0,0,0,0.9);
3280
+ pointer-events: none; white-space: nowrap;
3281
+ }
3282
+ /* 像素放大镜(方形)+ 坐标色值卡:参考图里两者是一体的,所以外层包一个定位容器 */
3283
+ .dg-cropMagWrap { position: absolute; width: 148px; pointer-events: none; }
3191
3284
  .dg-cropMagnifier {
3192
- position: absolute; width: 130px; height: 130px; border-radius: 50%;
3193
- border: 2px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,0.6);
3194
- pointer-events: none; overflow: hidden; background: #000; transform: translate(-50%, -50%);
3195
- }
3196
- .dg-cropMagnifier canvas { display: block; width: 100%; height: 100%; }
3285
+ width: 148px; height: 148px; border-radius: 3px;
3286
+ border: 1px solid rgba(255,255,255,0.5); box-shadow: 0 4px 16px rgba(0,0,0,0.55);
3287
+ overflow: hidden; background: #000;
3288
+ }
3289
+ .dg-cropMagnifier canvas {
3290
+ display: block; width: 100%; height: 100%;
3291
+ image-rendering: pixelated; /* 不做硬边就成了糊图,取色就不准了 */
3292
+ }
3293
+ .dg-cropMagInfo {
3294
+ margin-top: 3px; box-sizing: border-box; width: 148px;
3295
+ background: rgba(255,255,255,0.94); color: #1a1c20;
3296
+ border-radius: 3px; padding: 4px 6px; font-size: 11px; line-height: 1.5;
3297
+ display: grid; grid-template-columns: auto 1fr; column-gap: 10px;
3298
+ font-variant-numeric: tabular-nums; box-shadow: 0 2px 10px rgba(0,0,0,0.4);
3299
+ }
3300
+ .dg-cropMagInfoKey { color: #6b7280; }
3301
+ .dg-cropMagInfoVal { color: #111318; font-weight: 600; text-align: right; }
3302
+ .dg-cropMagHint { grid-column: 1 / -1; color: #6b7280; margin-top: 2px; font-size: 10px; }
3303
+ .dg-cropMagHintOk { color: #0a7d52; font-weight: 600; }
3197
3304
  .dg-cropPanel {
3198
- /* 位置由组件按裁剪框实时算好、以内联 left/top 注入:贴在选区下方,
3199
- 靠窗口下沿时自动翻到选区上方。千万别写死 left/bottom ——
3200
- cropLayer 是 fixed inset:0,写死就会跑到视口左下角,离选区十万八千里。 */
3305
+ /* 位置由组件以内联 right/bottom 注入:**固定在窗口右下角**(老板 2026-11-16
3306
+ 要求「靠边固定,跟随鼠标会挡住预览」)。这里千万别再写死 left/bottom 数值 ——
3307
+ cropLayer 是 fixed inset:0,CSS 里的值会和内联的叠在一起把面板顶跑位。 */
3201
3308
  position: absolute; z-index: 6; width: 300px;
3309
+ animation: dg-cropPanelIn 0.14s ease-out; /* 松手后才挂载,正好有「弹出来」的手感 */
3202
3310
  box-sizing: border-box; background: #1b1e24; color: #e8eaed;
3203
3311
  border: 1px solid rgba(106,146,255,0.55); border-radius: 8px; padding: 10px;
3204
3312
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
3205
3313
  }
3314
+ @keyframes dg-cropPanelIn {
3315
+ from { opacity: 0; transform: translateY(6px); }
3316
+ to { opacity: 1; transform: none; }
3317
+ }
3206
3318
  .dg-cropPanelHead { font-size: 12px; font-weight: 600; color: #a9c4ff; margin-bottom: 6px; }
3207
3319
  .dg-cropPanelHint { font-size: 11px; color: #b9c2cf; line-height: 1.5; margin-top: 6px; }
3208
3320
  .dg-cropPanelOps { display: flex; justify-content: flex-end; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
@@ -3380,6 +3492,22 @@ async function encodeMaskPngBytes(imageData, width, height) {
3380
3492
  return text !== ''
3381
3493
  }
3382
3494
 
3495
+ /**
3496
+ * 从 MIME / dataURL 推真实扩展名(2026-11-15)。
3497
+ *
3498
+ * 以前统一写死 ext:'png',遇到 JPEG 位图会被 Host 的 PNG 校验拒掉。
3499
+ * 这里只做「上报」,Host 仍按真实魔数复核,写错也不会产生坏文件。
3500
+ */
3501
+ function imageExtOf(mime, dataUrl) {
3502
+ const fromUrl = /^data:([^;,]+)/i.exec(String(dataUrl ?? ''))
3503
+ const m = String(mime ?? '').toLowerCase() || (fromUrl === null ? '' : fromUrl[1].toLowerCase())
3504
+ if (m === 'image/jpeg' || m === 'image/jpg' || m === 'image/pjpeg') return 'jpg'
3505
+ if (m === 'image/webp') return 'webp'
3506
+ if (m === 'image/gif') return 'gif'
3507
+ if (m === 'image/bmp' || m === 'image/x-ms-bmp') return 'bmp'
3508
+ return 'png'
3509
+ }
3510
+
3383
3511
  /** 把 File/Blob 读成 dataURL(含 `data:…;base64,` 前缀)。 */
3384
3512
  function fileToDataUrl(file) {
3385
3513
  return new Promise((resolve, reject) => {
@@ -3600,6 +3728,14 @@ const dragAssetIndex = new Map()
3600
3728
  const dragMaskByOverlay = new Map()
3601
3729
  const dragMaskBySource = new Map()
3602
3730
 
3731
+ /**
3732
+ * 双击卡片:同一张图「正在处理中」的登记本(模块级,界面重绘也不丢)。
3733
+ * 只用来挡连点 —— 上一次双击的文字/附图还没走完又来一次,两次会同时读到
3734
+ * 「输入框里还没有草稿」,于是文字和缩略图各写两份。处理完立刻摘掉;
3735
+ * 万一某次异常没走到收尾,超过 5 秒自动失效,绝不把这张图永久挡死。
3736
+ */
3737
+ const doubleClickInFlight = new Map()
3738
+
3603
3739
  /**
3604
3740
  * 生成拖出 File 的名字(纯函数,测试跑真身)。
3605
3741
  * 全角「|」分隔,控制字符清掉,长度夹在 240 以内,避免 DSH 卡片显示被截到看不懂。
@@ -3928,9 +4064,16 @@ function serializeFeedback(feedback) {
3928
4064
  await waitFlush()
3929
4065
  const before = stateText(ed)
3930
4066
 
3931
- // 用草稿头(前 24 字)判断,而不是全串匹配 ——
3932
- // 全串匹配在「草稿后面跟了用户自己打的字」时会失效(state 里包含但不再是完整 text)。
3933
- const headProbe = text.trim().slice(0, Math.min(24, text.trim().length))
4067
+ // 双击卡片生成的草稿是「产出台·文件名 | 路径=…」,用整段首段(最长 120 字)判断;
4068
+ // 固定前 24 字会把同一组图(原图 / 主遮罩 / 蓝填充预览)误判成同一份草稿:
4069
+ // 它们的文件名共享很长的前缀,前 24 字完全相同,双击第二张会连文字都不写。
4070
+ // 其它草稿(反馈篮那一大段)不带这个开头,仍用原来的 24 字探针,行为一点不变。
4071
+ // 也不用全串匹配:草稿后面跟了用户自己打的字时会失效。
4072
+ const trimmed = text.trim()
4073
+ const firstSegment = trimmed.split(/[||]/)[0].trim()
4074
+ const headProbe = (firstSegment.startsWith('产出台·') && firstSegment.length >= 8)
4075
+ ? firstSegment.slice(0, 120)
4076
+ : trimmed.slice(0, Math.min(24, trimmed.length))
3934
4077
  if (before.ok && headProbe !== '' && before.text.includes(headProbe)) {
3935
4078
  draftRef.current = text
3936
4079
  return { ok: true, via: 'composer', detail: 'already-present' }
@@ -3951,8 +4094,8 @@ function serializeFeedback(feedback) {
3951
4094
  return { ok: grew && contains, size: after.size }
3952
4095
  }
3953
4096
 
3954
- // 用于确认"确实插入了本次文本"的探针片段(取前 24 字,足够区分)
3955
- const probe = text.trim().slice(0, Math.min(24, text.trim().length))
4097
+ // 用于确认「确实插入了本次文本」的探针片段(复用上面的首段,能区分同组图片)
4098
+ const probe = headProbe
3956
4099
 
3957
4100
  // ---- 路径 1:**只发 beforeinput**(不跟 input)----
3958
4101
  // ⚠️ 真机实证:beforeinput 与 input 在同一同步块连发时,Lexical 在 flush 前
@@ -4080,7 +4223,11 @@ function serializeFeedback(feedback) {
4080
4223
  // 卡已被判「不要这张」时,批注也沿用打回;否则是「只改这个框」
4081
4224
  action: mark?.action === 'reject' ? 'reject' : 'redo-one-dim',
4082
4225
  reason: note === '' ? undefined : note,
4083
- region: { x: a.x, y: a.y, w: a.w, h: a.h },
4226
+ region: {
4227
+ x: a.x, y: a.y, w: a.w, h: a.h,
4228
+ // 不规则区域顶点随 region 一起走;草稿仍按外接框说人话
4229
+ ...(Array.isArray(a.polygon) ? { polygon: a.polygon } : {}),
4230
+ },
4084
4231
  frameOf: it.frameOf,
4085
4232
  // 遮罩来源随草稿带出(v0.14.5):由本图框选区域生成的 RGBA 遮罩资产
4086
4233
  maskOf: it.maskOf,
@@ -4219,7 +4366,7 @@ function serializeFeedback(feedback) {
4219
4366
  }, [
4220
4367
  h('div', { className: 'dg-feedbackHead', key: 'head' }, [
4221
4368
  h('span', { className: 'dg-feedbackTitle', key: 'title' },
4222
- format(t('feedbackBasketTitleN'), { n: rows.length }),
4369
+ t('feedbackBasketTitle'),
4223
4370
  ),
4224
4371
  h('button', {
4225
4372
  type: 'button', className: 'dg-btn', key: 'close',
@@ -4283,6 +4430,12 @@ function serializeFeedback(feedback) {
4283
4430
  : null,
4284
4431
  h('span', { className: 'dg-feedbackDim dg-feedbackRegion', key: 'r' },
4285
4432
  format(t('feedbackAnnotRegion'), { x: pct(a.x), y: pct(a.y), w: pct(a.w), h: pct(a.h) })),
4433
+ Array.isArray(a.polygon) && a.polygon.length >= 4
4434
+ ? h('span', {
4435
+ className: 'dg-feedbackDim', key: 'poly',
4436
+ 'data-gallery-feedback-poly': a.polygon.length,
4437
+ }, format(t('feedbackAnnotPolygonTag'), { n: String(a.polygon.length) }))
4438
+ : null,
4286
4439
  h('span', { className: 'dg-feedbackNote', key: 'note' },
4287
4440
  (typeof a.note === 'string' && a.note.trim() !== '') ? a.note : t('feedbackAnnotNoNote')),
4288
4441
  h('span', { className: 'dg-feedbackOps', key: 'ops' }, [
@@ -5388,7 +5541,7 @@ function serializeFeedback(feedback) {
5388
5541
  },
5389
5542
  })
5390
5543
  )),
5391
- trimUI,
5544
+ trimUI,
5392
5545
  h('div', { className: 'dg-mediaFoot', key: 'foot' }, [
5393
5546
  h('span', { className: 'dg-mediaFootName', key: 'name', title: item.relPath }, item.name),
5394
5547
  h('span', { className: 'dg-mediaFootMeta', key: 'meta' },
@@ -5678,13 +5831,28 @@ ${absPath}
5678
5831
  * · 裁剪结果(归一化矩形)交给上层 callHost('cropImage'),落盘到源图同目录并标素材。
5679
5832
  * · 零自动发送红线不变:本组件只产出 PNG,落盘与登记由 Host 完成。
5680
5833
  */
5834
+ /** 裁剪放大镜:148px 见方、每格 4px,因此覆盖原图 37×37 像素。
5835
+ * 为什么是这几个数(老板 11-16:10 倍太夸张、像素块太粗不好用,改回 4 倍):
5836
+ * ① 格宽 4px 既能看出「一格 = 一个像素」,又不至于几格就占满一片;
5837
+ * ② 4 倍下要看 37 格才填满,37 是奇数 → 光标那格正好落在正中,绿十字压得准;
5838
+ * ③ 37 × 4 = 148,size 必须是 factor 的整数倍,否则光标格会偏半格、十字压到缝上。
5839
+ * 三个数互相咬死:改倍率就得同时重算 size(tests/crop-frame-ui.test.mjs 有断言钉住)。 */
5840
+ const CROP_MAG_SIZE = 148
5841
+ const CROP_MAG_FACTOR = 4
5842
+
5681
5843
  function ImageCropper({ t, item, imgRef, onCrop, onCancel }) {
5682
5844
  const [rect, setRect] = React.useState(null) // {x,y,w,h} 归一化 0–1(相对图片宽高)
5683
- const [drag, setDrag] = React.useState(null) // { mode:'new'|'move'|'nw'|'ne'|'sw'|'se', sx, sy, startRect }
5845
+ // mode:new 新建 / move 整体挪 / 四角 nw ne sw se / 四边 n s w e(只动单侧)
5846
+ const [drag, setDrag] = React.useState(null) // { mode, sx, sy, startRect }
5684
5847
  const [mag, setMag] = React.useState(null) // { cx, cy(视口), nx, ny(归一化) }
5685
5848
  const [full, setFull] = React.useState(null) // 全分辨率 HTMLImageElement
5686
5849
  const [busy, setBusy] = React.useState(false)
5850
+ const [copied, setCopied] = React.useState('') // 复制回执,1.4 秒后自动消失
5687
5851
  const magCanvasRef = React.useRef(null)
5852
+ // 取色用的 1×1 离屏画布:只读一个像素,比重建整块画布便宜得多
5853
+ const probeCanvasRef = React.useRef(null)
5854
+ // 光标处色值放 ref:快捷键 effect 不必因颜色变化反复重挂
5855
+ const colorRef = React.useRef('')
5688
5856
 
5689
5857
  // 载入全分辨率源图(放大镜取真实像素 + 最终裁图)
5690
5858
  React.useEffect(() => {
@@ -5744,6 +5912,11 @@ ${absPath}
5744
5912
  else if (d.mode === 'ne') { y = n.y; w = n.x - s.x; h = (s.y + s.h) - n.y }
5745
5913
  else if (d.mode === 'sw') { x = n.x; w = (s.x + s.w) - n.x; h = n.y - s.y }
5746
5914
  else if (d.mode === 'nw') { x = n.x; y = n.y; w = (s.x + s.w) - n.x; h = (s.y + s.h) - n.y }
5915
+ // 四边中点:另一个轴原样不动,这才能「只收高度、不把宽度带歪」
5916
+ else if (d.mode === 'n') { y = n.y; h = (s.y + s.h) - n.y }
5917
+ else if (d.mode === 's') { h = n.y - s.y }
5918
+ else if (d.mode === 'w') { x = n.x; w = (s.x + s.w) - n.x }
5919
+ else if (d.mode === 'e') { w = n.x - s.x }
5747
5920
  if (w < 0) { x += w; w = -w }
5748
5921
  if (h < 0) { y += h; h = -h }
5749
5922
  x = clamp01(x); y = clamp01(y); w = clamp01(w); h = clamp01(h)
@@ -5775,30 +5948,75 @@ ${absPath}
5775
5948
  }
5776
5949
  const onLayerUp = () => setDrag(null)
5777
5950
 
5778
- // 放大镜绘制:从全分辨率源图取光标处的 3× 局部放大;越界区域填黑(与相机放大镜一致)。
5951
+ /**
5952
+ * 放大镜绘制:按整数像素格放大(4×),并关掉插值。
5953
+ * 不关插值就成了糊图、取色看着「不准」;4 倍下每格 4px,看得出格子又不像 10 倍那么粗。
5954
+ * 十字线用绿色高亮(白的在浅色招牌上根本看不见)。
5955
+ */
5779
5956
  React.useEffect(() => {
5780
5957
  const canvas = magCanvasRef.current
5781
5958
  if (canvas === null || full === null || mag === null) return
5782
5959
  const ctx = canvas.getContext('2d')
5783
5960
  if (ctx === null) return
5784
5961
  const SIZE = canvas.width
5785
- const FACTOR = 3
5962
+ const FACTOR = CROP_MAG_FACTOR
5963
+ const SPAN = SIZE / FACTOR // 源图取样边长(像素)
5786
5964
  const FW = full.naturalWidth
5787
5965
  const FH = full.naturalHeight
5788
- const halfSrc = (SIZE / FACTOR) / 2
5789
- const sx = clampNum(mag.nx * FW - halfSrc, 0, Math.max(0, FW - SIZE / FACTOR))
5790
- const sy = clampNum(mag.ny * FH - halfSrc, 0, Math.max(0, FH - SIZE / FACTOR))
5966
+ // 让光标所在像素成为正中间那格:左右各取 floor(SPAN/2) 格
5967
+ const half = Math.floor(SPAN / 2)
5968
+ const px = clampNum(Math.round(mag.nx * FW), 0, Math.max(0, FW - 1))
5969
+ const py = clampNum(Math.round(mag.ny * FH), 0, Math.max(0, FH - 1))
5970
+ const sx = clampNum(px - half, 0, Math.max(0, FW - SPAN))
5971
+ const sy = clampNum(py - half, 0, Math.max(0, FH - SPAN))
5972
+ ctx.imageSmoothingEnabled = false
5791
5973
  ctx.fillStyle = '#000'
5792
5974
  ctx.fillRect(0, 0, SIZE, SIZE)
5793
- ctx.drawImage(full, sx, sy, SIZE / FACTOR, SIZE / FACTOR, 0, 0, SIZE, SIZE)
5794
- ctx.strokeStyle = 'rgba(255,255,255,0.85)'
5795
- ctx.lineWidth = 1
5975
+ ctx.drawImage(full, sx, sy, SPAN, SPAN, 0, 0, SIZE, SIZE)
5976
+ // 绿十字:压在正中那一格的中线上,线宽 2 才够醒目
5977
+ const mid = SIZE / 2
5978
+ ctx.strokeStyle = 'rgba(0,230,118,0.95)'
5979
+ ctx.lineWidth = 2
5796
5980
  ctx.beginPath()
5797
- ctx.moveTo(SIZE / 2, 0); ctx.lineTo(SIZE / 2, SIZE)
5798
- ctx.moveTo(0, SIZE / 2); ctx.lineTo(SIZE, SIZE / 2)
5981
+ ctx.moveTo(mid, 0); ctx.lineTo(mid, SIZE)
5982
+ ctx.moveTo(0, mid); ctx.lineTo(SIZE, mid)
5799
5983
  ctx.stroke()
5800
5984
  }, [mag, full])
5801
5985
 
5986
+ /**
5987
+ * 裁剪态按键:Ctrl+C 复制光标处色值;左右键不翻页。
5988
+ * 翻页会把框套到另一张图上(框还在、图换了),所以必须拦住。
5989
+ * 走捕获阶段 + stopImmediatePropagation:查看器自己的 Ctrl+C 是「复制文件」,
5990
+ * 不先截住就会把文件写进剪贴板,而不是色值。
5991
+ */
5992
+ React.useEffect(() => {
5993
+ const onKey = (event) => {
5994
+ if (isTypingTarget(event.target)) return
5995
+ const key = String(event.key ?? '')
5996
+ if ((event.ctrlKey || event.metaKey) && (key === 'c' || key === 'C')) {
5997
+ const hex = colorRef.current
5998
+ if (hex === '') return
5999
+ event.preventDefault()
6000
+ event.stopImmediatePropagation()
6001
+ copyText(hex)
6002
+ setCopied(hex)
6003
+ return
6004
+ }
6005
+ if (key === 'ArrowLeft' || key === 'ArrowRight') {
6006
+ event.stopImmediatePropagation()
6007
+ }
6008
+ }
6009
+ window.addEventListener('keydown', onKey, true)
6010
+ return () => window.removeEventListener('keydown', onKey, true)
6011
+ }, [])
6012
+
6013
+ // 复制回执:1.4 秒后自动收起,避免一直挂在那里
6014
+ React.useEffect(() => {
6015
+ if (copied === '') return undefined
6016
+ const timer = setTimeout(() => setCopied(''), 1400)
6017
+ return () => clearTimeout(timer)
6018
+ }, [copied])
6019
+
5802
6020
  const confirmCrop = () => {
5803
6021
  if (full === null || rect === null || rect.w < 0.02 || rect.h < 0.02) return
5804
6022
  setBusy(true)
@@ -5843,44 +6061,108 @@ ${absPath}
5843
6061
  height: `${rect.h * r.height}px`,
5844
6062
  }
5845
6063
  : {}
5846
- const magX = mag !== null ? clampNum(mag.cx + 72, 72, (typeof window !== 'undefined' ? window.innerWidth : 9999) - 72) : 0
5847
- const magY = mag !== null ? clampNum(mag.cy - 72, 72, (typeof window !== 'undefined' ? window.innerHeight : 9999) - 72) : 0
6064
+ const vw = Number(typeof window !== 'undefined' ? window.innerWidth : 0) || 1280
6065
+ const vh = Number(typeof window !== 'undefined' ? window.innerHeight : 0) || 800
6066
+
6067
+ // 尺寸标签写的是「裁下来多少像素」,所以按原图自然尺寸 × 归一化比例算,不是屏幕像素
6068
+ const cropSize = (rect !== null && full !== null)
6069
+ ? {
6070
+ w: Math.max(1, Math.round(rect.w * full.naturalWidth)),
6071
+ h: Math.max(1, Math.round(rect.h * full.naturalHeight)),
6072
+ }
6073
+ : null
6074
+
6075
+ /** 光标处的原图像素坐标 + 色值。1×1 离屏画布取一个像素;
6076
+ * 图是 blob: 同源地址,不会污染画布,getImageData 可读。 */
6077
+ const probe = React.useMemo(() => {
6078
+ if (full === null || mag === null) return null
6079
+ const FW = full.naturalWidth
6080
+ const FH = full.naturalHeight
6081
+ if (FW <= 0 || FH <= 0) return null
6082
+ const px = clampNum(Math.round(mag.nx * FW), 0, FW - 1)
6083
+ const py = clampNum(Math.round(mag.ny * FH), 0, FH - 1)
6084
+ let hex = ''
6085
+ try {
6086
+ let canvas = probeCanvasRef.current
6087
+ if (canvas === null) {
6088
+ canvas = document.createElement('canvas')
6089
+ canvas.width = 1
6090
+ canvas.height = 1
6091
+ probeCanvasRef.current = canvas
6092
+ }
6093
+ const c2d = canvas.getContext('2d')
6094
+ if (c2d !== null) {
6095
+ c2d.clearRect(0, 0, 1, 1)
6096
+ c2d.drawImage(full, px, py, 1, 1, 0, 0, 1, 1)
6097
+ const d = c2d.getImageData(0, 0, 1, 1).data
6098
+ hex = '#' + [d[0], d[1], d[2]].map((v) => v.toString(16).padStart(2, '0')).join('').toUpperCase()
6099
+ }
6100
+ } catch { hex = '' }
6101
+ return { px, py, hex }
6102
+ }, [mag, full])
6103
+ colorRef.current = probe !== null ? probe.hex : ''
6104
+
6105
+ // 尺寸标签贴框左上角外侧;顶上没空间就挪进框内,别让它被视口裁掉
6106
+ const sizeStyle = (() => {
6107
+ if (rect === null || r === null) return {}
6108
+ const boxLeft = r.left + rect.x * r.width
6109
+ const boxTop = r.top + rect.y * r.height
6110
+ const above = boxTop - 20
6111
+ return {
6112
+ left: `${clampNum(boxLeft, 4, Math.max(4, vw - 96))}px`,
6113
+ top: `${above >= 4 ? above : boxTop + 3}px`,
6114
+ }
6115
+ })()
5848
6116
 
5849
6117
  /**
5850
- * 操作面板跟着选区走(微信截图式):水平居中于裁剪框、贴在框下方 12px;
5851
- * 若框贴着窗口下沿,翻到框上方。还没画框时贴在图片下沿中央。
5852
- * 全部用视口坐标 —— cropLayer 是 fixed inset:0,absolute 子元素即相对视口。
6118
+ * 操作面板**固定在窗口右下角**,不再跟着选区跑(老板 2026-11-16:
6119
+ * 「裁剪的这个状态确认框让靠边固定吧,跟随鼠标会挡住预览」)。
6120
+ * 原来按选区水平居中、贴框下方(微信截图式),实测选区在中间或偏下时
6121
+ * 正好压住要靠细节的那块,拖框时它还跟着晃、眼睛要一直追。
6122
+ * 现在钉在角落:位置可预期、永远不挡正在调的那块。
6123
+ * 用 right/bottom 而不是算好的 left/top —— 面板高度随提示文字换行变化,
6124
+ * 写死 top 一旦文字变长就会顶出窗口下沿。cropLayer 是 fixed inset:0,
6125
+ * absolute 子元素自然相对视口。
5853
6126
  */
5854
6127
  const PANEL_W = 300
5855
- const PANEL_H = 118
5856
- const panelStyle = (() => {
5857
- const vw = Number(typeof window !== 'undefined' ? window.innerWidth : 0) || 1280
5858
- const vh = Number(typeof window !== 'undefined' ? window.innerHeight : 0) || 800
5859
- const maxLeft = Math.max(8, vw - PANEL_W - 8)
5860
- const maxTop = Math.max(8, vh - PANEL_H - 8)
5861
- const hasBox = rect !== null && r !== null && rect.w > 0.02 && rect.h > 0.02
5862
- let cx
5863
- let boxTop
5864
- let boxBottom
5865
- if (hasBox) {
5866
- boxTop = r.top + rect.y * r.height
5867
- const boxLeft = r.left + rect.x * r.width
5868
- cx = boxLeft + (rect.w * r.width) / 2
5869
- boxBottom = boxTop + rect.h * r.height
5870
- } else if (r !== null) {
5871
- cx = r.left + r.width / 2
5872
- boxTop = r.top
5873
- boxBottom = r.bottom - PANEL_H - 16
5874
- } else {
5875
- cx = vw / 2
5876
- boxTop = 0
5877
- boxBottom = vh - PANEL_H - 20
5878
- }
5879
- const left = clampNum(cx - PANEL_W / 2, 8, maxLeft)
5880
- let top = hasBox ? boxBottom + 12 : boxBottom
5881
- if (hasBox && top + PANEL_H > vh - 8) top = boxTop - PANEL_H - 12
5882
- return { left: `${left}px`, top: `${clampNum(top, 8, maxTop)}px` }
6128
+ const PANEL_H = 118 // 估算值,只用于「别让放大镜压上去」
6129
+ const PANEL_MARGIN = 20
6130
+ const panelStyle = { right: `${PANEL_MARGIN}px`, bottom: `${PANEL_MARGIN}px` }
6131
+ // 拖动过程中先不显示面板(老板 2026-11-16:「或者选完后在弹出状态确认」)。
6132
+ // 拖的时候画面完全干净;松手才出现,位置永远在右下角,不跟鼠标跑。
6133
+ const showPanel = drag === null
6134
+ const canConfirm = rect !== null && rect.w >= 0.02 && rect.h >= 0.02
6135
+ // 面板实际矩形(估算,够判断重叠):右下角、宽 300、高约 118
6136
+ const panelLeft = Math.max(8, vw - PANEL_W - PANEL_MARGIN)
6137
+ const panelTop = Math.max(8, vh - PANEL_H - PANEL_MARGIN)
6138
+
6139
+ // 放大镜默认贴光标右下方(参考图即如此);放不下、或会压住面板,就换另一侧
6140
+ const MAG_W = CROP_MAG_SIZE
6141
+ const MAG_H = CROP_MAG_SIZE + 76 // 放大镜 + 间距 + 坐标色值卡
6142
+ const hitsPanel = (left, top) => left < panelLeft + PANEL_W && left + MAG_W > panelLeft
6143
+ && top < panelTop + PANEL_H && top + MAG_H > panelTop
6144
+ const magPos = (() => {
6145
+ if (mag === null) return { left: 0, top: 0 }
6146
+ const gap = 18
6147
+ // 四个候选按「右下 → 左下 → 右上 → 左上」的偏好序试,跟人眼找位置的顺序一致
6148
+ const spots = [
6149
+ { left: mag.cx + gap, top: mag.cy + gap },
6150
+ { left: mag.cx - gap - MAG_W, top: mag.cy + gap },
6151
+ { left: mag.cx + gap, top: mag.cy - gap - MAG_H },
6152
+ { left: mag.cx - gap - MAG_W, top: mag.cy - gap - MAG_H },
6153
+ ]
6154
+ const inView = (s) => s.left >= 8 && s.left + MAG_W <= vw - 8
6155
+ && s.top >= 8 && s.top + MAG_H <= vh - 8
6156
+ const picked = spots.find((s) => inView(s) && !hitsPanel(s.left, s.top))
6157
+ ?? spots.find((s) => !hitsPanel(s.left, s.top))
6158
+ ?? spots[0]
6159
+ return {
6160
+ left: clampNum(picked.left, 8, Math.max(8, vw - MAG_W - 8)),
6161
+ top: clampNum(picked.top, 8, Math.max(8, vh - MAG_H - 8)),
6162
+ }
5883
6163
  })()
6164
+ const magLeft = magPos.left
6165
+ const magTop = magPos.top
5884
6166
 
5885
6167
  return h('div', {
5886
6168
  className: 'dg-cropLayer',
@@ -5900,20 +6182,50 @@ ${absPath}
5900
6182
  style: rectStyle,
5901
6183
  onPointerDown: (e) => startDrag(e, 'move'),
5902
6184
  }, [
5903
- h('div', { className: 'dg-cropHandle dg-cropHandleNW', key: 'nw', onPointerDown: (e) => startDrag(e, 'nw') }),
5904
- h('div', { className: 'dg-cropHandle dg-cropHandleNE', key: 'ne', onPointerDown: (e) => startDrag(e, 'ne') }),
5905
- h('div', { className: 'dg-cropHandle dg-cropHandleSW', key: 'sw', onPointerDown: (e) => startDrag(e, 'sw') }),
5906
- h('div', { className: 'dg-cropHandle dg-cropHandleSE', key: 'se', onPointerDown: (e) => startDrag(e, 'se') }),
6185
+ // 四角:斜着调
6186
+ h('div', { className: 'dg-cropHandle dg-cropHandleNW', key: 'nw', 'data-gallery-crop-handle': 'nw', onPointerDown: (e) => startDrag(e, 'nw') }),
6187
+ h('div', { className: 'dg-cropHandle dg-cropHandleNE', key: 'ne', 'data-gallery-crop-handle': 'ne', onPointerDown: (e) => startDrag(e, 'ne') }),
6188
+ h('div', { className: 'dg-cropHandle dg-cropHandleSW', key: 'sw', 'data-gallery-crop-handle': 'sw', onPointerDown: (e) => startDrag(e, 'sw') }),
6189
+ h('div', { className: 'dg-cropHandle dg-cropHandleSE', key: 'se', 'data-gallery-crop-handle': 'se', onPointerDown: (e) => startDrag(e, 'se') }),
6190
+ // 四边中点:单边调(参考图上共八个手柄)
6191
+ h('div', { className: 'dg-cropHandle dg-cropHandleN', key: 'n', 'data-gallery-crop-handle': 'n', onPointerDown: (e) => startDrag(e, 'n') }),
6192
+ h('div', { className: 'dg-cropHandle dg-cropHandleS', key: 's', 'data-gallery-crop-handle': 's', onPointerDown: (e) => startDrag(e, 's') }),
6193
+ h('div', { className: 'dg-cropHandle dg-cropHandleW', key: 'w', 'data-gallery-crop-handle': 'w', onPointerDown: (e) => startDrag(e, 'w') }),
6194
+ h('div', { className: 'dg-cropHandle dg-cropHandleE', key: 'e', 'data-gallery-crop-handle': 'e', onPointerDown: (e) => startDrag(e, 'e') }),
5907
6195
  ])
5908
6196
  : null,
5909
- mag !== null && full !== null
6197
+ // 左上角尺寸标签:显示裁下来是多少像素
6198
+ rect !== null && cropSize !== null
5910
6199
  ? h('div', {
5911
- className: 'dg-cropMagnifier',
6200
+ className: 'dg-cropSize',
6201
+ key: 'size',
6202
+ 'data-gallery-crop-size': true,
6203
+ style: sizeStyle,
6204
+ }, `${cropSize.w} × ${cropSize.h}`)
6205
+ : null,
6206
+ mag !== null && full !== null && probe !== null
6207
+ ? h('div', {
6208
+ className: 'dg-cropMagWrap',
5912
6209
  key: 'mag',
5913
- style: { left: `${magX}px`, top: `${magY}px` },
5914
- }, h('canvas', { ref: magCanvasRef, width: 130, height: 130, key: 'magCanvas' }))
6210
+ 'data-gallery-crop-mag': true,
6211
+ style: { left: `${magLeft}px`, top: `${magTop}px` },
6212
+ }, [
6213
+ h('div', { className: 'dg-cropMagnifier', key: 'canvas' },
6214
+ h('canvas', { ref: magCanvasRef, width: CROP_MAG_SIZE, height: CROP_MAG_SIZE, key: 'magCanvas' })),
6215
+ h('div', { className: 'dg-cropMagInfo', key: 'info' }, [
6216
+ h('span', { className: 'dg-cropMagInfoKey', key: 'kx' }, t('cropCoord')),
6217
+ h('span', { className: 'dg-cropMagInfoVal', key: 'vx', 'data-gallery-crop-coord': true }, `${probe.px}, ${probe.py}`),
6218
+ h('span', { className: 'dg-cropMagInfoKey', key: 'kc' }, t('cropColor')),
6219
+ h('span', { className: 'dg-cropMagInfoVal', key: 'vc', 'data-gallery-crop-color': true }, probe.hex === '' ? '—' : probe.hex),
6220
+ h('span', {
6221
+ className: copied === '' ? 'dg-cropMagHint' : 'dg-cropMagHint dg-cropMagHintOk',
6222
+ key: 'hint',
6223
+ 'data-gallery-crop-copyhint': true,
6224
+ }, copied === '' ? t('cropCopyColor') : format(t('cropCopied'), { hex: copied })),
6225
+ ]),
6226
+ ])
5915
6227
  : null,
5916
- h('div', {
6228
+ showPanel ? h('div', {
5917
6229
  className: 'dg-cropPanel',
5918
6230
  key: 'panel',
5919
6231
  'data-gallery-crop-panel': true,
@@ -5930,12 +6242,13 @@ ${absPath}
5930
6242
  onClick: (e) => { e.stopPropagation(); onCancel() },
5931
6243
  }, t('cropCancel')),
5932
6244
  h('button', {
5933
- type: 'button', className: 'dg-btn dg-btnPrimary', key: 'ok', disabled: busy,
6245
+ type: 'button', className: 'dg-btn dg-btnPrimary', key: 'ok',
6246
+ disabled: busy || !canConfirm, // 还没拖出框就点不动,避免点了没反应像坏了
5934
6247
  'data-gallery-crop-confirm': true,
5935
6248
  onClick: (e) => { e.stopPropagation(); confirmCrop() },
5936
6249
  }, busy ? t('cropSaving') : t('cropConfirm')),
5937
6250
  ]),
5938
- ]),
6251
+ ]) : null,
5939
6252
  ])
5940
6253
  }
5941
6254
 
@@ -6659,7 +6972,9 @@ ${absPath}
6659
6972
  * 设计要点:
6660
6973
  * · 坐标全部归一化(0–1,相对图片宽高),见 shared/protocol.js 的 ANNOTATION_* 契约
6661
6974
  * · SVG 覆盖在图片之上;不干扰查看器原有的缩放/平移(只有「批注模式」下才接管指针)
6662
- * · 拖拽画矩形 → 亮框**一直留着**直到保存/取消 → 输入框写说明 → 存进批注列表
6975
+ * · 左键按住拖拽画矩形 → 亮框**一直留着**直到保存/取消 → 输入框写说明 → 存进批注列表
6976
+ * · 左键单击逐点圈不规则区域 → 闭合后直接进反馈篮(不生成遮罩文件),可顺手写一句说明
6977
+ * · 右键单击逐点圈选区 → 闭合成实心多边形 → 导出遮罩 + 彩色填充预览
6663
6978
  * · 已存在的批注按归一化坐标还原绘制,带编号,缩放/换屏都不失真
6664
6979
  * · 批注不发送任何东西;出口是与决策草稿同一通道(见 05-feedback.js)
6665
6980
  *
@@ -6671,7 +6986,8 @@ ${absPath}
6671
6986
  *
6672
6987
  * v0.14.2 修:
6673
6988
  * ⑤ 弹窗开着时第二处按不下:改为一按下就先把当前草稿存档,可连续圈多处
6674
- * ⑥ 只认「按住拖拽」:补「点两下」定义矩形(点起点 → 点终点),两种习惯都能用
6989
+ * ⑥ 「点两下成矩形」已于 2026-11-15 作废:左键单击改为「逐点闭合区域标记」。
6990
+ * 现在左键只有按住拖动才画矩形;单击是给不规则区域加一个顶点。
6675
6991
  *
6676
6992
  * v0.14.4 本地热修:
6677
6993
  * ⑦ SVG 原先覆盖整个预览容器且不带 transform,图片却是 contain 居中后单独
@@ -6684,14 +7000,17 @@ ${absPath}
6684
7000
  function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, frameMs, zoom, pan, imgBox, transformTransition, onExportMask }) {
6685
7001
  const [draft, setDraft] = React.useState(null)
6686
7002
  const [editing, setEditing] = React.useState(null)
6687
- /** 已点下第一下、等第二下定终点时的起点(归一化坐标)。 */
6688
- const [pendingStart, setPendingStart] = React.useState(null)
6689
7003
  const svgRef = React.useRef(null)
7004
+ /** 左键按下时记起点与「有没有真拖动」:拖动=矩形,没拖动=一个区域顶点。 */
7005
+ const dragStartRef = React.useRef(null)
6690
7006
  /** 遮罩导出提示(成功/失败),2.5 秒自动消失。 */
6691
7007
  const [maskNotice, setMaskNotice] = React.useState(null)
6692
7008
  const [maskBusy, setMaskBusy] = React.useState(false)
6693
- /** 右键多边形选区:归一化顶点 / 橡皮筋终点 / 正在拖动的顶点下标。 */
7009
+ /** 多边形选区:mask(右键→填充遮罩) / note(左键单击→区域标记进反馈篮),互斥共用一组顶点。 */
6694
7010
  const [poly, setPoly] = React.useState([])
7011
+ const [polyMode, setPolyMode] = React.useState('mask')
7012
+ /** 不规则区域可以顺手写一句说明(可留空),只随反馈走,不生成任何文件。 */
7013
+ const [polyNote, setPolyNote] = React.useState('')
6695
7014
  const [polyHover, setPolyHover] = React.useState(null)
6696
7015
  const [polyDrag, setPolyDrag] = React.useState(null)
6697
7016
  /** v0.14.7 选区填充色(红 / 绿 / 蓝),同时决定导出的彩色预览图颜色。 */
@@ -6721,12 +7040,22 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6721
7040
  .finally(() => setMaskBusy(false))
6722
7041
  }
6723
7042
 
7043
+ /** 清掉没闭合的多边形草稿,模式复位到右键(填充遮罩)。 */
7044
+ const resetPoly = () => {
7045
+ setPoly([])
7046
+ setPolyHover(null)
7047
+ setPolyDrag(null)
7048
+ setPolyNote('')
7049
+ setPolyMode('mask')
7050
+ }
7051
+
6724
7052
  /**
6725
- * 闭合多边形 → 立刻生成遮罩资产。老板要的是「右键点完就形成区域遮罩」,
6726
- * 所以闭合即导出,不再多一层确认;顶点/面积在闭合前一直可见可撤销。
6727
- * 零自动发送红线不变:这里只落盘遮罩资产,草稿仍要人工发送。
7053
+ * 闭合多边形 → 分两条路,绝不混:
7054
+ * · mask(右键):立刻生成遮罩资产 + 彩色填充预览(老行为,零自动发送)
7055
+ * · note(左键单击):只加一条「不规则区域」批注,直接进反馈篮,不落盘任何图片
7056
+ * 老板 2026-11-15 拍板:左键圈出来的区域是「给人 / 给助手看的标记」,不是遮罩文件。
6728
7057
  */
6729
- const commitPolygon = (points) => {
7058
+ const commitPolygon = (points, mode = polyMode) => {
6730
7059
  if (points.length < POLYGON_LIMITS.min) {
6731
7060
  setMaskNotice({ kind: 'failed', text: t('polyTooFew') })
6732
7061
  return
@@ -6736,13 +7065,21 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6736
7065
  return
6737
7066
  }
6738
7067
  const box = polygonBBox(points)
6739
- setPoly([])
6740
- setPolyHover(null)
6741
- setPolyDrag(null)
7068
+ const verts = points.map((p) => [clamp01(p.x), clamp01(p.y)])
7069
+ resetPoly()
7070
+ if (mode === 'note') {
7071
+ const normalized = normalizeAnnotation({
7072
+ shape: 'polygon', ...box, polygon: verts,
7073
+ fillColor, note: polyNote, frameMs: frameMs ?? null,
7074
+ })
7075
+ if (normalized !== null && typeof onAdd === 'function') onAdd(normalized)
7076
+ setMaskNotice({ kind: 'ok', text: t('polyNoteSaved') })
7077
+ return
7078
+ }
6742
7079
  runExportMask({
6743
7080
  shape: 'polygon',
6744
7081
  ...box,
6745
- polygon: points.map((p) => [clamp01(p.x), clamp01(p.y)]),
7082
+ polygon: verts,
6746
7083
  fillColor,
6747
7084
  note: '',
6748
7085
  })
@@ -6757,30 +7094,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6757
7094
  || (typeof el.closest === 'function' && el.closest('[data-gallery-annot-editor]') !== null))) return
6758
7095
  if (e.key === 'Enter' && poly.length >= POLYGON_LIMITS.min) {
6759
7096
  e.preventDefault()
6760
- commitPolygon(poly)
7097
+ commitPolygon(poly, polyMode)
6761
7098
  } else if (e.key === 'Backspace') {
6762
7099
  e.preventDefault()
6763
7100
  setPoly((cur) => cur.slice(0, -1))
6764
7101
  setPolyHover(null)
6765
7102
  } else if (e.key === 'Escape') {
6766
7103
  e.preventDefault()
6767
- setPoly([])
6768
- setPolyHover(null)
7104
+ resetPoly()
6769
7105
  }
6770
7106
  }
6771
7107
  window.addEventListener('keydown', onKey)
6772
7108
  return () => window.removeEventListener('keydown', onKey)
6773
- }, [active, poly, editing])
7109
+ }, [active, poly, editing, polyMode])
6774
7110
 
6775
7111
  /** 退出标注模式时清掉未保存的草稿,避免输入框/虚线框/顶点残留。 */
6776
7112
  React.useEffect(() => {
6777
7113
  if (active) return undefined
6778
7114
  setDraft(null)
6779
7115
  setEditing(null)
6780
- setPendingStart(null)
6781
- setPoly([])
6782
- setPolyHover(null)
6783
- setPolyDrag(null)
7116
+ dragStartRef.current = null
7117
+ resetPoly()
6784
7118
  return undefined
6785
7119
  }, [active])
6786
7120
 
@@ -6809,7 +7143,6 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6809
7143
  const clearPending = () => {
6810
7144
  setDraft(null)
6811
7145
  setEditing(null)
6812
- setPendingStart(null)
6813
7146
  }
6814
7147
 
6815
7148
  /**
@@ -6828,70 +7161,76 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6828
7161
  // 不能直接塞 {x,y,w,h},否则 Math.min(undefined) → NaN%,框画不出来。
6829
7162
  setDraft({ x0: box.x, y0: box.y, x1: box.x + box.w, y1: box.y + box.h })
6830
7163
  setEditing({ shape: 'rect', ...box, note: '', frameMs: frameMs ?? null })
6831
- setPendingStart(null)
7164
+ }
7165
+
7166
+ /** 逐点采集一个多边形;mode 决定闭合后去哪儿,两套选区互斥、切换时清空旧点。 */
7167
+ const addPolygonPoint = (p, mode) => {
7168
+ const switching = polyMode !== mode || poly.length === 0
7169
+ const cur = switching ? [] : poly
7170
+ if (switching) {
7171
+ setPolyMode(mode)
7172
+ setPolyNote('')
7173
+ setPolyHover(null)
7174
+ setPolyDrag(null)
7175
+ }
7176
+ const first = cur[0]
7177
+ const nearFirst = cur.length >= POLYGON_LIMITS.min && first !== undefined
7178
+ && Math.hypot(p.x - first.x, p.y - first.y) <= POLYGON_LIMITS.closeRadius
7179
+ if (nearFirst || cur.length >= POLYGON_LIMITS.max) {
7180
+ commitPolygon(cur, mode)
7181
+ return
7182
+ }
7183
+ const next = [...cur, p]
7184
+ setPoly(next)
7185
+ setPolyHover(null)
7186
+ if (next.length >= POLYGON_LIMITS.max) commitPolygon(next, mode)
6832
7187
  }
6833
7188
 
6834
7189
  const onPointerDown = (event) => {
6835
- // 中键(1)放行给查看器的原生拖拽平移;左键留给画框(v0.14.4 标注态中键移动)。
6836
- // 若继续对所有按键 stopPropagation,中键会被吞、标注时挪不动图。
7190
+ // 中键(1)放行给查看器原生拖拽平移;左键(0)/右键(2)才由标注层接管。
6837
7191
  if (annotationPointerRouting(active, event.button) !== 'draw') return
6838
7192
  // 放大状态下查看器会在 pointerdown 里 setPointerCapture;这里必须拦住冒泡,
6839
7193
  // 否则弹窗内的输入框/按钮会被「拖图」逻辑抢走,表现为点击无反应。
6840
7194
  event.stopPropagation()
6841
- // 右键(2):多边形遮罩选区逐点采集(4–20 点)。点回首点 / 满 20 点 / Enter / 面板按钮都可闭合。
6842
- // 左键矩形批注与右键多边形互斥,避免两套草稿同时活着互相打架。
7195
+ // 右键(2):填充遮罩选区逐点采集(4–20 点)。点回首点 / 满 20 点 / Enter / 面板按钮都可闭合。
6843
7196
  if (event.button === 2) {
6844
7197
  event.preventDefault()
6845
7198
  const p = toNorm(event)
6846
7199
  if (p === null) return
6847
7200
  clearPending()
6848
- const first = poly[0]
6849
- const nearFirst = poly.length >= POLYGON_LIMITS.min && first !== undefined
6850
- && Math.hypot(p.x - first.x, p.y - first.y) <= POLYGON_LIMITS.closeRadius
6851
- if (nearFirst || poly.length >= POLYGON_LIMITS.max) {
6852
- commitPolygon(poly)
6853
- return
6854
- }
6855
- const next = [...poly, p]
6856
- setPoly(next)
6857
- setPolyHover(null)
6858
- if (next.length >= POLYGON_LIMITS.max) commitPolygon(next)
7201
+ dragStartRef.current = null
7202
+ addPolygonPoint(p, 'mask')
6859
7203
  return
6860
7204
  }
6861
7205
  if (event.button !== 0) return
6862
7206
  const p = toNorm(event)
6863
7207
  if (p === null) return
6864
7208
  event.preventDefault()
6865
- if (poly.length > 0) {
6866
- setPoly([])
6867
- setPolyHover(null)
6868
- setPolyDrag(null)
6869
- }
6870
7209
  try { event.currentTarget.setPointerCapture(event.pointerId) } catch { /* 忽略 */ }
6871
-
6872
- // 上一处还在输入 → 先存档,第二处才按得下去(v0.14.2 ⑤)
7210
+ // 上一处还在输入 → 先存档,下一处才按得下去(v0.14.2 ⑤)
6873
7211
  if (editing !== null) commitEditing()
6874
-
6875
- // 已经点过第一下 → 这一下当终点,直接成框(v0.14.2 ⑥)
6876
- if (pendingStart !== null) {
6877
- const box = rectFrom(pendingStart, p)
6878
- if (isValidBox(box)) {
6879
- beginEdit(box)
6880
- } else {
6881
- // 两次点到同一处:把起点挪到新位置,继续等第二下
6882
- setPendingStart(p)
6883
- setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
6884
- }
6885
- return
6886
- }
6887
-
6888
- setPendingStart(p)
6889
- setDraft({ x0: p.x, y0: p.y, x1: p.x, y1: p.y })
7212
+ // 先只记起点:松手时才判定「拖过=矩形」还是「没拖=一个区域顶点」。
7213
+ // 这样单纯点一下不会闪出虚线框,也不会再出现「点两下成矩形」。
7214
+ dragStartRef.current = { start: p, moved: false }
6890
7215
  }
6891
7216
 
6892
7217
  const onPointerMove = (event) => {
6893
- // 中键平移进行中:标注层一律不插手,让查看器独占指针(双保险,主保险是中键不再拦冒泡)
7218
+ // 中键平移进行中:标注层一律不插手,让查看器独占指针
6894
7219
  if (dragging) return
7220
+ const gesture = dragStartRef.current
7221
+ // 左键按下还没判定:移动超过阈值才算「拖框」,此刻才建立矩形草稿
7222
+ if (gesture !== null && !gesture.moved) {
7223
+ const p = toNorm(event)
7224
+ if (p === null) return
7225
+ if (Math.hypot(p.x - gesture.start.x, p.y - gesture.start.y) < ANNOT_DRAG_THRESHOLD) return
7226
+ gesture.moved = true
7227
+ // 真拖动=矩形批注,先撤掉没闭合的多边形草稿,两套选区不混着画
7228
+ resetPoly()
7229
+ setDraft({ x0: gesture.start.x, y0: gesture.start.y, x1: p.x, y1: p.y })
7230
+ event.stopPropagation()
7231
+ event.preventDefault()
7232
+ return
7233
+ }
6895
7234
  // 多边形橡皮筋:只在没有矩形草稿、没有说明弹窗时跟随指针
6896
7235
  if (active && poly.length > 0 && draft === null && editing === null) {
6897
7236
  event.stopPropagation()
@@ -6909,17 +7248,22 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6909
7248
 
6910
7249
  const finishDraft = (event) => {
6911
7250
  if (dragging) return
6912
- if (draft === null || editing !== null) return
7251
+ const gesture = dragStartRef.current
7252
+ if (gesture === null) return
7253
+ dragStartRef.current = null
6913
7254
  event.preventDefault()
6914
7255
  event.stopPropagation()
6915
- const box = rectFrom({ x: draft.x0, y: draft.y0 }, { x: draft.x1, y: draft.y1 })
6916
- if (!isValidBox(box)) {
6917
- // 只是点了一下、还没拖:保留起点,等第二下点终点(v0.14.2 ⑥)
6918
- setPendingStart({ x: draft.x0, y: draft.y0 })
7256
+ const p = toNorm(event) ?? gesture.start
7257
+ if (!gesture.moved) {
7258
+ // 单纯点一下 = 不规则区域的一个顶点;点回起点 / 满 20 点即闭合进反馈篮
6919
7259
  setDraft(null)
7260
+ addPolygonPoint(p, 'note')
6920
7261
  return
6921
7262
  }
6922
- // 草稿框不清:输入框弹出期间,图上必须仍然看得见刚才圈的位置
7263
+ // 拖出来的矩形:亮框不清,输入框弹出期间图上必须仍看得见刚圈的位置
7264
+ const box = rectFrom(gesture.start, p)
7265
+ setDraft(null)
7266
+ if (!isValidBox(box)) return
6923
7267
  beginEdit(box)
6924
7268
  }
6925
7269
 
@@ -6997,7 +7341,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
6997
7341
  ])
6998
7342
  })
6999
7343
 
7000
- // ---- 正在画的框 / 已点下的起点(保存前一直可见)----
7344
+ // ---- 正在拖的矩形(保存前一直可见);单击加顶点不画虚线框 ----
7001
7345
  const draftShape = draft !== null
7002
7346
  ? (() => {
7003
7347
  const x = Math.min(draft.x0, draft.x1)
@@ -7013,21 +7357,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7013
7357
  }, t('annotPendingTag')),
7014
7358
  ])
7015
7359
  })()
7016
- : (pendingStart !== null
7017
- ? h('g', { key: 'startPoint' }, [
7018
- h('circle', {
7019
- cx: (pendingStart.x * 100) + '%', cy: (pendingStart.y * 100) + '%', r: 5,
7020
- fill: '#ffd166', stroke: '#000', strokeWidth: 1.5,
7021
- }),
7022
- h('text', {
7023
- x: (pendingStart.x * 100) + '%', y: (pendingStart.y * 100) + '%',
7024
- dx: 9, dy: 4, fill: '#ffe08a', fontSize: 12, stroke: '#000', strokeWidth: 0.6,
7025
- style: { paintOrder: 'stroke' },
7026
- }, t('annotStartTag')),
7027
- ])
7028
- : null)
7360
+ : null
7029
7361
 
7030
- /** 右键多边形预览:实心半透明填充 + 可拖顶点 + 橡皮筋(点回首点即闭合)。 */
7362
+ /** 多边形预览:实心半透明填充 + 可拖顶点 + 橡皮筋(点回首点即闭合),两种模式共用。 */
7031
7363
  const polyShape = poly.length === 0 ? null : (() => {
7032
7364
  const toPx = (p) => [p.x * boxW, p.y * boxH]
7033
7365
  const pts = poly.map(toPx)
@@ -7057,6 +7389,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7057
7389
  'data-gallery-poly-vertex': String(idx),
7058
7390
  onPointerDown: (e) => {
7059
7391
  if (e.button !== 0) return
7392
+ // 点回起点=闭合选区,别被「拖顶点」抢走:首点在够点数时放行,
7393
+ // 事件冒泡到 SVG 的 pointerdown/pointerup,由 addPolygonPoint 判闭合。
7394
+ if (idx === 0 && poly.length >= POLYGON_LIMITS.min) return
7060
7395
  e.stopPropagation()
7061
7396
  e.preventDefault()
7062
7397
  setPolyDrag(idx)
@@ -7093,11 +7428,16 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7093
7428
 
7094
7429
  /** 多边形选区操作条:点数 / 外接框 / 面积实时可见,闭合前可撤销、可清空。 */
7095
7430
  const polyBox = poly.length > 0 ? polygonBBox(poly) : null
7096
- const polyPanel = poly.length === 0 ? null : h('div', {
7097
- className: 'dg-polyPanel', key: 'polyPanel', 'data-gallery-poly-panel': true,
7431
+ const isNoteMode = polyMode === 'note'
7432
+ // 拖顶点时先把面板藏起来(老板 2026-11-16:确认框别挡正在看的那块),
7433
+ // 松手立刻回来、带淡入;位置本来就钉在右下角,只在拖动这一瞬让开。
7434
+ const polyPanel = (poly.length === 0 || polyDrag !== null) ? null : h('div', {
7435
+ className: 'dg-polyPanel', key: 'polyPanel',
7436
+ 'data-gallery-poly-panel': true,
7437
+ 'data-gallery-poly-mode': polyMode,
7098
7438
  ...blockViewer,
7099
7439
  }, [
7100
- h('div', { className: 'dg-polyPanelHead', key: 'h' }, t('polyTitle')),
7440
+ h('div', { className: 'dg-polyPanelHead', key: 'h' }, t(isNoteMode ? 'polyNoteTitle' : 'polyTitle')),
7101
7441
  h('div', { className: 'dg-polyPanelInfo', key: 'i', 'data-gallery-poly-info': true },
7102
7442
  format(t('polyInfo'), {
7103
7443
  n: String(poly.length), max: String(POLYGON_LIMITS.max),
@@ -7105,7 +7445,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7105
7445
  w: Math.round(polyBox.w * 100), h: Math.round(polyBox.h * 100),
7106
7446
  area: (polygonArea(poly) * 100).toFixed(2),
7107
7447
  })),
7108
- h('div', { className: 'dg-polyPanelHint', key: 'p' }, t('polyHint')),
7448
+ h('div', { className: 'dg-polyPanelHint', key: 'p' }, t(isNoteMode ? 'polyNoteHint' : 'polyHint')),
7449
+ // 只有「区域标记」模式才给说明框:遮罩导出不需要文字,也别把说明塞进文件名
7450
+ isNoteMode ? h('div', { className: 'dg-polyPanelNote', key: 'note' },
7451
+ h('input', {
7452
+ type: 'text', className: 'dg-polyNoteInput',
7453
+ 'data-gallery-poly-note': true,
7454
+ placeholder: t('polyNotePlaceholder'),
7455
+ value: polyNote, maxLength: 500,
7456
+ // 字母 / 退格 / 回车都归输入框,别被查看器全局快捷键与闭合监听抢走
7457
+ onKeyDown: (e) => e.stopPropagation(),
7458
+ onChange: (e) => setPolyNote(e.target.value),
7459
+ })) : null,
7109
7460
  h('div', { className: 'dg-polyColors', key: 'colors', 'data-gallery-poly-colors': true }, [
7110
7461
  h('span', { className: 'dg-polyColorsLabel', key: 'l' }, t('polyFillColor')),
7111
7462
  ...MASK_FILL_KEYS.map((k) => h('button', {
@@ -7131,15 +7482,15 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7131
7482
  type: 'button', className: 'dg-btn dg-btnSmall', key: 'c',
7132
7483
  onClick: (e) => {
7133
7484
  e.stopPropagation(); e.preventDefault()
7134
- setPoly([]); setPolyHover(null); setPolyDrag(null)
7485
+ resetPoly()
7135
7486
  },
7136
7487
  }, t('polyClear')),
7137
7488
  h('button', {
7138
7489
  type: 'button', className: 'dg-btn dg-btnSmall dg-polyClose', key: 's',
7139
7490
  'data-gallery-poly-close': true,
7140
- disabled: maskBusy || poly.length < POLYGON_LIMITS.min,
7141
- onClick: (e) => { e.stopPropagation(); e.preventDefault(); commitPolygon(poly) },
7142
- }, t('polyClose')),
7491
+ disabled: (isNoteMode ? false : maskBusy) || poly.length < POLYGON_LIMITS.min,
7492
+ onClick: (e) => { e.stopPropagation(); e.preventDefault(); commitPolygon(poly, polyMode) },
7493
+ }, t(isNoteMode ? 'polyNoteClose' : 'polyClose')),
7143
7494
  ]),
7144
7495
  ])
7145
7496
 
@@ -7234,7 +7585,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7234
7585
  onPointerDown,
7235
7586
  onPointerMove,
7236
7587
  onPointerUp: finishDraft,
7237
- onPointerCancel: () => { setDraft(null); setPendingStart(null) },
7588
+ onPointerCancel: () => { setDraft(null); dragStartRef.current = null },
7238
7589
  onClick: active ? (event) => { event.preventDefault(); event.stopPropagation() } : undefined,
7239
7590
  onContextMenu: active ? (event) => { event.preventDefault(); event.stopPropagation() } : undefined,
7240
7591
  }, [draftShape, polyShape, ...shapes]),
@@ -7687,8 +8038,57 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7687
8038
  *
7688
8039
  * 绝不自动发送:只写草稿,发送由人自己按。
7689
8040
  */
8041
+ /**
8042
+ * 阶段 3 / C2:双击时把图片本体也放进输入框(尽力而为)。
8043
+ *
8044
+ * 宿主对话输入框的粘贴处理会同时读「文件」和「纯文本」;这里只放文件,
8045
+ * 不带 text/plain,所以不会把上面那段文字重复插一遍。
8046
+ * 合成事件有三处没经过真机实证(宿主内部实现、Electron 对合成 File 取路径、
8047
+ * 覆盖 clipboardData),因此全程 try/catch:失败就只是「没附图」,
8048
+ * 文字草稿、发送按钮、既有双击行为一律不受影响。
8049
+ *
8050
+ * 红线:绝不调用发送,也不写任何业务数据。
8051
+ */
8052
+ const isImageRel = (rel) => /\.(png|jpe?g|webp|bmp|gif|avif|tiff?)$/i.test(String(rel ?? ''))
8053
+
8054
+ async function attachAssetImageToComposer(target) {
8055
+ const relPath = String(target?.relPath ?? '')
8056
+ if (!isImageRel(relPath)) return { ok: false, reason: 'not-image' }
8057
+ const composer = document.querySelector('[data-composer-input][data-lexical-editor="true"]')
8058
+ ?? document.querySelector('[data-lexical-editor="true"]')
8059
+ if (composer === null) return { ok: false, reason: 'no-composer' }
8060
+ try {
8061
+ const response = await fetch(mediaUrlOf(relPath, target?.mtime), { credentials: 'same-origin' })
8062
+ if (!response.ok) return { ok: false, reason: 'fetch-' + response.status }
8063
+ const blob = await response.blob()
8064
+ if (!(blob.size > 0) || blob.size > 20 * 1024 * 1024) {
8065
+ return { ok: false, reason: 'size' }
8066
+ }
8067
+ const name = String(target?.name ?? relPath.split('/').pop() ?? 'image.png')
8068
+ const file = new File([blob], name, { type: blob.type || 'image/png' })
8069
+ const dt = new DataTransfer()
8070
+ dt.items.add(file)
8071
+ const ev = new ClipboardEvent('paste', { bubbles: true, cancelable: true })
8072
+ Object.defineProperty(ev, 'clipboardData', { value: dt, configurable: true })
8073
+ ev.__dshGallerySynthetic = true
8074
+ // 焦点先进输入框:插件自己的 document 级粘贴监听有「焦点在编辑区就放行」的门控。
8075
+ composer.focus()
8076
+ composer.dispatchEvent(ev)
8077
+ return { ok: true, name, size: blob.size }
8078
+ } catch (error) {
8079
+ console.warn('dsh-gallery: 图片附件未自动加入输入框(文字草稿不受影响)', error)
8080
+ return { ok: false, reason: String(error?.message ?? error) }
8081
+ }
8082
+ }
7690
8083
  const writeAssetToComposer = (target, abs) => {
7691
8084
  const info = target ?? {}
8085
+ const key = String(info.relPath ?? '')
8086
+ // 连点保护:上一次还没处理完就直接忽略,避免文字和缩略图各写两份。
8087
+ // 5 秒兜底 + finally 摘除,处理完(含失败)绝不长期占着。
8088
+ const now = Date.now()
8089
+ const busyAt = key === '' ? undefined : doubleClickInFlight.get(key)
8090
+ if (busyAt !== undefined && now - busyAt < 5000) return
8091
+ if (key !== '') doubleClickInFlight.set(key, now)
7692
8092
  // 预览图 / 原图没有自己的 maskOf,按 overlayRelPath / sourceRelPath 反查主遮罩
7693
8093
  const linked = dragMaskByOverlay.get(info.relPath) ?? dragMaskBySource.get(info.relPath) ?? null
7694
8094
  const hasMask = info?.maskOf !== null && info?.maskOf !== undefined
@@ -7699,12 +8099,19 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7699
8099
  void writeDraftToComposer(text, sessionId).then((result) => {
7700
8100
  // 写不进 composer 就放剪贴板,人自己粘
7701
8101
  if (!result.ok) void copyText(text)
8102
+ // 文字那步有幂等:草稿已在输入框时返回 already-present,本次并没有真的插入文字。
8103
+ // 附图必须跟着同一把尺子走,否则重复双击会一次次往输入框塞同一张缩略图。
8104
+ const alreadyPresent = result.ok && result.detail === 'already-present'
8105
+ if (result.ok && !alreadyPresent) void attachAssetImageToComposer(info)
7702
8106
  showToast(result.ok ? 'ok' : 'failed',
7703
- result.ok ? t('feedbackDraftReady') : t('feedbackDraftInClipboard'))
8107
+ alreadyPresent ? t('feedbackDraftAlreadyThere')
8108
+ : (result.ok ? t('feedbackDraftReady') : t('feedbackDraftInClipboard')))
7704
8109
  }).catch((error) => {
7705
8110
  console.warn('dsh-gallery: 写输入框失败,已退回剪贴板', error)
7706
8111
  void copyText(text)
7707
8112
  showToast('failed', t('feedbackDraftInClipboard'))
8113
+ }).finally(() => {
8114
+ if (key !== '') doubleClickInFlight.delete(key)
7708
8115
  })
7709
8116
  }
7710
8117
 
@@ -7722,6 +8129,38 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7722
8129
  // 让回调(如右键菜单)读到最新值而不必重建依赖
7723
8130
  const viewerRef = React.useRef(null)
7724
8131
  React.useEffect(() => { viewerRef.current = viewer }, [viewer])
8132
+
8133
+ /**
8134
+ * 阶段 3 / C1:把「人此刻正在看哪张图」告诉后台。
8135
+ * 关闭查看器时不清空 —— 保留最后一次,人回头问「我刚看的那张」仍然答得上来。
8136
+ * 纯状态同步:不发送任何消息,失败只记日志,绝不影响看图本身。
8137
+ */
8138
+ React.useEffect(() => {
8139
+ if (viewer === null || !Array.isArray(viewer.list)) return
8140
+ const current = viewer.list[viewer.index]
8141
+ if (current === null || current === undefined || String(current.relPath ?? '') === '') return
8142
+ // 原图 / 彩色填充预览图自己没有 maskOf;用列表刷新时建好的反查表补上,
8143
+ // 让「助手查刚看的图」与双击、拖图写进输入框拿到同一张主遮罩。
8144
+ const linkedMask = dragMaskByOverlay.get(String(current.relPath))
8145
+ ?? dragMaskBySource.get(String(current.relPath)) ?? null
8146
+ void callHost('setContext', {
8147
+ item: {
8148
+ relPath: String(current.relPath),
8149
+ name: String(current.name ?? ''),
8150
+ absPath: String(current.absPath ?? ''),
8151
+ category: String(current.category ?? 'unknown'),
8152
+ categoryManual: current.categoryManual === true,
8153
+ maskOf: current.maskOf ?? (linkedMask !== null
8154
+ ? { relPath: String(linkedMask.relPath ?? '') } : null),
8155
+ sessionId: String(current.sessionId ?? viewer.originSid ?? ''),
8156
+ sessionTitle: String(current.sessionTitle ?? viewer.originTitle ?? ''),
8157
+ // 第二档:文件自身改动时间(后台按活跃度排「最近看过的图」时要用)
8158
+ mtime: Number(current.mtime) || 0,
8159
+ },
8160
+ }).catch((error) => {
8161
+ console.warn('dsh-gallery: 同步「正在看的图」失败(不影响看图)', error)
8162
+ })
8163
+ }, [viewer])
7725
8164
  /**
7726
8165
  * v0.16.2 粘贴落点:全局视图下「鼠标所在的对话组」。
7727
8166
  *
@@ -7753,6 +8192,10 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7753
8192
  const [settingsOpen, setSettingsOpen] = React.useState(false)
7754
8193
  // 全局分组:哪些组是展开的(键是 sessionId 或 '__history__')
7755
8194
  const [openGroups, setOpenGroups] = React.useState(new Set())
8195
+ // 每组额外取回来的明细(首次只有 60 张,点「再显示」再追加 60 张)。
8196
+ // 全量明细留在后台内存,界面一次只画一小批:加载轻、也不卡。
8197
+ const [groupExtras, setGroupExtras] = React.useState(() => new Map())
8198
+ const [groupBusy, setGroupBusy] = React.useState(() => new Set())
7756
8199
  /**
7757
8200
  * 「打开对话」的实测结论:sid → 'ok' | 'failed'。
7758
8201
  * 它比 Host 的归档字段优先级更高:点得开就撤掉一切标注,点不开才标无法重建。
@@ -7804,6 +8247,36 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7804
8247
  }))
7805
8248
  // 取值失败兜底到 image 那份(正常情况三种 kind 都建过桶,走不到这里)
7806
8249
  const categoryFilter = categoryFilterMap[kind] ?? categoryFilterMap.image
8250
+ /**
8251
+ * 2026-11-16 第二档:把「面板此刻长什么样」同步给后台。
8252
+ * 人切视图、改分类开关、翻页时防抖上报,模型才知道您眼前筛掉了哪几类、
8253
+ * 一共多少张、分几个对话组 —— 否则它只能瞎猜「产出台里现在有什么」。
8254
+ * 纯状态同步:600ms 防抖,失败只记日志,绝不影响列表本身。
8255
+ */
8256
+ React.useEffect(() => {
8257
+ if (view.status !== 'ready' || view.data === null) return
8258
+ const timer = setTimeout(() => {
8259
+ const data = view.data
8260
+ void callHost('setPanel', {
8261
+ panel: {
8262
+ scope,
8263
+ kind,
8264
+ page,
8265
+ total: Number(data.total) || 0,
8266
+ groupCount: Array.isArray(data.groups) ? data.groups.length : 0,
8267
+ categories: {
8268
+ final: categoryFilter.final !== false,
8269
+ input: categoryFilter.input !== false,
8270
+ intermediate: categoryFilter.intermediate !== false,
8271
+ unknown: categoryFilter.unknown !== false,
8272
+ },
8273
+ },
8274
+ }).catch((error) => {
8275
+ console.warn('dsh-gallery: 同步面板状态失败(不影响使用)', error)
8276
+ })
8277
+ }, 600)
8278
+ return () => clearTimeout(timer)
8279
+ }, [view, scope, kind, page, categoryFilter])
7807
8280
  /** 批量选择(v0.13.7):选中的 relPath 集合。清空条件:切 kind / 切 scope / 刷新后失效项自动剔除。 */
7808
8281
  const [selected, setSelected] = React.useState(new Set())
7809
8282
  /** 批量模式:用户显式开启,或已有选中项时自动生效(避免勾了看不见批量条)。 */
@@ -7836,6 +8309,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
7836
8309
  y: Number(a?.y) || 0,
7837
8310
  w: Number(a?.w) || 0,
7838
8311
  h: Number(a?.h) || 0,
8312
+ // 不规则区域:顶点挂在 region 里原样透传,Host 展开与草稿都认这个对象
8313
+ ...(a?.shape === 'polygon' && Array.isArray(a?.polygon)
8314
+ ? { polygon: a.polygon, shape: 'polygon' } : {}),
7839
8315
  },
7840
8316
  markedAt: Number(a?.createdAt) || Date.now(),
7841
8317
  }), [])
@@ -8226,8 +8702,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8226
8702
  // 先同步 ref 再 setState:落盘要读「加上这一条之后」的完整数组
8227
8703
  annotationsRef.current = nextAll
8228
8704
  setAnnotations(nextAll)
8229
- // v0.16.4 · A 档:框选批注同样是判定 → 进待处理。
8230
- // v0.16.5:整组写,Agent 才拿得到同一张图上的每一处;
8705
+ // v0.16.4 · A 档:框选批注同样是判定 → 进待处理。
8706
+ // v0.16.5:整组写,Agent 才拿得到同一张图上的每一处;
8231
8707
  // 若该图已有非批注判定(如「交付不合格」),保留那条 action 不被冲掉。
8232
8708
  const existing = marks[relPath]
8233
8709
  writePendingAnnotations(relPath, next, {
@@ -8401,6 +8877,12 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8401
8877
  // v0.16.4:分类(素材 / 过程稿 / 定稿),批注落盘与草稿都要用
8402
8878
  category: it.category ?? 'unknown',
8403
8879
  categoryManual: it.categoryManual === true,
8880
+ // 阶段 3 / C1:同步「正在看哪张」要用的字段。
8881
+ // maskOf 只留 relPath,避免把整个关联对象塞进 viewer state。
8882
+ absPath: it.absPath ?? '',
8883
+ maskOf: it.maskOf ? { relPath: String(it.maskOf.relPath ?? '') } : null,
8884
+ sessionId: it.sessionId ?? '',
8885
+ sessionTitle: it.sessionTitle ?? '',
8404
8886
  }))
8405
8887
  // v0.16.2:记住这张图属于哪个对话组 —— 裁剪产物要跟着来源组落盘,
8406
8888
  // 不能一律塞进当前对话(否则在历史对话的图上裁剪,产物跑到别的对话)。
@@ -8593,6 +9075,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8593
9075
  let okCount = 0
8594
9076
  let lastErr = ''
8595
9077
  let skipped = 0
9078
+ // 空壳位图(只有名字没内容)标记:交给系统剪贴板读真实文件路径兜底
9079
+ let needClipboardFallback = false
8596
9080
  for (const file of images) {
8597
9081
  // 没有磁盘路径、MIME 又不是图片的(如复制的 PDF/zip):读成 base64 也过不了
8598
9082
  // PNG 校验,直接跳过并计数,最后给一条明确的「请拖入画廊」提示。
@@ -8602,7 +9086,10 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8602
9086
  const dataUrl = await fileToDataUrl(file)
8603
9087
  const comma = dataUrl.indexOf(',')
8604
9088
  const base64 = comma >= 0 ? dataUrl.slice(comma + 1) : dataUrl
8605
- const payload = await callHost('pasteImage', { sessionId: pasteTargetSid(), data: base64, ext: 'png' })
9089
+ // 空壳(Electron 对某些来源只给文件名、不给内容):别硬发空 base64,
9090
+ // 改走系统剪贴板按真实路径复制,任何格式都能原样搬过去。
9091
+ if (base64 === '' || Number(file?.size ?? 0) === 0) { needClipboardFallback = true; continue }
9092
+ const payload = await callHost('pasteImage', { sessionId: pasteTargetSid(), data: base64, ext: imageExtOf(mime, dataUrl) })
8606
9093
  if (payload?.ok === true) { okCount += 1; showPasteNotice('ok', format(t('pasteImageOk'), { name: payload.name ?? '', target: pasteTargetLabel() })) }
8607
9094
  else lastErr = payload?.error?.message ?? 'pasteImage failed'
8608
9095
  } catch (error) {
@@ -8621,14 +9108,21 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8621
9108
  if (okCount > 0) {
8622
9109
  void refresh()
8623
9110
  if (lastErr !== '') console.warn('dsh-gallery: 部分粘贴失败', lastErr)
8624
- } else if (lastErr !== '') {
9111
+ return
9112
+ }
9113
+ // 事件里是空壳:退回系统剪贴板,Host 用 PowerShell 读 CF_HDROP 拿真实路径
9114
+ if (needClipboardFallback) {
9115
+ const got = await pasteFromClipboard()
9116
+ if (got) return
9117
+ }
9118
+ if (lastErr !== '') {
8625
9119
  showPasteNotice('fail', format(t('pasteFailed'), { message: lastErr }))
8626
9120
  } else if (skipped > 0) {
8627
9121
  showPasteNotice('fail', t('pasteUnsupported'))
8628
9122
  } else {
8629
9123
  showPasteNotice('fail', t('pasteEmpty'))
8630
9124
  }
8631
- }, [sessionId, refresh, t, showPasteNotice])
9125
+ }, [sessionId, refresh, t, showPasteNotice, pasteFromClipboard])
8632
9126
 
8633
9127
  /** Ctrl+V:优先吃 paste 事件的图片/文件;事件没给文件信息时退到系统剪贴板。 */
8634
9128
  const doPasteEvent = React.useCallback(async (clipboardData, event) => {
@@ -8697,12 +9191,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8697
9191
  * 所以必须挂 document 级监听,再用两道门控避免抢走对话输入框的粘贴:
8698
9192
  * ① 鼠标必须悬停在本面板上(hoveringRef);
8699
9193
  * ② 焦点不能在 input/textarea/contenteditable 里。
8700
- */
8701
- const hoveringRef = React.useRef(false)
8702
- React.useEffect(() => {
8703
- const onDocPaste = (event) => {
8704
- if (hoveringRef.current !== true) return
8705
- if (event?.defaultPrevented === true) return
9194
+ */
9195
+ const hoveringRef = React.useRef(false)
9196
+ React.useEffect(() => {
9197
+ const onDocPaste = (event) => {
9198
+ if (hoveringRef.current !== true) return
9199
+ // 阶段 3 / C2:我们自己在输入框合成的图片粘贴事件,不是往面板里粘图。
9200
+ if (event?.__dshGallerySynthetic === true) return
9201
+ if (event?.defaultPrevented === true) return
8706
9202
  const ae = document.activeElement
8707
9203
  const tag = (ae?.tagName ?? '').toLowerCase()
8708
9204
  if (tag === 'input' || tag === 'textarea' || ae?.isContentEditable === true) return
@@ -8915,7 +9411,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8915
9411
  h('span', { className: 'dg-sub', key: 'sub' },
8916
9412
  data === null
8917
9413
  ? (view.status === 'failed' ? t('errorTitle') : t('loading'))
8918
- : format(t('subCount'), { shown: visibleItems.length, total: data.total })),
9414
+ : (scope === 'global' && Array.isArray(data.groups) && data.groups.length > 0
9415
+ ? format(t('subCountGroups'), { total: data.total, groups: data.groups.length })
9416
+ : format(t('subCount'), { shown: visibleItems.length, total: data.total }))),
8919
9417
  ]),
8920
9418
  scopeSwitch,
8921
9419
  // 图片 / 文件 / 音视频 三画廊切换(v0.10.1)
@@ -8970,6 +9468,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8970
9468
  // 反馈篮独立入口(S3-a):关闭后能重新打开,不必再标记一张卡
8971
9469
  // 计数取「表态 ∪ 批注」并集:只有框选批注、没表态的卡也算一条待发反馈
8972
9470
  const markedCount = new Set([...Object.keys(marks), ...Object.keys(annotations)]).size
9471
+ // 2026-11-15:按钮上不再显示「· N 条」,恒显「反馈篮」。
9472
+ // 条数数据属性保留(不是可见数字),反馈的读写与生命周期一点不动。
8973
9473
  const basketToggle = h('button', {
8974
9474
  type: 'button',
8975
9475
  className: 'dg-btn dg-basketToggle',
@@ -8979,30 +9479,18 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
8979
9479
  title: t('feedbackBasketToggleHint'),
8980
9480
  'aria-label': t('feedbackBasketToggleHint'),
8981
9481
  onClick: () => setBasketOpen((v) => !v),
8982
- }, markedCount > 0
8983
- ? format(t('feedbackBasketToggleN'), { n: markedCount })
8984
- : t('feedbackBasketToggle'))
9482
+ }, t('feedbackBasketToggle'))
8985
9483
 
8986
9484
  /**
8987
- * v0.16.4 · B 档:待处理反馈角标。
9485
+ * 2026-11-15:待处理数字角标已下线(老板拍板「留篮子、去掉数字」)。
8988
9486
  *
8989
- * 为什么要和上面那个「反馈篮 · N 条」并存:
8990
- * · 按钮上的 N = 篮子里现在有几条(持久)
8991
- * · 角标上的 N = 自上次处理完以来有几条新判定(一次性)
8992
- * 人做完一轮后按钮还显示条数(标记还在),但角标归零 —— 表示「没有待办了」。
8993
- * 点角标 = 打开反馈篮,**不会**自动拉给 Agent。
9487
+ * 今天助手已能自己查资产、记住刚打开的那张、双击卡片直接带图进输入框,
9488
+ * 「攒意见 → 角标提醒 → 等助手来拉」这条老链路不再走;反馈文件自 12:24 起为空。
9489
+ * 但反馈篮本体保留:多条意见打包成草稿、框选批注、编辑 / 清空仍只有它做得到。
9490
+ * 数据层一律不动(pendingCount 的读写与 ack 照旧),避免碰反馈生命周期。
9491
+ * 恒为 null:渲染数组里仍引用 pendingBadge,留个空位比删变量安全。
8994
9492
  */
8995
- const pendingBadge = pendingCount > 0
8996
- ? h('button', {
8997
- type: 'button',
8998
- className: 'dg-pendingBadge',
8999
- key: 'pendingBadge',
9000
- 'data-gallery-pending-count': pendingCount,
9001
- title: format(t('pendingFeedbackBadgeHint'), { n: pendingCount }),
9002
- 'aria-label': format(t('pendingFeedbackBadgeHint'), { n: pendingCount }),
9003
- onClick: () => setBasketOpen(true),
9004
- }, format(t('pendingFeedbackBadge'), { n: pendingCount }))
9005
- : null
9493
+ const pendingBadge = null
9006
9494
 
9007
9495
  /**
9008
9496
  * 各分类的全局计数(供顶部开关显示数字 + 判断「已显示 N / 共 M」)。
@@ -9011,12 +9499,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9011
9499
  const catCounts = React.useMemo(() => {
9012
9500
  // v0.14.2:只数 4 个原生标签,表态层已下线
9013
9501
  const c = { final: 0, input: 0, intermediate: 0, unknown: 0 }
9502
+ // 🔴 全局分组视图下,下面渲染的是 data.groups(全库按对话分组),
9503
+ // 而 items 只是最新一页的 60 条。还按 items 统计,顶部数字会与
9504
+ // 各组小标签加总差几十倍 —— 直接汇总各组全量 counts,口径才一致。
9505
+ if (scope === 'global' && Array.isArray(data?.groups) && data.groups.length > 0) {
9506
+ for (const g of data.groups) {
9507
+ for (const k of Object.keys(c)) c[k] += Number(g.counts?.[k] ?? 0)
9508
+ }
9509
+ return c
9510
+ }
9511
+ // 2026-11-15:当前对话视图也按「本对话全部」算。后台 list 会带回 counts,
9512
+ // 直接用;items 只是第一页 60 张,数它会和全局「当前对话」组的小标签对不上。
9513
+ if (data?.counts !== null && typeof data?.counts === 'object') {
9514
+ for (const k of Object.keys(c)) c[k] = Number(data.counts[k] ?? 0)
9515
+ return c
9516
+ }
9014
9517
  for (const it of items) {
9015
9518
  const b = bucketOf(it)
9016
9519
  if (Object.prototype.hasOwnProperty.call(c, b)) c[b] += 1
9017
9520
  }
9018
9521
  return c
9019
- }, [items, bucketOf])
9522
+ }, [items, bucketOf, scope, data])
9020
9523
  const finalCount = catCounts.final
9021
9524
  const inputCount = catCounts.input
9022
9525
  const interimCount = catCounts.intermediate
@@ -9217,8 +9720,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9217
9720
  ]),
9218
9721
  ]),
9219
9722
  ])
9220
- : null
9221
-
9723
+ : null
9724
+
9222
9725
  let body
9223
9726
  if (view.status === 'loading') {
9224
9727
  body = h('div', { className: 'dg-body', key: 'body' }, h('p', { className: 'dg-status' }, t('loading')))
@@ -9230,8 +9733,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9230
9733
  ])
9231
9734
  } else if (data !== null && data.rootMissing) {
9232
9735
  // 目录不存在是最常见的「装上打不开」原因:直接给出改目录入口
9233
- body = h('div', { className: 'dg-body', key: 'body' }, [
9234
- h('p', { className: 'dg-status', key: 'msg' },
9736
+ body = h('div', { className: 'dg-body', key: 'body' }, [
9737
+ h('p', { className: 'dg-status', key: 'msg' },
9235
9738
  format(t('rootMissing'), { root: data.root })),
9236
9739
  h('p', { className: 'dg-status dg-statusAction', key: 'fix' },
9237
9740
  h('button', {
@@ -9244,7 +9747,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9244
9747
  } else if (items.length === 0) {
9245
9748
  // 当前对话为空时,要区分:会话记录没找到 / 日志空 / 找到了但确实没产出
9246
9749
  // 全局为空时,按画廊类型给不同文案(图片 / 文件)
9247
- let emptyText = kind === 'file' ? t('emptyFile')
9750
+ let emptyText = kind === 'file' ? t('emptyFile')
9248
9751
  : kind === 'media' ? t('emptyMedia')
9249
9752
  : t('empty')
9250
9753
  if (scope === 'session' && data !== null) {
@@ -9257,8 +9760,26 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9257
9760
  emptyText = t('emptySession')
9258
9761
  }
9259
9762
  }
9260
- body = h('div', { className: 'dg-body', key: 'body' },
9261
- h('p', { className: 'dg-status' }, emptyText))
9763
+ // 新对话空状态也要能粘贴:和「有图」分支一样接三样 ——
9764
+ // ① 外层 bodyWrap 的 hover 标记,否则 document 级 Ctrl+V 门控直接忽略;
9765
+ // ② onPaste / onContextMenu,右键菜单与 Ctrl+V 都走这里。
9766
+ // onBodyPaste / onBodyContextMenu / hoveringRef 都在本分支之前声明,无 TDZ。
9767
+ body = h('div', {
9768
+ className: 'dg-bodyWrap',
9769
+ key: 'bodyWrap',
9770
+ onMouseEnter: () => { hoveringRef.current = true },
9771
+ onMouseLeave: () => { hoveringRef.current = false; pasteTargetRef.current = null },
9772
+ }, [
9773
+ h('div', {
9774
+ className: `dg-body${kind === 'file' ? ' dg-fileBody' : ''}`,
9775
+ key: 'body',
9776
+ 'data-gallery-body': true,
9777
+ onPaste: onBodyPaste,
9778
+ onContextMenu: onBodyContextMenu,
9779
+ }, [
9780
+ h('p', { className: 'dg-status' }, emptyText),
9781
+ ]),
9782
+ ])
9262
9783
  } else {
9263
9784
  // 全局模式 + 有分组数据 → 按对话分组渲染(可折叠)
9264
9785
  const useGroups = scope === 'global' && Array.isArray(data.groups) && data.groups.length > 0
@@ -9411,11 +9932,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9411
9932
  const sidebarSnapshot = readSidebarSessions()
9412
9933
  const groupNodes = data.groups.map((group, gi) => {
9413
9934
  const groupKey = group.sessionId ?? '__history__'
9414
- const isOpen = openGroups.has(groupKey)
9415
- // v0.14.3:过程稿显隐只认顶部「过程稿」开关,组内不再第二套开关。
9935
+ const isOpen = openGroups.has(groupKey)
9936
+ // v0.14.3:过程稿显隐只认顶部「过程稿」开关,组内不再第二套开关。
9416
9937
  // 顶部开 → 所有组的过程稿都显示;顶部关 → 全部隐藏。
9417
9938
  // 分类开关过滤:按 bucketOf 判断该文件属哪一类,再查开关。
9418
- const visibleFiles = group.files.filter(
9939
+ // 后端首次只给每组前 60 张,点「再显示」再追加 60 张。
9940
+ const extra = groupExtras.get(groupKey) ?? []
9941
+ const allFiles = [...(Array.isArray(group.files) ? group.files : []), ...extra]
9942
+ const visibleFiles = allFiles.filter(
9419
9943
  (f) => categoryFilter[bucketOf(f)] !== false)
9420
9944
 
9421
9945
  const chips = []
@@ -9423,8 +9947,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9423
9947
  chips.push(h('span', { className: 'dg-chip dg-chip-final', key: 'f' }, format(t('groupFinal'), { n: group.counts.final })))
9424
9948
  }
9425
9949
  if (group.counts.input > 0) {
9426
- chips.push(h('span', { className: 'dg-chip dg-chip-input', key: 'i' }, format(t('groupInput'), { n: group.counts.input })))
9427
- }
9950
+ chips.push(h('span', { className: 'dg-chip dg-chip-input', key: 'i' }, format(t('groupInput'), { n: group.counts.input })))
9951
+ }
9428
9952
  if (group.counts.intermediate > 0) {
9429
9953
  chips.push(h('span', { className: 'dg-chip dg-chip-intermediate', key: 'm' }, format(t('groupIntermediate'), { n: group.counts.intermediate })))
9430
9954
  }
@@ -9502,6 +10026,42 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9502
10026
  ? h('div', { className: `dg-grid${kind === 'file' ? ' dg-fileGrid' : ''}`, key: 'grid' },
9503
10027
  visibleFiles.map((f) => cardFor(f, headKey, visibleFiles, group)))
9504
10028
  : h('div', { className: 'dg-groupEmpty', key: 'empty' }, t('groupEmpty')),
10029
+ allFiles.length < Number(group.fileCount ?? 0)
10030
+ ? h('button', {
10031
+ type: 'button',
10032
+ className: 'dg-btn dg-groupMore',
10033
+ key: 'more',
10034
+ 'data-gallery-group-more': groupKey,
10035
+ disabled: groupBusy.has(groupKey),
10036
+ onClick: () => {
10037
+ if (groupBusy.has(groupKey)) return
10038
+ setGroupBusy((prev) => new Set(prev).add(groupKey))
10039
+ void callHost('groupMore', {
10040
+ kind, scope: 'global', sessionId, groupKey,
10041
+ offset: allFiles.length, limit: GROUP_PAGE,
10042
+ }).then((r) => {
10043
+ if (r?.ok !== true || !Array.isArray(r.files)) return
10044
+ setGroupExtras((prev) => {
10045
+ const next = new Map(prev)
10046
+ next.set(groupKey, [...(prev.get(groupKey) ?? []), ...r.files])
10047
+ return next
10048
+ })
10049
+ }).catch((error) => {
10050
+ console.warn('dsh-gallery: 再显示失败(不影响已显示的图)', error)
10051
+ }).finally(() => {
10052
+ setGroupBusy((prev) => {
10053
+ const next = new Set(prev)
10054
+ next.delete(groupKey)
10055
+ return next
10056
+ })
10057
+ })
10058
+ },
10059
+ }, format(t('groupShowMore'), {
10060
+ step: Math.min(GROUP_PAGE, Number(group.fileCount ?? 0) - allFiles.length),
10061
+ shown: allFiles.length,
10062
+ total: Number(group.fileCount ?? 0),
10063
+ }))
10064
+ : null,
9505
10065
  group.truncated
9506
10066
  ? h('div', { className: 'dg-groupEmpty', key: 'trunc', style: { marginTop: '8px' } },
9507
10067
  format(t('groupTruncated'), { shown: group.returnedCount, total: group.fileCount }))
@@ -9741,8 +10301,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
9741
10301
  item: mediaPlaying,
9742
10302
  t,
9743
10303
  sessionId: mediaSameAsCurrent ? (sessionId ?? '') : mediaOriginSid,
9744
- sessionTitle: mediaSameAsCurrent && Array.isArray(data?.groups)
9745
- ? (data.groups.find((g) => g.isCurrent)?.title ?? '')
10304
+ sessionTitle: mediaSameAsCurrent && Array.isArray(data?.groups)
10305
+ ? (data.groups.find((g) => g.isCurrent)?.title ?? '')
9746
10306
  : '',
9747
10307
  sessionCreatedAt: mediaSameAsCurrent && Array.isArray(data?.groups)
9748
10308
  ? (data.groups.find((g) => g.isCurrent)?.createdAt ?? 0)
@@ -10336,7 +10896,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10336
10896
  * @param filter - {
10337
10897
  * kind?: 'image'|'file'|'media', scope?: 'global'|'session', sessionId?: string,
10338
10898
  * label?: 'input'|'intermediate'|'final', // 与 category 同义,取生效值(手动标签优先)
10339
- * category?: 同上, confirmed?: boolean, action?: string,
10899
+ * category?: 同上, action?: string,
10340
10900
  * ext?: '.png', q?: string, limit?: number, page?: number
10341
10901
  * }
10342
10902
  * @returns { schema, items, count, total, error? }
@@ -10376,7 +10936,6 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10376
10936
  name: String(it.name ?? relPath.split('/').pop() ?? relPath),
10377
10937
  category: String(it.category ?? 'unknown'),
10378
10938
  categoryManual: it.categoryManual === true,
10379
- confirmed: it.confirmed === true,
10380
10939
  action: String(it.markAction ?? ''),
10381
10940
  ext: String(it.extension ?? ''),
10382
10941
  size: Number(it.size) || 0,
@@ -10403,7 +10962,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
10403
10962
  * 否则 Agent 看一眼就把用户的意见吞了。
10404
10963
  *
10405
10964
  * @returns { schema, items, count, draft }
10406
- * items[i] = { relPath, absolute, action, reason, changeOnly, keep, region, markedAt, category, sessionId, confirmed }
10965
+ * items[i] = { relPath, absolute, action, reason, changeOnly, keep, region, markedAt, category, sessionId }
10407
10966
  * draft = 已渲染好的成稿文本(可直接用,省得自己拼)
10408
10967
  */
10409
10968
  async getPendingFeedback() {