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

do not block on CodyLLMSiteConfiguration (configOverwrites) fetch in initial auth #5799

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

sqs
Copy link
Member

@sqs sqs commented Oct 3, 2024

To authenticate a user and start showing the UI, we actually don't need to
fetch the CodyLLMSiteConfiguration (configOverwrites). This reduces the
number of HTTP requests (albeit they were parallelized somewhat) needed
before the user can be authenticated and start seeing the Cody UI.

This uncovered some possible "bugs" in the anthropic.test.ts autocomplete
tests, where they were asserting that the model would be set but it
actually would not be in real life. In Provider.maybeFilterOutModel it
sees that this.configOverwrites?.provider === 'sourcegraph' in the test,
but that should not be true in real life because it’s being passed an
authStatus that is non-dotcom. The reason the test is bad is because that
method gets the auth status from currentAuthStatus(), which is dotcom in
testing only because of a prior test's mock value.

  • do not block on fetching the user's Cody Pro subscription status when authing

Test plan

CI & e2e. Sign in and ensure that operation that need the site version (such as autocomplete) still function without an error.

Changelog

  • Made authentication faster and less prone to network instability by reducing the number of HTTP requests needed for authentication.

@sqs sqs requested a review from a team October 3, 2024 22:47
@sqs
Copy link
Member Author

sqs commented Oct 3, 2024

cc @RXminuS

@RXminuS
Copy link
Contributor

RXminuS commented Oct 3, 2024

Just having a look at another failing test where UI seems to render before it responds to clicks to account tab

@sqs sqs force-pushed the sqs/combined-auth-reqs branch 5 times, most recently from 0c2ed91 to 1fb9e9c Compare October 5, 2024 07:26
@sqs sqs requested a review from valerybugakov October 5, 2024 07:29
@sqs
Copy link
Member Author

sqs commented Oct 5, 2024

@valerybugakov Can you PTAL at the changes I needed to make to the anthropic.test.ts autocomplete provider tests? I think some of the expected values were still wrong as I understood the actual expected behavior, but I am not sure. The purpose of this PR is to extract configOverwrites into a separate observable and value, so it's possible that the new code has a bug or the old code has a bug in reading the wrong configOverwrites.

@sqs sqs changed the title reduce blocking HTTP requests during authentication do not block on CodyLLMSiteConfiguration (configOverwrites) fetch in initial auth Oct 5, 2024
@sqs sqs force-pushed the sqs/combined-auth-reqs branch 4 times, most recently from 00553ff to ef7f310 Compare October 5, 2024 22:06
…initial auth

To authenticate a user and start showing the UI, we actually don't need to fetch the CodyLLMSiteConfiguration (`configOverwrites`). This reduces the number of HTTP requests (albeit they were parallelized somewhat) needed before the user can be authenticated and start seeing the Cody UI.

This uncovered some possible "bugs" in the `anthropic.test.ts` autocomplete tests, where they were asserting that the `model` would be set but it actually would not be in real life. In `Provider.maybeFilterOutModel` it sees that `this.configOverwrites?.provider === 'sourcegraph'` in the test, but that should not be true in real life because it’s being passed an `authStatus` that is non-dotcom. The reason the test is bad is because that method gets the auth status from `currentAuthStatus()`, which is dotcom in testing only because of a prior test's mock value.
expect(getRequestParamsWithoutMessages(provider)).toStrictEqual({
...requestParams,
// The model ID is ignored by BYOK clients
model: undefined,
})
expect(getRequestParamsWithoutMessages(provider)).toStrictEqual(requestParams)
Copy link
Member

@valerybugakov valerybugakov Oct 7, 2024

Choose a reason for hiding this comment

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

In the previous version, the test used mockAuthStatus(AUTH_STATUS_FIXTURE_AUTHED) based on isDotCom parameter, which didn't have configOverwrites. This was inconsistent with provider creation arguments and implicitly made it a BYOK provider. Thanks for fixing this!

@valerybugakov valerybugakov merged commit bc9f965 into main Oct 7, 2024
19 checks passed
@valerybugakov valerybugakov deleted the sqs/combined-auth-reqs branch October 7, 2024 01:29
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