Skip to content

fix(timer): make tag debounce actually reject stale ticks#1012

Open
momomuchu wants to merge 1 commit into
charmbracelet:mainfrom
momomuchu:fix/timer-tag-double-speed-1007
Open

fix(timer): make tag debounce actually reject stale ticks#1012
momomuchu wants to merge 1 commit into
charmbracelet:mainfrom
momomuchu:fix/timer-tag-double-speed-1007

Conversation

@momomuchu

Copy link
Copy Markdown

timer/timer.go copied the tag field from stopwatch (730f5a2) but never incremented it, so the debounce guard in Update never rejects anything. A duplicate Start/Toggle on an already-running timer spawns a second tick stream that runs forever, permanently doubling the countdown speed.

This increments tag on each accepted tick, same as stopwatch already does, so the stale stream gets rejected after the first unavoidable race.

Note: #867/#922 also touch this symptom via a different mechanism (guarding Update/startStop on running-state equality). This PR doesn't touch that path or compete with it, it's scoped to #1007, which asks why tag is dead code. The answer is it's supposed to do exactly this and was just never wired up, so finishing it seemed better than deleting it.

Fixes #1007

tag was added in 730f5a2 alongside stopwatch's identical mechanism,
but timer never increments it, so the guard in Update never rejects
anything. A duplicate Start/Toggle on an already-running timer spawns
a second tick stream that runs forever, permanently doubling the
countdown speed.

Increment tag on each accepted tick, mirroring stopwatch, so the
stale stream gets rejected after the first race.

Fixes charmbracelet#1007
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.

tag field in timer appears to be redundant

1 participant