Skip to content

fix: preserve stopwatch elapsed time when start is called while running - #157

Open
yonash24 wants to merge 1 commit into
amrlabib:masterfrom
yonash24:fix/stopwatch-start-while-running
Open

yonash24 wants to merge 1 commit into
amrlabib:masterfrom
yonash24:fix/stopwatch-start-while-running

Conversation

@yonash24

Copy link
Copy Markdown

Calling start() while the stopwatch is already running resets its time origin using the elapsed time from the last render. For example, calling it 500ms after starting a default stopwatch makes the first one-second tick report only 500ms. Repeated remote "start" events can therefore discard elapsed time.

Return early when already running, keeping the existing start-after-pause behavior. Add regression cases with both the default 1000ms interval and a custom 100ms interval. The existing whole-tick test did not exercise this case.

Related: #146. This fixes repeated starts on a running stopwatch; it does not establish a shared clock or promise websocket synchronization.

Validation: both regression cases fail before the source change. Afterward all 70 tests pass with npm test -- --runInBand; npm run lint, npx tsc --noEmit, npm run build:prod and git diff --check pass.

AI-assisted investigation, implementation and tests.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant