Skip to content
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

feat(@fluid-example/ai-collab): Integrate User Avatar into Sample App #22850

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

chentong7
Copy link
Contributor

@chentong7 chentong7 commented Oct 18, 2024

Description

This PoC demonstrates the integration of Microsoft's Presence API into an existing AI-powered application. The key objectives include ramping up the current AI app, incorporating the Presence API library, and integrating this functionality to display user presence information. Specifically, this demo will show the avatar of a signed-in Microsoft account on top of the sample AI app's user interface, indicating the user’s online status or availability in real time.

By completing this PoC, we aim to enhance the AI app's user experience with seamless integration of Microsoft's identity and presence services, allowing for personalized interactions based on user status.

Sample

Screenshot (5)
Screenshot (6)
Screenshot (7)

@github-actions github-actions bot added area: examples Changes that focus on our examples dependencies Pull requests that update a dependency file base: main PRs targeted against main branch labels Oct 18, 2024
examples/apps/ai-collab/package.json Outdated Show resolved Hide resolved
examples/apps/ai-collab/package.json Outdated Show resolved Hide resolved
examples/apps/ai-collab/src/app/tasks-list/presence.ts Outdated Show resolved Hide resolved
examples/apps/ai-collab/src/app/tasks-list/page.tsx Outdated Show resolved Hide resolved
@chentong7 chentong7 changed the title AI App Ramp up + Presence Integration feat(@fluid-example/ai-collab): Integrate User Avatar into Sample App Oct 23, 2024
Copy link
Collaborator

@msfluid-bot msfluid-bot left a comment

Choose a reason for hiding this comment

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

Code Coverage Summary

No packages impacted by the change.


Baseline commit: 34f6b6b
Baseline build: 303134
Happy Coding!!

Code coverage comparison check passed!!

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Oct 23, 2024

@fluid-example/bundle-size-tests: +245 Bytes
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 464.08 KB 464.11 KB +35 Bytes
azureClient.js 562.24 KB 562.29 KB +49 Bytes
connectionState.js 724 Bytes 724 Bytes No change
containerRuntime.js 261.67 KB 261.68 KB +14 Bytes
fluidFramework.js 406.31 KB 406.32 KB +14 Bytes
loader.js 134.16 KB 134.18 KB +14 Bytes
map.js 42.71 KB 42.71 KB +7 Bytes
matrix.js 148.54 KB 148.54 KB +7 Bytes
odspClient.js 528.18 KB 528.23 KB +49 Bytes
odspDriver.js 97.84 KB 97.86 KB +21 Bytes
odspPrefetchSnapshot.js 42.81 KB 42.82 KB +14 Bytes
sharedString.js 164.73 KB 164.74 KB +7 Bytes
sharedTree.js 396.77 KB 396.77 KB +7 Bytes
Total Size 3.32 MB 3.32 MB +245 Bytes

Baseline commit: 34f6b6b

Generated by 🚫 dangerJS against dd433b1

@chentong7 chentong7 requested review from seanimam, alexvy86 and a team October 24, 2024 18:09
@chentong7 chentong7 force-pushed the ai-tong branch 2 times, most recently from 0664756 to c809a4f Compare October 25, 2024 20:12
Copy link
Member

@tylerbutler tylerbutler left a comment

Choose a reason for hiding this comment

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

I am having trouble understanding what the presence code is doing. I tried running the sample locally with tinylicious and I don't see any presence information. Am I doing something wrong?

@chentong7
Copy link
Contributor Author

chentong7 commented Oct 28, 2024

I am having trouble understanding what the presence code is doing. I tried running the sample locally with tinylicious and I don't see any presence information. Am I doing something wrong?

The presence code is responsible for syncing the client's user's avatar. If you are using the Tinylicious server, it won't have Microsoft account information, so it will display a default user photo at the top. However, if you are using the SPE client and have signed in with a Microsoft account, it will retrieve the account profile photo, update the presence, and re-render the page to show the new user's avatar at the top.

Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

@chentong7 I just noticed that even with two tabs connected on the same container, I'm not seeing two presence entries like we should:

image

Where did we end up with that? I thought we said we wanted that behavior (presence should show audience members, so each tab should count as a separate one)?

const tenantId = process.env.NEXT_PUBLIC_SPE_ENTRA_TENANT_ID;
if (tenantId === undefined || clientId === undefined) {
// add a default photo for tinylicious client
userPresenceGroup.onlineUsers.local.set(`id-${uuid()}`, {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For tinylicious client, the default photo should be added into container presence group here for each opening new tab. And it should trigger the previous effect function to re-render the page like the spe client does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it happening for you, though? As you can see in my screenshot, I only see one circle with default photo, but I have 2 tabs open.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems like it didn't re-render the page for you. I can see tinylicious clients on my local. Let me see how to make it refresh page itself...
Screenshot (8)

Copy link
Contributor

Choose a reason for hiding this comment

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

More than re-rendering the page, I think the presence group should update real-time as things (the connected clients) change. The presence framework probably has events to tell us when things change?

I'm still curious though, I just started the app from the latest commit in the PR (dd433b1) and I'm still only seeing one circle, even when I start the second client from a different browser 🤔 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you click refresh on page manually, the second circle should show-up. It was running slow to appear on my side too. I put the userPresenceGroup in state but it seems not detect the object changed and failed to re-render the page auto. I guess it does need a handler to monitor the addUser event and refresh page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: examples Changes that focus on our examples base: main PRs targeted against main branch dependencies Pull requests that update a dependency file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants