Peach: Local-first video metadata scraper and media manager.
feat(ui): 「需要处理」接上人脸模型下载失败
longmeidao64e4ae8d8b70
diff --git a/frontend/src/react/activity/activity-page.tsx b/frontend/src/react/activity/activity-page.tsxindex eeb16cf07..d5749328d 100644--- a/frontend/src/react/activity/activity-page.tsx+++ b/frontend/src/react/activity/activity-page.tsx@@ -93,7 +93,8 @@ function RunCard(followups?: TaskRunPayload[] },) {return (- <li data-status={run.status} data-task-key={run.task_key} data-run-id={run.id}+ // `id` 让「需要处理」那一行的「查看失败记录」能直接滚到这张卡。+ <li id={`run-${run.id}`} data-status={run.status} data-task-key={run.task_key} data-run-id={run.id}className={cardClass({padding: 'none',bordered: 'line',diff --git a/frontend/test/react/activity.test.tsx b/frontend/test/react/activity.test.tsxindex 176a5b1a9..8e3ad67b3 100644--- a/frontend/test/react/activity.test.tsx+++ b/frontend/test/react/activity.test.tsx@@ -170,6 +170,8 @@ it('后台问题排在最前,每项只写是什么、从什么时候起和写expect(buttonNamed('立即重试', tunnel!)).toBeNull();expect(follow?.textContent).toContain('自 ');expect(follow?.textContent).toContain(' 起');+ // 任务卡带锚点,「查看失败记录」这类链接能滚到那张卡。+ expect(host.querySelector('#run-1')?.getAttribute('data-run-id')).toBe('1');// 链接在左、重试在右。const [first, second] = [...follow!.querySelectorAll('[data-note-action] a, [data-note-action] button')];expect([first?.textContent, second?.textContent]).toEqual([expect.stringContaining('打开关注调度'), '立即重试']);diff --git a/src/peach/background_issues.py b/src/peach/background_issues.pyindex e1da86de7..f7e13b298 100644--- a/src/peach/background_issues.py+++ b/src/peach/background_issues.py@@ -8,12 +8,12 @@这里不再复述一遍。高频逐条的失败(站点圆标、头像、单个推送文件)不进来:它们各自有任务记录,汇总在这里只会刷屏。-动作按能不能原地修好分:网络、调度、amane 桥这类重跑一次就可能好的给 `retry`(界面上-一律叫「立即重试」);要改设置、填凭据的只给链接。每项都带链接,`link_label` 写具体去处。+动作按能不能原地修好分:网络、调度、amane 桥、人脸模型这类重跑一次就可能好的给 `retry`+(界面上一律叫「立即重试」);要改设置、填凭据的只给链接。每项都带链接,`link_label` 写具体去处。-时间分两种:`since` 是服务自己记下的起点,只有两个调度有(连续失败里第一轮的开始);-其余服务不记失败时刻,`noticed_at` 是这个进程第一次读到这一项的时间,会晚于实际发生,-重启后重新计。两者不互相顶替。+时间分两种:`since` 是服务自己记下的起点,两个调度(连续失败里第一轮的开始)和人脸模型+(那条失败记录的结束时刻)有;其余服务不记失败时刻,`noticed_at` 是这个进程第一次读到+这一项的时间,会晚于实际发生,重启后重新计。两者不互相顶替。加一类问题就是往 `PROVIDERS` 里加一个函数:读 `(app_state, contract, config)`,返回零到多条 `Issue`。服务没装配时 `getattr` 拿到 None,函数照样返回空。@@ -143,6 +143,22 @@ def _network(state, _contract, _config) -> list[Issue]:retry="/api/network-status/check", retry_available=True)]+def _face_models(_state, contract, _config) -> list[Issue]:+ runs = getattr(contract, "task_runs", None)+ # 账本还没迁移出任务记录表时任务中心整个是关着的,这一行跟着不报。+ if runs is None or not runs.available():+ return []+ from . import face_models+ status = face_models.status(runs)+ # 只有最新一条记录是失败才报:还没取过(`missing`)下次用到时会自己去取,不算问题;+ # 重新下载在跑时这一行先收起。失败原因只在那张任务卡上写,链接指过去。+ if status["state"] != "failed":+ return []+ # 模型存在本机工具目录、不碰账本,只读端同样可以重取。+ return [Issue("face-models", "人脸模型下载失败", f"/tasks#run-{status['run_id']}", "查看失败记录",+ since=status["failed_at"], retry=status["retry_url"], retry_available=True)]++Provider = Callable[[Any, Any, Any], Iterable[Issue]]PROVIDERS: tuple[Provider, ...] = (@@ -157,6 +173,7 @@ PROVIDERS: tuple[Provider, ...] = (_automatic_updates,_library_sharing,_amane_bridge,+ _face_models,)diff --git a/tests/test_background_issues.py b/tests/test_background_issues.pyindex 640af3392..75db99160 100644--- a/tests/test_background_issues.py+++ b/tests/test_background_issues.py@@ -150,6 +150,22 @@ class BackgroundIssueTests(unittest.TestCase):self.state.sync = SimpleNamespace(read_only=True)self.assertFalse(self.collect()[0]["retry_available"])+ def test_a_failed_face_model_download_points_at_its_card_and_can_be_retried(self):+ latest: list = []+ self.contract.task_runs = SimpleNamespace(query=lambda **_: list(latest), available=lambda: True)+ # 还没取过:下次用到时会自己去取,不算问题。+ self.assertEqual(self.collect(), [])+ latest.append(SimpleNamespace(id=42, active=False, status="failed",+ finished_at="2026-10-22T08:00:00Z", error="连不上 GitHub"))+ [row] = self.collect()+ self.assertEqual({key: row[key] for key in ("key", "href", "link_label", "since", "retry", "retry_available")}, {+ "key": "face-models", "href": "/tasks#run-42", "link_label": "查看失败记录",+ "since": "2026-10-22T08:00:00Z", "retry": "/api/face-models", "retry_available": True})+ self.assertNotIn("连不上 GitHub", json.dumps(row, ensure_ascii=False))+ # 重新下载在跑时这一行先收起。+ latest[0] = SimpleNamespace(id=43, active=True, status="running", finished_at=None, error="")+ self.assertEqual(self.collect(), [])+def test_one_broken_service_does_not_hide_the_others(self):def broken():raise RuntimeError("状态文件读坏了")diff --git a/web/dist/peach-app.js b/web/dist/peach-app.jsindex 7d6ef3b02..46fc87e4f 100644--- a/web/dist/peach-app.js+++ b/web/dist/peach-app.js@@ -2,7 +2,7 @@(function() {try {var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, t = new e.Error().stack;- t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "846ceca9-5b00-4c94-a82e-dce20d3a86ab", e._sentryDebugIdIdentifier = "sentry-dbid-846ceca9-5b00-4c94-a82e-dce20d3a86ab");+ t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "aa9656ee-f849-486f-897c-f9bfccbd9deb", e._sentryDebugIdIdentifier = "sentry-dbid-aa9656ee-f849-486f-897c-f9bfccbd9deb");} catch {}})();var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, n) => {@@ -38890,6 +38890,7 @@ function iye({ rows: e }) {}function Rj({ run: e, meta: t, children: n, footer: r, followups: i }) {return /* @__PURE__ */ (0, D.jsxs)("li", {+ id: `run-${e.id}`,"data-status": e.status,"data-task-key": e.task_key,"data-run-id": e.id,@@ -115767,4 +115768,4 @@ pxt(mxt);//#endregionexport { $w as applyTheme, Zk as peachHistory, Jo as popCount, Vgt as showToast };-//# debugId=846ceca9-5b00-4c94-a82e-dce20d3a86ab\ No newline at end of file+//# debugId=aa9656ee-f849-486f-897c-f9bfccbd9deb\ No newline at end of file