Python
fix(auto-approve): shadow export shows progress and the save time, check/checks plural (OPE-224)
Devika Verma90cf2d2745dc
diff --git a/surfaces/gui/src/components/SettingsView.tsx b/surfaces/gui/src/components/SettingsView.tsxindex 88e49ae6..b37498d1 100644--- a/surfaces/gui/src/components/SettingsView.tsx+++ b/surfaces/gui/src/components/SettingsView.tsx@@ -1405,6 +1405,7 @@ function AutoApproveCard() {const [keyError, setKeyError] = useState("");const [summary, setSummary] = useState<ShadowSummary | null>(null);const [exported, setExported] = useState("");+ const [exporting, setExporting] = useState(false);// Shadow results follow the chosen reviewer: reload when shadow turns on or the// reviewer changes, so the line never mixes reviewers (OPE-224).@@ -1418,8 +1419,18 @@ function AutoApproveCard() {}, [shadow, reviewer]);const exportResults = async () => {+ setExporting(true);+ setExported("");const r = await exportShadowResults().catch(() => ({ ok: false } as { ok: boolean; path?: string }));- setExported(r.ok && r.path ? r.path : t("settingsx.auto_approve.shadow_export_failed"));+ setExporting(false);+ // The time makes a repeat export visibly new: the file name is per day, so the path+ // alone would not change between clicks.+ const time = new Date().toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });+ setExported(+ r.ok && r.path+ ? t("settingsx.auto_approve.shadow_export_saved", { path: r.path, time })+ : t("settingsx.auto_approve.shadow_export_failed"),+ );};useEffect(() => {@@ -1516,7 +1527,7 @@ function AutoApproveCard() {<><div>{t("settingsx.auto_approve.shadow_summary_counts", {- checks: summary.checks, run: summary.run, asked: summary.asked, stopped: summary.stopped,+ count: summary.checks, run: summary.run, asked: summary.asked, stopped: summary.stopped,})}</div>{summary.decided > 0 && (@@ -1524,15 +1535,16 @@ function AutoApproveCard() {)}<buttontype="button"- className="mt-1 text-accent hover:underline"+ className="mt-1 text-accent hover:underline disabled:opacity-50"data-testid="shadow-export"+ disabled={exporting}onClick={exportResults}>- {t("settingsx.auto_approve.shadow_export")}+ {exporting ? t("settingsx.auto_approve.shadow_exporting") : t("settingsx.auto_approve.shadow_export")}</button>{exported && (<div className="select-all break-all" data-testid="shadow-export-path">- {t("settingsx.auto_approve.shadow_export_saved", { path: exported })}+ {exported}</div>)}</>diff --git a/surfaces/gui/src/locales/en.json b/surfaces/gui/src/locales/en.jsonindex ffab749e..a51825fa 100644--- a/surfaces/gui/src/locales/en.json+++ b/surfaces/gui/src/locales/en.json@@ -2503,12 +2503,14 @@"reviewer_key_placeholder_jev": "TypeSafe API key","reviewer_key_failed": "Couldn’t save the key.","shadow_summary_title": "Shadow results · last {{days}} days, all sessions, {{reviewer}}",- "shadow_summary_counts": "{{checks}} checks: would have run {{run}} · asked you {{asked}} · stopped {{stopped}}","shadow_summary_matched": "Matched your own decision {{matched}} of {{decided}} times.","shadow_summary_empty": "Nothing recorded yet. Keep working as usual; each approval card you answer is recorded.","shadow_export": "Export full results",- "shadow_export_saved": "Saved to {{path}}",- "shadow_export_failed": "Couldn’t export the results."+ "shadow_export_saved": "Saved at {{time}} to {{path}}",+ "shadow_export_failed": "Couldn’t export the results.",+ "shadow_summary_counts_one": "{{count}} check: would have run {{run}} · asked you {{asked}} · stopped {{stopped}}",+ "shadow_summary_counts_other": "{{count}} checks: would have run {{run}} · asked you {{asked}} · stopped {{stopped}}",+ "shadow_exporting": "Exporting…"},"sandbox": {"title": "Sandbox",diff --git a/surfaces/gui/src/locales/zh.json b/surfaces/gui/src/locales/zh.jsonindex 09bf2a74..28225154 100644--- a/surfaces/gui/src/locales/zh.json+++ b/surfaces/gui/src/locales/zh.json@@ -2459,12 +2459,14 @@"reviewer_key_placeholder_jev": "TypeSafe API 密钥","reviewer_key_failed": "无法保存密钥。","shadow_summary_title": "影子评估结果 · 最近 {{days}} 天,所有会话,{{reviewer}}",- "shadow_summary_counts": "{{checks}} 次检查:本会放行 {{run}} · 询问你 {{asked}} · 阻止 {{stopped}}","shadow_summary_matched": "与你自己的决定一致 {{matched}} / {{decided}} 次。","shadow_summary_empty": "尚无记录。照常使用即可;你处理的每张审批卡片都会被记录。","shadow_export": "导出完整结果",- "shadow_export_saved": "已保存到 {{path}}",- "shadow_export_failed": "无法导出结果。"+ "shadow_export_saved": "已于 {{time}} 保存到 {{path}}",+ "shadow_export_failed": "无法导出结果。",+ "shadow_summary_counts_one": "{{count}} 次检查:本会放行 {{run}} · 询问你 {{asked}} · 阻止 {{stopped}}",+ "shadow_summary_counts_other": "{{count}} 次检查:本会放行 {{run}} · 询问你 {{asked}} · 阻止 {{stopped}}",+ "shadow_exporting": "正在导出…"},"sandbox": {"title": "沙箱",