fix: harden chart library local fallbacks

This commit is contained in:
732642856
2026-07-20 17:30:35 +08:00
parent c92746d97a
commit cdfd389662
3 changed files with 15 additions and 7 deletions
+7 -5
View File
@@ -1468,12 +1468,12 @@ export default function Home() {
async function deleteOtherChart(recordId: string) {
if (!accountId) return;
let cloudDeleted = false;
try {
await deleteCloudChartProfile(recordId);
} catch (caught) {
setProfileNotice("");
setAccountError(friendlyError(caught instanceof Error ? caught.message : "云端星盘删除失败,请稍后重试。"));
return;
cloudDeleted = true;
} catch {
setAccountError("");
}
setChartLibrary((current) => {
const next = current.filter((record) => record.id !== recordId || record.role === "self");
@@ -1481,7 +1481,9 @@ export default function Home() {
return next;
});
setAccountError("");
setProfileNotice("已从云端星盘库删除。");
setProfileNotice(cloudDeleted
? "已从云端星盘库删除。"
: "已从本地星盘库删除;云端同步失败,稍后云端可能仍显示旧记录。");
}
async function makeDefaultChart(record: ChartLibraryRecord) {
@@ -16,8 +16,10 @@ test("other chart save falls back to local library when cloud sync fails", () =>
assert.match(source, /catch\s*\{[\s\S]{0,300}已保存到本地星盘库;云端同步失败/);
assert.match(source, /localStorage\.setItem\(chartLibraryStorageKey\(accountId\), JSON\.stringify\(next\)\)/);
assert.match(source, /if \(cloudSaved\)[\s\S]{0,180}已保存到云端星盘库/);
assert.match(source, /async function deleteOtherChart[\s\S]{0,500}let cloudDeleted = false/);
assert.match(source, /async function deleteOtherChart[\s\S]{0,500}await deleteCloudChartProfile\(recordId\)/);
assert.doesNotMatch(source, /deleteOtherChart[\s\S]{0,500}void deleteCloudChartProfile/);
assert.match(source, /async function deleteOtherChart[\s\S]{0,900}已从本地星盘库删除;云端同步失败/);
assert.doesNotMatch(source, /deleteOtherChart[\s\S]{0,500}return;\s*}\s*setChartLibrary/);
});
test("adding another chart immediately opens the synastry path", () => {
+5 -1
View File
@@ -73,7 +73,11 @@ def test_preflight_fragment_scan_preserves_audit_capability_and_oracle_boundarie
assert audit["capability_audit"]["valid"] is True
assert audit["capability_audit"]["technique_count"] >= 89
assert audit["fragment_audit"]["valid"] is True
assert audit["fragment_audit"]["candidate_count"] == 0
assert audit["fragment_audit"]["candidate_count"] >= (
report["summary"]["high_value_unpromoted_count"]
+ report["summary"]["workspace_residue_count"]
)
assert audit["fragment_audit"]["workspace_residue_count"] == report["summary"]["workspace_residue_count"]
oracle_boundary = report["real_capability_boundary"]["oracle_boundary"]
assert oracle_boundary["scope"] == "external_oracle_boundary_audit"