dsh-gallery 0.16.3 → 0.16.6
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/CHANGELOG.md +96 -3
- package/README.md +53 -6
- package/client.js +504 -73
- package/host/feedback.js +138 -0
- package/host/http.js +288 -5
- package/package.json +102 -100
package/client.js
CHANGED
|
@@ -544,8 +544,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
544
544
|
refresh: '刷新',
|
|
545
545
|
preview: '预览',
|
|
546
546
|
previewInSidebar: '在 DSH 右侧栏预览该文件',
|
|
547
|
-
copy: '
|
|
548
|
-
copyPath: '
|
|
547
|
+
copy: '带路径复制',
|
|
548
|
+
copyPath: '复制文件名+绝对路径+关联遮罩(可直接粘进对话框)',
|
|
549
549
|
copied: '已复制',
|
|
550
550
|
openFolder: '打开所在文件夹',
|
|
551
551
|
kindImage: '图片',
|
|
@@ -736,7 +736,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
736
736
|
ctxHide: '隐藏(不再列出)',
|
|
737
737
|
ctxUnhide: '取消隐藏',
|
|
738
738
|
ctxReveal: '打开所在文件夹',
|
|
739
|
-
ctxCopy: '
|
|
739
|
+
ctxCopy: '带路径复制',
|
|
740
740
|
ctxDelete: '删除文件',
|
|
741
741
|
ctxDeleteConfirm: '确认删除?此操作不可恢复',
|
|
742
742
|
ctxDeleteYes: '确认删除',
|
|
@@ -770,6 +770,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
770
770
|
feedbackBasketToggleHint: '打开/关闭反馈篮,可在此生成决策草稿',
|
|
771
771
|
feedbackBasketTitleN: '反馈篮 · {n} 条',
|
|
772
772
|
feedbackBasketEmpty: '还没有可发的条目。在卡片上右键选择动作,或在图片上框选批注,都会进这里。',
|
|
773
|
+
pendingFeedbackBadge: '{n} 条待处理',
|
|
774
|
+
pendingFeedbackBadgeHint: '有 {n} 条反馈还没处理。点这里打开反馈篮;生成草稿或清空后归零。',
|
|
773
775
|
feedbackTargetSession: '将发往会话:{title}',
|
|
774
776
|
feedbackForeignWarn: '有 {n} 条来自其他会话,不能一起提交(请先切到那个会话)。',
|
|
775
777
|
feedbackForeignWarnShort: '含其他会话的条目,已禁用提交',
|
|
@@ -926,8 +928,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
926
928
|
refresh: 'Refresh',
|
|
927
929
|
preview: 'Preview',
|
|
928
930
|
previewInSidebar: 'Preview this file in the DSH sidebar',
|
|
929
|
-
copy: 'Copy path',
|
|
930
|
-
copyPath: 'Copy
|
|
931
|
+
copy: 'Copy with path',
|
|
932
|
+
copyPath: 'Copy file name + absolute path + linked mask (pasteable into chat)',
|
|
931
933
|
copied: 'Copied',
|
|
932
934
|
openFolder: 'Open containing folder',
|
|
933
935
|
kindImage: 'Images',
|
|
@@ -1117,7 +1119,7 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1117
1119
|
ctxHide: 'Hide (stop listing)',
|
|
1118
1120
|
ctxUnhide: 'Unhide',
|
|
1119
1121
|
ctxReveal: 'Open containing folder',
|
|
1120
|
-
ctxCopy: 'Copy path',
|
|
1122
|
+
ctxCopy: 'Copy with path',
|
|
1121
1123
|
ctxDelete: 'Delete file',
|
|
1122
1124
|
ctxDeleteConfirm: 'Delete permanently? This cannot be undone',
|
|
1123
1125
|
ctxDeleteYes: 'Delete',
|
|
@@ -1149,6 +1151,8 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
1149
1151
|
feedbackBasketToggleHint: 'Toggle the feedback basket to generate a draft',
|
|
1150
1152
|
feedbackBasketTitleN: 'Feedback basket · {n} item(s)',
|
|
1151
1153
|
feedbackBasketEmpty: 'Nothing to send yet. Right-click a card for an action, or box an area on an image — both land here.',
|
|
1154
|
+
pendingFeedbackBadge: '{n} pending',
|
|
1155
|
+
pendingFeedbackBadgeHint: '{n} feedback item(s) waiting. Click to open the basket; it clears after you generate a draft or empty it.',
|
|
1152
1156
|
feedbackTargetSession: 'Will be sent to session: {title}',
|
|
1153
1157
|
feedbackForeignWarn: '{n} item(s) belong to another session and cannot be sent together.',
|
|
1154
1158
|
feedbackForeignWarnShort: 'Contains items from another session — submit disabled',
|
|
@@ -2893,6 +2897,24 @@ async function encodeMaskPngBytes(imageData, width, height) {
|
|
|
2893
2897
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
|
|
2894
2898
|
}
|
|
2895
2899
|
.dg-basketToggle[data-gallery-basket-count="0"] { color: #a9b1bd; }
|
|
2900
|
+
/* v0.16.4 · B 档:待处理反馈角标(挂在反馈篮入口旁,点它=打开反馈篮) */
|
|
2901
|
+
.dg-pendingBadge {
|
|
2902
|
+
/* 反馈篮按钮是 fixed right:16px bottom:16px;角标放它正上方,不抢点击 */
|
|
2903
|
+
position: fixed; right: 16px; bottom: 56px; z-index: 45;
|
|
2904
|
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
|
|
2905
|
+
border: 0;
|
|
2906
|
+
border-radius: 999px;
|
|
2907
|
+
padding: 1px 8px;
|
|
2908
|
+
margin-left: 6px;
|
|
2909
|
+
font-size: 11px;
|
|
2910
|
+
line-height: 18px;
|
|
2911
|
+
font-weight: 600;
|
|
2912
|
+
cursor: pointer;
|
|
2913
|
+
color: #7a3d00;
|
|
2914
|
+
background: #ffe1b8;
|
|
2915
|
+
}
|
|
2916
|
+
.dg-pendingBadge:hover { background: #ffd39a; }
|
|
2917
|
+
.dg-pendingBadge:focus-visible { outline: 2px solid #ff9f43; outline-offset: 1px; }
|
|
2896
2918
|
|
|
2897
2919
|
/* ---------- v0.13.7:分类开关 / 确认角标 / 批量 / 删除对话框 ---------- */
|
|
2898
2920
|
|
|
@@ -4039,7 +4061,7 @@ function serializeFeedback(feedback) {
|
|
|
4039
4061
|
*/
|
|
4040
4062
|
function FeedbackBasket({ t, items, currentSessionId, targetSessionTitle,
|
|
4041
4063
|
onClose, onRemove, onEdit, onClear, onEditSave,
|
|
4042
|
-
onRemoveAnnotation, onClearAll }) {
|
|
4064
|
+
onRemoveAnnotation, onClearAll, onAck }) {
|
|
4043
4065
|
// 语言判断:用 t 探测一个已知键 —— 命中中文就按 zh 渲染,否则 en。
|
|
4044
4066
|
// (不引入 detectLocale,插件没有这个工具函数)
|
|
4045
4067
|
const [locale] = React.useState(() => {
|
|
@@ -4122,6 +4144,16 @@ function serializeFeedback(feedback) {
|
|
|
4122
4144
|
? t('feedbackDraftReady')
|
|
4123
4145
|
: t('feedbackDraftInClipboard'),
|
|
4124
4146
|
})
|
|
4147
|
+
/**
|
|
4148
|
+
* v0.16.4:草稿已经写进 composer —— 这批反馈交到人手里了。
|
|
4149
|
+
* 此时才把「待处理」清掉(B 档角标归零)。
|
|
4150
|
+
* 注意:marks / labels 一个都不动,人还能继续看、继续改。
|
|
4151
|
+
*/
|
|
4152
|
+
if (typeof onAck === 'function') {
|
|
4153
|
+
try {
|
|
4154
|
+
await onAck(items.map((it) => it.relPath))
|
|
4155
|
+
} catch { /* ack 失败不影响草稿已经写进去这个事实 */ }
|
|
4156
|
+
}
|
|
4125
4157
|
} else {
|
|
4126
4158
|
setNotice({ kind: 'failed', text: t('feedbackDraftFailed') })
|
|
4127
4159
|
}
|
|
@@ -4130,7 +4162,7 @@ function serializeFeedback(feedback) {
|
|
|
4130
4162
|
} finally {
|
|
4131
4163
|
setBusy(false)
|
|
4132
4164
|
}
|
|
4133
|
-
}, [canSubmit, items, currentSessionId, locale, targetSessionTitle, t])
|
|
4165
|
+
}, [canSubmit, items, currentSessionId, locale, targetSessionTitle, t, onAck])
|
|
4134
4166
|
|
|
4135
4167
|
return h('div', { className: 'dg-feedbackLayer', key: 'feedbackLayer' }, [
|
|
4136
4168
|
h('div', {
|
|
@@ -5354,7 +5386,10 @@ function serializeFeedback(feedback) {
|
|
|
5354
5386
|
|
|
5355
5387
|
const onCopy = async (event) => {
|
|
5356
5388
|
event.stopPropagation()
|
|
5357
|
-
|
|
5389
|
+
// v0.17.0:复制【结构化信息】而不是裸路径 —— 与拖图带的信息同格式,
|
|
5390
|
+
// 粘到对话框里,Agent 一次就拿到 文件名 / 绝对路径 / 主遮罩。
|
|
5391
|
+
const name = dragNameOf(item, absPath)
|
|
5392
|
+
const ok = await copyText(name)
|
|
5358
5393
|
setCopied(ok)
|
|
5359
5394
|
}
|
|
5360
5395
|
const onEye = (event) => {
|
|
@@ -6401,20 +6436,11 @@ ${absPath}
|
|
|
6401
6436
|
},
|
|
6402
6437
|
}, cropActive ? `✂ ${t('cropExit')}` : `✂ ${t('cropEnter')}`)
|
|
6403
6438
|
: null,
|
|
6404
|
-
//
|
|
6405
|
-
//
|
|
6406
|
-
//
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
className: 'dg-btn',
|
|
6410
|
-
key: 'dragAsset',
|
|
6411
|
-
draggable: true,
|
|
6412
|
-
'data-gallery-relpath': item.relPath,
|
|
6413
|
-
'data-gallery-dragviewer': true,
|
|
6414
|
-
title: '拖到对话:附带绝对路径 / 主遮罩 / 填充预览文件名',
|
|
6415
|
-
'aria-label': '拖到对话',
|
|
6416
|
-
onClick: (event) => event.stopPropagation(),
|
|
6417
|
-
}, '⇥ 拖到对话'),
|
|
6439
|
+
// v0.17.0:删掉查看器顶部的「⇥ 拖到对话」按钮。
|
|
6440
|
+
// 原来它存在是因为 Viewer 大图本身 draggable:false + pointerEvents:none
|
|
6441
|
+
// (标注态的中键平移 / 右键多边形都依赖它),需要一个可拖的把手。
|
|
6442
|
+
// 现在:列表卡片本身就能拖(dragstart 拦截照旧,会带绝对路径 / 主遮罩),
|
|
6443
|
+
// 查看器里改用工具条「⧉ 复制」或右键「带路径复制」拿同样信息。
|
|
6418
6444
|
// v0.16.3:Ctrl+C 复制当前文件;按钮是这条快捷键的可见入口(远程控制也能点)
|
|
6419
6445
|
h('button', {
|
|
6420
6446
|
type: 'button',
|
|
@@ -7629,12 +7655,24 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7629
7655
|
* unknown —— 未归类
|
|
7630
7656
|
*/
|
|
7631
7657
|
// v0.14.2:表态层下线,只剩 4 个原生标签(定稿 / 素材 / 过程稿 / 未归类)
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7636
|
-
|
|
7637
|
-
|
|
7658
|
+
/**
|
|
7659
|
+
* v0.16.5:分类显隐**按看板类型分开记**(老板 2026-11-13 报)。
|
|
7660
|
+
*
|
|
7661
|
+
* 原来的坑:一份 categoryFilter 三类共用。在「文件」里关掉过程稿 / 素材
|
|
7662
|
+
* (文件一般只看终稿),切回「图片」时图片的过程稿和素材也跟着没了 ——
|
|
7663
|
+
* 得来回点开关。两类资产的正常看法本来就不同,开关不该互相牵连。
|
|
7664
|
+
*
|
|
7665
|
+
* 现在按 kind 各存一份:image / file / media 互不影响。
|
|
7666
|
+
* 「只记本次使用、不持久化」这条不变 —— 重开面板仍从全显示开始
|
|
7667
|
+
* (用户若忘了自己关过哪一类,会以为文件丢了)。
|
|
7668
|
+
*/
|
|
7669
|
+
const [categoryFilterMap, setCategoryFilterMap] = React.useState(() => ({
|
|
7670
|
+
image: { final: true, input: true, intermediate: true, unknown: true },
|
|
7671
|
+
file: { final: true, input: true, intermediate: true, unknown: true },
|
|
7672
|
+
media: { final: true, input: true, intermediate: true, unknown: true },
|
|
7673
|
+
}))
|
|
7674
|
+
// 取值失败兜底到 image 那份(正常情况三种 kind 都建过桶,走不到这里)
|
|
7675
|
+
const categoryFilter = categoryFilterMap[kind] ?? categoryFilterMap.image
|
|
7638
7676
|
/** 批量选择(v0.13.7):选中的 relPath 集合。清空条件:切 kind / 切 scope / 刷新后失效项自动剔除。 */
|
|
7639
7677
|
const [selected, setSelected] = React.useState(new Set())
|
|
7640
7678
|
/** 批量模式:用户显式开启,或已有选中项时自动生效(避免勾了看不见批量条)。 */
|
|
@@ -7642,10 +7680,72 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7642
7680
|
/**
|
|
7643
7681
|
* 框选批注(v0.14.0):按 relPath 存,一次查看器内可加多条。
|
|
7644
7682
|
*
|
|
7645
|
-
*
|
|
7646
|
-
*
|
|
7683
|
+
* v0.16.4 起批注会写进「待处理反馈」落盘(A 档要 Agent 拉得到)。
|
|
7684
|
+
* v0.16.5 修:同一张图的多条批注**必须整组写**——
|
|
7685
|
+
* 原来每加一条就写一条 item,而 feedback.json 的键是 relPath,
|
|
7686
|
+
* 后写的把先写的覆盖掉,一张图框三处只剩最后一条。
|
|
7687
|
+
* 现在每次写「该图的完整批注数组」,Host 侧再展开成多条。
|
|
7688
|
+
*
|
|
7689
|
+
* 🔴 为什么必须有 ref:setAnnotations 的 updater 是异步的,
|
|
7690
|
+
* 写完马上要拿「加上这一条之后」的完整数组去落盘,读 state 会读到旧值。
|
|
7647
7691
|
*/
|
|
7648
7692
|
const [annotations, setAnnotations] = React.useState({})
|
|
7693
|
+
const annotationsRef = React.useRef({})
|
|
7694
|
+
/**
|
|
7695
|
+
* recordPendingFeedback 定义在本段之后,但批注落盘要用它。
|
|
7696
|
+
* 用 ref 转一手,避免「先声明后使用」的顺序倒挂(TDZ)。
|
|
7697
|
+
*/
|
|
7698
|
+
const recordPendingFeedbackRef = React.useRef(null)
|
|
7699
|
+
/** 批注的落盘形态:只留坐标与说明,id / markedAt 用于前端对号。 */
|
|
7700
|
+
const toStoredAnnot = React.useCallback((a) => ({
|
|
7701
|
+
id: String(a?.id ?? ''),
|
|
7702
|
+
note: typeof a?.note === 'string' ? a.note : '',
|
|
7703
|
+
region: {
|
|
7704
|
+
x: Number(a?.x) || 0,
|
|
7705
|
+
y: Number(a?.y) || 0,
|
|
7706
|
+
w: Number(a?.w) || 0,
|
|
7707
|
+
h: Number(a?.h) || 0,
|
|
7708
|
+
},
|
|
7709
|
+
markedAt: Number(a?.createdAt) || Date.now(),
|
|
7710
|
+
}), [])
|
|
7711
|
+
/** 某图当前批注的落盘形态(没有就返回空数组)。 */
|
|
7712
|
+
const storedAnnotsFor = React.useCallback((relPath) => {
|
|
7713
|
+
const list = annotationsRef.current?.[relPath]
|
|
7714
|
+
return Array.isArray(list) ? list.map(toStoredAnnot) : []
|
|
7715
|
+
}, [toStoredAnnot])
|
|
7716
|
+
/**
|
|
7717
|
+
* 同一条 relPath 上的批注写入「待处理」。
|
|
7718
|
+
*
|
|
7719
|
+
* action 语义:
|
|
7720
|
+
* · 该图还没有别的判定 → 'annotate'(按框选区域改)
|
|
7721
|
+
* · 该图已经有一条非 annotate 的判定(比如「交付不合格」)→ 保留原 action
|
|
7722
|
+
* 草稿里 mark 行与批注行本来就会各占一行,落盘这边也不能把前者冲掉。
|
|
7723
|
+
*/
|
|
7724
|
+
const writePendingAnnotations = React.useCallback((relPath, list, meta) => {
|
|
7725
|
+
// ref 在渲染期挂载;理论上此时必然就绪,兜一手避免极端时序下抛错
|
|
7726
|
+
const fire = recordPendingFeedbackRef.current
|
|
7727
|
+
if (typeof fire !== 'function') return
|
|
7728
|
+
const annots = Array.isArray(list) ? list.map(toStoredAnnot) : []
|
|
7729
|
+
if (annots.length === 0) {
|
|
7730
|
+
void fire([{ path: relPath, item: null }])
|
|
7731
|
+
return
|
|
7732
|
+
}
|
|
7733
|
+
const prevAction = meta?.action ?? ''
|
|
7734
|
+
const keepAction = prevAction !== '' && prevAction !== 'annotate'
|
|
7735
|
+
void fire([{
|
|
7736
|
+
path: relPath,
|
|
7737
|
+
item: {
|
|
7738
|
+
...(keepAction ? { action: prevAction } : { action: 'annotate' }),
|
|
7739
|
+
...(keepAction && meta?.reason ? { reason: meta.reason } : {}),
|
|
7740
|
+
// 兼容旧读法:顶层 region 仍放最后一条,只读 region 的老逻辑不会空
|
|
7741
|
+
region: annots[annots.length - 1].region,
|
|
7742
|
+
annotations: annots,
|
|
7743
|
+
category: meta?.category ?? 'unknown',
|
|
7744
|
+
sessionId: meta?.sessionId ?? '',
|
|
7745
|
+
markedAt: Date.now(),
|
|
7746
|
+
},
|
|
7747
|
+
}])
|
|
7748
|
+
}, [toStoredAnnot])
|
|
7649
7749
|
/**
|
|
7650
7750
|
* 遮罩「原图 → 资产」的内存兜底(v0.14.5):导出成功后立刻登记,
|
|
7651
7751
|
* 不用等列表重扫 / 翻页,反馈草稿马上就能带出遮罩路径。刷新后由扫描侧
|
|
@@ -7678,6 +7778,16 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7678
7778
|
const [labelDialog, setLabelDialog] = React.useState(null)
|
|
7679
7779
|
// 反馈篮是否打开
|
|
7680
7780
|
const [basketOpen, setBasketOpen] = React.useState(false)
|
|
7781
|
+
/**
|
|
7782
|
+
* v0.16.4 · 待处理反馈条数(B 档角标)。
|
|
7783
|
+
*
|
|
7784
|
+
* 注意与 markedCount 的区别:
|
|
7785
|
+
* · markedCount = 反馈篮里现在有几条(来自 marks ∪ annotations,**持久状态**)
|
|
7786
|
+
* · pendingCount = 自上次「处理完」以来有几条新判定(**一次性消息**)
|
|
7787
|
+
* 人生成草稿 / 清空篮子后 pendingCount 归零,marks 保留 ——
|
|
7788
|
+
* 两者混同就会重演「删一条反馈把定好的标签也撤了」的错。
|
|
7789
|
+
*/
|
|
7790
|
+
const [pendingCount, setPendingCount] = React.useState(0)
|
|
7681
7791
|
// 编辑中的条目(null 表示不编辑)
|
|
7682
7792
|
const [editingItem, setEditingItem] = React.useState(null)
|
|
7683
7793
|
// 网格滚动位置:打开查看器前记录,关闭后恢复,让视图停在原缩略图处
|
|
@@ -7699,6 +7809,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7699
7809
|
if (payload?.labels !== null && typeof payload?.labels === 'object') setLabels(payload.labels)
|
|
7700
7810
|
})
|
|
7701
7811
|
.catch((error) => console.warn('dsh-gallery: getLabels 失败', error))
|
|
7812
|
+
// v0.16.4 · B 档:台面打开时读一次待处理条数(纯读,不标记已读)
|
|
7813
|
+
callHost('getPendingFeedback', {})
|
|
7814
|
+
.then((payload) => {
|
|
7815
|
+
if (!alive || payload?.ok === false) return
|
|
7816
|
+
setPendingCount(Number.isFinite(payload?.count) ? payload.count : 0)
|
|
7817
|
+
})
|
|
7818
|
+
.catch((error) => console.warn('dsh-gallery: getPendingFeedback 失败', error))
|
|
7702
7819
|
return () => { alive = false }
|
|
7703
7820
|
}, [])
|
|
7704
7821
|
|
|
@@ -7717,10 +7834,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7717
7834
|
return 'unknown'
|
|
7718
7835
|
}, [])
|
|
7719
7836
|
|
|
7720
|
-
/**
|
|
7837
|
+
/** 切一个分类的显隐(v0.16.5:只作用于当前看板类型,三类各记各的)。 */
|
|
7721
7838
|
const toggleCategory = React.useCallback((key) => {
|
|
7722
|
-
|
|
7723
|
-
|
|
7839
|
+
setCategoryFilterMap((prev) => {
|
|
7840
|
+
const cur = prev[kind] ?? prev.image
|
|
7841
|
+
return { ...prev, [kind]: { ...cur, [key]: !cur[key] } }
|
|
7842
|
+
})
|
|
7843
|
+
}, [kind])
|
|
7724
7844
|
|
|
7725
7845
|
/** 批量选择切换。 */
|
|
7726
7846
|
const toggleSelect = React.useCallback((relPath) => {
|
|
@@ -7750,6 +7870,64 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7750
7870
|
setLabelDialog({ item: first ?? null, paths, category: first?.category ?? 'unknown' })
|
|
7751
7871
|
}, [selected])
|
|
7752
7872
|
|
|
7873
|
+
/**
|
|
7874
|
+
* 取某资产归属的会话 id(全局分组视图里组才有 sessionId,扁平列表没有)。
|
|
7875
|
+
*
|
|
7876
|
+
* ⚠️ 依赖只能用 `view`,**不能用 `data`**:`data` 在本组件后半段才声明,
|
|
7877
|
+
* 而依赖数组是渲染时立即求值的 —— 写 `[data, sessionId]` 会直接
|
|
7878
|
+
* `Cannot access 'data' before initialization`(渲染冒烟当场炸)。
|
|
7879
|
+
*/
|
|
7880
|
+
const sessionIdOfPath = React.useCallback((relPath) => {
|
|
7881
|
+
const groups = (view.status === 'ready' && Array.isArray(view.data?.groups))
|
|
7882
|
+
? view.data.groups
|
|
7883
|
+
: []
|
|
7884
|
+
for (const g of groups) {
|
|
7885
|
+
if (Array.isArray(g.files) && g.files.some((f) => f.relPath === relPath)) {
|
|
7886
|
+
return String(g.sessionId ?? '')
|
|
7887
|
+
}
|
|
7888
|
+
}
|
|
7889
|
+
return String(sessionId ?? '')
|
|
7890
|
+
}, [view, sessionId])
|
|
7891
|
+
|
|
7892
|
+
/**
|
|
7893
|
+
* v0.16.4 · A 档地基:把「人对资产的判定」镜像进待处理反馈。
|
|
7894
|
+
*
|
|
7895
|
+
* 为什么不复用 marks 当数据源:marks 是**持久状态**(改过就一直生效),
|
|
7896
|
+
* 而待处理反馈是**一次性消息**(人处理完就该消失)。Agent 要拉的是后者 ——
|
|
7897
|
+
* 「有新意见待处理」和「这张图当前是什么状态」是两件事。
|
|
7898
|
+
*
|
|
7899
|
+
* 全程只写反馈文件,不发送、不注入、不碰 composer。
|
|
7900
|
+
*
|
|
7901
|
+
* @param updates - [{ path, item }],item 传 null 表示从待处理里摘掉该条
|
|
7902
|
+
*/
|
|
7903
|
+
const recordPendingFeedback = React.useCallback(async (updates) => {
|
|
7904
|
+
if (!Array.isArray(updates) || updates.length === 0) return
|
|
7905
|
+
try {
|
|
7906
|
+
const res = await callHost('setFeedbackBatch', { updates })
|
|
7907
|
+
if (res?.ok === false) throw new Error(res?.error?.message ?? 'setFeedbackBatch failed')
|
|
7908
|
+
if (Number.isFinite(res?.count)) setPendingCount(res.count)
|
|
7909
|
+
} catch (error) {
|
|
7910
|
+
// 落盘失败不能拦住主流程(标签/标记已经写成功了),但要留下线索
|
|
7911
|
+
console.warn('dsh-gallery: 待处理反馈落盘失败', error)
|
|
7912
|
+
}
|
|
7913
|
+
}, [])
|
|
7914
|
+
// 批注落盘那段(定义在本函数之前)要转一手调用,这里把最新引用挂上去
|
|
7915
|
+
recordPendingFeedbackRef.current = recordPendingFeedback
|
|
7916
|
+
|
|
7917
|
+
/**
|
|
7918
|
+
* v0.16.4:人已经处理完这批反馈(草稿进 composer / 清空篮子)→ 从待处理里移除。
|
|
7919
|
+
* **只有人能触发这个**;Agent 拉取(getPendingFeedback)绝不走这里。
|
|
7920
|
+
*/
|
|
7921
|
+
const ackPending = React.useCallback(async (paths) => {
|
|
7922
|
+
try {
|
|
7923
|
+
const res = await callHost('ackFeedback', { paths: Array.isArray(paths) ? paths : [] })
|
|
7924
|
+
if (res?.ok === false) throw new Error(res?.error?.message ?? 'ackFeedback failed')
|
|
7925
|
+
if (Number.isFinite(res?.count)) setPendingCount(res.count)
|
|
7926
|
+
} catch (error) {
|
|
7927
|
+
console.warn('dsh-gallery: 确认待处理反馈失败', error)
|
|
7928
|
+
}
|
|
7929
|
+
}, [])
|
|
7930
|
+
|
|
7753
7931
|
/**
|
|
7754
7932
|
* 手动改标签的主逻辑(v0.14.2)。
|
|
7755
7933
|
*
|
|
@@ -7821,6 +7999,21 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7821
7999
|
const mp = await callHost('marksBatch', { updates: markUpdates })
|
|
7822
8000
|
if (mp?.ok === false) throw new Error(mp?.error?.message ?? t('errorTitle'))
|
|
7823
8001
|
if (mp?.marks !== undefined) setMarks(mp.marks)
|
|
8002
|
+
// v0.16.4 · A 档:这些判定进「待处理」(一次性),Agent 才拉得到。
|
|
8003
|
+
// 注意仍**不发送** —— 发送永远由人在反馈篮里点。
|
|
8004
|
+
await recordPendingFeedback(markUpdates.map((u) => ({
|
|
8005
|
+
path: u.path,
|
|
8006
|
+
item: {
|
|
8007
|
+
action: u.mark.action,
|
|
8008
|
+
...(u.mark.reason !== undefined ? { reason: u.mark.reason } : {}),
|
|
8009
|
+
// v0.16.5:这张图上已有的框选批注要一起带上,
|
|
8010
|
+
// 否则「先框两处、再改标签」会把批注从待处理里冲掉
|
|
8011
|
+
...(storedAnnotsFor(u.path).length > 0 ? { annotations: storedAnnotsFor(u.path) } : {}),
|
|
8012
|
+
category: u.mark.category ?? 'unknown',
|
|
8013
|
+
sessionId: sessionIdOfPath(u.path),
|
|
8014
|
+
markedAt: u.mark.markedAt ?? Date.now(),
|
|
8015
|
+
},
|
|
8016
|
+
})))
|
|
7824
8017
|
}
|
|
7825
8018
|
} catch (error) {
|
|
7826
8019
|
console.warn('dsh-gallery: 改标签落盘失败', error)
|
|
@@ -7830,7 +8023,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7830
8023
|
setBatchMode(false)
|
|
7831
8024
|
// refresh 定义在本函数之后:不放进依赖数组,实际调用时早已初始化
|
|
7832
8025
|
void refresh()
|
|
7833
|
-
}, [labelDialog, t])
|
|
8026
|
+
}, [labelDialog, t, recordPendingFeedback, sessionIdOfPath, storedAnnotsFor])
|
|
7834
8027
|
|
|
7835
8028
|
/**
|
|
7836
8029
|
* 更新一条标记的附加字段(理由 / 只改 / 锁死)。
|
|
@@ -7850,8 +8043,23 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7850
8043
|
} catch (error) {
|
|
7851
8044
|
console.warn('dsh-gallery: 更新标记失败', error)
|
|
7852
8045
|
}
|
|
8046
|
+
// v0.16.4 · A 档:编辑理由/只改/锁死也算一次新判定 → 刷新待处理里的那份
|
|
8047
|
+
await recordPendingFeedback([{
|
|
8048
|
+
path: relPath,
|
|
8049
|
+
item: {
|
|
8050
|
+
action: nextMark.action,
|
|
8051
|
+
...(nextMark.reason !== undefined ? { reason: nextMark.reason } : {}),
|
|
8052
|
+
...(Array.isArray(nextMark.changeOnly) && nextMark.changeOnly.length > 0 ? { changeOnly: nextMark.changeOnly } : {}),
|
|
8053
|
+
...(Array.isArray(nextMark.keep) && nextMark.keep.length > 0 ? { keep: nextMark.keep } : {}),
|
|
8054
|
+
// v0.16.5:编辑判定时把这张图上的批注一起带上,别冲掉
|
|
8055
|
+
...(storedAnnotsFor(relPath).length > 0 ? { annotations: storedAnnotsFor(relPath) } : {}),
|
|
8056
|
+
category: nextMark.category ?? 'unknown',
|
|
8057
|
+
sessionId: sessionIdOfPath(relPath),
|
|
8058
|
+
markedAt: nextMark.markedAt ?? Date.now(),
|
|
8059
|
+
},
|
|
8060
|
+
}])
|
|
7853
8061
|
}
|
|
7854
|
-
}, [])
|
|
8062
|
+
}, [recordPendingFeedback, sessionIdOfPath, storedAnnotsFor])
|
|
7855
8063
|
|
|
7856
8064
|
/** 恢复自动判定:只删 labels 覆写,不动反馈篮里的任何条目。 */
|
|
7857
8065
|
const resetLabels = React.useCallback(async () => {
|
|
@@ -7877,40 +8085,86 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7877
8085
|
// v0.14.2:表态层的「确认 / 取消确认 / 单张表态」回调已整体移除,
|
|
7878
8086
|
// 人的判断现在直接落在标签上(labels 覆写),表达走反馈篮。
|
|
7879
8087
|
|
|
7880
|
-
/** 加一条批注(v0.14.0)。 */
|
|
8088
|
+
/** 加一条批注(v0.14.0)。v0.16.5:整组写盘,不再一条覆盖一条。 */
|
|
7881
8089
|
const addAnnotation = React.useCallback((item, annot) => {
|
|
7882
8090
|
const relPath = item.relPath
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
8091
|
+
const cur = annotationsRef.current[relPath] ?? []
|
|
8092
|
+
if (cur.length >= 50) return // 与契约上限一致
|
|
8093
|
+
const next = [...cur, annot]
|
|
8094
|
+
const nextAll = { ...annotationsRef.current, [relPath]: next }
|
|
8095
|
+
// 先同步 ref 再 setState:落盘要读「加上这一条之后」的完整数组
|
|
8096
|
+
annotationsRef.current = nextAll
|
|
8097
|
+
setAnnotations(nextAll)
|
|
8098
|
+
// v0.16.4 · A 档:框选批注同样是判定 → 进待处理。
|
|
8099
|
+
// v0.16.5:整组写,Agent 才拿得到同一张图上的每一处;
|
|
8100
|
+
// 若该图已有非批注判定(如「交付不合格」),保留那条 action 不被冲掉。
|
|
8101
|
+
const existing = marks[relPath]
|
|
8102
|
+
writePendingAnnotations(relPath, next, {
|
|
8103
|
+
category: item.category ?? 'unknown',
|
|
8104
|
+
sessionId: sessionIdOfPath(relPath),
|
|
8105
|
+
action: existing?.action ?? '',
|
|
8106
|
+
reason: existing?.reason ?? '',
|
|
7887
8107
|
})
|
|
7888
|
-
}, [])
|
|
8108
|
+
}, [marks, sessionIdOfPath, writePendingAnnotations])
|
|
7889
8109
|
|
|
7890
|
-
/** 删一条批注。 */
|
|
8110
|
+
/** 删一条批注。v0.16.5:删完把剩下的整组回写,别让待处理里留着已删的那条。 */
|
|
7891
8111
|
const removeAnnotation = React.useCallback((item, id) => {
|
|
7892
8112
|
const relPath = item.relPath
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
|
|
7901
|
-
|
|
8113
|
+
const cur = annotationsRef.current[relPath] ?? []
|
|
8114
|
+
const next = cur.filter((a) => a.id !== id)
|
|
8115
|
+
const nextAll = { ...annotationsRef.current }
|
|
8116
|
+
if (next.length === 0) delete nextAll[relPath]
|
|
8117
|
+
else nextAll[relPath] = next
|
|
8118
|
+
annotationsRef.current = nextAll
|
|
8119
|
+
setAnnotations(nextAll)
|
|
8120
|
+
if (next.length === 0) {
|
|
8121
|
+
void recordPendingFeedback([{ path: relPath, item: null }])
|
|
8122
|
+
} else {
|
|
8123
|
+
writePendingAnnotations(relPath, next, {
|
|
8124
|
+
category: item?.category ?? 'unknown',
|
|
8125
|
+
sessionId: sessionIdOfPath(relPath),
|
|
8126
|
+
action: marks[relPath]?.action ?? '',
|
|
8127
|
+
reason: marks[relPath]?.reason ?? '',
|
|
8128
|
+
})
|
|
8129
|
+
}
|
|
8130
|
+
}, [marks, recordPendingFeedback, sessionIdOfPath, writePendingAnnotations])
|
|
7902
8131
|
|
|
7903
8132
|
/** 删一条批注(按 relPath,反馈篮用;查看器走带 item 的那个)。 */
|
|
7904
8133
|
const removeAnnotationById = React.useCallback((relPath, id) => {
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
8134
|
+
const cur = annotationsRef.current[relPath] ?? []
|
|
8135
|
+
const next = cur.filter((a) => a.id !== id)
|
|
8136
|
+
const nextAll = { ...annotationsRef.current }
|
|
8137
|
+
if (next.length === 0) delete nextAll[relPath]
|
|
8138
|
+
else nextAll[relPath] = next
|
|
8139
|
+
annotationsRef.current = nextAll
|
|
8140
|
+
setAnnotations(nextAll)
|
|
8141
|
+
if (next.length === 0) {
|
|
8142
|
+
// 批注清空了,但若这张图还有标记判定,判定本身要留着
|
|
8143
|
+
const m = marks[relPath]
|
|
8144
|
+
if (m === undefined) void recordPendingFeedback([{ path: relPath, item: null }])
|
|
8145
|
+
else {
|
|
8146
|
+
void recordPendingFeedback([{
|
|
8147
|
+
path: relPath,
|
|
8148
|
+
item: {
|
|
8149
|
+
action: m.action,
|
|
8150
|
+
...(m.reason !== undefined ? { reason: m.reason } : {}),
|
|
8151
|
+
...(Array.isArray(m.changeOnly) && m.changeOnly.length > 0 ? { changeOnly: m.changeOnly } : {}),
|
|
8152
|
+
...(Array.isArray(m.keep) && m.keep.length > 0 ? { keep: m.keep } : {}),
|
|
8153
|
+
category: m.category ?? 'unknown',
|
|
8154
|
+
sessionId: sessionIdOfPath(relPath),
|
|
8155
|
+
markedAt: m.markedAt ?? Date.now(),
|
|
8156
|
+
},
|
|
8157
|
+
}])
|
|
8158
|
+
}
|
|
8159
|
+
} else {
|
|
8160
|
+
writePendingAnnotations(relPath, next, {
|
|
8161
|
+
category: 'unknown',
|
|
8162
|
+
sessionId: sessionIdOfPath(relPath),
|
|
8163
|
+
action: marks[relPath]?.action ?? '',
|
|
8164
|
+
reason: marks[relPath]?.reason ?? '',
|
|
8165
|
+
})
|
|
8166
|
+
}
|
|
8167
|
+
}, [marks, recordPendingFeedback, sessionIdOfPath, writePendingAnnotations])
|
|
7914
8168
|
|
|
7915
8169
|
/** 取某文件的批注列表(给查看器用)。 */
|
|
7916
8170
|
const annotationsOf = React.useCallback((item) => {
|
|
@@ -7929,7 +8183,20 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7929
8183
|
} catch (error) {
|
|
7930
8184
|
console.warn('dsh-gallery: 清除标记失败', error)
|
|
7931
8185
|
}
|
|
7932
|
-
|
|
8186
|
+
// v0.16.4:人主动撤掉一条 → 它也一并从「待处理」里摘掉。
|
|
8187
|
+
// v0.16.5:只摘「标记」,别连坐这张图上的批注 —— 撤掉判定不等于把框选说明也删了。
|
|
8188
|
+
const leftAnnots = annotationsRef.current[relPath] ?? []
|
|
8189
|
+
if (leftAnnots.length > 0) {
|
|
8190
|
+
writePendingAnnotations(relPath, leftAnnots, {
|
|
8191
|
+
category: 'unknown',
|
|
8192
|
+
sessionId: sessionIdOfPath(relPath),
|
|
8193
|
+
action: '',
|
|
8194
|
+
reason: '',
|
|
8195
|
+
})
|
|
8196
|
+
} else {
|
|
8197
|
+
await recordPendingFeedback([{ path: relPath, item: null }])
|
|
8198
|
+
}
|
|
8199
|
+
}, [recordPendingFeedback, sessionIdOfPath, writePendingAnnotations])
|
|
7933
8200
|
|
|
7934
8201
|
/** 清空全部标记。 */
|
|
7935
8202
|
const clearMarks = React.useCallback(async () => {
|
|
@@ -7938,6 +8205,17 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7938
8205
|
for (const relPath of paths) {
|
|
7939
8206
|
try { await callHost('marks', { path: relPath, mark: null }) } catch { /* 忽略单条失败 */ }
|
|
7940
8207
|
}
|
|
8208
|
+
/**
|
|
8209
|
+
* v0.16.4:人点「清空反馈篮」= 明确表示这批已经处理完。
|
|
8210
|
+
* 待处理反馈一并清掉(不传 paths 即清空全部);
|
|
8211
|
+
* 手动标签 labels 不动 —— 那是持久状态,与「有没有待办」无关。
|
|
8212
|
+
*/
|
|
8213
|
+
try {
|
|
8214
|
+
await callHost('ackFeedback', {})
|
|
8215
|
+
setPendingCount(0)
|
|
8216
|
+
} catch (error) {
|
|
8217
|
+
console.warn('dsh-gallery: 清空待处理反馈失败', error)
|
|
8218
|
+
}
|
|
7941
8219
|
}, [marks])
|
|
7942
8220
|
|
|
7943
8221
|
/** 打开右键菜单。 */
|
|
@@ -7946,7 +8224,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7946
8224
|
lastContextRelPath.current = item.relPath
|
|
7947
8225
|
setCtxMenu({
|
|
7948
8226
|
item,
|
|
7949
|
-
absPath: absPath ??
|
|
8227
|
+
absPath: absPath ?? (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
8228
|
+
? item.absPath
|
|
8229
|
+
: buildAbsPath(view.status === 'ready' ? view.data.root : '', item.relPath)),
|
|
7950
8230
|
x: event.clientX,
|
|
7951
8231
|
y: event.clientY,
|
|
7952
8232
|
})
|
|
@@ -7975,12 +8255,21 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
7975
8255
|
}
|
|
7976
8256
|
}
|
|
7977
8257
|
// 只保留查看器需要的字段,避免把整个分组对象塞进 state
|
|
8258
|
+
//
|
|
8259
|
+
// 🔴 这个白名单是「查看器能拿到什么」的唯一来源:字段没进来,
|
|
8260
|
+
// 下游就永远是 undefined。v0.16.4 踩过 —— 批注落盘要写 category,
|
|
8261
|
+
// 而这里没带,结果 `item.category ?? 'unknown'` 一路兜底成 unknown,
|
|
8262
|
+
// 磁盘上两条裁剪批注的分类全丢了(登记里明明是 input)。
|
|
8263
|
+
// 以后要给批注 / 遮罩加字段,先加到这里。
|
|
7978
8264
|
const snapshot = list.map((it) => ({
|
|
7979
8265
|
relPath: it.relPath,
|
|
7980
8266
|
name: it.name ?? it.relPath.split('/').pop(),
|
|
7981
8267
|
extension: it.extension ?? ('.' + (it.relPath.split('.').pop() || '')),
|
|
7982
8268
|
width: it.width ?? null,
|
|
7983
8269
|
height: it.height ?? null,
|
|
8270
|
+
// v0.16.4:分类(素材 / 过程稿 / 定稿),批注落盘与草稿都要用
|
|
8271
|
+
category: it.category ?? 'unknown',
|
|
8272
|
+
categoryManual: it.categoryManual === true,
|
|
7984
8273
|
}))
|
|
7985
8274
|
// v0.16.2:记住这张图属于哪个对话组 —— 裁剪产物要跟着来源组落盘,
|
|
7986
8275
|
// 不能一律塞进当前对话(否则在历史对话的图上裁剪,产物跑到别的对话)。
|
|
@@ -8406,7 +8695,13 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8406
8695
|
}
|
|
8407
8696
|
const rel = String(it?.relPath ?? '')
|
|
8408
8697
|
if (rel !== '' && !dragAssetIndex.has(rel)) {
|
|
8409
|
-
|
|
8698
|
+
// v0.17.0:优先用 Host 下发的 absPath —— Host 用 rootOfAbs 按文件真实落盘位置
|
|
8699
|
+
// 算,是权威值。原来用 buildAbsPath(root, rel) 拿【第一个 root】去拼,
|
|
8700
|
+
// 文件在别的 root 下时拼出的是不存在的路径(实测三次都踩)。
|
|
8701
|
+
const realAbs = (typeof it?.absPath === 'string' && it.absPath !== '')
|
|
8702
|
+
? it.absPath
|
|
8703
|
+
: buildAbsPath(root, rel)
|
|
8704
|
+
dragAssetIndex.set(rel, { item: it, absPath: realAbs })
|
|
8410
8705
|
}
|
|
8411
8706
|
}
|
|
8412
8707
|
if (Array.isArray(data.items)) data.items.forEach(put)
|
|
@@ -8557,6 +8852,27 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8557
8852
|
? format(t('feedbackBasketToggleN'), { n: markedCount })
|
|
8558
8853
|
: t('feedbackBasketToggle'))
|
|
8559
8854
|
|
|
8855
|
+
/**
|
|
8856
|
+
* v0.16.4 · B 档:待处理反馈角标。
|
|
8857
|
+
*
|
|
8858
|
+
* 为什么要和上面那个「反馈篮 · N 条」并存:
|
|
8859
|
+
* · 按钮上的 N = 篮子里现在有几条(持久)
|
|
8860
|
+
* · 角标上的 N = 自上次处理完以来有几条新判定(一次性)
|
|
8861
|
+
* 人做完一轮后按钮还显示条数(标记还在),但角标归零 —— 表示「没有待办了」。
|
|
8862
|
+
* 点角标 = 打开反馈篮,**不会**自动拉给 Agent。
|
|
8863
|
+
*/
|
|
8864
|
+
const pendingBadge = pendingCount > 0
|
|
8865
|
+
? h('button', {
|
|
8866
|
+
type: 'button',
|
|
8867
|
+
className: 'dg-pendingBadge',
|
|
8868
|
+
key: 'pendingBadge',
|
|
8869
|
+
'data-gallery-pending-count': pendingCount,
|
|
8870
|
+
title: format(t('pendingFeedbackBadgeHint'), { n: pendingCount }),
|
|
8871
|
+
'aria-label': format(t('pendingFeedbackBadgeHint'), { n: pendingCount }),
|
|
8872
|
+
onClick: () => setBasketOpen(true),
|
|
8873
|
+
}, format(t('pendingFeedbackBadge'), { n: pendingCount }))
|
|
8874
|
+
: null
|
|
8875
|
+
|
|
8560
8876
|
/**
|
|
8561
8877
|
* 各分类的全局计数(供顶部开关显示数字 + 判断「已显示 N / 共 M」)。
|
|
8562
8878
|
* v0.13.7:确认态计数来自 marks,不来自自动分类。
|
|
@@ -8899,7 +9215,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8899
9215
|
?? (VIDEO_EXTS.includes(String(enriched.extension ?? '').toLowerCase()) ? 'video' : 'audio'),
|
|
8900
9216
|
},
|
|
8901
9217
|
t,
|
|
8902
|
-
absPath:
|
|
9218
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9219
|
+
? item.absPath
|
|
9220
|
+
: buildAbsPath(data.root, item.relPath)),
|
|
8903
9221
|
// v0.16.2:选段产物跟来源组走(groupKey 就是该组 sessionId)
|
|
8904
9222
|
onPlay: (target) => setMediaPlaying({ ...target, originSessionId: groupKey }),
|
|
8905
9223
|
onContextMenu: openContextMenu,
|
|
@@ -8910,7 +9228,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8910
9228
|
key: `${groupKey}:${item.relPath}`,
|
|
8911
9229
|
item: enriched,
|
|
8912
9230
|
t,
|
|
8913
|
-
absPath:
|
|
9231
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9232
|
+
? item.absPath
|
|
9233
|
+
: buildAbsPath(data.root, item.relPath)),
|
|
8914
9234
|
onOpenFolder: () => { void callHost('reveal', { path: item.relPath }).catch((e) => console.error('dsh-gallery: reveal 失败', e)) },
|
|
8915
9235
|
onContextMenu: openContextMenu,
|
|
8916
9236
|
onPreview: (abs) => {
|
|
@@ -8922,7 +9242,8 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
8922
9242
|
void copyText(abs)
|
|
8923
9243
|
}
|
|
8924
9244
|
},
|
|
8925
|
-
|
|
9245
|
+
// v0.17.0:同右键菜单,复制结构化信息(文件名 + 绝对路径 + 关联遮罩)
|
|
9246
|
+
onCopy: (abs) => { void copyText(dragNameOf(item, abs)) },
|
|
8926
9247
|
}), item, `${groupKey}:${item.relPath}`)
|
|
8927
9248
|
}
|
|
8928
9249
|
return wrapCard(h(Card, {
|
|
@@ -9088,7 +9409,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9088
9409
|
item,
|
|
9089
9410
|
t,
|
|
9090
9411
|
limiter: limiter.current,
|
|
9091
|
-
absPath:
|
|
9412
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9413
|
+
? item.absPath
|
|
9414
|
+
: buildAbsPath(data === null ? '' : data.root, item.relPath)),
|
|
9092
9415
|
onPlay: (target) => setMediaPlaying(target),
|
|
9093
9416
|
onContextMenu: openContextMenu,
|
|
9094
9417
|
}), item, item.relPath))
|
|
@@ -9098,7 +9421,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9098
9421
|
key: item.relPath,
|
|
9099
9422
|
item,
|
|
9100
9423
|
t,
|
|
9101
|
-
absPath:
|
|
9424
|
+
absPath: (typeof item?.absPath === 'string' && item.absPath !== ''
|
|
9425
|
+
? item.absPath
|
|
9426
|
+
: buildAbsPath(data.root, item.relPath)),
|
|
9102
9427
|
onOpenFolder: (abs) => { void callHost('reveal', { path: item.relPath }).catch((e) => console.error('dsh-gallery: reveal 失败', e)) },
|
|
9103
9428
|
onContextMenu: openContextMenu,
|
|
9104
9429
|
onPreview: (abs) => {
|
|
@@ -9370,7 +9695,14 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9370
9695
|
// 批注:属于反馈侧,删一条只动内存,不碰 marks
|
|
9371
9696
|
onRemoveAnnotation: (relPath, annotId) => { removeAnnotationById(relPath, annotId) },
|
|
9372
9697
|
// 「清空反馈篮」= 表态 + 批注一起清,否则批注留在图上、篮子却空了
|
|
9373
|
-
onClearAll: () => {
|
|
9698
|
+
onClearAll: () => {
|
|
9699
|
+
// ref 与 state 必须一起清:ref 是落盘读的那份,漏了就会把已清空的批注又写回去
|
|
9700
|
+
annotationsRef.current = {}
|
|
9701
|
+
void clearMarks()
|
|
9702
|
+
setAnnotations({})
|
|
9703
|
+
},
|
|
9704
|
+
// v0.16.4:草稿进 composer 后把待处理清零(人已处理完这批)
|
|
9705
|
+
onAck: (paths) => { void ackPending(paths) },
|
|
9374
9706
|
})
|
|
9375
9707
|
: null
|
|
9376
9708
|
|
|
@@ -9407,7 +9739,9 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9407
9739
|
: undefined,
|
|
9408
9740
|
onHide: () => { void doHide(ctxMenu.item) },
|
|
9409
9741
|
onReveal: () => { void doReveal(ctxMenu.item) },
|
|
9410
|
-
|
|
9742
|
+
// v0.17.0:复制【结构化信息】而不是裸路径 —— 与拖图带的信息同格式,
|
|
9743
|
+
// 粘到对话框里,Agent 一次就拿到 文件名 / 绝对路径 / 主遮罩。
|
|
9744
|
+
onCopy: () => { void copyText(dragNameOf(ctxMenu.item, ctxMenu.absPath)) },
|
|
9411
9745
|
// v0.16.0 单文件复制:写系统剪贴板文件列表,可在别的对话粘贴
|
|
9412
9746
|
onCopyFile: () => { void doCopyAssets([ctxMenu.item.relPath]) },
|
|
9413
9747
|
onDelete: () => setDeleteTarget({ item: ctxMenu.item, busy: false }),
|
|
@@ -9468,6 +9802,7 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9468
9802
|
return h('div', { className: 'dg-root', 'data-gallery-root': true }, [
|
|
9469
9803
|
header,
|
|
9470
9804
|
basketToggle,
|
|
9805
|
+
pendingBadge,
|
|
9471
9806
|
batchBar,
|
|
9472
9807
|
discardEntry,
|
|
9473
9808
|
discardDialogNode,
|
|
@@ -9836,6 +10171,104 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9836
10171
|
getFeedbackDraft() {
|
|
9837
10172
|
return draftRef.current ?? ''
|
|
9838
10173
|
},
|
|
10174
|
+
/**
|
|
10175
|
+
* v0.16.4 · A 档:按条件取资产(**结构化**,不是渲染文本)。
|
|
10176
|
+
*
|
|
10177
|
+
* 为什么给结构化:Agent 要自己判断「这批图够不够用」,
|
|
10178
|
+
* 只给一坨文字它没法筛、没法排序、没法拿路径去喂工作流。
|
|
10179
|
+
*
|
|
10180
|
+
* 走既有的 `list` op(Host 侧做筛选与缓存),**不新增扫描路径**。
|
|
10181
|
+
* 纯读:不写任何文件、不发消息、不影响台面状态。
|
|
10182
|
+
*
|
|
10183
|
+
* @param filter - {
|
|
10184
|
+
* kind?: 'image'|'file'|'media', scope?: 'global'|'session', sessionId?: string,
|
|
10185
|
+
* label?: 'input'|'intermediate'|'final', // 与 category 同义,取生效值(手动标签优先)
|
|
10186
|
+
* category?: 同上, confirmed?: boolean, action?: string,
|
|
10187
|
+
* ext?: '.png', q?: string, limit?: number, page?: number
|
|
10188
|
+
* }
|
|
10189
|
+
* @returns { schema, items, count, total, error? }
|
|
10190
|
+
*/
|
|
10191
|
+
async listAssets(filter) {
|
|
10192
|
+
const f = (filter !== null && typeof filter === 'object') ? filter : {}
|
|
10193
|
+
try {
|
|
10194
|
+
const payload = await callHost('list', f)
|
|
10195
|
+
if (payload?.ok === false) {
|
|
10196
|
+
return { schema: 1, items: [], count: 0, total: 0, error: String(payload?.error?.message ?? 'list failed') }
|
|
10197
|
+
}
|
|
10198
|
+
// 全局分组视图下文件在 groups[].files,扁平视图下在 items —— 两种都摊平
|
|
10199
|
+
const flat = []
|
|
10200
|
+
if (Array.isArray(payload?.items)) for (const it of payload.items) flat.push(it)
|
|
10201
|
+
if (Array.isArray(payload?.groups)) {
|
|
10202
|
+
for (const g of payload.groups) {
|
|
10203
|
+
if (!Array.isArray(g?.files)) continue
|
|
10204
|
+
for (const it of g.files) {
|
|
10205
|
+
flat.push({
|
|
10206
|
+
...it,
|
|
10207
|
+
sessionId: it.sessionId ?? g.sessionId,
|
|
10208
|
+
sessionTitle: it.sessionTitle ?? g.title,
|
|
10209
|
+
})
|
|
10210
|
+
}
|
|
10211
|
+
}
|
|
10212
|
+
}
|
|
10213
|
+
const seen = new Set()
|
|
10214
|
+
const items = []
|
|
10215
|
+
for (const it of flat) {
|
|
10216
|
+
const relPath = String(it?.relPath ?? '')
|
|
10217
|
+
if (relPath === '' || seen.has(relPath)) continue
|
|
10218
|
+
seen.add(relPath)
|
|
10219
|
+
items.push({
|
|
10220
|
+
relPath,
|
|
10221
|
+
// absolute 必须给:Agent 要拿它去改文件 / 喂工作流
|
|
10222
|
+
absolute: String(it.absPath ?? ''),
|
|
10223
|
+
name: String(it.name ?? relPath.split('/').pop() ?? relPath),
|
|
10224
|
+
category: String(it.category ?? 'unknown'),
|
|
10225
|
+
categoryManual: it.categoryManual === true,
|
|
10226
|
+
confirmed: it.confirmed === true,
|
|
10227
|
+
action: String(it.markAction ?? ''),
|
|
10228
|
+
ext: String(it.extension ?? ''),
|
|
10229
|
+
size: Number(it.size) || 0,
|
|
10230
|
+
mtime: Number(it.mtime) || 0,
|
|
10231
|
+
width: it.width ?? null,
|
|
10232
|
+
height: it.height ?? null,
|
|
10233
|
+
sessionId: String(it.sessionId ?? ''),
|
|
10234
|
+
sessionTitle: String(it.sessionTitle ?? ''),
|
|
10235
|
+
})
|
|
10236
|
+
}
|
|
10237
|
+
const wanted = Number(f.limit)
|
|
10238
|
+
const limit = Number.isFinite(wanted) && wanted > 0 ? Math.trunc(wanted) : 0
|
|
10239
|
+
const sliced = limit > 0 ? items.slice(0, limit) : items
|
|
10240
|
+
return { schema: 1, items: sliced, count: sliced.length, total: items.length }
|
|
10241
|
+
} catch (error) {
|
|
10242
|
+
return { schema: 1, items: [], count: 0, total: 0, error: String(error?.message ?? error) }
|
|
10243
|
+
}
|
|
10244
|
+
},
|
|
10245
|
+
/**
|
|
10246
|
+
* v0.16.4 · A 档:取待处理反馈(**纯读**)。
|
|
10247
|
+
*
|
|
10248
|
+
* 🔴 Agent 拉走 ≠ 人处理完。这里**不** ack、**不**清零 ——
|
|
10249
|
+
* 清零只发生在人点「生成草稿」或「清空反馈篮」时。
|
|
10250
|
+
* 否则 Agent 看一眼就把用户的意见吞了。
|
|
10251
|
+
*
|
|
10252
|
+
* @returns { schema, items, count, draft }
|
|
10253
|
+
* items[i] = { relPath, absolute, action, reason, changeOnly, keep, region, markedAt, category, sessionId, confirmed }
|
|
10254
|
+
* draft = 已渲染好的成稿文本(可直接用,省得自己拼)
|
|
10255
|
+
*/
|
|
10256
|
+
async getPendingFeedback() {
|
|
10257
|
+
try {
|
|
10258
|
+
const payload = await callHost('getPendingFeedback', {})
|
|
10259
|
+
if (payload?.ok === false) {
|
|
10260
|
+
return { schema: 1, items: [], count: 0, draft: '', error: String(payload?.error?.message ?? 'failed') }
|
|
10261
|
+
}
|
|
10262
|
+
return {
|
|
10263
|
+
schema: Number(payload?.schema) || 1,
|
|
10264
|
+
items: Array.isArray(payload?.items) ? payload.items : [],
|
|
10265
|
+
count: Number.isFinite(payload?.count) ? payload.count : 0,
|
|
10266
|
+
draft: String(payload?.draft ?? ''),
|
|
10267
|
+
}
|
|
10268
|
+
} catch (error) {
|
|
10269
|
+
return { schema: 1, items: [], count: 0, draft: '', error: String(error?.message ?? error) }
|
|
10270
|
+
}
|
|
10271
|
+
},
|
|
9839
10272
|
}
|
|
9840
10273
|
window.dshGallerySeam = seam
|
|
9841
10274
|
return seam
|
|
@@ -9905,8 +10338,6 @@ function AnnotationLayer({ t, annotations, onAdd, onRemove, active, dragging, fr
|
|
|
9905
10338
|
// 拖完在输入框 Ctrl+V 能粘出「产出台·…」= 新代码确实执行过、dragstart 命中;
|
|
9906
10339
|
// 粘不出 = 面板仍加载旧模块,需重载窗口。编码 / 写入失败时它就是唯一可用通道。
|
|
9907
10340
|
void copyText(name)
|
|
9908
|
-
// 从 Viewer「拖到对话」按钮拖出时,取预览大图而不是按钮内的节点;
|
|
9909
|
-
// 列表卡片则仍用自己那张缩略图。两者都是同源 blob URL,canvas 不会被污染。
|
|
9910
10341
|
const img = card.hasAttribute('data-gallery-dragviewer')
|
|
9911
10342
|
? document.querySelector('.dg-viewerBody img')
|
|
9912
10343
|
: (target.matches('img') ? target : target.querySelector('img'))
|