- 
                Notifications
    You must be signed in to change notification settings 
- Fork 130
Make useSession wait for agent only if an agent was dispatched #1226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            5 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      0a9c2c5
              
                feat: temporarily copy decodeTokenPayload into this project from live…
              
              
                1egoman c0bac8a
              
                feat: add logic to only wait for agent to be available if an agent was
              
              
                1egoman 388ac32
              
                fix: add changeset
              
              
                1egoman 3ab537f
              
                Revert "feat: temporarily copy decodeTokenPayload into this project f…
              
              
                1egoman d8cc488
              
                feat: install updated livekit-client package with new decodeTokenPayl…
              
              
                1egoman File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@livekit/components-react': patch | ||
| --- | ||
|  | ||
| Make useSession wait for agent only if an agent was dispatched | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
      
      Oops, something went wrong.
      
    
  
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -5,5 +5,5 @@ packages: | |
| - 'tooling/*' | ||
|  | ||
| catalog: | ||
| livekit-client: ^2.15.8 | ||
| livekit-client: ^2.15.14 | ||
| "@livekit/protocol": ^1.42.0 | ||
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitUntilConnectedwill block until a the underlying room is connected, andagent.waitUntilAvailablewill 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.No, this isn't required -
agentis always set, but its internal state changes as the agent goes through the connection lifecycle.