feat(ui): track live level + device notice in the recording store (T7.3)
This commit is contained in:
@@ -10,12 +10,21 @@ class RecordingStore {
|
||||
segments = $state<TranscriptSegment[]>([]);
|
||||
/** Whether audio is being retained as .wav for the in-flight meeting (ADR-0009). */
|
||||
retention = $state(false);
|
||||
/** Live input level for the waveform/meter (FR-CAP-5); 0 when not recording. */
|
||||
levelRms = $state(0);
|
||||
levelPeak = $state(0);
|
||||
/** Set while a capture-device reconnect is in progress; cleared on recovery (FR-CAP-6). */
|
||||
deviceNotice = $state<string | null>(null);
|
||||
|
||||
async init() {
|
||||
await events.onRecordingState((p) => {
|
||||
const e = p as { state: "recording" | "paused" | "stopped"; elapsedMs: number };
|
||||
this.state = e.state === "stopped" ? "idle" : e.state;
|
||||
this.elapsedMs = e.elapsedMs ?? this.elapsedMs;
|
||||
if (e.state === "stopped") {
|
||||
this.levelRms = 0;
|
||||
this.levelPeak = 0;
|
||||
}
|
||||
});
|
||||
await events.onRetention((p) => {
|
||||
this.retention = p.record;
|
||||
@@ -26,11 +35,19 @@ class RecordingStore {
|
||||
if (i >= 0) this.segments[i] = segment;
|
||||
else this.segments.push(segment);
|
||||
});
|
||||
await events.onLevel(({ rms, peak }) => {
|
||||
this.levelRms = rms;
|
||||
this.levelPeak = peak;
|
||||
});
|
||||
await events.onDeviceChanged(({ recovered, message }) => {
|
||||
this.deviceNotice = recovered ? null : message;
|
||||
});
|
||||
}
|
||||
|
||||
async start(title?: string, record = false) {
|
||||
this.segments = [];
|
||||
this.retention = record;
|
||||
this.deviceNotice = null;
|
||||
this.meetingId = await api.startRecording(title, undefined, record);
|
||||
this.state = "recording";
|
||||
}
|
||||
@@ -38,6 +55,9 @@ class RecordingStore {
|
||||
async stop() {
|
||||
if (this.meetingId) await api.stopRecording(this.meetingId);
|
||||
this.state = "idle";
|
||||
this.levelRms = 0;
|
||||
this.levelPeak = 0;
|
||||
this.deviceNotice = null;
|
||||
}
|
||||
|
||||
/** Toggle audio retention mid-meeting (FR-REC-1); caller must have gated consent already. */
|
||||
|
||||
Reference in New Issue
Block a user