From d561de06ecbcd7737900f0390930b454f32854ed Mon Sep 17 00:00:00 2001 From: MS-01-Codex <3647348c-0c07-48e0-8938-fb9280321c5f@agents.multica.local> Date: Tue, 18 Aug 2026 21:52:15 +0800 Subject: [PATCH] fix: reload sentiment cycle history after backfill backfillData() only refreshed system settings after a successful backfill, leaving state.sentimentHistory/sentimentHistoryKey populated with the stale pre-backfill cache, so an already-open sentiment cycle page kept showing the old one-day history. After a successful backfill, clear both cache fields and, when the sentiment cycle view is active, force loadSentimentHistory(true) so the history renders immediately. Add a frontend contract test covering the refresh path. Co-authored-by: multica-agent --- config/architecture-inventory.json | 4 ++-- frontend/shared/admin.js | 5 +++++ tests/test_frontend_contract.py | 9 +++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/config/architecture-inventory.json b/config/architecture-inventory.json index 1c83018..f0eaaf4 100644 --- a/config/architecture-inventory.json +++ b/config/architecture-inventory.json @@ -541,8 +541,8 @@ }, { "path": "frontend/shared/admin.js", - "bytes": 14386, - "lines": 265 + "bytes": 14556, + "lines": 270 }, { "path": "backend/features/heaven/market_context.py", diff --git a/frontend/shared/admin.js b/frontend/shared/admin.js index dce394f..50dbbd2 100644 --- a/frontend/shared/admin.js +++ b/frontend/shared/admin.js @@ -8,6 +8,11 @@ async function backfillData() { end_date: document.querySelector("#backfillEnd").value, }); showToast(`历史回补完成,共处理 ${payload.results.length} 个工作日`); + state.sentimentHistory = null; + state.sentimentHistoryKey = ""; + if (state.activeView === "sentimentCycleView") { + await loadSentimentHistory(true); + } await openAdminSettings(true); } catch (error) { showToast(error.message); diff --git a/tests/test_frontend_contract.py b/tests/test_frontend_contract.py index 06d4e15..ab8f0fd 100644 --- a/tests/test_frontend_contract.py +++ b/tests/test_frontend_contract.py @@ -166,6 +166,15 @@ class FrontendContractTests(unittest.TestCase): self.assertIn('id="accountDropdown"', self.html) self.assertIn('id="settingsButton"', self.html) + def test_backfill_clears_sentiment_cache_and_reloads_sentiment_view(self): + start = self.script.index("async function backfillData") + end = self.script.index("async function openAdminSettings", start) + backfill = self.script[start:end] + self.assertIn("state.sentimentHistory = null;", backfill) + self.assertIn('state.sentimentHistoryKey = "";', backfill) + self.assertIn('if (state.activeView === "sentimentCycleView")', backfill) + self.assertIn("await loadSentimentHistory(true);", backfill) + def test_screener_uses_progressive_strategy_editor(self): for step in ("regime", "strategy", "run", "result"): self.assertIn(f'data-screener-step="{step}"', self.html)