sourcegraph/client/cody/webviews/Chat.module.css
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

71 lines
1.9 KiB
CSS

.inner-container {
height: 100%;
overflow: auto;
}
.transcript-item {
font-size: var(--vscode-editor-font-size);
font-family: var(--vscode-font-family);
font-weight: var(--vscode-font-weight);
color: var(--vscode-input-foreground);
border-color: var(--vscode-sideBarSectionHeader-border);
}
/* Apply a slight tint to the human transcript item. */
body[data-vscode-theme-kind='vscode-light'] .human-transcript-item,
body[data-vscode-theme-kind='vscode-high-contrast-light'] .human-transcript-item {
background-color: rgba(0, 0, 0, 0.07); /* slight dark tint */
}
body[data-vscode-theme-kind='vscode-dark'] .human-transcript-item,
body[data-vscode-theme-kind='vscode-high-contrast'] .human-transcript-item {
background-color: rgba(255, 255, 255, 0.07); /* slight light tint */
}
.transcript-item-participant {
font-size: var(--vscode-editor-font-size);
color: var(--vscode-descriptionForeground);
}
.transcript-item pre,
.transcript-item span > code,
.transcript-item p > code,
.transcript-item pre > code {
/* Our syntax highlighter emits colors intended for dark backgrounds only. */
background-color: var(--code-background);
color: var(--code-foreground);
}
.transcript-action {
background: var(--button-secondary-background);
color: var(--button-secondary-foreground);
font-size: var(--vscode-editor-font-size);
}
.code-blocks-copy-button {
color: var(--vscode-button-secondaryForeground);
background-color: var(--vscode-button-secondaryBackground);
border: none;
}
.input-row {
border-top: solid 1px var(--vscode-sideBarSectionHeader-border);
}
.chat-input-context {
color: var(--vscode-input-foreground);
}
.chat-input {
outline: none;
}
:global(.token-hallucinated) {
border-bottom: 2px solid var(--vscode-testing-iconQueued);
word-break: break-all;
}
:global(.token-not-hallucinated) {
border-bottom: 2px solid var(--vscode-testing-iconPassed);
word-break: break-all;
}