Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 使用中性任务控件并核验深浅色浮层

longmeidaoad00fff5020e
diff --git a/docs/reference-snapshots/processing-task-controls.md b/docs/reference-snapshots/processing-task-controls.md
index ece550156..e46dc95f3 100644
--- a/docs/reference-snapshots/processing-task-controls.md
+++ b/docs/reference-snapshots/processing-task-controls.md
@@ -1,6 +1,6 @@
# 扫描任务控件取证
-2026-10-18 通过隔离 `agent-browser` 会话检查公开演示。本文件为人工取证笔记,不作为上游 Markdown 快照登记。
+2026-10-18 通过隔离 `agent-browser` 会话检查公开演示。本文件为人工取证笔记;渲染界面与用户截图没有可重抓的上游 Markdown 快照,不登记到 `docs/reference-sources.json`。
## 公开参考
@@ -29,4 +29,6 @@ Effort 是重建方案,不是官方 Pro 源码副本。轨道与拖柄采用
任务浮层以不透明 `background-primary-default` 为底,错误/警告 token 通过背景图层叠色。深色状态 token 含 60% 透明度,不能直接当作悬浮卡片唯一背景;普通页面中的状态提示继续使用既有语义背景。
+展开/收起使用中性 `secondary` 图标按钮,详情入口使用 `secondary` 链接;深浅色均通过语义 token 适配,不给辅助操作填强调色。
+
扫描错误结果四周内边距为 12px,正文与分隔线、分隔线与清单标题、清单标题与首条问题、末条问题与日志分隔线均留 12px;条目在内部线两侧各留 8px,文件名与错误说明间留 4px。Note 与 Disclosure 开放样式组合参数,仅该结果面板覆盖默认间距,避免父级 gap 与子级 margin 累加。
diff --git a/frontend/e2e/design-controls.test.ts b/frontend/e2e/design-controls.test.ts
index ffcc43448..d0cc398d0 100644
--- a/frontend/e2e/design-controls.test.ts
+++ b/frontend/e2e/design-controls.test.ts
@@ -244,7 +244,7 @@ describe('设计决定:控件、状态与首页顶部', () => {
await banner.waitFor({ state: 'visible', timeout: 15_000 });
/* 计算值现在是 `oklab()`/`oklch()`,两种记法之间没法直接比字符串,所以统一在
canvas 上取回 RGBA 再比。 */
- const surface = await banner.evaluate((element) => {
+ const readSurface = () => banner.evaluate((element) => {
const style = getComputedStyle(element);
const context = document.createElement('canvas').getContext('2d')!;
const paint = (color: string) => {
@@ -253,18 +253,29 @@ describe('设计决定:控件、状态与首页顶部', () => {
context.fillRect(0, 0, 1, 1);
return [...context.getImageData(0, 0, 1, 1).data];
};
- return { tint: style.backgroundColor, line: paint(style.borderTopColor), ink: paint(style.color) };
+ return { base: paint(style.backgroundColor), tint: style.backgroundImage,
+ line: paint(style.borderTopColor), ink: paint(style.color),
+ button: getComputedStyle(element.querySelector('button[aria-expanded]')!).backgroundColor,
+ link: getComputedStyle(element.querySelector('a')!).color };
});
- assert.equal(surface.tint,
- await tokenColor(failed.page, '.peach-react', '--color-background-tertiary-error'));
- // 上下两条线取自己的文字色:红底上横一条中性灰线,读起来是把这一条切成了两半。
- for (const at of [0, 1, 2]) {
- assert.ok(Math.abs(surface.line[at]! - surface.ink[at]!) <= 2,
- `横幅的线没跟着语气走:线 ${surface.line} 与字 ${surface.ink} 不是同一个色`);
+ for (const theme of ['light', 'dark']) {
+ await failed.page.evaluate(value => {
+ document.documentElement.dataset.theme = value;
+ document.documentElement.classList.toggle('dark', value === 'dark');
+ }, theme);
+ const surface = await readSurface();
+ const errorTint = await tokenColor(failed.page, '.peach-react', '--color-background-tertiary-error');
+ assert.equal(surface.base[3], 255, '任务卡的底层不透明');
+ assert.equal(surface.tint, `linear-gradient(${errorTint}, ${errorTint})`);
+ assert.equal(surface.button, await tokenColor(failed.page, '.peach-react', '--color-background-primary-default'));
+ assert.equal(surface.link, await tokenColor(failed.page, '.peach-react', '--color-text-secondary'));
+ for (const at of [0, 1, 2]) {
+ assert.ok(Math.abs(surface.line[at]! - surface.ink[at]!) <= 2,
+ `横幅的线没跟着语气走:线 ${surface.line} 与字 ${surface.ink} 不是同一个色`);
+ }
+ assert.ok(surface.line[3]! < surface.ink[3]!, '状态分隔线比正文更淡');
}
- assert.ok(surface.line[3]! < surface.ink[3]!,
- '线和字一样实,整条读起来像三行字');
- // 垃圾文件也是目录路径,但它是数据管理底下的一页:同一趟失败的任务,横幅不跟进去。
+ // 数据管理子页继续保留同一趟尚未处理的失败提示。
await failed.page.goto(new URL('/junk-files', failed.page.url()).href, { waitUntil: 'load' });
await failed.page.locator('[data-junk-filters]').waitFor({ state: 'visible', timeout: 15_000 });
await failed.page.waitForTimeout(1_000);
diff --git a/frontend/src/react/library-processing/library-processing-notice.tsx b/frontend/src/react/library-processing/library-processing-notice.tsx
index 9c52af21a..4eed0db6d 100644
--- a/frontend/src/react/library-processing/library-processing-notice.tsx
+++ b/frontend/src/react/library-processing/library-processing-notice.tsx
@@ -72,7 +72,7 @@ export function ProcessingNoticePanel({ state, problem = '', measure = false }:
<p className="text-body-medium">{title}</p>
{active ? <p data-processing-eta="" className="text-caption-1-regular text-text-secondary tabular-nums wrap-anywhere">{remainingTime(state!)}</p> : null}
</div>
- <Button size="small" variant="ghost" iconOnly leadingIcon={expanded ? RiArrowDownSLine : RiArrowUpSLine}
+ <Button size="small" variant="secondary" iconOnly leadingIcon={expanded ? RiArrowDownSLine : RiArrowUpSLine}
aria-label={expanded ? '收起任务详情' : '展开任务详情'} aria-expanded={expanded} onClick={toggle} />
</div>
{expanded ? <div className={cx('flex min-w-0 flex-col gap-2 border-t pt-3',
@@ -94,7 +94,7 @@ export function ProcessingNoticePanel({ state, problem = '', measure = false }:
</div> : null}
<div className="flex flex-wrap items-center justify-between gap-2">
{active ? <ProcessingControls state={state!} disabled={!!problem} /> : null}
- <LinkButton href="/data-cleanup#libraryProcessing" size="small" trailingIcon={RiArrowRightLine}>
+ <LinkButton href="/data-cleanup#libraryProcessing" variant="secondary" size="small" trailingIcon={RiArrowRightLine}>
{problem || failed ? '查看并处理' : '任务详情'}
</LinkButton>
</div>
diff --git a/frontend/test/react/library-processing.test.tsx b/frontend/test/react/library-processing.test.tsx
index 95b3cf757..2f6042273 100644
--- a/frontend/test/react/library-processing.test.tsx
+++ b/frontend/test/react/library-processing.test.tsx
@@ -207,8 +207,6 @@ it('失败时把问题清单折叠进错误提示,重试只交失败的那些
const log = details.querySelector('p')!;
expect(log.textContent).toBe(`完整记录:${LOG}`);
expect(log.closest('.text-text-secondary')).not.toBeNull();
- // 那条线取这行灰字自己的颜色:中性 separator 在有色底上是另一种灰,跟它对不上。
- expect(log.closest('.border-t')!.className).toContain('border-current/20');
expect(details.querySelector('button[aria-label="在资源管理器中显示"]')).not.toBeNull();
// 补上没做完的那些是这一趟的事,重新跑一整批是下一趟的事:页脚那颗留着,各答各的问题。
expect(buttonNamed('同步媒体库', host)?.textContent).toBe('同步媒体库');
diff --git a/src/peach/library_processing.py b/src/peach/library_processing.py
index 8366718f5..915179834 100644
--- a/src/peach/library_processing.py
+++ b/src/peach/library_processing.py
@@ -2015,6 +2015,34 @@ def _read_local_metadata(config, db_path, row, cover_root, listing, state, updat
return code, nfo is not None, payload, entries
+def _processing_steps(stage, asset_ids, *, metadata_only_enabled):
+ """按本趟真实处理范围构造有序阶段清单。"""
+ scanning = asset_ids is None and stage in (ALL_STAGES, SCAN_STAGE)
+ steps = [('sources', '扫描文件' if scanning else '检查媒体目录')]
+ if stage not in (SCAN_STAGE, PREVIEWS_STAGE):
+ steps.append(('local', '读取本地资料'))
+ if stage == PREVIEWS_STAGE or stage in (ALL_STAGES, COLLECT_STAGE):
+ media_label = ('生成视频预览' if stage == PREVIEWS_STAGE else
+ '读取媒体属性' if metadata_only_enabled else '读取媒体属性与生成预览')
+ steps.append(('media', media_label))
+ if stage not in (SCAN_STAGE, PREVIEWS_STAGE):
+ steps.append(('collect', '采集外部资料与封面'))
+ return [dict(id=key, label=label, status='current' if index == 0 else 'pending')
+ for index, (key, label) in enumerate(steps)]
+
+
+def _complete_processing_step(steps, key):
+ """返回完成当前阶段并激活下一阶段的独立快照。"""
+ progress = [dict(item) for item in steps]
+ for index, item in enumerate(progress):
+ if item['id'] == key:
+ item['status'] = 'complete'
+ if index + 1 < len(progress):
+ progress[index + 1]['status'] = 'current'
+ break
+ return progress
+
+
def process_library(config, db_path, candidate_root, cover_root, *, location='configured',
report=lambda state: None, provider_factory=None, job_id=None,
retry_ids=None, active=lambda: True, stage=ALL_STAGES,
@@ -2069,17 +2097,8 @@ def process_library(config, db_path, candidate_root, cover_root, *, location='co
followups=[],
started_at=time.time(), error='')
state.update(initial_estimate(config, db_path, stage, scope_ids, speed_mode))
- steps = [('sources', '扫描文件' if scope_ids is None and stage in (ALL_STAGES, SCAN_STAGE) else '检查媒体目录')]
- if stage not in (SCAN_STAGE, PREVIEWS_STAGE):
- steps.append(('local', '读取本地资料'))
- if stage == PREVIEWS_STAGE or stage in (ALL_STAGES, COLLECT_STAGE):
- media_label = ('生成视频预览' if stage == PREVIEWS_STAGE else
- '读取媒体属性' if metadata_only(config.directory('state')) else '读取媒体属性与生成预览')
- steps.append(('media', media_label))
- if stage not in (SCAN_STAGE, PREVIEWS_STAGE):
- steps.append(('collect', '采集外部资料与封面'))
- state['steps'] = [dict(id=key, label=label, status='current' if index == 0 else 'pending')
- for index, (key, label) in enumerate(steps)]
+ state['steps'] = _processing_steps(stage, scope_ids,
+ metadata_only_enabled=metadata_only(config.directory('state')))
estimate = ProcessingEstimate(config, state, control)
# 实体表的水位在开工前记一次:比它大的实体就是这一轮建出来的(`_entity_followups`)。
checkpoints = _LibraryCheckpoints(state, resume_state, database)
@@ -2132,14 +2151,7 @@ def process_library(config, db_path, candidate_root, cover_root, *, location='co
def finish_step(key):
"""阶段成功返回后发布完成状态;异常退出的阶段保留当前状态。"""
- progress = [dict(item) for item in state['steps']]
- for index, item in enumerate(progress):
- if item['id'] == key:
- item['status'] = 'complete'
- if index + 1 < len(progress):
- progress[index + 1]['status'] = 'current'
- break
- update(steps=progress)
+ update(steps=_complete_processing_step(state['steps'], key))
update()
remote = _RemoteSession(config, provider_factory, _MissCache(misses_path(config)),
diff --git a/web/dist/peach-app.js b/web/dist/peach-app.js
index 0f26ab39e..5b8d9a84f 100644
--- a/web/dist/peach-app.js
+++ b/web/dist/peach-app.js
@@ -45037,7 +45037,7 @@ function EP({ state: e, problem: t = "", measure: n = !1 }) {
}),
/* @__PURE__ */ (0, C.jsx)(K, {
size: "small",
- variant: "ghost",
+ variant: "secondary",
iconOnly: !0,
leadingIcon: r ? OO : jO,
"aria-label": r ? "收起任务详情" : "展开任务详情",
@@ -45096,6 +45096,7 @@ function EP({ state: e, problem: t = "", measure: n = !1 }) {
disabled: !!t
}) : null, /* @__PURE__ */ (0, C.jsx)(Ok, {
href: "/data-cleanup#libraryProcessing",
+ variant: "secondary",
size: "small",
trailingIcon: kO,
children: t || o ? "查看并处理" : "任务详情"