refactor(api): complete fastapi migration and related features

Finish native FastAPI controllers, drop vendored microdot, and add
Wi-Fi driver runtime, beat SSE, simulated BPM, sequence playback
improvements, bridge ESP-NOW sources, UI updates, and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-11 22:55:28 +12:00
parent cb9758b97b
commit ace5770b3a
73 changed files with 4540 additions and 4487 deletions

View File

@@ -9,7 +9,11 @@ SRC_PATH = os.path.join(PROJECT_ROOT, "src")
if SRC_PATH not in sys.path:
sys.path.insert(0, SRC_PATH)
from util.audio_detector import AudioBeatDetector # noqa: E402
from util.audio_detector import ( # noqa: E402
AudioBeatDetector,
set_shared_beat_detector,
shared_beat_detector_timing_sequences,
)
class _FakeRuntime:
@@ -83,7 +87,47 @@ def test_silence_gap_starts_holdover_and_resets_tempo_once():
det._maybe_recover_after_silence_gap(rt)
assert rt.reset_tempo_calls == 1
det._record_beat(120.0)
assert det._holdover_active is False
assert det._holdover_active is True
def test_timing_sequences_true_while_holdover_active():
det = AudioBeatDetector()
set_shared_beat_detector(det)
try:
with det._lock:
det._running = True
det._status["running"] = True
det._status["bpm"] = 120.0
det._record_beat(120.0)
assert det._holdover_active is True
assert shared_beat_detector_timing_sequences() is True
finally:
set_shared_beat_detector(None)
def test_timing_sequences_false_when_running_without_beats():
det = AudioBeatDetector()
set_shared_beat_detector(det)
try:
with det._lock:
det._running = True
det._status["running"] = True
assert shared_beat_detector_timing_sequences() is False
det._record_beat(120.0)
assert shared_beat_detector_timing_sequences() is True
det._stop_bpm_holdover()
with det._lock:
det._last_real_beat_ts = time.time() - 5.0
assert shared_beat_detector_timing_sequences() is False
finally:
set_shared_beat_detector(None)
def test_record_beat_keeps_previous_bpm_when_new_readout_invalid():
det = AudioBeatDetector()
det._record_beat(128.0)
det._record_beat(None)
assert det.status()["bpm"] == 128.0
def test_holdover_last_beat_does_not_block_tempo_retry():