feat: AppState gains speaker pause fields and AWAITING_SPEAKERS status

This commit is contained in:
2026-04-02 01:06:30 +02:00
parent 033c1fc486
commit dbb35ce71d
2 changed files with 17 additions and 1 deletions
+6 -1
View File
@@ -8,15 +8,20 @@ class Status(str, Enum):
IDLE = "idle" IDLE = "idle"
RECORDING = "recording" RECORDING = "recording"
PROCESSING = "processing" PROCESSING = "processing"
AWAITING_SPEAKERS = "awaiting_speakers"
ERROR = "error" ERROR = "error"
@dataclass @dataclass
class AppState: class AppState:
status: Status = Status.IDLE status: Status = Status.IDLE
recording_user: str | None = None # which user triggered the current recording recording_user: str | None = None
last_error: str | None = None last_error: str | None = None
_listeners: list[Callable] = field(default_factory=list, repr=False) _listeners: list[Callable] = field(default_factory=list, repr=False)
# Diarization pipeline pause
_speakers_event: asyncio.Event | None = None
_pending_aligned_segments: list[tuple[str, str]] | None = None
_speaker_names: dict[str, str] | None = None
def subscribe(self, callback: Callable): def subscribe(self, callback: Callable):
self._listeners.append(callback) self._listeners.append(callback)
+11
View File
@@ -160,6 +160,17 @@ def test_status_includes_is_admin():
app.dependency_overrides.pop(current_user, None) app.dependency_overrides.pop(current_user, None)
def test_state_has_speaker_fields():
from api.state import AppState
s = AppState()
assert hasattr(s, "_speakers_event")
assert hasattr(s, "_pending_aligned_segments")
assert hasattr(s, "_speaker_names")
assert s._speakers_event is None
assert s._pending_aligned_segments is None
assert s._speaker_names is None
def test_put_config_deep_merges(tmp_path, monkeypatch): def test_put_config_deep_merges(tmp_path, monkeypatch):
import config as cfg_mod import config as cfg_mod
monkeypatch.setattr(cfg_mod, "CONFIG_PATH", str(tmp_path / "config.toml")) monkeypatch.setattr(cfg_mod, "CONFIG_PATH", str(tmp_path / "config.toml"))