Skip to content

Copilot Chat: Reduce calls to MSAL getIdToken#1612

Merged
gitri-ms merged 12 commits intomicrosoft:mainfrom
TaoChenOSU:users/taochen/copilot_getidtoken_call_fix
Jul 6, 2023
Merged

Copilot Chat: Reduce calls to MSAL getIdToken#1612
gitri-ms merged 12 commits intomicrosoft:mainfrom
TaoChenOSU:users/taochen/copilot_getidtoken_call_fix

Conversation

@TaoChenOSU
Copy link
Contributor

Motivation and Context

Many Copilot Chat app React components call getActiveAccount() to get the logged in user id/name as one of the setup steps. This will trigger MSAL to retrieve ID tokens from the cache, resulting in unnecessary calls to getIdToken as shown below.

24cfecf0-4896-4561-98ba-3b65a9947c5a

Description

Cache the logged in user id/name in the Redux store so that components don't have to repeatedly call getActiveAccount().

Contribution Checklist

@TaoChenOSU TaoChenOSU added PR: ready for review All feedback addressed, ready for reviews samples labels Jun 20, 2023
@TaoChenOSU TaoChenOSU requested a review from a team as a code owner June 20, 2023 17:55
@TaoChenOSU TaoChenOSU self-assigned this Jun 20, 2023
@TaoChenOSU TaoChenOSU requested review from amsacha and dehoward June 20, 2023 21:09
dehoward
dehoward previously approved these changes Jun 20, 2023
teresaqhoang
teresaqhoang previously approved these changes Jun 20, 2023
amsacha
amsacha previously approved these changes Jun 20, 2023
amsacha
amsacha previously approved these changes Jun 26, 2023
@TaoChenOSU TaoChenOSU added PR: ready to merge PR has been approved by all reviewers, and is ready to merge. and removed PR: ready for review All feedback addressed, ready for reviews labels Jun 26, 2023
dehoward
dehoward previously approved these changes Jun 27, 2023
teresaqhoang
teresaqhoang previously approved these changes Jun 30, 2023
@dehoward
Copy link

resolving conflicts

@dehoward dehoward dismissed stale reviews from teresaqhoang, amsacha, and themself via c1f0289 June 30, 2023 19:42
@gitri-ms gitri-ms added this pull request to the merge queue Jul 6, 2023
Merged via the queue into microsoft:main with commit 1e1d590 Jul 6, 2023
golden-aries pushed a commit to golden-aries/semantic-kernel that referenced this pull request Oct 10, 2023
### Motivation and Context
<!-- Thank you for your contribution to the semantic-kernel repo!
Please help reviewers and future users, providing the following
information:
  1. Why is this change required?
  2. What problem does it solve?
  3. What scenario does it contribute to?
  4. If it fixes an open issue, please link to the issue here.
-->
Many Copilot Chat app React components call getActiveAccount() to get
the logged in user id/name as one of the setup steps. This will trigger
MSAL to retrieve ID tokens from the cache, resulting in unnecessary
calls to getIdToken as shown below.


![24cfecf0-4896-4561-98ba-3b65a9947c5a](https://github.com/microsoft/semantic-kernel/assets/12570346/f726cf97-fdf3-4913-a5a7-2f13a85cc04e)

### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
Cache the logged in user id/name in the Redux store so that components
don't have to repeatedly call getActiveAccount().

### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [ ] The code builds clean without any errors or warnings
- [ ] The PR follows SK Contribution Guidelines
(https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md)
- [ ] The code follows the .NET coding conventions
(https://learn.microsoft.com/dotnet/csharp/fundamentals/coding-style/coding-conventions)
verified with `dotnet format`
- [ ] All unit tests pass, and I have added new tests where possible
- [ ] I didn't break anyone 😄

---------

Co-authored-by: Adrian Bonar <56417140+adrianwyatt@users.noreply.github.com>
Co-authored-by: Teresa Hoang <125500434+teresaqhoang@users.noreply.github.com>
Co-authored-by: Desmond Howard <dehoward@microsoft.com>
Co-authored-by: Aman Sachan <51973971+amsacha@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: ready to merge PR has been approved by all reviewers, and is ready to merge.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

7 participants