Skip to content

Mahika - 🔥 : timer auto-reconnect and stop false chimes [FE] - #5751

Merged
one-community merged 5 commits into
developmentfrom
mahika/timer-reconnect-pr
Nov 6, 2026
Merged

one-community merged 5 commits into
developmentfrom
mahika/timer-reconnect-pr

Conversation

@mahikakakkad

Copy link
Copy Markdown
Contributor

Description

Fixes the timer bugs reported this week:

  1. Timer showing "Disconnected" and staying stuck after any connection drop (wifi blip, laptop sleep, server restart). It now reconnects by itself and keeps retrying while the user is logged in.
  2. Timer chiming "Timer Paused" when returning to the computer, while paused, or in the middle of the night. A background tab that missed updates no longer decides on its own that the timer was cut off; it reconnects and checks the server first.
  3. The "Reload timer" button reset the display to 15 minutes before reconnecting, so it looked like the session's time was lost.

Related PRS (if any):

Follow-up to #5721 (merged). No backend changes in this PR.

Main changes explained:

  • Timer.jsx: auto-reconnect with backoff (1s → 30s), then keeps retrying every 30s while the login token is valid. Shows "Reconnecting…" instead of "Disconnected" while retrying.
  • Timer.jsx: resyncs with the server when a tab becomes visible again or the internet comes back.
  • Timer.jsx: missed heartbeats no longer trigger the "Timer Paused" chime directly; only the server's real forced pause (or being offline for several attempts while the timer was running) does.
  • Timer.jsx: the local countdown stops while disconnected, so a disconnected tab can't hit 0 and chime on its own.
  • Timer.jsx: "Reload timer" keeps the last real timer state instead of resetting to 15 minutes.
  • TimerStatus.jsx: "Reconnecting…" / "Disconnected" states.
  • Timer.test.jsx: tests for all of the above.

How to test:

  1. Check out this branch, npm install, npm run start:local, and run the backend (development)
  2. Log in and start the timer
  3. Stop the backend for ~30 seconds, then start it again. The timer shows "Reconnecting…" and comes back by itself, with no refresh
  4. Start the timer, turn wifi off for 30 seconds, then on. It reconnects by itself
  5. Open two tabs, start the timer in tab 1, log the time in tab 1. Tab 2 updates and doesn't chime later (leave it a few minutes, switch back to it)
  6. Verify in dark mode

Screenshots or videos of changes:

demo-01-reconnecting-light Backend stopped: timer shows "Reconnecting…" (light mode) demo-02-reconnecting-dark Same state in dark mode demo-03-recovered-dark Backend back up: timer reconnected by itself in ~10s, no refresh

Note:

None.

@netlify

netlify Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit fbef0d4
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6aed675e618678380aaf0005
😎 Deploy Preview https://deploy-preview-5751--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@one-community one-community added High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible Urgent Priority labels Nov 1, 2026
vidiyala99
vidiyala99 previously approved these changes Nov 1, 2026

@vidiyala99 vidiyala99 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested at head 71dc688 on the review box (FE on this branch, dev backend, test account, timer running at about 00:30).

  • Stopped the backend for about 45s, then for 80s+ (the old code gave up at about 61s): the timer showed "Reconnecting..." the whole time. It never switched to "Disconnected", no "Timer Paused" modal appeared, and no countdown ran while the connection was down.
  • Started the backend again: the timer reconnected by itself with no refresh and resumed at the server's value (00:28:39 after about 2m15s away from 00:30:54), then ticked normally. Repeated with a 25s outage, same result.

Two small things, neither blocking:

  1. On one of the two recoveries the display showed 00:15:00 for one sample (I sampled every 3s) before jumping to the real value. It looks like the default message is applied when the new socket clears lastJsonMessage. It fixes itself in a moment, but it is the same "looks like time was lost" flash the Reload fix was meant to remove.
  2. The PR describes a local chime after 3 failed attempts while the timer was running. In both outages (25s and 80s+) no modal appeared. That is the safe direction for the false-chime bug, but it does not match the description.

Not tested: wifi off/on, laptop sleep, the two-tab case, and the Reload button (only shown for a bad token; I only checked the diff, which removes the reset to 15 min). CI is green (SonarCloud and tests).

Approving.

Backend stopped: timer shows Reconnecting..., no Disconnected, no chime

Image

Backend back up: timer reconnected by itself and resumed at the server value, no refresh

Image

@one-community

Copy link
Copy Markdown
Member

Tested at head 71dc688 on the review box (FE on this branch, dev backend, test account, timer running at about 00:30).

  • Stopped the backend for about 45s, then for 80s+ (the old code gave up at about 61s): the timer showed "Reconnecting..." the whole time. It never switched to "Disconnected", no "Timer Paused" modal appeared, and no countdown ran while the connection was down.
  • Started the backend again: the timer reconnected by itself with no refresh and resumed at the server's value (00:28:39 after about 2m15s away from 00:30:54), then ticked normally. Repeated with a 25s outage, same result.

Two small things, neither blocking:

  1. On one of the two recoveries the display showed 00:15:00 for one sample (I sampled every 3s) before jumping to the real value. It looks like the default message is applied when the new socket clears lastJsonMessage. It fixes itself in a moment, but it is the same "looks like time was lost" flash the Reload fix was meant to remove.
  2. The PR describes a local chime after 3 failed attempts while the timer was running. In both outages (25s and 80s+) no modal appeared. That is the safe direction for the false-chime bug, but it does not match the description.

Not tested: wifi off/on, laptop sleep, the two-tab case, and the Reload button (only shown for a bad token; I only checked the diff, which removes the reset to 15 min). CI is green (SonarCloud and tests).

Approving.

Backend stopped: timer shows Reconnecting..., no Disconnected, no chime

Image **Backend back up: timer reconnected by itself and resumed at the server value, no refresh** Image

#2 needs to be fixed for sure

iAbhi001
iAbhi001 previously approved these changes Nov 3, 2026

@iAbhi001 iAbhi001 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.

Tested locally at commit 71dc688 on HighestGoodNetworkApp as DevAdmin in dark mode alongside the development backend. Unit tests in Timer.test.jsx passed cleanly. When stopping the backend, the timer immediately switches to "Reconnecting…" with clear contrast, freezing the local count to prevent runaway completions or false chimes. Once the backend was restarted, the timer reconnected automatically on its own and resumed counting down at 00:13:50 from the synchronized server time without requiring a manual page refresh. Background tabs also re-sync cleanly without triggering delayed chimes upon tab focus. Approving.

Image Image

@one-community one-community changed the title Mahika - fix: timer auto-reconnect and stop false chimes [FE] Mahika - 🔥 : timer auto-reconnect and stop false chimes [FE] Nov 6, 2026
…nect attempts from wiping timer state

A reconnect attempt resets lastJsonMessage to null until a fresh reply
arrives, and an unguarded effect read that as "nothing yet, apply
defaultMessage" - wiping started/paused back to false on every single
retry. This silently defeated the offline-chime threshold (it could
never see "was running" by the time enough attempts had passed, so it
never fired no matter how long the outage lasted) and flashed the
goal/time display to the hardcoded 15-minute default for a moment on
every reconnect.

Also speeds up the heartbeat-miss detector (was 60s interval / 4
misses, ~4+ minutes) to a few consecutive misses over ~15-20s, since
an abruptly killed backend doesn't always deliver a prompt WebSocket
close/error to an already-established connection.
The previous commit's pre-commit hook ran raw prettier --write (which
doesn't see eslint-disable comments) and moved NOSONAR off the exact
line SonarQube flags, silently making the suppression a no-op. A
prettier-ignore on the try statement keeps the catch clause's layout -
and the inline NOSONAR comment - intact.
@mahikakakkad
mahikakakkad dismissed stale reviews from iAbhi001 and vidiyala99 via fbef0d4 November 6, 2026 05:36
@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

@AnshShah-18 AnshShah-18 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested the latest version of PR #5751 locally with the development backend. The timer test suite passed 19/19 tests. During manual testing, I stopped the backend while the timer was running and confirmed that the UI switched to “Reconnecting…” and the local countdown stopped. After repeated failed reconnect attempts, the expected offline pause/chime behavior triggered. Once the backend was restarted, the timer reconnected automatically without requiring a page refresh and resumed from the server value. I also did not observe the previous brief 00:15:00 flash during recovery.

Image Image

Approving.

@one-community

Copy link
Copy Markdown
Member

Thank you all, merging!

@one-community
one-community merged commit eac5494 into development Nov 6, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible Urgent Priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants