Repository navigation
fix(dispatch): 乘客取消已接的訂單時也通知 App 司機(先前只推 LINE) - #56
Merged
Merged
Conversation
App 的搶單/多裝置/弱網三輪 debug 對真後端逐則印 payload 查出四件事, 但先前只寫在 fleet-app 的 TODO:接單/放棄失敗回 200+文案(應為 409)、 沒搶到的司機收不到任何事件、逾時取消只通知乘客、多裝置位置互相覆蓋且無踢舊 session。 後端這份清單上沒有它們,等於這些缺口沒人會排進後端的工作。 ride.stop_updated 只推乘客那一項已於 PR #53 修掉,一併標記。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
cancelActiveRide 的「通知司機」只有 line.PushText,App 司機一則 WS 事件都收不到。 司機端沒有任何輪詢(進行中行程全靠 WS),行程卡因此永遠留在畫面上—— 他會繼續開往上車點接一個已經取消的乘客,直到按下「乘客已上車」被後端擋下才知道; 而後端在取消當下就已經把他放回 Idle,畫面與真實狀態完全相反。 這是 dispatch#52(司機放棄只推 LINE、App 乘客收不到)在司機側的鏡像。 App 端本來就有 ride.cancelled 的處理,缺的一直是這則事件。 測試:新增兩案(已接訂單時乘客與司機各收到一則、未派單時不推給司機)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
thothawei
added a commit
that referenced
this pull request
Jul 29, 2026
ride.picked_up 先前只推乘客。司機的第二台裝置(或 LINE 那條路徑)標記上車後, 這一台會停在「前往上車點」階段——按鈕還是「乘客已上車」,按下去只會被後端拒絕 (狀態已是 PickedUp),而「放棄此單」這時也已不可用。 App 端本來就有這則事件的處理(切到 onTrip 階段),缺的一直是事件本身。 與 ride.stop_updated(#53)、ride.cancelled(#56)同一族。 測試:pickUpFixture 抽出可注入 publisher 的版本;新增一案斷言乘客與司機各收到一則。 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.
怎麼找到的
把後端 13 個事件型別的實際收件人逐一列出來(
grep每個s.publish(...)的Recipient),再跟 App 兩端的 handler 對照。矩陣一攤開就看到一個洞:ride.assignedride.acceptedride.completedride.stop_updatedride.cancelled而 App 司機端早就寫好了
ride.cancelled的處理——那段程式碼到今天為止是死的。機制
cancelActiveRide的「通知司機」只有line.PushText:司機端沒有任何輪詢(進行中行程全靠 WS,
grep -n "Timer.periodic" driver_controller.dart零命中),所以:releaseAndReset把他放回 Idle ——畫面與真實狀態完全相反,他甚至可能同時收到新派單;這是 dispatch#52(司機放棄只推 LINE、App 乘客收不到)在司機側的鏡像——同一個 bug 的另一半,當時只修了一邊。
改了什麼
cancelActiveRide在推 LINE 之外,補推ride.cancelled給該司機(RoleDriver)。App 端不需要改就會收掉卡片;配套的「說明原因」在 fleet-app 的 PR。驗收
go build ./.../go vet/gofmt乾淨。ride.cancelled、未派單的訂單不推給司機(不能憑空推給誰)。publish後,TestCancelByCustomerID_通知App司機FAIL。🤖 Generated with Claude Code