Skip to content

Ansh - 🔥 timer submission pause and clear behavior - #5778

Open
AnshShah-18 wants to merge 2 commits into
developmentfrom
Ansh_timer_submission_hotfix
Open

AnshShah-18 wants to merge 2 commits into
developmentfrom
Ansh_timer_submission_hotfix

Conversation

@AnshShah-18

Copy link
Copy Markdown
Contributor

Description

Fixes a timer issue where submitting a time log from the timer could take several seconds to process while the timer continued running. After the submission completed, the timer could also remain at the leftover time instead of clearing/resetting.

The issue was caused by the time-entry flow waiting for the time-log request to finish before stopping the timer. The previous STOP_TIMER behavior also preserved the remaining timer value.

This PR updates the flow so the timer pauses immediately when the user submits a timer-based time log, then clears/reset the timer only after the time entry has been successfully saved.

Related PRS (if any):

None. This is a frontend-only change and does not require a backend PR.

Main changes explained:

  • Update TimeEntryForm.jsx to pause the timer immediately after form validation and before the time-log submission request begins.
  • Update the successful timer submission flow to send CLEAR_TIMER instead of STOP_TIMER, ensuring the timer resets after the time log is successfully saved.
  • Update Timer.jsx to pass sendPause and sendClear to the timer time-entry form.
  • Add a regression test verifying that the timer pauses before it clears during a successful timer-based time-log submission.

How to test:

  1. Check out this PR branch:

    git switch Ansh_timer_submission_hotfix
  2. Start the frontend:

    npm run start:local
  3. Start the development backend.

  4. Log in to the development site with a test account that has a project/task available for time logging.

  5. Start the timer and allow some time to accumulate.

  6. Click Log Time.

  7. Select a valid project/task, enter the required notes, and click Submit.

  8. Verify that the timer pauses immediately when Submit is clicked instead of continuing to count down while the time-log request is processing.

  9. After the time log is successfully submitted, verify that:

    • The success notification appears.
    • The timer is cleared/reset.
    • The timer displays its initial value again, for example 00:15:00.
    • Elapsed time resets to 00:00:00.
  10. Run the related automated tests:

npx vitest run src/components/Timer src/components/Timelog/TimeEntryForm/__tests__/TimeEntryForm.test.jsx

Expected result: 19 tests passed across 3 test files.

Screenshots or videos of changes:

Untitled.mp4

@netlify

netlify Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit 985c857
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6aed7f2cecec959860b93bc6
😎 Deploy Preview https://deploy-preview-5778--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 6, 2026
@one-community one-community changed the title Ansh - Fix timer submission pause and clear behavior Ansh - 🔥 timer submission pause and clear behavior Nov 6, 2026
vidiyala99
vidiyala99 previously approved these changes Nov 6, 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 fb4ba62 on a local build of this branch, with the backend on HGNRest development running locally (apidev returns 500 tonight). Logged in as a volunteer and drove the real timer over its websocket. The test account has no projects, so I injected one fake project into the form and answered the time-entry save from the browser instead of sending it. Nothing was written to the dev DB.

Works:

  1. The timer pauses as soon as Submit is clicked. I held the save for 6 seconds. The timer stayed at 00:26:41 the whole time, where on development it would keep counting down.
  2. After the save succeeds, the timer clears. It went back to the full goal (00:31:00), the form closed, and "Time logged successfully!" showed.
  3. All 19 tests in src/components/Timer and TimeEntryForm.test.jsx pass locally, including the new pause-before-clear test.

Approving. Two notes for you and Jae:

  • If the save returns a server error, the timer is still cleared and the time is lost. I answered the save with a 500: the app showed "Time logged successfully!", cleared the timer to 00:31:00, and closed the form. This isn't new. postTimeEntry catches the error and returns the status code instead of throwing, so submitTimeEntry never reaches handleError, and development does the same thing with STOP_TIMER. Now that this PR clears the timer, it's worth a small follow-up: check the returned status before calling sendClear(), and if the save failed, leave the timer paused so the user can retry.
  • This PR and #5788 (Mahika) fix the same bug in different ways, and git merge-tree shows they conflict in TimeEntryForm.jsx and Timer.jsx. Only one of them should merge. This one is smaller and needs no backend change. It also merges cleanly with #5751.

Not blocking: replacing STOP_TIMER with CLEAR_TIMER drops the old "keep the leftover time after a partial log" behaviour (stopTimer set goal = time left). That's what the description asks for, so I'm only flagging it in case anyone relied on it.

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

3 participants