Skip to content

Conversation

@pblazej
Copy link
Contributor

@pblazej pblazej commented Dec 3, 2025

Also, a little change to useSession for the camera track...

@changeset-bot
Copy link

changeset-bot bot commented Dec 3, 2025

🦋 Changeset detected

Latest commit: 1383d77

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@livekit/component-example-next Patch
@livekit/components-react Patch
@livekit/components-js-docs Patch
@livekit/component-docs-storybook Patch
@livekit/components-docs-gen Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2025

size-limit report 📦

Path Size
LiveKitRoom only 6 KB (0%)
LiveKitRoom with VideoConference 32.46 KB (0%)
All exports 43.26 KB (+0.08% 🔺)

@pblazej pblazej marked this pull request as ready for review December 4, 2025 11:12
@pblazej pblazej requested review from 1egoman and lukasIO December 4, 2025 11:12
console.error('Failed to end session:', err);
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought(non-blocking): 😢

Copy link
Contributor

@1egoman 1egoman Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also a thought:, but maybe it could make sense to destructure the session to get those start / end values out? I think you had said a few weeks back that does silence the warning?

);
};

session.internal.emitter.on(SessionEvent.MediaDevicesError, handleMediaDevicesError);
Copy link
Contributor

@lukasIO lukasIO Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: @1egoman maybe we should think about a cleaner high level helper for this.

using the internal emitters in the examples doesn't feel great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a better way to do this proposed, useEvents, though it didn't get much discussion because I figured it was fairly non controversial - https://github.com/livekit/components-js/blob/main/packages/react/src/hooks/useEvents.ts#L5.

So the thinking is the above could be something like the below instead:

useEvents(session, SessionEvent.MediaDevicesError, handleMediaDevicesError);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrated all instances of session.internal (which all happened to be even listener related) over to use this useEvents pattern.

roomName,
participantIdentity: userIdentity,
participantName: userIdentity,
room,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: @1egoman is there anything ensuring that session is still "in charge" of the room connection cycle when users use this pattern?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not currently, no. It's an "escape hatch" you can use to provide a custom room and if the caller modifies the room's state extensively out of band it will definitely cause things to break. This definitely needs to be documented better than it currently is.

Comment on lines 22 to 24
const tokenSource = useMemo(() => {
return TokenSource.endpoint(process.env.NEXT_PUBLIC_LK_TOKEN_ENDPOINT!);
}, []);
Copy link
Contributor

@1egoman 1egoman Dec 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think if at all possible, the examples (where it can be done) should define the TokenSource outside the component as a constant rather than in the component in a memoized fashion.

Making sure that the TokenSource doesn't change reference proved to be a challenge when Thom was porting over agent-starter-react to use these new apis, and I'd like to try to push people away from injecting local component state into TokenSources (configurable token sources should include all the metadata somebody would need in TokenSource.custom cases) unless you are doing something truly weird like agent-starter-react does to handle sandbox environments properly.

@pblazej
Copy link
Contributor Author

pblazej commented Dec 5, 2025

Thank you for the feedback! I'll probably tackle that early next week to bring it to production standard.

@1egoman
Copy link
Contributor

1egoman commented Dec 9, 2025

@pblazej FYI I applied all the changes lukas and I suggested, so I think this should be good to merge.

@1egoman 1egoman enabled auto-merge (squash) December 9, 2025 17:53
@1egoman 1egoman disabled auto-merge December 9, 2025 17:53
@1egoman 1egoman merged commit 7790393 into main Dec 9, 2025
6 checks passed
@1egoman 1egoman deleted the blaze/update-agent-examples branch December 9, 2025 17:53
@github-actions github-actions bot mentioned this pull request Dec 9, 2025
@pblazej
Copy link
Contributor Author

pblazej commented Dec 10, 2025

@1egoman thanks for handling that!

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.

4 participants