Repository navigation
fix(stops): ride.stop_updated 也推給司機——單裝置假設在多裝置下不成立 - #53
Merged
Merged
Conversation
原本這則事件只推給乘客,理由寫在註解裡:「司機端剛做完動作、 會自己重讀 active」。那假設了司機只有一台裝置:同一位司機的第二台 裝置(或 LINE 那條路徑)標記到達/跳過時,這台不會重讀,畫面會停在 舊的「下一站」——而「下一站」正是司機端唯一給操作的那一站, 兩台會對不同的站給按鈕。 動作來源那台會多收到一則自己造成的事件(它已經重讀過了), 那是一次多餘的重讀,遠比兩台狀態不一致便宜。 驗收:go build/go vet/gofmt 乾淨;service 測試(真 PostGIS)改為 斷言乘客+司機各一則並驗收件人,反向確認拿掉 driver publish 會 FAIL。 模擬器實跑對照:舊版標記後 8 分鐘司機 App 完全沒動;新版 5 秒內 整份清單跟上(前兩站綠勾「已完成」、下一站前移、地圖重畫)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Jul 29, 2026
thothawei
added a commit
that referenced
this pull request
Jul 29, 2026
App 的搶單/多裝置/弱網三輪 debug 對真後端逐則印 payload 查出四件事, 但先前只寫在 fleet-app 的 TODO:接單/放棄失敗回 200+文案(應為 409)、 沒搶到的司機收不到任何事件、逾時取消只通知乘客、多裝置位置互相覆蓋且無踢舊 session。 後端這份清單上沒有它們,等於這些缺口沒人會排進後端的工作。 ride.stop_updated 只推乘客那一項已於 PR #53 修掉,一併標記。 Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
thothawei
added a commit
that referenced
this pull request
Jul 29, 2026
* docs(todo): 補記 App 端實跑查出的四個後端缺口(T1–T4) App 的搶單/多裝置/弱網三輪 debug 對真後端逐則印 payload 查出四件事, 但先前只寫在 fleet-app 的 TODO:接單/放棄失敗回 200+文案(應為 409)、 沒搶到的司機收不到任何事件、逾時取消只通知乘客、多裝置位置互相覆蓋且無踢舊 session。 後端這份清單上沒有它們,等於這些缺口沒人會排進後端的工作。 ride.stop_updated 只推乘客那一項已於 PR #53 修掉,一併標記。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * fix(dispatch): 乘客取消已接的訂單時也通知 App 司機(先前只推 LINE) cancelActiveRide 的「通知司機」只有 line.PushText,App 司機一則 WS 事件都收不到。 司機端沒有任何輪詢(進行中行程全靠 WS),行程卡因此永遠留在畫面上—— 他會繼續開往上車點接一個已經取消的乘客,直到按下「乘客已上車」被後端擋下才知道; 而後端在取消當下就已經把他放回 Idle,畫面與真實狀態完全相反。 這是 dispatch#52(司機放棄只推 LINE、App 乘客收不到)在司機側的鏡像。 App 端本來就有 ride.cancelled 的處理,缺的一直是這則事件。 測試:新增兩案(已接訂單時乘客與司機各收到一則、未派單時不推給司機)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- 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.
問題
ride.stop_updated原本只推給乘客,理由就寫在publishStops的註解裡:「司機端剛做完動作、會自己重讀 active」。那句話假設了司機只有一台裝置。後端 Hub 是
map[*Client]bool,同一個 driver id 的每條連線都會收到事件,所以多裝置本來就是支援的——只是這則事件沒送。實際後果:同一位司機的第二台裝置(或 LINE 那條路徑)標記到達/跳過時,這台不會重讀,畫面停在舊的「下一站」,而「下一站」正是司機端唯一給操作的那一站,兩台會對不同的站給按鈕。改了什麼
publishStops改吃整個*model.Ride,在推給乘客之後、DriverID != nil時也推給司機(同一個 event 物件,payload 一樣是整趟 stops)。動作來源那台會多收到一則自己造成的事件(它已經重讀過了)——那是一次多餘的重讀,遠比兩台狀態不一致便宜。
驗收
go build ./.../go vet/gofmt乾淨。internal/service測試(真 PostGIS,testcontainers):三個 publish 案改為斷言「乘客+司機各一則」並驗第二則的收件人與型別;反向確認拿掉 driver publish 後TestMarkArrived_推ride_stop_updated給乘客FAIL(預期推 2 則事件(乘客+司機),得到 1)。m6_pixeldriver flavor + docker compose,2 乘客 4 站的 ride docs(status): 更新 STATUS.md 至 2026-07-12 現況 #9):App 端對應的處理在 fleet-app 的 PR(收到事件後以後端為準重讀 active)。
🤖 Generated with Claude Code