Skip to content

Fix auto ping timer conflict during manual ping#52

Merged
MrAlders0n merged 6 commits intodevfrom
copilot/fix-auto-ping-timer-conflict
Dec 18, 2025
Merged

Fix auto ping timer conflict during manual ping#52
MrAlders0n merged 6 commits intodevfrom
copilot/fix-auto-ping-timer-conflict

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

When auto ping is active and user triggers manual ping, both timers compete to update status display, causing flickering between "Waiting for API post" and "Waiting for next auto ping".

Changes

Pause/Resume Mechanism

  • Added state.pausedAutoTimerRemainingMs to store auto timer state during manual ping
  • Created pauseAutoCountdown() to pause timer and store remaining time (validated 1s-5min range)
  • Created resumeAutoCountdown() to restore timer from paused state

Modified Timer Logic

  • sendPing(): Detects manual ping during auto mode → pauses auto countdown
  • scheduleApiPostAndMapRefresh(): Attempts resume before scheduling new auto ping
  • stopAutoPing(), cleanupAllTimers(): Clear paused state on disconnect/stop

Constants

  • MIN_PAUSE_THRESHOLD_MS = 1000 - Don't pause if <1s remaining
  • MAX_REASONABLE_TIMER_MS = 300000 - Handle clock skew

Behavior

// Before: Both timers active simultaneously
autoCountdownTimer.update()  "Waiting for next auto ping (20s)"
apiCountdownTimer.update()   "Wait to post API (7s)"
// Status flickers between both

// After: Single timer active
pauseAutoCountdown()  // Stores 20000ms
apiCountdownTimer.start(7000)  // Shows "Wait to post API (7s)"
resumeAutoCountdown()  // Restarts at 20000ms after API completes

Ensures only one timer updates status at any time. Auto ping timing preserved across manual interventions.

Original prompt

Bug: Auto Ping Timer Conflicts with Manual Ping

Current Behavior

When auto ping is enabled and a user triggers a manual ping, both timers run simultaneously, causing the status display to flip back and forth between:

  • "Waiting for API post"
  • "Waiting for next auto ping"

This creates a confusing UX where both functions compete to update the status.

Expected Behavior

When a manual ping is triggered while auto ping is active:

  1. Pause the auto ping timer at its current value (e.g., 20 seconds remaining)
  2. Display the manual ping status ("Waiting to post to API" with its 7-second countdown)
  3. After the manual ping completes, resume the auto ping timer from where it was paused
  4. Continue the auto ping countdown as normal

Example Flow

  1. User enables auto ping → ping sent
  2. Status shows: "20 seconds until next auto ping"
  3. User clicks manual ping
  4. Auto ping timer pauses at 20 seconds
  5. Status shows: "Waiting to post to API (7s countdown)"
  6. Manual ping completes
  7. Status returns to: "20 seconds until next auto ping"
  8. Auto ping countdown resumes from 20 seconds

Technical Notes

  • Ensure only one timer updates the status at a time
  • Store the remaining auto ping time when manual ping is triggered
  • Implement a "paused" state for the auto ping interval
  • Consider using a state machine or flags to prevent race conditions between the two ping functions

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 5 commits December 18, 2025 19:29
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
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] Fix auto ping timer conflicts with manual ping Fix auto ping timer conflict during manual ping Dec 18, 2025
Copilot AI requested a review from MrAlders0n December 18, 2025 19:45
@MrAlders0n MrAlders0n marked this pull request as ready for review December 18, 2025 19:46
@MrAlders0n MrAlders0n merged commit 6275c5a into dev Dec 18, 2025
@MrAlders0n MrAlders0n deleted the copilot/fix-auto-ping-timer-conflict 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