fix(chat): make cloud the only truth for charts, synastry, and pin/archive
Independent Staging Quality Gate / validate (push) Has been cancelled
Independent Staging Quality Gate / publish (push) Has been cancelled

Local fallbacks were creating fake saves and resurrecting deleted rows.
Pin and archive now live on chat_sessions so they follow the account.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-01 21:38:21 +08:00
parent 31c7b48261
commit ce6a8a7e72
16 changed files with 390 additions and 153 deletions
+15 -5
View File
@@ -126,7 +126,9 @@ def test_chat_page_uses_authenticated_cloud_persistence() -> None:
assert "系统正在以账户记录为准同步点数" in source
assert "回答中途断开,已保留现有内容,本次已计费。" not in source
assert "本次已开始生成并计费" not in source
assert 'localStorage.setItem(chartLibraryStorageKey(accountId)' in source
# Former value: `localStorage.setItem(chartLibraryStorageKey(accountId)`
# wrote a local library copy on cloud save failure.
assert "localStorage.setItem(chartLibraryStorageKey(accountId)" not in source
assert 'localStorage.setItem("chat_sessions"' not in source
@@ -180,19 +182,24 @@ def test_chart_profile_library_has_cloud_table_api_and_local_fallback() -> None:
"draftSynastryQuestionFromChart",
"synastryReportCard",
"synastryHistory",
"synastryHistoryStorageKey",
"discardLegacyCloudMirrorKeys",
"synastry-report-card",
"synastry-history-list",
'fetch("/api/synastry"',
"Ashtakoot",
"chartLibraryStorageKey",
"Cloud chart library is best-effort",
"jyotisha_chart_library",
"保存失败,请重试",
"星盘库",
"添加其他星盘",
"用于合盘",
"设为默认",
):
assert token in page
# Former values: synastryHistoryStorageKey, chartLibraryStorageKey,
# and the comment "Cloud chart library is best-effort".
assert "synastryHistoryStorageKey" not in page
assert "chartLibraryStorageKey" not in page
assert "Cloud chart library is best-effort" not in page
assert "ayanam-profile" not in page
assert "ayanam-sessions" not in page
@@ -251,11 +258,14 @@ def test_synastry_reports_are_cloud_persisted_per_user() -> None:
"fetchCloudSynastryHistory",
"saveCloudSynastryReport",
'fetch("/api/synastry-reports"',
"writeSynastryHistory(accountId, next)",
"未能存入历史",
"cloud_synastry_history_unavailable",
"cloud_synastry_report_save_failed",
):
assert token in page
# Former value: writeSynastryHistory(accountId, next) wrote a local
# history copy when cloud save failed.
assert "writeSynastryHistory(accountId, next)" not in page
def test_consultation_credit_lifecycle_is_idempotent_and_server_only() -> None: