Skip to content

fix(core): surface final lk.transcription_final for user transcriptions#1357

Open
rchengLK wants to merge 1 commit into
mainfrom
fix/transcription-final-user-stt
Open

fix(core): surface final lk.transcription_final for user transcriptions#1357
rchengLK wants to merge 1 commit into
mainfrom
fix/transcription-final-user-stt

Conversation

@rchengLK

Copy link
Copy Markdown

Summary

useTranscriptions reports a stale lk.transcription_final for user STT segments —
it stays "false" even after the segment is finalized. Agent (TTS) segments are
unaffected and correctly report "true".

Root cause

Transcription updates for a segment arrive as separate text streams sharing the same
lk.segment_id. setupTextStream dedupes by that id, but when it finds an existing
entry it updates only text and keeps the streamInfo captured from the first
stream it saw for the segment:

textStreams[index] = {
  ...textStreams[index],
  text: accumulatedText,
  // streamInfo never refreshed
};

Because streamInfo.attributes is frozen at the first interim update, any attribute that
changes 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") replaces
only .text, so consumers never observe the final flag. Agent segments happen to work
because the first stream they see already carries lk.transcription_final="true".

Fix

Carry the latest streamInfo forward on update:

textStreams[index] = {
  ...textStreams[index],
  text: accumulatedText,
  streamInfo: reader.info,
};

reader.info for a later stream is a refresh of the same segment's info — lk.segment_id
is still present (dedup is unaffected), and lk.transcription_final / lk.transcribed_track_id
etc. 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_transcribed
event reports is_final=True, but the UI shows "false" for every user segment.

Testing

  • pnpm --filter @livekit/components-core build — passes
  • pnpm --filter @livekit/components-core test — 98/98 passing
  • Verified end-to-end against a live agent: user segments now flip to final="true" on finalization.

Changeset

@livekit/components-core — patch: Fix useTranscriptions reporting a stale
lk.transcription_final (and other mutable stream attributes) for user STT segments;
setupTextStream now carries the latest streamInfo forward on segment updates.

Notes

…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>
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components-js-storybook-5kld Ready Ready Preview, Comment Jun 24, 2026 4:47pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f102228

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@rchengLK rchengLK requested a review from lukasIO June 24, 2026 16:47
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
LiveKitRoom only 6.01 KB (0%)
LiveKitRoom with VideoConference 32.25 KB (0%)
All exports 43.69 KB (+0.02% 🔺)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants