-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add install, embeddings enabled notices for post-hoc app setup (#1089)
Adds popups to install app, set up embeddings, etc. when using the simplified onboarding flow. Automatically switches to app for embeddings, when app has embeddings available. Polishes vscode storybook so codicons work and there are more relevant style variables. Part of #632. ![Screenshot 2023-09-19 at 22 41 14](https://github.com/sourcegraph/cody/assets/55120/b3b103af-1010-4922-83cf-3631ae8cf11f) ## Caveats - The app prompts are still displayed on Windows, but there's no Windows app to download. - [These prompts](https://www.figma.com/file/INGthyKM1cYki5H02JPDpW/VS-Code-Beta-2-%3C%3E-App-Onboarding?type=design&node-id=53-374&mode=design&t=ivzuiEzqtVsJtkD8-0) for Enterprise are not implemented. Enterprise uses the legacy widget. - There's little/no logging for interactions with this UI. ## Test plan ``` pnpm -C vscode storybook ``` Open http://localhost:6007 and examine the App-less Onboarding storybooks. Manual tests: 0. Uninstall Cody App. Remove test VScode state: `rm -rf /tmp/vscode-cody-extension-dev-host` 1. Run VScode with "Launch VScode Extension (Desktop; separate instance)" (equivalently, `--user-data-dir=/tmp/vscode-cody-extension-dev-host`) so you have no App token cached. 2. Open user settings JSON and add `"testing.simplified-onboarding": true` and restart VScode. 3. Create a new git repository with `git init /tmp/bar; cd /tmp/bar; git remote add origin git@host.example:bar/bar.git` . Open `/tmp/bar` in VScode. 4. Sign in with simplified onboarding. 5. The context underneath the chat box should be red. Click to open the notification. Check the link and Install App buttons work. 6. Install App. Click the Reload button. The prompt should change to Embeddings Not Found/Open App. 7. Click Open App, add embeddings for the repo. Wait for embeddings to complete. Back in VScode, click the Reload button. The indicator should change to a checked database icon. Or, if App presents a "back to VScode" button, click it and the indicator should change automatically. Or simulate that click by going `open vscode://sourcegraph.cody-ai/app-done' at the console. 8. Close app and wait 20 seconds. The indicator should go red/show a cross. 9. Open app and wait 20 seconds. The indicator should be checked. 10. Close app. Wait for the indicator to go read. Immediately open app, pop up the toast, and hit reload. The indicator should be checked immediately. 11. Clone something indexed by dotcom, for example, https://github.com/preactjs/preact . Open in VScode and open a file in the repository. The database icon should be checked (that is, using dotcom embeddings.)
- Loading branch information
1 parent
d165c77
commit 92fe107
Showing
28 changed files
with
1,000 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,51 @@ | ||
import { SourcegraphGraphQLAPIClient } from '../sourcegraph-api/graphql/client' | ||
|
||
import { SourcegraphEmbeddingsSearchClient } from './client' | ||
|
||
// A factory for SourcegraphEmbeddingsSearchClients. Queries the client | ||
// connection and app (if available) in parallel and returns the one with | ||
// embeddings available. | ||
export const EmbeddingsDetector = { | ||
// Creates an embeddings search client with the first client in `clients` | ||
// that has embeddings. If none have embeddings, returns undefined. If all | ||
// fail, returns the first error. | ||
async newEmbeddingsSearchClient( | ||
clients: readonly SourcegraphGraphQLAPIClient[], | ||
codebase: string | ||
): Promise<SourcegraphEmbeddingsSearchClient | Error | undefined> { | ||
let firstError: Error | undefined | ||
let allFailed = true | ||
for (const promise of clients.map(client => this.detectEmbeddings(client, codebase))) { | ||
const result = await promise | ||
const isError = result instanceof Error | ||
allFailed &&= isError | ||
if (isError) { | ||
console.log('EmbeddingsDetector', `Error getting embeddings availability for ${codebase}`, result) | ||
firstError ||= result | ||
continue | ||
} | ||
if (result === undefined) { | ||
continue | ||
} | ||
// We got a result, drop the rest of the promises on the floor. | ||
return result() | ||
} | ||
return allFailed ? firstError : undefined | ||
}, | ||
|
||
// Detects whether *one* client has embeddings for the specified codebase. | ||
// Returns one of: | ||
// - A thunk to construct an embeddings search client, if embeddings exist. | ||
// - undefined, if the client doesn't have embeddings. | ||
// - An error. | ||
async detectEmbeddings( | ||
client: SourcegraphGraphQLAPIClient, | ||
codebase: string | ||
): Promise<(() => SourcegraphEmbeddingsSearchClient) | Error | undefined> { | ||
const repoId = await client.getRepoIdIfEmbeddingExists(codebase) | ||
if (repoId instanceof Error) { | ||
return repoId | ||
} | ||
return repoId ? () => new SourcegraphEmbeddingsSearchClient(client, repoId) : undefined | ||
}, | ||
} |
This file contains 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
This file contains 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 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.