Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: complete benchmark playback before recording startup evidence (#8857)

[._.]/ Adam Eivyb42ae54a4c95
diff --git a/client/src/services/voiceProfileBenchmark.js b/client/src/services/voiceProfileBenchmark.js
index 656c48c8ad..e6a2293fc7 100644
--- a/client/src/services/voiceProfileBenchmark.js
+++ b/client/src/services/voiceProfileBenchmark.js
@@ -14,23 +14,26 @@ export async function prepareProfilePlayback(profileId, payload = {}, options) {
const audio = new Audio(`data:audio/wav;base64,${benchmark.audioBase64}`);
const playbackStartupMs = await new Promise((resolve, reject) => {
let settled = false;
+ let firstPlaybackMs = null;
const finish = (error) => {
if (settled) return;
settled = true;
- const elapsed = Math.ceil(performance.now() - playbackStartedAt);
clearTimeout(timeout);
audio.removeEventListener('playing', onPlaying);
audio.removeEventListener('error', onError);
+ audio.removeEventListener('ended', onEnded);
audio.pause();
audio.removeAttribute('src');
- if (error) reject(error);
- else resolve(elapsed);
+ if (error || firstPlaybackMs === null) reject(error || new Error('The benchmark ended without starting playback'));
+ else resolve(firstPlaybackMs);
};
- const onPlaying = () => finish();
+ const onPlaying = () => { firstPlaybackMs ??= Math.ceil(performance.now() - playbackStartedAt); };
+ const onEnded = () => finish();
const onError = () => finish(new Error('The benchmark audio could not play'));
const timeout = setTimeout(() => finish(new Error('Benchmark playback timed out')), 30000);
audio.addEventListener('playing', onPlaying);
audio.addEventListener('error', onError);
+ audio.addEventListener('ended', onEnded);
// Browser play() reports playback denial through its promise.
audio.play().catch(finish);
});
diff --git a/client/src/services/voiceProfileBenchmark.test.js b/client/src/services/voiceProfileBenchmark.test.js
index 408835600b..c67cfd35e5 100644
--- a/client/src/services/voiceProfileBenchmark.test.js
+++ b/client/src/services/voiceProfileBenchmark.test.js
@@ -27,6 +27,9 @@ describe('profile browser playback qualification', () => {
expect(completeVoiceProfileInteractiveBenchmark).not.toHaveBeenCalled();
clock.mockReturnValue(10250);
audio.dispatchEvent(new Event('playing'));
+ expect(completeVoiceProfileInteractiveBenchmark).not.toHaveBeenCalled();
+ clock.mockReturnValue(13000);
+ audio.dispatchEvent(new Event('ended'));
await expect(pending).resolves.toEqual({ profile: { id: 'profile-1' } });
expect(completeVoiceProfileInteractiveBenchmark).toHaveBeenCalledWith('profile-1', {
benchmarkId: 'probe-1', renderRequestLatencyMs: 200, playbackStartupMs: 250,
diff --git a/docs/features/voice.md b/docs/features/voice.md
index 0e5ae4ff1f..e5a2d621a5 100644
--- a/docs/features/voice.md
+++ b/docs/features/voice.md
@@ -71,7 +71,9 @@ or first-chunk streaming latency. Rendering
alone never enables the route. A one-use receipt expires after two minutes, binds
the measurement to the rendered profile revision, and saves its boundary, model
revision and route decision together. Restarting the server or changing the
-profile requires a fresh benchmark. Playback rejection or timeout cannot qualify.
+profile requires a fresh benchmark. The probe must reach `ended` after `playing`
+before submitting its startup measurement. Playback rejection or timeout cannot
+qualify.
The browser reports its own playback event; this is a trusted operator-reported
measurement, not an attestation of another machine's audio output. The receipt
binds the report to a current probe but cannot prove that a remote client played