fix(transcript): collapse rolling segment echoes
Normalize incremental backend hypothesis chains before persistence and ignore stale or replayed webhook callbacks so duplicate transcript text does not survive ingest. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -12,12 +12,22 @@ const jobId = params.jobId;
|
||||
const job = getJob(jobId);
|
||||
if (!job) throw error(404, 'Job not found');
|
||||
|
||||
const whisperJob = (await request.json()) as WhisperJob;
|
||||
|
||||
// Discard the result if the job was cancelled locally while whisper was running
|
||||
if (job.status === 'cancelled') {
|
||||
return json({ ok: true });
|
||||
}
|
||||
|
||||
const whisperJob = (await request.json()) as WhisperJob;
|
||||
// Ignore stale callbacks from a previous whisper job after a local retry/reset.
|
||||
if (job.whisperJobId && whisperJob.id !== job.whisperJobId) {
|
||||
return json({ ok: true, ignored: 'stale_whisper_job' });
|
||||
}
|
||||
|
||||
// Ignore replayed success callbacks after the transcript is already persisted.
|
||||
if (job.status === 'done' && job.segmentsJson) {
|
||||
return json({ ok: true, ignored: 'duplicate_webhook' });
|
||||
}
|
||||
|
||||
if (whisperJob.status === 'failed' || whisperJob.status === 'cancelled') {
|
||||
const msg = whisperJob.error ?? `Whisper job ${whisperJob.status}`;
|
||||
|
||||
Reference in New Issue
Block a user