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: real integration with Experience Shell #43

Merged
merged 19 commits into from
Nov 21, 2023
Merged

feat: real integration with Experience Shell #43

merged 19 commits into from
Nov 21, 2023

Conversation

askayastha22
Copy link
Member

Description

Related Issue

Motivation and Context

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@askayastha22 askayastha22 changed the title Integration with Experience Shell feat: integration with Experience Shell Nov 17, 2023
@askayastha22 askayastha22 changed the title feat: integration with Experience Shell feat: real integration with Experience Shell Nov 17, 2023
@@ -66,7 +66,7 @@ export function GenerateButton() {

const generateResults = useCallback(async () => {
const finalPrompt = renderPrompt(prompt, parameters);
const { queryId, response } = await firefallService.complete(finalPrompt, temperature, imsToken);
const { queryId, response } = await firefallService.complete(finalPrompt, temperature, user.imsToken);
Copy link
Collaborator

Choose a reason for hiding this comment

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

The IMS token should be injected into the service in a constructor. This way, we won't even touch this file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The EXC Shell triggers a refresh token when there is 20% duration left. A configuration event is sent to the iframe. The app could also listen directly to user.on('change:imsToken', () => {})

If we move this in a constructor we need to re-initialize firefall service when token changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I just realized that any configuration change will recreate the FirefallService due to shellEventsHandler being called.

@@ -127,7 +127,7 @@ export function ResultCard({ result, ...props }) {
const saveSession = useSaveSession();

const sendFeedback = useCallback((sentiment) => {
firefallService.feedback(result.resultId, sentiment, imsToken)
firefallService.feedback(result.resultId, sentiment, user.imsToken)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please pass the token to the service in its constructor.


export const ShellAuthContext = createContext({});

export const ShellAuthProvider = ({ children }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest merging this provider with the Application Provider, as auth data is not required on its own anywhere in the app. It is only needed to construct the services.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I considered separating the Auth context too, as it makes things easier to read and follow in the code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In my mental models, each app has a model but:

  • Models could also be split into classes to isolate the concerns, simplify testing.
  • A single large context that holds all the state for the entire app could lead to unnecessary re-renders.
  • Smaller, more focused contexts can be more easily reused across different parts of our app, especially as we change the app based on our learnings.
  • Managing the state of a large, monolithic context can become cumbersome and error-prone.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I considered separating the Auth context too

Separating contexts doesn't necessarily mean separating the providers. The context itself has a modular structure. React does not care if the context object has only one root or many. I would suggest that we at least move the Shell provider above the Application Context.
cc @ddragosd @askayastha22

Copy link
Member Author

Choose a reason for hiding this comment

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

@vtsaplin The Unified Shell config is set in ApplicationProvider and read in ShellAuthProvider. Is moving ShellAuthProvider above ApplicationProvider okay?

Copy link
Collaborator

Choose a reason for hiding this comment

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

@vtsaplin let's do this change in a separate PR to unblock the Shell testing

@askayastha22 askayastha22 marked this pull request as ready for review November 21, 2023 20:46
Copy link
Collaborator

@ddragosd ddragosd left a comment

Choose a reason for hiding this comment

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

blanket approval to merge to main and test w unified shell. @vtsaplin we can still make changes

@ddragosd ddragosd merged commit e50e785 into main Nov 21, 2023
1 of 4 checks passed
@ddragosd ddragosd deleted the exc-shell-auth branch November 21, 2023 22:58
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