dsh-gallery 0.14.0 → 0.14.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/host/http.js CHANGED
@@ -19,8 +19,23 @@ import {
19
19
  validateRootCandidate, readSettingsPayload,
20
20
  } from './settings.js'
21
21
  import { scanGallery } from './scan.js'
22
+
23
+ /**
24
+ * 列表请求的短缓存 + 并发去重(加载提速,不改变返回内容与分组顺序)。
25
+ *
26
+ * 客户端会自动刷新,切换对话又会再发一次;旧实现每次都真扫一遍,
27
+ * 多个请求叠在一起会把 Host CPU 占满,面板就一直停在「正在扫描…」。
28
+ * 4 秒内的相同请求直接复用,同一时刻的相同请求只跑一次。
29
+ */
30
+ const LIST_CACHE_MS = 4000
31
+ const listCache = new Map()
32
+ const listInflight = new Map()
22
33
  import { resolveReadable, serveMedia, contentTypeFor } from './media.js'
23
34
  import { MARK_ACTIONS, readMarks, writeMarks, setMark, setMarksBatch, marksFilePath } from './marks.js'
35
+ import { LABEL_CATEGORIES, readLabels, setLabel, setLabelsBatch, deleteLabels } from './labels.js'
36
+ import {
37
+ registerFrame, deleteFrames, frameTimecode, makeFrameName,
38
+ } from './frames.js'
24
39
 
25
40
  /** reveal 相关的排查日志(失败/异常时便于定位,不影响功能)。 */
26
41
  /**
@@ -253,7 +268,32 @@ export function registerOpsRoute(ctx, config) {
253
268
 
254
269
  const sessionId = typeof body?.sessionId === 'string' ? body.sessionId : ''
255
270
 
256
- return json(await scanGallery(config, kind, scope, sessionId, body?.page))
271
+ // 配置 / 隐藏列表写在 settingsFile 里,它的 mtime 变了就让缓存失效。
272
+ // sessionId 必须在键里:切对话后不能复用上一会话的分组结果。
273
+ let settingsStamp = 0
274
+ try { settingsStamp = (await fsp.stat(resolved.settingsFile)).mtimeMs } catch { /* 文件还不存在 */ }
275
+ const cacheKey = JSON.stringify([
276
+ kind, scope, sessionId, body?.page ?? 1,
277
+ resolved.roots, resolved.windowHours, resolved.maxDepth,
278
+ resolved.maxItems, settingsStamp,
279
+ ])
280
+ const hit = listCache.get(cacheKey)
281
+ if (hit !== undefined && Date.now() - hit.at < LIST_CACHE_MS) return json(hit.value)
282
+ const inflight = listInflight.get(cacheKey)
283
+ if (inflight !== undefined) return json(await inflight)
284
+
285
+ const task = scanGallery(config, kind, scope, sessionId, body?.page)
286
+ .then((value) => {
287
+ listCache.set(cacheKey, { at: Date.now(), value })
288
+ if (listCache.size > 24) {
289
+ const oldest = listCache.keys().next().value
290
+ if (oldest !== undefined) listCache.delete(oldest)
291
+ }
292
+ return value
293
+ })
294
+ .finally(() => { listInflight.delete(cacheKey) })
295
+ listInflight.set(cacheKey, task)
296
+ return json(await task)
257
297
 
258
298
  } catch (error) {
259
299
 
@@ -503,6 +543,150 @@ export function registerOpsRoute(ctx, config) {
503
543
 
504
544
  // 在文件管理器中定位该文件(仅 Windows)
505
545
 
546
+ // ---- v0.14.2 手动标签覆写(持久,与反馈篮 marks 分开)----
547
+ if (op === 'getLabels') {
548
+ const stored = await readLabels(resolveOptions(config).settingsFile)
549
+ return json({ ok: true, labels: stored.labels })
550
+ }
551
+
552
+ if (op === 'setLabel') {
553
+ const relPath = String(body?.path ?? '')
554
+ if (relPath === '') {
555
+ return json({ ok: false, error: { code: 'bad-request', message: '缺少 path' } }, 400)
556
+ }
557
+ const label = body?.label
558
+ if (label !== null && label !== undefined &&
559
+ (typeof label !== 'object' || !LABEL_CATEGORIES.includes(label.category))) {
560
+ return json({ ok: false, error: { code: 'bad-request', message: 'category 不合法' } }, 400)
561
+ }
562
+ try {
563
+ const next = await setLabel(resolveOptions(config).settingsFile, relPath,
564
+ label === undefined ? null : label)
565
+ // 标签变了必须让下一次 list 立刻重扫,否则 4 秒缓存里还是旧角标
566
+ listCache.clear()
567
+ return json({ ok: true, labels: next })
568
+ } catch (error) {
569
+ return json({ ok: false, error: { code: 'labels-write-failed', message: String(error?.message ?? error) } }, 500)
570
+ }
571
+ }
572
+
573
+ if (op === 'setLabelsBatch') {
574
+ const updates = Array.isArray(body?.updates) ? body.updates : null
575
+ if (updates === null) {
576
+ return json({ ok: false, error: { code: 'bad-request', message: '缺少 updates 数组' } }, 400)
577
+ }
578
+ if (updates.length > 200) {
579
+ return json({ ok: false, error: { code: 'too-many', message: '单次最多 200 条' } }, 400)
580
+ }
581
+ for (const u of updates) {
582
+ const label = u?.label
583
+ if (label !== null && label !== undefined &&
584
+ (typeof label !== 'object' || !LABEL_CATEGORIES.includes(label.category))) {
585
+ return json({ ok: false, error: { code: 'bad-request', message: 'category 不合法' } }, 400)
586
+ }
587
+ }
588
+ try {
589
+ const next = await setLabelsBatch(resolveOptions(config).settingsFile, updates)
590
+ listCache.clear()
591
+ return json({ ok: true, labels: next, applied: updates.length })
592
+ } catch (error) {
593
+ return json({ ok: false, error: { code: 'labels-write-failed', message: String(error?.message ?? error) } }, 500)
594
+ }
595
+ }
596
+
597
+ // ---- v0.14.3 视频截帧:直接写进当前对话资产,不再弹系统保存框 ----
598
+ if (op === 'saveFrame') {
599
+ const opts = resolveOptions(config)
600
+ const videoRel = String(body?.path ?? '').replace(/\\/g, '/')
601
+ const data = typeof body?.data === 'string' ? body.data : ''
602
+ const frameMs = Number(body?.frameMs)
603
+ if (videoRel === '' || data === '') {
604
+ return json({ ok: false, error: { code: 'bad-request', message: '缺少 path 或 data' } }, 400)
605
+ }
606
+ if (!Number.isFinite(frameMs) || frameMs < 0) {
607
+ return json({ ok: false, error: { code: 'bad-request', message: 'frameMs 不合法' } }, 400)
608
+ }
609
+
610
+ // 源视频必须真实存在于扫描目录内;同时拿到它所属的 root 以反算 relPath。
611
+ // 不能用 resolveUnderRoots(它取第一个匹配的 root),多目录时会串错。
612
+ let videoAbs = null
613
+ let ownerRoot = null
614
+ for (const root of opts.roots) {
615
+ if (typeof root !== 'string' || root === '') continue
616
+ const abs = path.resolve(root, videoRel)
617
+ if (!isInside(root, abs)) continue
618
+ try {
619
+ const st = await fsp.stat(abs)
620
+ if (st.isFile()) { videoAbs = abs; ownerRoot = root; break }
621
+ } catch { /* 换下一个 root */ }
622
+ }
623
+ if (videoAbs === null) {
624
+ return json({ ok: false, error: { code: 'video-not-found', message: '源视频不在扫描目录内' } }, 404)
625
+ }
626
+
627
+ const buf = Buffer.from(data, 'base64')
628
+ if (buf.length < 8 || buf.length > 24 * 1024 * 1024) {
629
+ return json({ ok: false, error: { code: 'bad-png', message: 'PNG 数据为空或超过 24 MB' } }, 400)
630
+ }
631
+ // PNG 魔数:不允许把任意 base64 写进资产目录
632
+ if (!(buf[0] === 0x89 && buf[1] === 0x50 && buf[2] === 0x4e && buf[3] === 0x47)) {
633
+ return json({ ok: false, error: { code: 'bad-png', message: '数据不是 PNG' } }, 400)
634
+ }
635
+
636
+ const dir = path.dirname(videoAbs)
637
+ const videoName = path.basename(videoAbs)
638
+ let name = makeFrameName(videoName, frameMs)
639
+ let abs = path.join(dir, name)
640
+ // 同一帧重复截:不覆盖已有文件,依次加 -2 / -3 …
641
+ let n = 2
642
+ while (n <= 99) {
643
+ let exists = true
644
+ try { await fsp.access(abs) } catch { exists = false }
645
+ if (!exists) break
646
+ name = makeFrameName(videoName, frameMs, `-${n}`)
647
+ abs = path.join(dir, name)
648
+ n += 1
649
+ }
650
+ if (!isInside(ownerRoot, abs)) {
651
+ return json({ ok: false, error: { code: 'outside-roots', message: '目标路径越出扫描目录' } }, 400)
652
+ }
653
+
654
+ // 原子写:先落到 .tmp 再改名,避免扫描读到半截 PNG
655
+ const tmp = `${abs}.tmp-${process.pid}-${Date.now().toString(36)}`
656
+ try {
657
+ await fsp.mkdir(dir, { recursive: true })
658
+ await fsp.writeFile(tmp, buf)
659
+ await fsp.rename(tmp, abs)
660
+ } catch (error) {
661
+ try { await fsp.rm(tmp, { force: true }) } catch { /* 忽略 */ }
662
+ return json({ ok: false, error: { code: 'frame-write-failed', message: String(error?.message ?? error) } }, 500)
663
+ }
664
+
665
+ const relPath = path.relative(ownerRoot, abs).split(path.sep).join('/')
666
+ const timecode = frameTimecode(frameMs)
667
+ try {
668
+ await registerFrame(opts.settingsFile, {
669
+ relPath,
670
+ sessionId: String(body?.sessionId ?? ''),
671
+ sessionTitle: String(body?.sessionTitle ?? ''),
672
+ sessionCreatedAt: Number(body?.sessionCreatedAt) || 0,
673
+ videoRelPath: videoRel,
674
+ videoName,
675
+ frameMs: Math.round(frameMs),
676
+ timecode,
677
+ })
678
+ } catch (error) {
679
+ return json({ ok: false, error: { code: 'frame-register-failed', message: String(error?.message ?? error) } }, 500)
680
+ }
681
+
682
+ // 新资产要立刻出现在列表里,不能等 4 秒缓存过期
683
+ listCache.clear()
684
+ return json({
685
+ ok: true, relPath, absPath: abs, name, timecode,
686
+ frameMs: Math.round(frameMs), videoName,
687
+ })
688
+ }
689
+
506
690
  // ---- 标记(S3-a)----
507
691
  if (op === 'getMarks') {
508
692
  const settingsFile = resolveOptions(config).settingsFile
@@ -692,6 +876,12 @@ export function registerOpsRoute(ctx, config) {
692
876
  }
693
877
  }
694
878
 
879
+ // 文件删了,手动标签覆写与截帧登记一并清掉(失败不影响删除结果)
880
+ if (deleted.length > 0) {
881
+ try { await deleteLabels(settingsFile, deleted) } catch { /* 忽略 */ }
882
+ try { await deleteFrames(settingsFile, deleted) } catch { /* 忽略 */ }
883
+ }
884
+
695
885
  return json({
696
886
  ok: failed.length === 0,
697
887
  deleted,
@@ -970,6 +1160,9 @@ export function registerOpsRoute(ctx, config) {
970
1160
 
971
1161
  }
972
1162
 
1163
+ // 单文件删除:同步清掉截帧登记,避免残留孤儿记录
1164
+ try { await deleteFrames(opts.settingsFile, [rel]) } catch { /* 忽略 */ }
1165
+
973
1166
  return json({ ok: true, deleted: found.absolute })
974
1167
 
975
1168
  } catch (error) {
package/host/labels.js ADDED
@@ -0,0 +1,98 @@
1
+ /**
2
+ * 手动标签覆写(v0.14.2):独立文件 dsh-gallery-labels.json。
3
+ *
4
+ * 为什么要和 marks.json(反馈篮)分开:
5
+ * · 标签是**持久状态** —— 手动改过就一直生效,刷新 / 重启 / 重扫都不回退;
6
+ * · 反馈篮条目是**一次性消息** —— 生成草稿、人工合并发送后清空。
7
+ * 若共用一份,用户从反馈篮删掉一条,会把已经定好的标签一起撤销,语义就错了。
8
+ *
9
+ * 数据形态:
10
+ * {
11
+ * "schema": 1,
12
+ * "labels": {
13
+ * "<relPath>": { "category": "input|intermediate|final",
14
+ * "from": "机器原判", "adjustedAt": 1700000000000 }
15
+ * }
16
+ * }
17
+ *
18
+ * 键用 relPath(与 marks 一致),文件被移动/改名后不会误命中;孤儿记录不影响扫描。
19
+ */
20
+
21
+ import { promises as fsp } from 'node:fs'
22
+ import path from 'node:path'
23
+
24
+ /** 允许手动指定的标签;与 classify.js 的 ASSET_CATEGORY 对齐(不含 unknown)。 */
25
+ export const LABEL_CATEGORIES = ['input', 'intermediate', 'final']
26
+
27
+ const LABELS_FILENAME = 'dsh-gallery-labels.json'
28
+
29
+ /** 进程内写队列,与 marks.js 同策略:把「读-改-写」串起来,避免并发互相覆盖。 */
30
+ let writeChain = Promise.resolve()
31
+
32
+ function enqueue(fn) {
33
+ const next = writeChain.then(fn, fn)
34
+ writeChain = next.catch(() => {})
35
+ return next
36
+ }
37
+
38
+ export function labelsFilePath(settingsFile) {
39
+ return path.join(path.dirname(settingsFile), LABELS_FILENAME)
40
+ }
41
+
42
+ /** 读标签覆写。文件不存在 / 格式坏都返回空对象,绝不抛错。 */
43
+ export async function readLabels(settingsFile) {
44
+ try {
45
+ const raw = await fsp.readFile(labelsFilePath(settingsFile), 'utf8')
46
+ const parsed = JSON.parse(raw)
47
+ const labels = (parsed !== null && typeof parsed === 'object' &&
48
+ typeof parsed.labels === 'object' && parsed.labels !== null) ? parsed.labels : {}
49
+ return { schema: 1, labels }
50
+ } catch {
51
+ return { schema: 1, labels: {} }
52
+ }
53
+ }
54
+
55
+ /** 原子写(tmp → rename),tmp 名带 pid + 随机数,并发不互踩。 */
56
+ async function writeLabels(settingsFile, labels) {
57
+ const file = labelsFilePath(settingsFile)
58
+ const tmp = `${file}.tmp-${process.pid}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`
59
+ const payload = { schema: 1, labels: labels ?? {} }
60
+ await fsp.mkdir(path.dirname(file), { recursive: true })
61
+ await fsp.writeFile(tmp, JSON.stringify(payload, null, 2))
62
+ await fsp.rename(tmp, file)
63
+ }
64
+
65
+ /** 设 / 清一条标签覆写;label 为 null 表示「恢复自动判定」。 */
66
+ export async function setLabel(settingsFile, relPath, label) {
67
+ return enqueue(async () => {
68
+ const current = await readLabels(settingsFile)
69
+ const next = { ...current.labels }
70
+ if (label === null || label === undefined) delete next[relPath]
71
+ else next[relPath] = { ...label, adjustedAt: label.adjustedAt ?? Date.now() }
72
+ await writeLabels(settingsFile, next)
73
+ return next
74
+ })
75
+ }
76
+
77
+ /** 批量设 / 清,一次读改写 + 一次原子写。 */
78
+ export async function setLabelsBatch(settingsFile, updates) {
79
+ return enqueue(async () => {
80
+ const current = await readLabels(settingsFile)
81
+ const next = { ...current.labels }
82
+ for (const u of updates) {
83
+ const relPath = String(u?.path ?? '')
84
+ if (relPath === '') continue
85
+ const label = u?.label
86
+ if (label === null || label === undefined) delete next[relPath]
87
+ else next[relPath] = { ...label, adjustedAt: label.adjustedAt ?? Date.now() }
88
+ }
89
+ await writeLabels(settingsFile, next)
90
+ return next
91
+ })
92
+ }
93
+
94
+ /** 文件被删除后清掉对应覆写,避免留孤儿记录。 */
95
+ export async function deleteLabels(settingsFile, relPaths) {
96
+ if (!Array.isArray(relPaths) || relPaths.length === 0) return {}
97
+ return setLabelsBatch(settingsFile, relPaths.map((p) => ({ path: p, label: null })))
98
+ }
package/host/marks.js CHANGED
@@ -45,6 +45,11 @@ export const MARK_ACTIONS = [
45
45
  'redo-one-dim',
46
46
  'regenerate-selected',
47
47
  'set-reference',
48
+ // v0.14.2:手动改标签产生的三条反馈语义。
49
+ // 旧 6 个动作仍兼容老 marks 数据,但界面上不再提供入口(表态层已下线)。
50
+ 'finalize-asset',
51
+ 'reject-delivery',
52
+ 'set-label',
48
53
  ]
49
54
 
50
55
  const MARKS_FILENAME = 'dsh-gallery-marks.json'
package/host/scan.js CHANGED
@@ -7,12 +7,14 @@
7
7
  import { promises as fsp, readFileSync, statSync, createReadStream } from 'node:fs'
8
8
  import path from 'node:path'
9
9
  import { ASSET_CATEGORY, classifyAsset } from './classify.js'
10
- import { BASH_TOOLS, DEFAULT_SESSIONS_DIR, OUTPUT_TOOLS, VIDEO_EXTS, VIEW_IMAGE_EXTS, VIEW_TOOLS } from './constants.js'
10
+ import { BASH_TOOLS, DEFAULT_SESSIONS_DIR, DSH_HOME, OUTPUT_TOOLS, VIDEO_EXTS, VIEW_IMAGE_EXTS, VIEW_TOOLS } from './constants.js'
11
11
  import { isInside, measureImage, readHead } from './fsutil.js'
12
12
  import { buildGroups } from './groups.js'
13
13
  import { collectAbsolutePaths, findSubSessionLogs, locateSessionDir, readSessionLogText } from './session.js'
14
14
  import { readHiddenList, resolveOptions } from './settings.js'
15
- import { buildSessionIndex } from './session-index.js'
15
+ import { readLabels, LABEL_CATEGORIES } from './labels.js'
16
+ import { readFrames } from './frames.js'
17
+ import { buildSessionIndex, readSessionStates } from './session-index.js'
16
18
 
17
19
  export function extractAssetInfo(logText, sessionStartMs = 0) {
18
20
  const assets = new Map()
@@ -267,6 +269,16 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
267
269
  )))
268
270
  const skipSet = new Set(opts.skipDirs)
269
271
 
272
+ // 截帧登记(v0.14.3):新截出来的 PNG 不在任何会话日志里,
273
+ // 靠这份只读登记把它挂回产出它的对话,否则会掉进「历史资产」组。
274
+ const frameByRel = new Map()
275
+ try {
276
+ const stored = await readFrames(opts.settingsFile)
277
+ for (const [rel, f] of Object.entries(stored.frames ?? {})) {
278
+ if (f !== null && typeof f === 'object') frameByRel.set(String(rel).toLowerCase(), f)
279
+ }
280
+ } catch { /* 读不到就不登记,不影响正常扫描 */ }
281
+
270
282
  // 当前对话范围:先解析会话日志(含子智能体会话),得到「本对话产出过的路径」
271
283
  let scopeInfo = { ok: true, reason: 'global', taskDirs: [], paths: [], relPaths: [], subSessions: 0 }
272
284
  let sessionRelSet = null
@@ -275,6 +287,15 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
275
287
  // 修法 B:用「精确相对路径」集合判定,而不是只靠第一层目录名。
276
288
  // 这样既能处理有子目录的情况,也能处理「文件直接躺在 root 根目录下」。
277
289
  sessionRelSet = new Set((scopeInfo.relPaths ?? []).map((p) => p.toLowerCase()))
290
+ // 会话日志缺失时 resolveSessionScope 可能不带分类表,补一个空的
291
+ if (!(scopeInfo.categoryByRel instanceof Map)) scopeInfo.categoryByRel = new Map()
292
+ // 本对话截出来的帧:让它通过范围过滤,并给一个明确标签
293
+ for (const [rel, f] of frameByRel) {
294
+ if (String(f.sessionId ?? '') === sessionId) {
295
+ sessionRelSet.add(rel)
296
+ scopeInfo.categoryByRel?.set(rel, ASSET_CATEGORY.INTERMEDIATE)
297
+ }
298
+ }
278
299
  }
279
300
 
280
301
  // 会话索引:建立「文件 → 所属对话 + 分类」的映射,供全局按对话分组用
@@ -401,10 +422,38 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
401
422
 
402
423
  const rootMissing = !anyRootExists
403
424
 
425
+ // v0.14.2:手动标签覆写优先于机器预判的产出状态。
426
+ // 覆写落在扫描阶段而不是客户端,分组计数 / 顶部筛选 / 组头统计才会一起跟着变。
427
+ let manualLabels = {}
428
+ try {
429
+ manualLabels = (await readLabels(opts.settingsFile)).labels ?? {}
430
+ } catch { /* 读不到就老老实实用机器标签,不阻断扫描 */ }
431
+
404
432
  // 给每个条目附加「分类」和「所属对话」
405
433
  for (const item of matches) {
406
434
  const abs = path.join(item.rootDir, ...item.relPath.split('/'))
407
- const owner = ownerByAbs.get(abs)
435
+ const frame = frameByRel.get(item.relPath.toLowerCase())
436
+ // 帧来源元数据透传到卡片 / 反馈篮,草稿里才能写清「取自哪段视频的哪一帧」
437
+ if (frame !== undefined) {
438
+ item.frameOf = {
439
+ videoName: String(frame.videoName ?? ''),
440
+ videoRelPath: String(frame.videoRelPath ?? ''),
441
+ timecode: String(frame.timecode ?? ''),
442
+ frameMs: Number(frame.frameMs) || 0,
443
+ }
444
+ }
445
+ // 截帧不在会话日志里:ownerByAbs 查不到时,用登记里的会话信息补一个虚拟归属。
446
+ // 日志里已有归属的文件(例如视频本身)一律沿用原归属,不受影响。
447
+ const frameSid = String(frame?.sessionId ?? '')
448
+ const virtualOwner = frame !== undefined && frameSid !== ''
449
+ ? {
450
+ sessionId: frameSid,
451
+ title: String(frame.sessionTitle ?? '') || sessionIndex?.get(frameSid)?.title || '',
452
+ createdAt: Number(frame.sessionCreatedAt) || sessionIndex?.get(frameSid)?.createdAt || 0,
453
+ category: ASSET_CATEGORY.INTERMEDIATE,
454
+ }
455
+ : undefined
456
+ const owner = ownerByAbs.get(abs) ?? virtualOwner
408
457
  item.absPath = abs
409
458
  if (isSession) {
410
459
  item.category = (scopeInfo.categoryByRel?.get(item.relPath.toLowerCase())) ?? null
@@ -420,6 +469,15 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
420
469
  item.category = ASSET_CATEGORY.UNKNOWN
421
470
  item.sessionId = null
422
471
  }
472
+
473
+ // 手动改过的标签覆盖机器预判,且刷新 / 重扫 / 重启都不会回退。
474
+ const manual = manualLabels[item.relPath]
475
+ if (manual !== undefined && LABEL_CATEGORIES.includes(manual?.category)) {
476
+ item.category = manual.category
477
+ item.categoryManual = true
478
+ } else {
479
+ item.categoryManual = false
480
+ }
423
481
  }
424
482
 
425
483
  matches.sort((a, b) => b.mtime - a.mtime)
@@ -449,6 +507,9 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
449
507
  item.height = measured?.height ?? null
450
508
  }))
451
509
 
510
+ // 会话状态只读判定:只给分组加标注,不改排序、不改显示范围(0.14.1 原样)
511
+ const sessionStates = isSession ? null : await readSessionStates(DSH_HOME)
512
+
452
513
  // 全量统计:供「全局按对话分组」使用(不受分页限制)
453
514
  const allItemsSummary = []
454
515
  if (!isSession) {
@@ -468,6 +529,8 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
468
529
  extension: item.extension,
469
530
  // 音视频类型(video / audio),客户端据此选 <video> 还是 <audio>
470
531
  ...(item.mediaType !== undefined ? { mediaType: item.mediaType } : {}),
532
+ // 截帧来源:反馈篮与草稿正文据此写清取自哪段视频的哪一帧
533
+ ...(item.frameOf !== undefined ? { frameOf: item.frameOf } : {}),
471
534
  })
472
535
  }
473
536
  }
@@ -503,7 +566,7 @@ export async function scanGallery(config, kind = 'image', scope = 'global', sess
503
566
  rootMissing,
504
567
  scan: { directories, entries, capped },
505
568
  // 全局模式额外返回:按对话分组的数据(客户端做折叠展示用)
506
- groups: isSession ? null : buildGroups(allItemsSummary, 120, sessionId),
569
+ groups: isSession ? null : buildGroups(allItemsSummary, 120, sessionId, sessionStates),
507
570
  }
508
571
  }
509
572