Skip to content

Conversation

@1egoman
Copy link
Contributor

@1egoman 1egoman commented Oct 24, 2025

As an alternative to #1225, instead of calling agent.waitUntilAvailable(...) on each session.start() call, instead only call it if the participant token dispatches an agent.

@changeset-bot
Copy link

changeset-bot bot commented Oct 24, 2025

🦋 Changeset detected

Latest commit: d8cc488

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

This PR includes changesets to release 5 packages
Name Type
@livekit/components-react Patch
@livekit/component-example-next 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

@1egoman 1egoman force-pushed the usesession-waits-for-agent-only-if-dispatched branch from 4c7ac01 to 3935507 Compare October 24, 2025 13:41
@1egoman 1egoman force-pushed the usesession-waits-for-agent-only-if-dispatched branch from 3935507 to 388ac32 Compare October 24, 2025 13:45
@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
LiveKitRoom only 6 KB (0%)
LiveKitRoom with VideoConference 32.23 KB (0%)
All exports 42.65 KB (+0.28% 🔺)

@1egoman 1egoman marked this pull request as ready for review October 28, 2025 08:46
Copy link

@xianshijing-lk xianshijing-lk left a comment

Choose a reason for hiding this comment

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

one question.

: Promise.resolve(),
]);

await waitUntilConnected(signal);

Choose a reason for hiding this comment

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

question

without knowing enough context on the code, I wonder if we shoul do both waitUntilConnected() and await agent.waitUntilAvailable(signal); in some cases ?

or it should be something like
if (tokenDispatchesAgent && agent) {
await agent.waitUntilAvailable(signal);
} else {
await waitUntilConnected(signal);
}

also, should you guard agent ?

Copy link
Contributor Author

@1egoman 1egoman Oct 28, 2025

Choose a reason for hiding this comment

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

or it should be something like

waitUntilConnected will block until a the underlying room is connected, and agent.waitUntilAvailable will block until the agent has connected. One is dependent on the other, and while I guess technically the agent could never connect until the room connects first, this should always happen in a sequential fashion so I'm not sure that it really matters that much. So I guess I don't have a strong preference given both should behave identically, but maybe lean slightly towards what I have now.

also, should you guard agent ?

No, this isn't required - agent is always set, but its internal state changes as the agent goes through the connection lifecycle.

@1egoman 1egoman merged commit 09b09eb into main Oct 29, 2025
6 checks passed
@1egoman 1egoman deleted the usesession-waits-for-agent-only-if-dispatched branch October 29, 2025 14:31
@github-actions github-actions bot mentioned this pull request Oct 23, 2025
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.

3 participants