Skip to content

Fix stuck placeholder by adding sample count fallback for GPS warmup#74

Draft
google-labs-jules[bot] wants to merge 1 commit into
fix-tests-timestamp-mocking-6344235090466894727from
bugfix/stuck-placeholder-timestamp-fallback-12631748451433477638
Draft

Fix stuck placeholder by adding sample count fallback for GPS warmup#74
google-labs-jules[bot] wants to merge 1 commit into
fix-tests-timestamp-mocking-6344235090466894727from
bugfix/stuck-placeholder-timestamp-fallback-12631748451433477638

Conversation

@google-labs-jules
Copy link
Copy Markdown
Contributor

This change fixes a bug where the speedometer would remain stuck on the placeholder (———) indefinitely if the GPS timestamps received from the device did not advance by at least 1000ms (the warmup period), even if valid speed data was being received.

This could happen if the device sends cached fixes or if the timestamp resolution/update frequency is quirky.

Per the user's constraints to "care about the timestamp field" and "not make up our own timestamp" (i.e., not blindly use Date.now()), the fix implements a fallback mechanism based on the count of valid samples received.

Changes:

  • Added speedSampleCount to src/app.ts.
  • Updated handlePosition to increment speedSampleCount.
  • Modified the warmup condition to be satisfied if pos.timestamp - firstSpeedTimestamp >= GPS_WARMUP_MS OR speedSampleCount >= 5.
  • Updated resetState to clear the counter.
  • Verified the fix with a reproduction test case (which simulates stagnant timestamps) and ensured existing tests pass.

PR created automatically by Jules for task 12631748451433477638 started by @samuel-skean

Introduced a sample count fallback (`speedSampleCount`) for the GPS warmup logic. The application now displays speed if either the GPS timestamp advances by 1000ms OR 5 valid speed samples are received. This prevents the "stuck placeholder" issue when the GPS device reports valid speed data but timestamps are stagnant or update slowly, while still primarily relying on `pos.timestamp` as requested. `lastUpdateTimestamp` remains strictly tied to `pos.timestamp` for accurate data age calculations.
@google-labs-jules
Copy link
Copy Markdown
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying speedometer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 010f35e
Status: ✅  Deploy successful!
Preview URL: https://c4029c4f.speedometer-f1o.pages.dev
Branch Preview URL: https://bugfix-stuck-placeholder-tim.speedometer-f1o.pages.dev

View logs

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.

0 participants