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: preserve playback gesture and distinguish measured timing segments (#8857)

[._.]/ Adam Eivy19f4688dd71a
diff --git a/client/src/components/universe/CharacterDetailEditor.jsx b/client/src/components/universe/CharacterDetailEditor.jsx
index 2039bbcbf8..228e94ca06 100644
--- a/client/src/components/universe/CharacterDetailEditor.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.jsx
@@ -49,7 +49,7 @@ import {
promoteVoiceProfile,
startFineTuningJob,
} from '../../services/apiVoice';
-import { qualifyProfilePlayback } from '../../services/voiceProfileBenchmark';
+import { prepareProfilePlayback } from '../../services/voiceProfileBenchmark';
import VoicePicker from '../voice/VoicePicker';
import TabPills from '../ui/TabPills';
import useDrawerTab from '../../hooks/useDrawerTab';
@@ -900,9 +900,18 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
return result;
}, { errorMessage: 'Could not render voice benchmark' });
+ const [pendingPlayback, setPendingPlayback] = useState(null);
+ const playbackReady = pendingPlayback?.profileId === profile?.id && pendingPlayback?.profileRevision === profile?.version;
const [qualifyInteractive, qualifyingInteractive] = useAsyncAction(async () => {
if (!profile?.id) return null;
- const result = await qualifyProfilePlayback(profile.id, { maxFirstAudioMs: 900 }, { silent: true });
+ if (!playbackReady) {
+ const probe = await prepareProfilePlayback(profile.id, { maxFirstAudioMs: 900 }, { silent: true });
+ setPendingPlayback(probe);
+ return probe;
+ }
+ setPendingPlayback(null);
+ const result = await pendingPlayback.play();
+ setProfile(result?.profile || null);
await refreshProfiles();
return result;
}, { errorMessage: 'Interactive benchmark qualification failed' });
@@ -959,7 +968,7 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
</p>
{profile.benchmark?.interactiveLatencyMs ? (
<p className="text-[10px] text-port-success">
- Request-to-playback benchmark: {profile.benchmark.interactiveLatencyMs}ms (threshold: {profile.routes?.interactive?.maxFirstAudioMs || 900}ms)
+ {profile.benchmark.interactiveMeasurement?.boundary === 'browser-playing-segmented' ? 'Render + playback-start benchmark:' : 'Buffered synthesis benchmark:'} {profile.benchmark.interactiveLatencyMs}ms (threshold: {profile.routes?.interactive?.maxFirstAudioMs || 900}ms)
</p>
) : null}
</div>
@@ -984,7 +993,7 @@ function VoiceProfileSection({ universeId, entry, disabled }) {
type="button" onClick={qualifyInteractive} disabled={disabled || qualifyingInteractive || !approved}
className="inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-port-border text-gray-400 hover:text-white hover:border-gray-500 disabled:opacity-40"
>
- {qualifyingInteractive ? <Loader2 size={10} className="animate-spin" /> : <Activity size={10} />} Qualify interactive route
+ {qualifyingInteractive ? <Loader2 size={10} className="animate-spin" /> : <Activity size={10} />} {playbackReady ? 'Play benchmark to qualify' : 'Qualify interactive route'}
</button>
</div>
diff --git a/client/src/components/universe/CharacterDetailEditor.test.jsx b/client/src/components/universe/CharacterDetailEditor.test.jsx
index a0d1d02fc2..72294d0240 100644
--- a/client/src/components/universe/CharacterDetailEditor.test.jsx
+++ b/client/src/components/universe/CharacterDetailEditor.test.jsx
@@ -27,8 +27,8 @@ import {
createVoiceDesignCandidate,
} from '../../services/apiVoice';
-vi.mock('../../services/voiceProfileBenchmark', () => ({ qualifyProfilePlayback: vi.fn() }));
-import { qualifyProfilePlayback } from '../../services/voiceProfileBenchmark';
+vi.mock('../../services/voiceProfileBenchmark', () => ({ prepareProfilePlayback: vi.fn() }));
+import { prepareProfilePlayback } from '../../services/voiceProfileBenchmark';
const ARIA = { id: 'chr-aria', name: 'Aria' };
const BRAM = { id: 'chr-bram', name: 'Bram' };
@@ -289,7 +289,8 @@ describe('CharacterDetailEditor — production package (#5378)', () => {
routes: { studio: { enabled: true }, interactive: { enabled: false, maxFirstAudioMs: 900 } },
}],
});
- qualifyProfilePlayback.mockResolvedValueOnce({
+ const play = vi.fn().mockResolvedValue({ profile: { id: 'voice-profile-1' } });
+ prepareProfilePlayback.mockResolvedValueOnce({ profileId: 'voice-profile-1', profileRevision: 1, play,
profile: {
id: 'voice-profile-1', version: 1, approval: { status: 'approved' },
routes: { studio: { enabled: true }, interactive: { enabled: true, maxFirstAudioMs: 900 } },
@@ -303,9 +304,12 @@ describe('CharacterDetailEditor — production package (#5378)', () => {
fireEvent.click(screen.getByRole('tab', { name: 'Voice' }));
fireEvent.click(await screen.findByRole('button', { name: /Qualify interactive route/i }));
- await waitFor(() => expect(qualifyProfilePlayback).toHaveBeenCalledWith(
+ await waitFor(() => expect(prepareProfilePlayback).toHaveBeenCalledWith(
'voice-profile-1', { maxFirstAudioMs: 900 }, { silent: true },
));
+ expect(play).not.toHaveBeenCalled();
+ fireEvent.click(await screen.findByRole('button', { name: /Play benchmark to qualify/i }));
+ expect(play).toHaveBeenCalled();
});
it('marks a voice-canon revision as approved', () => {
diff --git a/client/src/services/README.md b/client/src/services/README.md
index 840703f78f..2caba82282 100644
--- a/client/src/services/README.md
+++ b/client/src/services/README.md
@@ -150,7 +150,7 @@ toasts on throw). **Custom catch ⇒ `silent: true`** — otherwise toasts fire
| File | Purpose |
|---|---|
-| `voiceProfileBenchmark.js` | Measures request-to-playing latency for fresh profile probes and submits a one-use playback receipt. |
+| `voiceProfileBenchmark.js` | Prepares fresh profile probes and measures render plus explicit playback-start time for one-use qualification receipts. |
| `voiceClient.js` | Browser-side voice capture + playback (two modes). |
| `browserLlm.js` | Client for Chrome's on-device "Gemini Nano" (Prompt API): dual-shape detection, availability enum, cached `promptNano()` with timeout. Tier 2 of the voice fast-resolution cascade. |
| `voiceFastPath.js` | Voice fast-resolution cascade: trigger nav → on-device Nano → server LLM. Decides how each spoken/typed turn is resolved. |
diff --git a/client/src/services/voiceProfileBenchmark.js b/client/src/services/voiceProfileBenchmark.js
index 1fd44ed1ff..656c48c8ad 100644
--- a/client/src/services/voiceProfileBenchmark.js
+++ b/client/src/services/voiceProfileBenchmark.js
@@ -1,33 +1,42 @@
import { benchmarkProfileInteractive, completeVoiceProfileInteractiveBenchmark } from './apiVoice';
-/** Measure a fresh render through the browser's actual playback-start event. */
-export async function qualifyProfilePlayback(profileId, payload = {}, options) {
+/** Prepare a fresh probe; its returned play action needs a second user gesture. */
+export async function prepareProfilePlayback(profileId, payload = {}, options) {
const startedAt = performance.now();
const { benchmark } = await benchmarkProfileInteractive(profileId, payload, options);
+ const renderRequestLatencyMs = Math.ceil(performance.now() - startedAt);
if (!benchmark?.benchmarkId || !benchmark?.audioBase64) throw new Error('No playable benchmark was returned');
- const audio = new Audio(`data:audio/wav;base64,${benchmark.audioBase64}`);
- const playbackLatencyMs = await new Promise((resolve, reject) => {
- let settled = false;
- const finish = (error) => {
- if (settled) return;
- settled = true;
- const elapsed = Math.ceil(performance.now() - startedAt);
- clearTimeout(timeout);
- audio.removeEventListener('playing', onPlaying);
- audio.removeEventListener('error', onError);
- audio.pause();
- audio.removeAttribute('src');
- if (error) reject(error);
- else resolve(elapsed);
- };
- const onPlaying = () => 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);
- Promise.resolve().then(() => audio.play()).catch(finish);
- });
- return completeVoiceProfileInteractiveBenchmark(profileId, {
- benchmarkId: benchmark.benchmarkId, playbackLatencyMs,
- }, options);
+ return {
+ profileId, profileRevision: benchmark.profileRevision,
+ // No await before play(): this runs directly in the operator's click gesture.
+ play: async () => {
+ const playbackStartedAt = performance.now();
+ const audio = new Audio(`data:audio/wav;base64,${benchmark.audioBase64}`);
+ const playbackStartupMs = await new Promise((resolve, reject) => {
+ let settled = false;
+ 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.pause();
+ audio.removeAttribute('src');
+ if (error) reject(error);
+ else resolve(elapsed);
+ };
+ const onPlaying = () => 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);
+ // Browser play() reports playback denial through its promise.
+ audio.play().catch(finish);
+ });
+ return completeVoiceProfileInteractiveBenchmark(profileId, {
+ benchmarkId: benchmark.benchmarkId, renderRequestLatencyMs, playbackStartupMs,
+ }, options);
+ },
+ };
}
diff --git a/client/src/services/voiceProfileBenchmark.test.js b/client/src/services/voiceProfileBenchmark.test.js
index bf0825e223..408835600b 100644
--- a/client/src/services/voiceProfileBenchmark.test.js
+++ b/client/src/services/voiceProfileBenchmark.test.js
@@ -1,30 +1,35 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
vi.mock('./apiVoice', () => ({ benchmarkProfileInteractive: vi.fn(), completeVoiceProfileInteractiveBenchmark: vi.fn() }));
import { benchmarkProfileInteractive, completeVoiceProfileInteractiveBenchmark } from './apiVoice';
-import { qualifyProfilePlayback } from './voiceProfileBenchmark';
+import { prepareProfilePlayback } from './voiceProfileBenchmark';
afterEach(() => { vi.restoreAllMocks(); vi.unstubAllGlobals(); vi.useRealTimers(); vi.clearAllMocks(); });
const prepare = (play = vi.fn().mockResolvedValue()) => {
const audio = new EventTarget();
Object.assign(audio, { play, pause: vi.fn(), removeAttribute: vi.fn() });
vi.stubGlobal('Audio', vi.fn(function () { return audio; }));
- benchmarkProfileInteractive.mockResolvedValue({ benchmark: { benchmarkId: 'probe-1', audioBase64: 'fixture' } });
+ benchmarkProfileInteractive.mockResolvedValue({ benchmark: { benchmarkId: 'probe-1', profileRevision: 2, audioBase64: 'fixture' } });
return audio;
};
describe('profile browser playback qualification', () => {
- it('waits for playing, includes request time, and submits only actual playback evidence', async () => {
+ it('plays synchronously in the second gesture and measures both segments excluding operator wait', async () => {
const audio = prepare();
const clock = vi.spyOn(performance, 'now').mockReturnValue(100);
completeVoiceProfileInteractiveBenchmark.mockResolvedValue({ profile: { id: 'profile-1' } });
- const pending = qualifyProfilePlayback('profile-1');
- await vi.waitFor(() => expect(audio.play).toHaveBeenCalled());
+ const preparing = prepareProfilePlayback('profile-1');
+ clock.mockReturnValue(300);
+ const probe = await preparing;
+ expect(audio.play).not.toHaveBeenCalled();
+ clock.mockReturnValue(10000);
+ const pending = probe.play();
+ expect(audio.play).toHaveBeenCalled();
expect(completeVoiceProfileInteractiveBenchmark).not.toHaveBeenCalled();
- clock.mockReturnValue(550);
+ clock.mockReturnValue(10250);
audio.dispatchEvent(new Event('playing'));
await expect(pending).resolves.toEqual({ profile: { id: 'profile-1' } });
expect(completeVoiceProfileInteractiveBenchmark).toHaveBeenCalledWith('profile-1', {
- benchmarkId: 'probe-1', playbackLatencyMs: 450,
+ benchmarkId: 'probe-1', renderRequestLatencyMs: 200, playbackStartupMs: 250,
}, undefined);
expect(audio.pause).toHaveBeenCalled();
expect(audio.removeAttribute).toHaveBeenCalledWith('src');
@@ -32,11 +37,13 @@ describe('profile browser playback qualification', () => {
it('does not qualify rejected playback or a playback timeout', async () => {
prepare(vi.fn().mockRejectedValue(new Error('Playback denied')));
- await expect(qualifyProfilePlayback('profile-1')).rejects.toThrow('Playback denied');
+ const denied = await prepareProfilePlayback('profile-1');
+ await expect(denied.play()).rejects.toThrow('Playback denied');
expect(completeVoiceProfileInteractiveBenchmark).not.toHaveBeenCalled();
vi.useFakeTimers();
const audio = prepare();
- const pending = qualifyProfilePlayback('profile-1');
+ const probe = await prepareProfilePlayback('profile-1');
+ const pending = probe.play();
const rejection = expect(pending).rejects.toThrow('Benchmark playback timed out');
await vi.advanceTimersByTimeAsync(30000);
await rejection;
diff --git a/docs/features/voice.md b/docs/features/voice.md
index 555c611d39..6f3ba90a9c 100644
--- a/docs/features/voice.md
+++ b/docs/features/voice.md
@@ -62,9 +62,12 @@ reference is generated, so no personal recording or consent is needed for this
smoke. A successful command or non-silent WAV alone does not establish quality.
Interactive profile qualification plays a fresh buffered WAV in the browser.
-Timing starts before the render request and stops at the browser's `playing`
-event, so it includes rendering, response transfer, decoding and playback startup.
-It is a request-to-playback benchmark, not first-chunk streaming latency. Rendering
+The first click renders and transfers the probe. A second explicit playback
+click preserves browser autoplay permission. The latency gate sums measured
+render-request time and click-to-`playing` startup time, including response
+transfer and decoding, while excluding the operator's wait between clicks.
+It is a render-plus-playback-start benchmark, not continuous request-to-playback
+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
diff --git a/server/routes/voice.js b/server/routes/voice.js
index a807aa63f5..b3b88d98df 100644
--- a/server/routes/voice.js
+++ b/server/routes/voice.js
@@ -254,7 +254,8 @@ const interactiveBenchmarkSchema = z.object({
const interactivePlaybackReceiptSchema = z.object({
benchmarkId: z.string().uuid(),
- playbackLatencyMs: z.number().min(0).max(120000),
+ renderRequestLatencyMs: z.number().min(0).max(3600000),
+ playbackStartupMs: z.number().min(0).max(30000),
}).strict();
const fineTuneStartSchema = z.object({
diff --git a/server/routes/voice.test.js b/server/routes/voice.test.js
index 35d985a7bf..d1275be6d5 100644
--- a/server/routes/voice.test.js
+++ b/server/routes/voice.test.js
@@ -210,13 +210,13 @@ describe('Voice Routes', () => {
it('validates a playback receipt before completing interactive qualification', async () => {
profileBenchmarks.completeProfileInteractiveBenchmark.mockResolvedValue({ id: 'voice-profile-1' });
- const receipt = { benchmarkId: '12345678-1234-4234-8234-123456789012', playbackLatencyMs: 200 };
+ const receipt = { benchmarkId: '12345678-1234-4234-8234-123456789012', renderRequestLatencyMs: 150, playbackStartupMs: 50 };
const res = await request(buildApp()).post('/api/voice/profiles/voice-profile-1/benchmark-interactive/complete').send(receipt);
expect(res.status).toBe(200);
expect(res.body).toEqual({ profile: { id: 'voice-profile-1' } });
expect(profileBenchmarks.completeProfileInteractiveBenchmark).toHaveBeenCalledWith('voice-profile-1', receipt);
const invalid = await request(buildApp()).post('/api/voice/profiles/voice-profile-1/benchmark-interactive/complete')
- .send({ ...receipt, playbackLatencyMs: -1 });
+ .send({ ...receipt, playbackStartupMs: -1 });
expect(invalid.status).toBe(400);
});
diff --git a/server/services/voice/profileBenchmarks.js b/server/services/voice/profileBenchmarks.js
index 3831556462..7b2b30d6a1 100644
--- a/server/services/voice/profileBenchmarks.js
+++ b/server/services/voice/profileBenchmarks.js
@@ -99,7 +99,7 @@ export async function benchmarkProfileInteractive(profileId, { maxFirstAudioMs =
}
/** Save only a receipt for the probe actually played by the browser. */
-export async function completeProfileInteractiveBenchmark(profileId, { benchmarkId, playbackLatencyMs }) {
+export async function completeProfileInteractiveBenchmark(profileId, { benchmarkId, renderRequestLatencyMs, playbackStartupMs }) {
const pending = playbackBenchmarks.get(benchmarkId);
if (!pending || pending.profile.id !== profileId || pending.expiresAt <= performance.now()) {
throw new ServerError('Playback benchmark expired or does not match this profile; run it again', {
@@ -107,19 +107,21 @@ export async function completeProfileInteractiveBenchmark(profileId, { benchmark
});
}
playbackBenchmarks.delete(benchmarkId);
- if (!Number.isFinite(playbackLatencyMs) || playbackLatencyMs < pending.synthesisLatencyMs || playbackLatencyMs > PLAYBACK_TTL_MS) {
+ if (!Number.isFinite(renderRequestLatencyMs) || renderRequestLatencyMs < pending.synthesisLatencyMs ||
+ !Number.isFinite(playbackStartupMs) || playbackStartupMs < 0 || playbackStartupMs > 30000) {
throw new ServerError('Playback timing does not include the rendered probe; run it again', {
status: 400, code: 'VOICE_BENCHMARK_TIMING_INVALID',
});
}
- const latencyMs = Math.ceil(playbackLatencyMs);
+ const latencyMs = Math.ceil(renderRequestLatencyMs + playbackStartupMs);
return saveProfileBenchmark(pending.profile, {
profileRevision: pending.profile.version,
renderedAt: new Date().toISOString(),
interactiveLatencyMs: latencyMs,
similarityScore: null,
interactiveMeasurement: {
- boundary: 'browser-playing', synthesisLatencyMs: pending.synthesisLatencyMs,
+ boundary: 'browser-playing-segmented', synthesisLatencyMs: pending.synthesisLatencyMs,
+ renderRequestLatencyMs: Math.ceil(renderRequestLatencyMs), playbackStartupMs: Math.ceil(playbackStartupMs),
modelRevision: pending.modelRevision,
},
}, { interactive: { enabled: latencyMs <= pending.maxFirstAudioMs, maxFirstAudioMs: pending.maxFirstAudioMs } });
diff --git a/server/services/voice/profileBenchmarks.test.js b/server/services/voice/profileBenchmarks.test.js
index e839e71779..187de1a3f9 100644
--- a/server/services/voice/profileBenchmarks.test.js
+++ b/server/services/voice/profileBenchmarks.test.js
@@ -68,17 +68,17 @@ describe('interactive qualification', () => {
expect(saveProfileBenchmark).not.toHaveBeenCalled();
expect(probe).toMatchObject({ profileRevision: 2, audioBase64: expect.any(String) });
await completeProfileInteractiveBenchmark(PROFILE.id, {
- benchmarkId: probe.benchmarkId, playbackLatencyMs: 1200,
+ benchmarkId: probe.benchmarkId, renderRequestLatencyMs: 1100, playbackStartupMs: 100,
});
expect(saveProfileBenchmark).toHaveBeenLastCalledWith(PROFILE, expect.objectContaining({
interactiveLatencyMs: 1200, similarityScore: null, profileRevision: 2,
- interactiveMeasurement: { boundary: 'browser-playing', synthesisLatencyMs: 0, modelRevision: 'example-model@revision' },
+ interactiveMeasurement: { boundary: 'browser-playing-segmented', synthesisLatencyMs: 0, renderRequestLatencyMs: 1100, playbackStartupMs: 100, modelRevision: 'example-model@revision' },
}), { interactive: { enabled: false, maxFirstAudioMs: 900 } });
await expect(completeProfileInteractiveBenchmark(PROFILE.id, {
- benchmarkId: probe.benchmarkId, playbackLatencyMs: 10,
+ benchmarkId: probe.benchmarkId, renderRequestLatencyMs: 10, playbackStartupMs: 0,
})).rejects.toMatchObject({ code: 'VOICE_BENCHMARK_RECEIPT_INVALID' });
const timely = await benchmarkProfileInteractive(PROFILE.id);
- await completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: timely.benchmarkId, playbackLatencyMs: 50 });
+ await completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: timely.benchmarkId, renderRequestLatencyMs: 50, playbackStartupMs: 0 });
expect(saveProfileBenchmark).toHaveBeenLastCalledWith(PROFILE, expect.objectContaining({ interactiveLatencyMs: 50 }), {
interactive: { enabled: true, maxFirstAudioMs: 900 },
});
@@ -93,17 +93,17 @@ describe('interactive qualification', () => {
synthesize.mockResolvedValue({ wav: pcmToWavBuffer(new Float32Array(240), { sampleRate: 24000 }) });
const clock = vi.spyOn(performance, 'now').mockReturnValue(100);
const first = await benchmarkProfileInteractive(PROFILE.id);
- await expect(completeProfileInteractiveBenchmark('another-profile', { benchmarkId: first.benchmarkId, playbackLatencyMs: 50 }))
+ await expect(completeProfileInteractiveBenchmark('another-profile', { benchmarkId: first.benchmarkId, renderRequestLatencyMs: 50, playbackStartupMs: 0 }))
.rejects.toMatchObject({ code: 'VOICE_BENCHMARK_RECEIPT_INVALID' });
const second = await benchmarkProfileInteractive(PROFILE.id);
- await expect(completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: first.benchmarkId, playbackLatencyMs: 50 }))
+ await expect(completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: first.benchmarkId, renderRequestLatencyMs: 50, playbackStartupMs: 0 }))
.rejects.toMatchObject({ code: 'VOICE_BENCHMARK_RECEIPT_INVALID' });
clock.mockReturnValue(120101);
- await expect(completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: second.benchmarkId, playbackLatencyMs: 50 }))
+ await expect(completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: second.benchmarkId, renderRequestLatencyMs: 50, playbackStartupMs: 0 }))
.rejects.toMatchObject({ code: 'VOICE_BENCHMARK_RECEIPT_INVALID' });
clock.mockReturnValueOnce(100).mockReturnValueOnce(200).mockReturnValue(200);
const third = await benchmarkProfileInteractive(PROFILE.id);
- await expect(completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: third.benchmarkId, playbackLatencyMs: 50 }))
+ await expect(completeProfileInteractiveBenchmark(PROFILE.id, { benchmarkId: third.benchmarkId, renderRequestLatencyMs: 50, playbackStartupMs: 0 }))
.rejects.toMatchObject({ code: 'VOICE_BENCHMARK_TIMING_INVALID' });
expect(saveProfileBenchmark).not.toHaveBeenCalled();
clock.mockRestore();
diff --git a/server/services/voice/profiles.js b/server/services/voice/profiles.js
index 207096ee85..8d1bef9e51 100644
--- a/server/services/voice/profiles.js
+++ b/server/services/voice/profiles.js
@@ -103,9 +103,12 @@ const sanitizeBenchmark = (raw) => {
lines,
mastering: sanitizeMastering(raw.mastering),
interactiveLatencyMs: Number.isFinite(raw.interactiveLatencyMs) ? Math.round(raw.interactiveLatencyMs) : null,
- interactiveMeasurement: raw.interactiveMeasurement?.boundary === 'browser-playing' &&
- Number.isFinite(raw.interactiveMeasurement.synthesisLatencyMs) ? {
- boundary: 'browser-playing',
+ interactiveMeasurement: raw.interactiveMeasurement?.boundary === 'browser-playing-segmented' &&
+ ['synthesisLatencyMs', 'renderRequestLatencyMs', 'playbackStartupMs']
+ .every((key) => Number.isFinite(raw.interactiveMeasurement[key]) && raw.interactiveMeasurement[key] >= 0) ? {
+ boundary: 'browser-playing-segmented',
+ renderRequestLatencyMs: Math.round(raw.interactiveMeasurement.renderRequestLatencyMs),
+ playbackStartupMs: Math.round(raw.interactiveMeasurement.playbackStartupMs),
synthesisLatencyMs: Math.max(0, Math.round(raw.interactiveMeasurement.synthesisLatencyMs)),
modelRevision: trimTo(raw.interactiveMeasurement.modelRevision, MAX_REVISION) || null,
} : null,
diff --git a/server/services/voice/profiles.test.js b/server/services/voice/profiles.test.js
index 99b4cdcaee..f1e7cd1afd 100644
--- a/server/services/voice/profiles.test.js
+++ b/server/services/voice/profiles.test.js
@@ -261,7 +261,7 @@ describe('voice profile contract', () => {
const benchmark = {
renderedAt: '2026-09-01T00:00:00.000Z', profileRevision: PROFILE.version,
interactiveLatencyMs: 120, similarityScore: null,
- interactiveMeasurement: { boundary: 'browser-playing', synthesisLatencyMs: 90, modelRevision: PROFILE.modelRevision },
+ interactiveMeasurement: { boundary: 'browser-playing-segmented', synthesisLatencyMs: 90, renderRequestLatencyMs: 100, playbackStartupMs: 20, modelRevision: PROFILE.modelRevision },
};
const interactive = { enabled: true, maxFirstAudioMs: 900 };
queryMock.mockResolvedValueOnce({ rows: [{ data: { ...PROFILE, benchmark, routes: { ...PROFILE.routes, interactive } } }] });