fix(app): App 被收掉再開,行程還在但位置回報整段消失(第二十三輪) - #94
Merged
Conversation
「定位健康度」這一族的最後一個角落。TODO 原本寫「前景服務被系統收走時 App 端沒有 任何偵測」——查下去發現那句要更正:服務被收走而 App 還活著時串流會停,第二十一輪的 定期重評已經接住(第二十二輪實測 12~24 秒降級)。真正沒有網的是冷啟動: init() 會用 _restoreActiveRide() 還原進行中行程(行程卡照樣顯示導航/已上車/完成), 但 _online 一律從 false 起、定位串流也沒起來 → 整趟零位置回報。後果不在司機端: 乘客端司機 marker 定格、後端抵達圍籬不觸發、F3 里程軌跡缺一整段。而 hero 只寫 「離線/目前不會收到派單」——在載客途中,那句話講的是接不接新單。 修法兩個: 1. 冷啟動還原到進行中行程時接回定位回報。三個限制寫在碼裡:只在冷啟動做(回前景也 自動上線的話離線鈕按不掉)、只在已有權限時做(冷啟動彈權限視窗太侵入,沒權限就留 一則「需要定位權限才能把位置回報給乘客」而不是「才能上線」)、沒有行程不自動上線。 2. refreshVehicle() 不再無條件 _setError(null)——它會把排在前面設好的訊息全洗掉, 上面那句權限提示就是這樣消失的。改成只清自己造成的那則。 驗收:flutter analyze 無 issue、flutter test 383 passed(377+新 6)。 反向驗證兩半各一次,各 2 案 FAIL。模擬器實跑同一台裝置、同一張行程 #37 跑兩個版本: force-stop 後修好的版本重開 8 秒內恢復回報(hero「上線中」),修改前 40 秒零筆 (行程卡完整、hero 卻寫「離線」)。負向對照:沒有行程時冷啟動零回報。 過程中踩到一條記進 TODO:接縫的預設實作會跑進測試環境——冷啟動直接 await 平台權限 確認,讓 driver_home_widget_test 從 4.8 秒變成 7 分鐘以上(測試環境沒有 platform channel,那個 Future 永遠不會完成)。預設探針現在先看 FLUTTER_TEST 回「查不到」, 並用三態(null/denied/granted)區分「查不到」與「被拒絕」。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
程式碼與測試沒有衝突——兩批動的是不同檔案(第二十三輪在司機端定位回報, 預約司機那批在乘客端)。衝突只有 docs/TODO.md 的三處與 README.md, 都是「兩邊各自新增」,兩邊內容都保留。 **數字是合併後重新實測的,不是沿用任一邊**(照 TODO 寫作規則第 4 條): - 第二十三輪自己是 383 passed/51 檔、預約司機那批是 408/53 - 合併後 `flutter test` **414 passed、54 個測試檔**、`flutter analyze` 無 issue 專章裡的 383 保留不動——那是第二十三輪當時的驗收事實,另加一行標明合併後的數字。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
thothawei
added a commit
that referenced
this pull request
Aug 1, 2026
PR #97 與 main 分岔:#94(第二十三輪)與 #95(預約司機+常用地點)先合併, docs/TODO.md 的目錄、測試數字、章節順序與 customer_controller 的 _clearSession 三處衝突。解法都是兩邊並存,不是二選一: - `_clearSession()`:分頁視窗(_historyWindow/_historyMoreError/_historyHasMore) 與常用地點/預約的清除**都要留**——兩者都是「換人登入不能留上一位的資料」。 - TODO 目錄補上第二十四輪那行(原本兩邊各刪掉對方的)。 - 「現況」的測試數字先留 main 的 414,收尾重數後再更正(寫作規則 4)。 - 第二十四輪專章接在預約司機專章之後,「下次任務」以第二十四輪那段為最新在前。 驗收:flutter analyze 無 issue、flutter test **423 passed**(main 414 + 本 PR 9)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
先更正一句 TODO
原本寫的是「前景服務被系統收走 → App 端沒有任何偵測」。查下去發現那句要改:服務被收走而 App 還活著時串流會停,第二十一輪的定期重評已經接住了(第二十二輪實測 12~24 秒降級)。真正沒有網的是冷啟動。
根因
init()會用_restoreActiveRide()把進行中行程還原(行程卡照樣顯示「導航/已上車/完成」),但_online一律從 false 起、定位串流也沒起來——整趟零位置回報。後果不在司機這一端:
而 hero 只寫「離線/目前不會收到派單」——在載客途中,那句話講的是接不接新單。觸發條件很日常:省電模式或廠商清背景把 App 收掉、司機自己從最近工作清單滑掉。
修法(兩個)
onAppResumed刻意不做——回前景也自動上線的話,那顆離線鈕就按不掉了)refreshVehicle()不再無條件_setError(null):它會把排在前面設好的訊息全洗掉,上面那句權限提示就是這樣消失的。改成只清自己造成的那則(同一種病第二十一輪在位置回報探針上修過一次)。驗收
flutter analyze無 issue、flutter test383 passed(377 +新 6)。refreshVehicle回去無條件清錯誤 → 2 案 FAIL。am force-stop(模擬系統收掉 App)過程中踩到的一條(已寫進 TODO)
接縫的預設實作會跑進測試環境:我一開始讓冷啟動直接 await 平台權限確認,
driver_home_widget_test從 4.8 秒變成 7 分鐘以上——測試環境沒有 platform channel,那支呼叫的 Future 永遠不會完成。預設探針現在先看FLUTTER_TEST回「查不到」,並用三態(null/denied/granted)區分「查不到」與「被拒絕」。🤖 Generated with Claude Code