Skip to content

Complete the server trip when the operator discards it locally - #725

Open
patrickrb wants to merge 2 commits into
devfrom
fix/abandon-completes-server-trip
Open

Complete the server trip when the operator discards it locally#725
patrickrb wants to merge 2 commits into
devfrom
fix/abandon-completes-server-trip

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Summary

Discard local trip dropped the phone's queue and forgot the trip, but never touched the server — so a trip row already created on roadsontheair.com stayed active forever. The site (correctly, per its heard-from-recently rule) called the rover Live for 24 hours and badged the trip active indefinitely after that, and with the app's local state gone there was no client left that could complete it. This stranded K1AF 2026-08-03 in production last night.

abandonTrip now snapshots the trip id, base URL and API key before clearTrip() wipes them, finishes the local teardown exactly as before, then fires one best-effort completeTrip:

  • Fire-and-forget by design — the button also serves the broken cases (bad key, deleted trip) where the call fails and the row was unreachable anyway; retry loops belong to End Trip's tripPendingComplete path, not here.
  • shouldCompleteAbandonedTrip (pure, tested) skips the doomed attempt when the trip was never created server-side or no API key is stored.
  • The Discard row's description now says it ends the trip on the server.

Companion site PR (patrickrb/road-trips-on-the-air-site#30) adds an owner-facing "End this trip" on the trip page for rows already stranded.

Testing

New RotaAbandonTest covers the eligibility decision. Full testDebugUnitTest passes. ktlintCheck/detekt remain red on clean dev in untouched files (Wsjtx*, DebugInject.kt) — no new issues from this change (verified against the reports).

🤖 Generated with Claude Code

Discard local trip was local-only: it dropped the queue and forgot the
trip, but a row already created on roadsontheair.com stayed active
forever — the site called the rover live for a day (the heard-from
window) and badged the trip active after that, and with the app's local
state gone no client could ever complete it. Exactly this stranded
K1AF 2026-08-03 in production.

abandonTrip now snapshots the trip id and credentials before clearTrip
wipes them and fires one best-effort completeTrip. Fire-and-forget is
deliberate: the button also serves the broken cases (bad key, deleted
trip) where the call fails and the row was unreachable anyway. A trip
still pending creation, or an install with no key, skips the doomed
attempt — shouldCompleteAbandonedTrip covers the decision.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 7.14286% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.90%. Comparing base (6977aa0) to head (3128be2).

Files with missing lines Patch % Lines
.../kotlin/radio/ks3ckc/ft8af/rota/RotaTripManager.kt 10.00% 9 Missing ⚠️
...otlin/radio/ks3ckc/ft8af/ui/rota/RoadTripScreen.kt 0.00% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                dev     #725      +/-   ##
============================================
- Coverage     35.91%   35.90%   -0.02%     
  Complexity      289      289              
============================================
  Files           248      248              
  Lines         30419    30433      +14     
  Branches       4018     4023       +5     
============================================
+ Hits          10926    10927       +1     
- Misses        19142    19155      +13     
  Partials        351      351              
Flag Coverage Δ
android 17.59% <7.14%> (-0.01%) ⬇️
native 9.93% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...otlin/radio/ks3ckc/ft8af/ui/rota/RoadTripScreen.kt 3.84% <0.00%> (-0.04%) ⬇️
.../kotlin/radio/ks3ckc/ft8af/rota/RotaTripManager.kt 5.93% <10.00%> (+0.13%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

There’s a correctness issue in shouldCompleteAbandonedTrip (whitespace trip IDs) and the updated discard description string appears to be unused, so the UI text change likely won’t take effect.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

This PR addresses a production issue where “Discard local trip” cleared local state but left an already-created trip row on roadsontheair.com stuck as active indefinitely by adding a best-effort server-side completion attempt during local discard.

Changes:

  • Snapshot trip identity/config before clearTrip(), then fire a one-shot completeTrip call after local teardown in abandonTrip().
  • Add shouldCompleteAbandonedTrip (pure helper) plus a new unit test to gate when the best-effort completion should run.
  • Update the “Discard local trip” description string to say it ends the trip on the server.
File summaries
File Description
ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/rota/RotaTripManager.kt Snapshots trip settings before clearing local state and conditionally triggers a best-effort server completion; adds shouldCompleteAbandonedTrip.
ft8af/app/src/test/kotlin/radio/ks3ckc/ft8af/rota/RotaAbandonTest.kt Adds unit coverage for the abandon eligibility decision logic.
ft8af/app/src/main/res/values/strings_compose.xml Updates the discard-trip description text to mention server-side ending.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/rota/RotaTripManager.kt Outdated
Comment thread ft8af/app/src/main/res/values/strings_compose.xml Outdated
A whitespace-only trip id now counts as no id (isNotBlank, matching the
key check), and rota_abandon_desc — which was defined but rendered
nowhere — is wired up as a caption under the active-trip buttons, since
Discard destroying undelivered data deserves saying before the tap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants