Repository navigation
feat: add +1 min control to give time back to the current round - #518
Open
Cordedmink2 wants to merge 1 commit into
Open
Cordedmink2 wants to merge 1 commit into
Cordedmink2 wants to merge 1 commit into
Conversation
Lets the user rewind the remaining time (e.g. after being distracted)
without restarting the round.
- New `TimerCommand::Rewind { secs }` moves the engine's elapsed position
backwards (clamped at 0). Total duration, round type and running/paused
state are unchanged, so the dial arc and the MM:SS readout stay derived
from the same elapsed/total pair.
- Running: the tick timeline is re-anchored at the last tick boundary so
counting continues from the new position without drift.
- Paused/suspended: stays paused; rewinding all the way to 0 returns the
engine to Idle and emits Reset (same outcome as Restart Round).
- Idle: ignored.
- `Start` received while Paused now resumes instead of being dropped (the
controller sends Start when the shared elapsed position is 0).
- New `timer_rewind` IPC command, `timer:rewound` Tauri event and additive
`rewound` WebSocket broadcast; tray arc redraws immediately.
- UI: a "+1 min" button inside the dial below the readout, with tooltip,
accessible label, 24px target, keyboard activation, and disabled state
when there is nothing to give back. Hidden in compact mode.
- Strings added for all 8 locales.
- 7 new engine tests (event-synchronised) plus a WebSocket serialisation test.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
If you get distracted partway through a focus round, the only options today are to keep going with less time than you meant to spend, or restart the round and lose your progress. This adds a small +1 min control so you can give time back to the current round.
What changes
TimerCommand::Rewind { secs }moves the elapsed position backwards, never below 0. The round's total duration, type and running/paused state stay the same. The dial arc and theMM:SSreadout are both computed from the sameelapsed_secsandtotal_secs, so they stay in sync.Reset, the same result as Restart Round, so the toggle, tray and UI all agree the round hasn't started.Start, it now resumes instead of silently dropping the command. The controller sendsStartwhenever the shared elapsed position is 0, which can happen if a running round is rewound to 0:00 and then paused.timer_rewindIPC command andtimer:rewoundTauri event. The tray arc redraws immediately. There is also an additiverewoundWebSocket broadcast ({ "type": "rewound", "payload": { "elapsed_secs", "total_secs" } }), so overlays don't drift. Existing message formats are unchanged.Relationship to #517
#517 also proposes extending the current round (+5) as part of a larger redesign: a distraction counter, sub-minute breaks and a control layout change. This PR is deliberately narrower. It adds one control, leaves the layout alone and doesn't change any settings. If you'd rather take #517's approach, I'm happy to close this.
Verification
cargo test: 96 passed, 0 failed. This includes 7 new event-synchronised engine tests:The timer tests passed 15 times in a row. I also checked the tests themselves: removing the timeline re-anchor makes 2 of them fail.
cargo clippy -- -D warnings: clean.npm run check: 0 errors, 0 warnings.prettier --checkis clean on the changed frontend files.The real Svelte main window was driven in headless Chromium against a mocked Tauri IPC that mirrors the engine's semantics (15/15 checks):
timer_rewind { secs: 60 }.stroke-dashoffsetstay consistent after rewinding while running, rewinding while paused, and on later ticks.I checked the layout at 300×400, 360×478 and 500×600: the button doesn't overlap the readout and stays inside the ring.
Builds and tests ran on Linux (aarch64, Rust stable in a Debian bookworm container). I haven't run it natively on macOS or Windows; the changes are platform-neutral.