diff --git a/vscode/src/chat/chat-view/ChatController.ts b/vscode/src/chat/chat-view/ChatController.ts index a6033c50f800..c0f5598ca4c4 100644 --- a/vscode/src/chat/chat-view/ChatController.ts +++ b/vscode/src/chat/chat-view/ChatController.ts @@ -275,6 +275,11 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv this.setWebviewToChat() break case 'submit': { + logDebug( + 'ChatController', + 'onDidReceiveMessage.submit', + JSON.stringify({ intent: message.intent, scores: message.intentScores }) + ) await this.handleUserMessage({ requestID: uuid.v4(), inputText: PromptString.unsafe_fromUserQuery(message.text), @@ -640,7 +645,7 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv command?: DefaultChatCommands intent?: ChatMessage['intent'] | undefined | null intentScores?: { intent: string; score: number }[] | undefined | null - manuallySelectedIntent?: boolean | undefined | null + manuallySelectedIntent?: ChatMessage['intent'] | undefined | null traceparent?: string | undefined | null selectedAgent?: string | undefined | null }): Promise { @@ -700,12 +705,14 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv signal, detectedIntent, detectedIntentScores, + manuallySelectedIntent, }: { requestID: string input: string signal: AbortSignal detectedIntent?: ChatMessage['intent'] | undefined | null detectedIntentScores?: { intent: string; score: number }[] | undefined | null + manuallySelectedIntent?: ChatMessage['intent'] | undefined | null }): Promise<{ intent: ChatMessage['intent'] intentScores: { intent: string; score: number }[] @@ -717,9 +724,13 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv // The `detectedIntent` comes from the webview, where it can either be manually set by the user // using the dropdown UI or automatically pre-fetched for the input while the user is typing. // If any such intent is already detected, we use that. - if (detectedIntent) { + + // TODO: detectedIntent is null here because it isn't persisted in the transcript for some reason + + // TODO: differentiate between manually selected intent and detected intent + if (manuallySelectedIntent) { return { - intent: detectedIntent, + intent: manuallySelectedIntent, intentScores: detectedIntentScores || [], } } @@ -784,6 +795,14 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv }) recorder.recordChatQuestionSubmitted(mentions) + logDebug( + 'ChatController', + 'getIntent', + JSON.stringify({ + detectedIntent: detectedIntent, + detectedIntentScores: detectedIntentScores, + }) + ) const { intent, intentScores } = await this.getIntentAndScores({ requestID, input: editorState @@ -791,6 +810,7 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv : inputText.toString(), detectedIntent, detectedIntentScores, + manuallySelectedIntent, signal, }) signal.throwIfAborted() @@ -808,16 +828,29 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv }) recorder.setIntentInfo({ - userSpecifiedIntent: - manuallySelectedIntent && detectedIntent - ? detectedIntent - : this.featureCodyExperimentalOneBox - ? 'auto' - : 'chat', + userSpecifiedIntent: manuallySelectedIntent + ? manuallySelectedIntent + : this.featureCodyExperimentalOneBox + ? 'auto' + : 'chat', detectedIntent: intent, detectedIntentScores: intentScores, }) + logDebug( + 'ChatController', + 'Setting intent info', + JSON.stringify({ + userSpecifiedIntent: manuallySelectedIntent + ? manuallySelectedIntent + : this.featureCodyExperimentalOneBox + ? 'auto' + : 'chat', + detectedIntent: intent, + detectedIntentScores: intentScores, + }) + ) + this.postEmptyMessageInProgress(model) let messageInProgress: ChatMessage = { speaker: 'assistant', model } try { @@ -1053,7 +1086,7 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv editorState: SerializedPromptEditorState | null intent?: ChatMessage['intent'] | undefined | null intentScores?: { intent: string; score: number }[] | undefined | null - manuallySelectedIntent?: boolean | undefined | null + manuallySelectedIntent?: ChatMessage['intent'] | undefined | null }): Promise { const abortSignal = this.startNewSubmitOrEditOperation() @@ -1070,6 +1103,11 @@ export class ChatController implements vscode.Disposable, vscode.WebviewViewProv return } this.chatBuilder.removeMessagesFromIndex(humanMessage, 'human') + logDebug( + 'ChatController', + 'handleEdit', + JSON.stringify({ intent: intent, scores: intentScores }) + ) return await this.handleUserMessage({ requestID, inputText: text, @@ -1734,4 +1772,4 @@ export function manipulateWebviewHTML(html: string, options: TransformHTMLOption async function joinModelWaitlist(): Promise { await localStorage.setOrDeleteWaitlistO1(true) telemetryRecorder.recordEvent('cody.joinLlmWaitlist', 'clicked') -} +} \ No newline at end of file diff --git a/vscode/src/chat/chat-view/handlers/OmniboxTelemetry.ts b/vscode/src/chat/chat-view/handlers/OmniboxTelemetry.ts index 49795efe34ba..1d076d01596a 100644 --- a/vscode/src/chat/chat-view/handlers/OmniboxTelemetry.ts +++ b/vscode/src/chat/chat-view/handlers/OmniboxTelemetry.ts @@ -6,6 +6,7 @@ import { currentAuthStatusAuthed, firstResultFromOperation, getTokenCounterUtils, + logDebug, logError, telemetryEvents, wrapInActiveSpan, @@ -65,6 +66,7 @@ export class OmniboxTelemetry { } public setIntentInfo(intentInfo: IntentInfo) { + logDebug('OmniboxTelemetry', 'setting intent info', JSON.stringify(intentInfo)) this.intentInfo = intentInfo } @@ -78,7 +80,7 @@ export class OmniboxTelemetry { if (!this.intentInfo) { logError( 'AgentTelemetry', - 'failed to log cody.chat-question/executed beacuse intent info was not set' + 'failed to log cody.chat-question/executed because intent info was not set' ) return } @@ -92,4 +94,4 @@ export class OmniboxTelemetry { this.tokenCounterUtils ) } -} +} \ No newline at end of file diff --git a/vscode/src/chat/protocol.ts b/vscode/src/chat/protocol.ts index 309d7be41f7a..183be4d7264e 100644 --- a/vscode/src/chat/protocol.ts +++ b/vscode/src/chat/protocol.ts @@ -213,7 +213,7 @@ export interface WebviewSubmitMessage extends WebviewContextMessage { editorState?: unknown | undefined | null intent?: ChatMessage['intent'] | undefined | null intentScores?: { intent: string; score: number }[] | undefined | null - manuallySelectedIntent?: boolean | undefined | null + manuallySelectedIntent?: ChatMessage['intent'] | undefined | null traceparent?: string | undefined | null steps?: ProcessingStep[] | undefined | null } @@ -226,7 +226,7 @@ interface WebviewEditMessage extends WebviewContextMessage { editorState?: unknown | undefined | null intent?: ChatMessage['intent'] | undefined | null intentScores?: { intent: string; score: number }[] | undefined | null - manuallySelectedIntent?: boolean | undefined | null + manuallySelectedIntent?: ChatMessage['intent'] | undefined | null steps?: ProcessingStep[] | undefined | null } @@ -309,4 +309,4 @@ export function isSourcegraphToken(text: string): boolean { interface CodyIDECssVariables { [key: string]: string -} +} \ No newline at end of file diff --git a/vscode/webviews/chat/Transcript.tsx b/vscode/webviews/chat/Transcript.tsx index 1fff91edf4c3..346d459e5a28 100644 --- a/vscode/webviews/chat/Transcript.tsx +++ b/vscode/webviews/chat/Transcript.tsx @@ -309,11 +309,17 @@ const TranscriptInteraction: FC = memo(props => { return } + console.log( + 'Transcript', + 'onUserAction', + JSON.stringify({ msg: humanMessage.intent, intentResults: intentResults }) + ) + const commonProps = { editorValue, - intent: intentFromSubmit || intentResults.current?.intent, - intentScores: intentFromSubmit ? undefined : intentResults.current?.allScores, - manuallySelectedIntent: !!intentFromSubmit, + intent: intentResults.current?.intent, + intentScores: intentResults.current?.allScores, + manuallySelectedIntent: intentFromSubmit, traceparent, } @@ -322,7 +328,7 @@ const TranscriptInteraction: FC = memo(props => { // reference search results that don't exist anymore. // This is a no-op if the input does not contain any search context chips. // NOTE: Doing this for the penultimate input only seems to suffice because - // editing a message earlier in the transcript will clear the converstation + // editing a message earlier in the transcript will clear the conversation // and reset the last input anyway. if (isLastSentInteraction) { lastEditorRef.current?.filterMentions(item => !isCodeSearchContextItem(item)) @@ -341,6 +347,7 @@ const TranscriptInteraction: FC = memo(props => { const onEditSubmit = useCallback( (intentFromSubmit?: ChatMessage['intent']): void => { + console.log('Transcript', 'onEditSubmit', JSON.stringify(intentFromSubmit)) onUserAction('edit', intentFromSubmit) }, [onUserAction] @@ -369,6 +376,7 @@ const TranscriptInteraction: FC = memo(props => { return } + console.log('Transcript', 'onChange', 'setting to undefined') setIntentResults(undefined) const subscription = extensionAPI @@ -377,6 +385,7 @@ const TranscriptInteraction: FC = memo(props => { ) .subscribe({ next: value => { + console.log('Transcript', 'onDetectedIntent', JSON.stringify(value)) setIntentResults(value) }, error: error => { @@ -524,6 +533,7 @@ const TranscriptInteraction: FC = memo(props => { const telemetryRecorder = useTelemetryRecorder() const reSubmitWithIntent = useCallback( (intent: ChatMessage['intent']) => { + console.log('Transcript', 'resubmitWithIntent', intent) const editorState = humanEditorRef.current?.getSerializedValue() if (editorState) { onEditSubmit(intent) @@ -721,7 +731,7 @@ export function editHumanMessage({ editorValue: SerializedPromptEditorValue intent?: ChatMessage['intent'] intentScores?: { intent: string; score: number }[] - manuallySelectedIntent?: boolean + manuallySelectedIntent?: ChatMessage['intent'] }): void { getVSCodeAPI().postMessage({ command: 'edit', @@ -746,7 +756,7 @@ function submitHumanMessage({ editorValue: SerializedPromptEditorValue intent?: ChatMessage['intent'] intentScores?: { intent: string; score: number }[] - manuallySelectedIntent?: boolean + manuallySelectedIntent?: ChatMessage['intent'] traceparent: string }): void { getVSCodeAPI().postMessage({ @@ -774,4 +784,4 @@ function reevaluateSearchWithSelectedFilters({ index: messageIndexInTranscript, selectedFilters, }) -} +} \ No newline at end of file