From 92d9bfd10873727c38452cfd413d5f395a8771b3 Mon Sep 17 00:00:00 2001 From: 732642856 <732642856@qq.com> Date: Mon, 20 Jul 2026 18:40:29 +0800 Subject: [PATCH] fix: expose synastry computation progress (#16) --- frontend/src/app/page.tsx | 8 +++++++- frontend/tests/chart-library-other-profile.test.ts | 8 ++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index cab54906..f5b81a8d 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -668,6 +668,7 @@ export default function Home() { const [activeAccountDialog, setActiveAccountDialog] = useState(null); const [chartLibrary, setChartLibrary] = useState([]); const [chartLibraryOpen, setChartLibraryOpen] = useState(false); + const [synastryPendingId, setSynastryPendingId] = useState(null); const [otherProfileDraft, setOtherProfileDraft] = useState(emptyProfile); const [synastryReportCard, setSynastryReportCard] = useState(null); const [synastryHistory, setSynastryHistory] = useState([]); @@ -1746,7 +1747,10 @@ export default function Home() { async function draftSynastryQuestionFromChart(record: ChartLibraryRecord) { if (record.role !== "other") return; + if (synastryPendingId) return; const baseQuestion = buildSynastryQuestion(profile, record.profile); + setSynastryPendingId(record.id); + setComposerNotice("正在计算基础合盘证据,请稍候。"); try { const response = await fetch("/api/synastry", { method: "POST", @@ -1801,6 +1805,8 @@ export default function Home() { } catch { chooseSuggestedQuestion(baseQuestion, "marriage"); setComposerNotice("合盘计算暂时不可用,已先生成问题草稿。"); + } finally { + setSynastryPendingId(null); } closeAccountDialog(); } @@ -2594,7 +2600,7 @@ export default function Home() { {record.profile.date} {record.profile.time} · {profilePlaceLabel(record.profile)}
- +
diff --git a/frontend/tests/chart-library-other-profile.test.ts b/frontend/tests/chart-library-other-profile.test.ts index 3507c687..7ed8d5fc 100644 --- a/frontend/tests/chart-library-other-profile.test.ts +++ b/frontend/tests/chart-library-other-profile.test.ts @@ -47,3 +47,11 @@ test("cloud save failures preserve the server error message", () => { assert.match(source, /const payload = await response\.json\(\)\.catch\(\(\) => null\) as \{ error\?: string \} \| null;/); assert.match(source, /throw new Error\(payload\?\.error \|\| "cloud_chart_profile_save_failed"\);/); }); + +test("synastry selection exposes a pending state while the evidence packet is computed", () => { + assert.match(source, /const \[synastryPendingId, setSynastryPendingId\] = useState\(null\);/); + assert.match(source, /setSynastryPendingId\(record\.id\);/); + assert.match(source, /finally \{\s*setSynastryPendingId\(null\);\s*\}/); + assert.match(source, /disabled=\{synastryPendingId !== null\}/); + assert.match(source, /synastryPendingId === record\.id \? "正在计算合盘\.\.\." : "用于合盘"/); +});