mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 14:51:44 +00:00
Cody: Log chat prediction usage (#51474)
Adds logging to the chat prediction experimental feature. ## Test plan https://user-images.githubusercontent.com/458591/236258186-697fcbfb-1ce8-45dd-8703-86a1e7b8dbee.mov <!-- All pull requests REQUIRE a test plan: https://docs.sourcegraph.com/dev/background-information/testing_principles -->
This commit is contained in:
parent
0c48b65e82
commit
b01eb60174
@ -23,7 +23,7 @@ interface ChatProps extends ChatClassNames {
|
||||
setFormInput: (input: string) => void
|
||||
inputHistory: string[]
|
||||
setInputHistory: (history: string[]) => void
|
||||
onSubmit: (text: string) => void
|
||||
onSubmit: (text: string, submitType: 'user' | 'suggestion') => void
|
||||
textAreaComponent: React.FunctionComponent<ChatUITextAreaProps>
|
||||
submitButtonComponent: React.FunctionComponent<ChatUISubmitButtonProps>
|
||||
suggestionButtonComponent?: React.FunctionComponent<ChatUISuggestionButtonProps>
|
||||
@ -138,12 +138,12 @@ export const Chat: React.FunctionComponent<ChatProps> = ({
|
||||
)
|
||||
|
||||
const submitInput = useCallback(
|
||||
(input: string): void => {
|
||||
(input: string, submitType: 'user' | 'suggestion'): void => {
|
||||
if (messageInProgress) {
|
||||
return
|
||||
}
|
||||
|
||||
onSubmit(input)
|
||||
onSubmit(input, submitType)
|
||||
setSuggestions?.(undefined)
|
||||
setHistoryIndex(input.length + 1)
|
||||
setInputHistory([...inputHistory, input])
|
||||
@ -156,7 +156,7 @@ export const Chat: React.FunctionComponent<ChatProps> = ({
|
||||
if (formInput.trim() && !messageInProgress) {
|
||||
setInputRows(5)
|
||||
setFormInput('')
|
||||
submitInput(formInput)
|
||||
submitInput(formInput, 'user')
|
||||
}
|
||||
}, [formInput, messageInProgress, setFormInput, submitInput])
|
||||
|
||||
@ -223,7 +223,7 @@ export const Chat: React.FunctionComponent<ChatProps> = ({
|
||||
<SuggestionButton
|
||||
key={suggestion}
|
||||
suggestion={suggestion}
|
||||
onClick={() => submitInput(suggestion)}
|
||||
onClick={() => submitInput(suggestion, 'suggestion')}
|
||||
/>
|
||||
) : null
|
||||
)}
|
||||
|
||||
@ -6,6 +6,8 @@ All notable changes to Sourcegraph Cody will be documented in this file.
|
||||
|
||||
### Added
|
||||
|
||||
- Adds usage metrics to the experimental chat predictions feature [pull/51474](https://github.com/sourcegraph/sourcegraph/pull/51474)
|
||||
|
||||
### Fixed
|
||||
|
||||
### Changed
|
||||
|
||||
@ -155,11 +155,11 @@ export class ChatViewProvider implements vscode.WebviewViewProvider, vscode.Disp
|
||||
this.sendChatHistory()
|
||||
break
|
||||
case 'submit':
|
||||
await this.onHumanMessageSubmitted(message.text)
|
||||
await this.onHumanMessageSubmitted(message.text, message.submitType)
|
||||
break
|
||||
case 'edit':
|
||||
this.transcript.removeLastInteraction()
|
||||
await this.onHumanMessageSubmitted(message.text)
|
||||
await this.onHumanMessageSubmitted(message.text, 'user')
|
||||
break
|
||||
case 'executeRecipe':
|
||||
await this.executeRecipe(message.recipe)
|
||||
@ -287,7 +287,10 @@ export class ChatViewProvider implements vscode.WebviewViewProvider, vscode.Disp
|
||||
void this.saveTranscriptToChatHistory()
|
||||
}
|
||||
|
||||
private async onHumanMessageSubmitted(text: string): Promise<void> {
|
||||
private async onHumanMessageSubmitted(text: string, submitType: 'user' | 'suggestion'): Promise<void> {
|
||||
if (submitType === 'suggestion') {
|
||||
logEvent('CodyVSCodeExtension:chatPredictions:used')
|
||||
}
|
||||
this.inputHistory.push(text)
|
||||
|
||||
if (this.config.experimentalChatPredictions) {
|
||||
|
||||
@ -12,7 +12,7 @@ export type WebviewMessage =
|
||||
command: 'initialized'
|
||||
}
|
||||
| { command: 'event'; event: string; value: string }
|
||||
| { command: 'submit'; text: string }
|
||||
| { command: 'submit'; text: string; submitType: 'user' | 'suggestion' }
|
||||
| { command: 'executeRecipe'; recipe: string }
|
||||
| { command: 'settings'; serverEndpoint: string; accessToken: string }
|
||||
| { command: 'removeToken' }
|
||||
|
||||
@ -51,8 +51,8 @@ export const Chat: React.FunctionComponent<React.PropsWithChildren<ChatboxProps>
|
||||
setSuggestions,
|
||||
}) => {
|
||||
const onSubmit = useCallback(
|
||||
(text: string) => {
|
||||
vscodeAPI.postMessage({ command: 'submit', text: escapeCodyMarkdown(text) })
|
||||
(text: string, submitType: 'user' | 'suggestion') => {
|
||||
vscodeAPI.postMessage({ command: 'submit', text: escapeCodyMarkdown(text), submitType })
|
||||
},
|
||||
[vscodeAPI]
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user