Skip to content

Add GPS status feedback and freshness validation for ping operations#49

Merged
MrAlders0n merged 4 commits intodevfrom
copilot/improve-gps-status-feedback
Dec 18, 2025
Merged

Add GPS status feedback and freshness validation for ping operations#49
MrAlders0n merged 4 commits intodevfrom
copilot/improve-gps-status-feedback

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

When GPS data was stale, manual pings silently requested fresh position without user feedback, eventually timing out with generic "ping timeout". Auto ping mode sent pings regardless of GPS data age, with no freshness validation.

Changes

Manual ping:

  • Display "GPS data too old, requesting fresh position" when requesting fresh GPS
  • Display "Error: could not get fresh GPS location" on timeout instead of generic error

Auto ping:

  • Validate GPS data age against configured threshold (interval + buffer) before each ping
  • Display "GPS data old, trying to refresh position" when attempting refresh
  • Display "GPS could not refresh position, skipping ping. Next attempt (Xs)" on failure
  • Skip ping when GPS refresh fails, schedule next attempt at configured interval
  • Only send pings with fresh GPS coordinates

Implementation:

async function getGpsCoordinatesForPing(isAutoMode) {
  if (isAutoMode) {
    // Validate GPS freshness
    const ageMs = Date.now() - state.lastFix.tsMs;
    const maxAge = intervalMs + GPS_FRESHNESS_BUFFER_MS;
    
    if (ageMs >= maxAge) {
      setStatus("GPS data old, trying to refresh position", STATUS_COLORS.warning);
      try {
        return await acquireFreshGpsPosition();
      } catch (e) {
        setStatus(`GPS could not refresh position, skipping ping. Next attempt (${intervalSec}s)`, STATUS_COLORS.error);
        return null;
      }
    }
  }
  // ... manual ping handling with status updates
}

Extracted acquireFreshGpsPosition() helper to eliminate duplication between auto and manual GPS acquisition paths.

Original prompt

Improve GPS Status Feedback During Ping Operations

Problem

When GPS coordinates are too old and the user presses the manual ping button, there is no visual feedback while the app attempts to request fresh position data. The user only sees a status change when the operation finally times out to "ping timeout", leaving them confused about what's happening.

Additionally, Auto Ping mode does not respect the GPS freshness threshold - it will attempt to send pings even when GPS data is stale.

Current Behavior

Manual Ping

  1. User presses manual ping button
  2. GPS data is detected as too old
  3. App silently requests fresh position
  4. User sees no status update during this process
  5. If timeout occurs, status shows generic "ping timeout"

Auto Ping

  • Auto ping sends pings regardless of GPS data age
  • No freshness validation before sending

Expected Behavior

Manual Ping

  1. User presses manual ping button
  2. GPS data is detected as too old
  3. Status immediately changes to: "GPS data too old, requesting fresh position"
  4. If fresh position is obtained, proceed with ping
  5. If timeout occurs, status changes to: "Error: could not get fresh GPS location"

Auto Ping

  • Auto ping mode should validate GPS freshness against the configured threshold before each ping
  • If GPS data is too old:
    • Do NOT send the ping
    • Attempt to request fresh GPS position
    • Status should change to: "GPS data old, trying to refresh position"
    • If refresh fails/times out, status should change to: "GPS could not refresh position, skipping ping. Next attempt (Xs)" (where X is the configured auto-ping interval)
    • If refresh succeeds: Send the ping and proceed with normal status messaging
    • Stay in auto ping mode and continue attempting at the set interval
    • Only send a ping when GPS coordinates are fresh

Debug Logs Reference

Console output when manual ping is attempted with stale GPS data:

[DEBUG] Manual ping button clicked
wardrive.js:18 [DEBUG] sendPing called (manual=true)
wardrive.js:18 [DEBUG] GPS data too old (90059ms), requesting fresh position
wardrive.js:18 [DEBUG] Requesting fresh GPS position for manual ping
wardrive.js:30 [DEBUG] Ping operation failed: Timeout expired GeolocationPositionError {code: 3, message: 'Timeout expired'}
debugError @ wardrive.js:30
sendPing @ wardrive.js:810
await in sendPing
(anonymous) @ wardrive.js:1045


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits December 18, 2025 18:07
- Manual ping now shows "GPS data too old, requesting fresh position" when requesting fresh GPS
- Manual ping shows "Error: could not get fresh GPS location" on timeout
- Auto ping validates GPS freshness before sending
- Auto ping shows "GPS data old, trying to refresh position" when refreshing
- Auto ping shows "GPS could not refresh position, skipping ping. Next attempt (Xs)" on failure
- Auto ping schedules next attempt when GPS refresh fails

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
- Created acquireFreshGpsPosition() helper to eliminate code duplication
- Reduces duplication between auto and manual GPS acquisition
- Improves code maintainability and readability

Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve GPS status feedback during ping operations Add GPS status feedback and freshness validation for ping operations Dec 18, 2025
Copilot AI requested a review from MrAlders0n December 18, 2025 18:12
@MrAlders0n MrAlders0n marked this pull request as ready for review December 18, 2025 18:14
@MrAlders0n MrAlders0n merged commit 75f235a into dev Dec 18, 2025
@MrAlders0n MrAlders0n deleted the copilot/improve-gps-status-feedback branch December 19, 2025 01:25
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