Skip to content

feat(earthquake): say what the replay knows about EEW - #676

Open
whes1015 wants to merge 3 commits into
mainfrom
feat/replay-eew-states
Open

whes1015 wants to merge 3 commits into
mainfrom
feat/replay-eew-states

Conversation

@whes1015

Copy link
Copy Markdown
Member

這個 PR 做了什麼

地震報告的重播畫面在沒有速報時原本是一片空白,使用者分不出「還沒出現」、「載入失敗」、「這場根本沒有速報」。這個 PR 把這三件事分開講,並修掉卡片會中途消失的問題:

  • 卡片 sticky:/api/v2/eq/eew/{sec} 回傳的是「該秒仍然有效」的速報集合,不是「該秒發布」。實測 2026-11-01 M5.6 事件,同一筆 serial 在 +30 秒到 +120 秒都還在集合裡,之後回到 []。原本卡片直接綁在輪詢結果上,事件還在播報時就會消失;現在保留最後一組非空集合,空回應代表「沒有新的」,不是「沒有」。
  • 四種狀態分開:ReplayEewSlot(card/pending/waiting/retrying/unavailable/none)決定槽位顯示什麼,優先序寫成純函式 replayEewSlot,可單獨測試。失敗一律走「正在重試」或「暫時無法取得」,絕不借用「沒有資料」的說法。
  • 三點採樣:進入重播時並行打三個時間點(開始 origin − 60 s、中間、origin + 300 s),三點都 200 且皆空才說「此次重播未偵測到速報資料」,並以小字說明依據;任一點失敗則不下結論。結果快取在 session 內,不會每次重進都重打。
  • 文案:5 個新字串進 12 個語系。

相關 issue

無。

怎麼驗

tool/check.sh        # all gates passed(3835 tests)
tool/dev/test.sh test/features/earthquake   # 380 passed

新增的測試:

  • test/features/earthquake/replay_eew_probe_test.dart:三點各打一次、任一有資料即 found、樣本失敗不下結論、JMA 與 CWA-only 過濾,以及 replayEewSlot 的優先序(卡片優先、失敗優先於空集合、未決定時不說話)。
  • test/features/earthquake/presentation/widgets/replay_eew_notice_test.dart:四種提示各自的文字與圖示,並斷言「重試」與「沒有資料」不會同時出現。
  • test/features/earthquake/presentation/pages/report_replay_page_test.dart:archive.eews = [] 之後卡片仍在;生命週期改成平台實際送出的鏈(inactive → hidden → paused → … → resumed),因為卡片現在整場保留一個 AppLifecycleListener。

檢查清單

  • tool/check.sh 全綠
  • 新增/修改的行為都有測試覆蓋
  • 使用者看得到的字串都走 AppLocalizations(12 語系)
  • commit 訊息符合 commit.md

@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.69%. Comparing base (16fc70a) to head (135da47).
⚠️ Report is 6 commits behind head on main.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lowrt lowrt added this to the v27.1 milestone Nov 20, 2026
Platform: all
Fix(zh-Hant): 重播時速報卡片不會在事件仍在播報時消失
Fix(en-US): the replayed EEW card no longer disappears while its alert still stands
Platform: all
New(zh-Hant): 重播沒抓到速報時會說明是尚未出現、正在重試,還是整場都沒偵測到
New(en-US): a replay without EEW now says whether it is not in yet, retrying, or was not detected at all
@whes1015
whes1015 force-pushed the feat/replay-eew-states branch from 46b8b54 to 993dd57 Compare November 20, 2026 20:02
Platform: all
Fix(zh-Hant): 重播超出速報保留範圍或早於第一筆時,畫面不再顯示成連線異常
Fix(en-US): a replay outside the EEW archive no longer looks like a broken connection
@whes1015
whes1015 force-pushed the feat/replay-eew-states branch from 993dd57 to 135da47 Compare November 20, 2026 20:13
@github-actions

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 19 selected item(s).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants