fix(core): surface final lk.transcription_final for user transcriptions#1357
fix(core): surface final lk.transcription_final for user transcriptions#1357rchengLK wants to merge 1 commit into
Conversation
…or user STT setupTextStream dedupes transcription updates by lk.segment_id but only updated `text`, freezing `streamInfo` at the first interim stream seen for a segment. As a result mutable attributes — notably lk.transcription_final flipping "false" -> "true" on the final user STT result — were never surfaced through useTranscriptions. Carry the latest reader.info forward on update. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
|
size-limit report 📦
|
Summary
useTranscriptionsreports a stalelk.transcription_finalfor user STT segments —it stays
"false"even after the segment is finalized. Agent (TTS) segments areunaffected and correctly report
"true".Root cause
Transcription updates for a segment arrive as separate text streams sharing the same
lk.segment_id.setupTextStreamdedupes by that id, but when it finds an existingentry it updates only
textand keeps thestreamInfocaptured from the firststream it saw for the segment:
Because
streamInfo.attributesis frozen at the first interim update, any attribute thatchanges over the life of a segment is lost. For user STT the first stream is an interim
result with
lk.transcription_final="false"; the finalizing stream ("true") replacesonly
.text, so consumers never observe the final flag. Agent segments happen to workbecause the first stream they see already carries
lk.transcription_final="true".Fix
Carry the latest
streamInfoforward on update:reader.infofor a later stream is a refresh of the same segment's info —lk.segment_idis still present (dedup is unaffected), and
lk.transcription_final/lk.transcribed_track_idetc. are brought up to date.
Reproduction
Frontend renders
useTranscriptions()[i].streamInfo.attributes['lk.transcription_final']and talks to a livekit-agents agent with STT enabled. The agent's
user_input_transcribedevent reports
is_final=True, but the UI shows"false"for every user segment.Testing
pnpm --filter @livekit/components-core build— passespnpm --filter @livekit/components-core test— 98/98 passingfinal="true"on finalization.Changeset
@livekit/components-core— patch: FixuseTranscriptionsreporting a stalelk.transcription_final(and other mutable stream attributes) for user STT segments;setupTextStreamnow carries the lateststreamInfoforward on segment updates.Notes
different fields, so they don't conflict.
@livekit/components-core.