From 1ce954556ddd13d2cc16b06585bc7441d74d75ea Mon Sep 17 00:00:00 2001 From: Alexander Gil Date: Wed, 20 May 2026 11:17:23 +0200 Subject: [PATCH 1/2] fix: restore parallel beep and sound playback --- src/timer.rs | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/src/timer.rs b/src/timer.rs index 3aff99c..f25ebfa 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -103,6 +103,31 @@ where } } +fn play_beep() -> Result<()> { + for _ in 0..BEEP_REPETITIONS { + sleep(stdDuration::from_millis(SOUND_START_DELAY)); + if beep(BEEP_FREQ, stdDuration::from_millis(BEEP_DURATION)).is_err() { + sleep(stdDuration::from_millis(BEEP_DURATION)); + } + + let remaining_delay = BEEP_DELAY.saturating_sub(SOUND_START_DELAY); + if remaining_delay > 0 { + sleep(stdDuration::from_millis(remaining_delay)); + } + } + Ok(()) +} + +fn play_sound() -> Result<()> { + let sound = Sound::new()?; + + for _ in 0..BEEP_REPETITIONS { + sound.play()?; + sleep(stdDuration::from_millis(BEEP_DELAY)); + } + Ok(()) +} + pub fn countdown(w: &mut W, end: OffsetDateTime, opts: &Opts) -> Result<()> where W: io::Write, @@ -123,23 +148,9 @@ where } if !opts.silence { - match Sound::new() { - Ok(sound) => { - for _ in 0..BEEP_REPETITIONS { - sleep(stdDuration::from_millis(SOUND_START_DELAY)); - if beep(BEEP_FREQ, stdDuration::from_millis(BEEP_DURATION)).is_err() - { - sleep(stdDuration::from_millis(BEEP_DURATION)); - } - - if sound.play().is_err() { - break; - } - sleep(stdDuration::from_millis(BEEP_DELAY)); - } - } - Err(e) => return Err(e), - } + let sound_handle = std::thread::spawn(|| play_sound().unwrap()); + play_beep()?; + sound_handle.join().map_err(|_| "Sound thread panicked")?; } return Ok(()); } From 8aec8305e7065546e4727ecc43cda08bb051f872 Mon Sep 17 00:00:00 2001 From: Alexander Gil Date: Wed, 20 May 2026 11:18:33 +0200 Subject: [PATCH 2/2] docs: add git rules to prevent amend mistakes --- AGENTS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 5a2247f..4d45211 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -281,6 +281,11 @@ git push origin release/v git-api pr create --title "release: Version " --body "..." ``` +## Git Rules + +- **NEVER `--amend` unless you verify HEAD is your commit first** — always run `git log --oneline -1` before amending to confirm you're amending the right commit. +- **When a commit fails (hooks modified files), just commit again normally** — do NOT use `--amend`, or you'll amend the parent commit. Simply stage the changes and `git commit -m "..."` again. + ### Note on Protected Branches The `master` branch is protected. Releases must go through a PR. After merge, tagging and GitHub release are automated.