Code AI platform with Code Search & Cody
Go to file
Beatrix df999af89a
Cody: Fallback to keyword context for invalid embeddings client (#50952)
RE: https://github.com/sourcegraph/sourcegraph/issues/50876 

This PR addresses the issues raised by a customer and beyang ([slack
thread](https://sourcegraph.slack.com/archives/C04NPH6SZMW/p1681861031576389?thread_ts=1681859730.152309&channel=C04NPH6SZMW&message_ts=1681861031.576389))
regarding cody.codebase:
1. make it visible to the user what context mechanism is being used
1. we should fall back to keyword search if embeddings don't work
1. also lack of embeddings should surface a user-visible error

### PR Summary

#### Issue 1: make it visible to the user what context mechanism is
being used

Solution from this PR: Show the current fetching method in the lower
left corner

![Screenshot 2023-04-20 at 3 43 34
PM](https://user-images.githubusercontent.com/68532117/233503321-706393a7-ba5c-43ae-93b4-54ae09485c91.png)

![Screenshot 2023-04-20 at 3 44 56
PM](https://user-images.githubusercontent.com/68532117/233503446-e593b685-62fd-49cf-a847-0187936df0b7.png)

#### Issue 2: fall back to keyword search when embedding is not
available

Solution from this PR: Fallback to keyword search when:
- codebase is not provided
- embeddings are not available for the current codebase

When codebase is not provided and the cody.useContext is set to
'embedding' or 'blended', we will now fallback to use keyword search
(see context fetching mode in lower left corner)
![Screenshot 2023-04-20 at 3 45 32
PM](https://user-images.githubusercontent.com/68532117/233503939-0e653a48-5322-4ae0-bbcc-315daa46911b.png)

When code is provided but Cody is unable to connect to the codebase, we
will now fallback to use keyword search (see context fetching mode in
lower left corner)
![Screenshot 2023-04-20 at 3 44 56
PM](https://user-images.githubusercontent.com/68532117/233503446-e593b685-62fd-49cf-a847-0187936df0b7.png)

#### Issue 4:  lack of embeddings should surface a user-visible error

Solution from this PR: display message on codebase change / invalid
codebase in UI (see screenshots above)

When the cody.codebase is change, a pop up will also show up and ask
user to reload VS Code (see lower right corner):
![Screenshot 2023-04-20 at 3 44 15
PM](https://user-images.githubusercontent.com/68532117/233504281-6fd7e0fb-c4ff-4ad9-b82f-5441661d07a1.png)

#### other minor fix

- Disable chat submission on enter key press when chat is in progress

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

See screenshot shared above. Passed all unit test

```
 PASS   cody  src/configuration.test.ts
 PASS   cody  src/completions/context.test.ts
 PASS   cody  src/keyword-context/local-keyword-context-fetcher.test.ts

Test Suites: 3 passed, 3 total
Tests:       5 passed, 5 total
Snapshots:   0 total
Time:        2.127 s
Ran all test suites.
```

---------

Co-authored-by: Philipp Spiess <hello@philippspiess.com>
2023-04-21 18:25:48 +00:00
.aspect bazel: remove disk/remote cache settings (#50814) 2023-04-18 16:03:19 +00:00
.buildkite ci: run gen-pipeline from workspace root (#50988) 2023-04-21 14:36:46 +00:00
.github dx: drop pr-previews (#50704) 2023-04-17 09:48:34 +00:00
.vscode focus cody chat on startup when launching debug task from vscode (#50685) 2023-04-15 20:48:36 -07:00
client Cody: Fallback to keyword context for invalid embeddings client (#50952) 2023-04-21 18:25:48 +00:00
cmd app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
dev Fix pipeline generator (#51004) 2023-04-21 18:17:41 +00:00
doc Update enabling_cody.md for broken link (#50999) 2023-04-21 17:45:35 +00:00
docker-images Implement Zig tree-sitter highlighting (#50563) 2023-04-13 11:52:23 -04:00
enterprise app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
internal Implement rate limiting for completions API (#50925) 2023-04-21 13:09:20 +00:00
lib bazel: add depguard as a nogo linter (#50585) 2023-04-13 14:19:45 +02:00
migrations Implement rate limiting for completions API (#50925) 2023-04-21 13:09:20 +00:00
monitoring chore: remove unused metrics for perms syncer (#50605) 2023-04-13 19:37:59 +02:00
schema Implement rate limiting for completions API (#50925) 2023-04-21 13:09:20 +00:00
src-tauri app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
third_party bazel: update buildfiles (#47744) 2023-02-16 16:32:59 +01:00
third-party-licenses chore: update third-party licenses (#50692) 2023-04-17 07:26:48 +02:00
ui/assets Revert docker bazel frontend (#50326) 2023-04-04 10:24:05 +00:00
wolfi-images Add Wolfi base images (#47034) 2023-01-31 12:09:09 +00:00
wolfi-packages test the code host connection for Perforce (fixes #43855) (#49069) 2023-03-10 13:16:22 -08:00
.bazel_fix_commands.json bazel: add command sets that uses bazel under the hood (#48460) 2023-03-02 11:31:51 +01:00
.bazelignore cody: add CLI (#50794) 2023-04-20 13:23:34 +00:00
.bazeliskrc chore: update to Aspect CLI 5.2.1 (#48798) 2023-03-07 10:13:33 +01:00
.bazelrc bazel: client e2e tests (#50330) 2023-04-13 04:01:37 -07:00
.bazelversion Update bazel to 6.1.1 (#50472) 2023-04-11 10:51:21 +02:00
.browserslistrc web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
.dockerignore web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
.editorconfig chore: Add .lua to editorconfig. (#44267) 2022-11-11 15:25:32 +08:00
.eslintignore [experiment] Merge SvelteKit prototype into main (#47238) 2023-02-13 17:53:23 +01:00
.eslintrc.js Better import ordering with prettier (#48188) 2023-03-13 08:37:23 +00:00
.gitattributes bazel: Build syntax-highlighter (#48703) 2023-03-08 19:08:09 +08:00
.gitignore Port back compat tests to Bazel (#50932) 2023-04-21 14:39:36 +02:00
.graphqlrc.yml Support multiple GraphQL schema files (#20077) 2021-04-19 14:35:49 +02:00
.hadolint.yaml bump comby version to 1.7.1 (#35830) 2022-05-20 20:12:01 -07:00
.mailmap mailmap: update replacements for Joe (#29614) 2022-01-12 10:56:56 +08:00
.mocharc.js build: still need BAZEL_BINDIR for webpack_bundle custom rule (#48796) 2023-03-07 20:02:11 -08:00
.npmrc web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
.percy.yml Update browser extention installation detection logic on web (#32449) 2022-03-14 23:29:39 +06:00
.prettierignore app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
.stylelintignore rework plugin structure and implement frontside blogpost (#46883) 2023-02-15 11:49:51 +02:00
.stylelintrc.json web: drop bootstrap depenedency (#41401) 2022-09-07 03:11:26 -07:00
.tool-versions Update to go 1.19.8 (#50341) 2023-04-05 17:39:02 +02:00
.trivyignore ci: ignore benign CVE-2021-43816 in prometheus (#31069) 2022-02-11 16:49:10 +00:00
babel.config.jest.js bazel: fix the web application bundle in Bazel (#50383) 2023-04-10 21:16:12 -07:00
babel.config.js bazel: fix the web application bundle in Bazel (#50383) 2023-04-10 21:16:12 -07:00
BUILD.bazel bazel: add unparam nogo linter (#50730) 2023-04-18 10:03:35 +00:00
CHANGELOG.md changelog update (#50830) 2023-04-18 16:55:43 -04:00
CONTRIBUTING.md Docs: Fix docs page link in main CONTRIBUTING.md (#45160) 2022-12-05 14:57:45 +01:00
deps.bzl embeddings: featureflagged search against weaviate (#50722) 2023-04-21 01:54:08 +00:00
doc.go
flake.lock nix: update to get latest go1.20.3 (#50639) 2023-04-18 08:49:55 +02:00
flake.nix nix: use go1.20 (#47541) 2023-02-13 12:19:12 +02:00
gen.go chore: Update go-mockgen (#44305) 2022-11-11 19:24:00 +00:00
go.mod app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
go.sum embeddings: featureflagged search against weaviate (#50722) 2023-04-21 01:54:08 +00:00
graphql-schema-linter.config.js Support multiple GraphQL schema files (#20077) 2021-04-19 14:35:49 +02:00
gulpfile.js web: drop legacy GraphQL schema generator (#45945) 2022-12-25 18:10:20 -08:00
jest.config.base.js bazel: wildcard jest tests (#49282) 2023-03-17 03:38:49 -07:00
jest.config.js tests: use glob for jest projects field (#29681) 2022-01-13 01:11:52 -08:00
jest.snapshot-resolver.js bazel: wildcard jest tests (#49282) 2023-03-17 03:38:49 -07:00
LICENSE update licensing language (#25620) 2021-10-04 15:40:59 +01:00
LICENSE.apache
LICENSE.enterprise
lighthouserc.js web: migrate from yarn to pnpm (#46143) 2023-01-11 19:50:09 -08:00
linter_deps.bzl bazel: add unparam nogo linter (#50730) 2023-04-18 10:03:35 +00:00
mockgen.temp.yaml Executor Runtimes (#47496) 2023-04-04 09:18:26 -06:00
mockgen.test.yaml [cleanup] Remove old GitHub App code (#50933) 2023-04-21 07:27:27 +02:00
mockgen.yaml mocks: Reorganize mock definitions into multiple files (#36967) 2022-06-27 20:59:16 +00:00
nogo_config.json bazel: add depguard as a nogo linter (#50585) 2023-04-13 14:19:45 +02:00
package.json app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
pnpm-lock.yaml app: experimental Tauri branch (#50620) 2023-04-21 19:48:47 +02:00
pnpm-workspace.yaml cody: development branch (#49761) 2023-03-23 20:41:11 +01:00
postcss.config.js extensibility: add featured extensions to registry (#21665) 2021-06-10 13:55:20 -04:00
prettier.config.js clean up Cody CSS to increase shareability and improve display in web app (#50279) 2023-04-03 12:29:05 -07:00
README.md update readme and docs index for 5.0 (#49988) 2023-03-24 21:48:46 -06:00
renovate.json chore: add test plans to bot and release tool PRs (#31351) 2022-02-22 07:53:25 -08:00
SECURITY.md
service-catalog.yaml lib/servicecatalog: init to distribute catalog (#46999) 2023-01-26 17:22:27 -08:00
sg.config.yaml llm-proxy: initialize service (#50774) 2023-04-18 21:42:27 +00:00
shell.nix nix: add bazel-watcher (#50956) 2023-04-21 13:14:35 +02:00
svgo.config.js Performance: Optimize static SVG assets with SVGO (#26285) 2021-10-27 15:27:36 +01:00
tsconfig.all.json extract Cody UI package, add Cody to web app (#50270) 2023-04-02 17:41:20 -07:00
tsconfig.base.json web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
tsconfig.eslint.json web: fix pnpm-lock issue (#47478) 2023-02-09 22:04:31 -08:00
WORKSPACE Port back compat tests to Bazel (#50932) 2023-04-21 14:39:36 +02:00

DocsContributingTwitterDiscord

Build status Scorecard Latest release Discord Contributors


Sourcegraph makes it easy to read, write, and fix code—even in big, complex codebases.

  • Code search: Search all of your repositories across all branches and all code hosts.
  • Code intelligence: Navigate code, find references, see code owners, trace history, and more.
  • Fix and refactor: Roll out large-scale changes to many repositories at once and track big migrations.

Getting started



Development

Refer to the Developing Sourcegraph guide to get started.

Documentation

The doc directory has additional documentation for developing and understanding Sourcegraph:

License

This repository contains both OSS-licensed and non-OSS-licensed files. We maintain one repository rather than two separate repositories mainly for development convenience.

All files in the enterprise and client/web/src/enterprise fall under LICENSE.enterprise.

The remaining files fall under the Apache 2 license. Sourcegraph OSS is built only from the Apache-licensed files in this repository.