From c002ddf5aead2a3cee7425d5e44431f84e118bbb Mon Sep 17 00:00:00 2001 From: Release Bot <107104610+sourcegraph-release-bot@users.noreply.github.com> Date: Thu, 12 Dec 2024 15:12:23 -0800 Subject: [PATCH] [Backport jb-v7.6.x] [Backport vscode-v1.52.x] Fix manual intent selection for onebox (#6339) Ship blocking bug - A bug was introduced as part of https://github.com/sourcegraph/cody/pull/6294 which causes manual selection of the intent to be ignored. This PR fixes the bug. ## Test plan https://www.loom.com/share/dfcfcc6decca4ca19cfb3220d8026a07?sid=99e6d5f1-84d5-4838-8ed8-200126c17305 ## Changelog <br> Backport 893922e8e852065a4ca6b19a2acaa3c9e3a46218 from #6324
Backport 104931cb0770596e807aaf1a820dcb8e1a6ae8d3 from #6325 --- vscode/webviews/chat/Transcript.tsx | 14 +++++++++++--- .../cells/messageCell/human/HumanMessageCell.tsx | 2 +- .../human/editor/HumanMessageEditor.tsx | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/vscode/webviews/chat/Transcript.tsx b/vscode/webviews/chat/Transcript.tsx index dd830681ec17..89f0d10d634b 100644 --- a/vscode/webviews/chat/Transcript.tsx +++ b/vscode/webviews/chat/Transcript.tsx @@ -558,6 +558,16 @@ const TranscriptInteraction: FC = memo(props => { ?.getSerializedValue() .contextItems.some(item => item.type === 'repository') + const onHumanMessageSubmit = useCallback( + (intent?: ChatMessage['intent']) => { + if (humanMessage.isUnsentFollowup) { + onFollowupSubmit(intent) + } + onEditSubmit(intent) + }, + [humanMessage.isUnsentFollowup, onFollowupSubmit, onEditSubmit] + ) + return ( <> = memo(props => { isSent={!humanMessage.isUnsentFollowup} isPendingPriorResponse={priorAssistantMessageIsLoading} onChange={onChange} - onSubmit={ - humanMessage.isUnsentFollowup ? () => onFollowupSubmit() : () => onEditSubmit() - } + onSubmit={onHumanMessageSubmit} onStop={onStop} isFirstInteraction={isFirstInteraction} isLastInteraction={isLastInteraction} diff --git a/vscode/webviews/chat/cells/messageCell/human/HumanMessageCell.tsx b/vscode/webviews/chat/cells/messageCell/human/HumanMessageCell.tsx index c9f224ab0dd0..4aa1477dd563 100644 --- a/vscode/webviews/chat/cells/messageCell/human/HumanMessageCell.tsx +++ b/vscode/webviews/chat/cells/messageCell/human/HumanMessageCell.tsx @@ -35,7 +35,7 @@ interface HumanMessageCellProps { onEditorFocusChange?: (focused: boolean) => void onChange?: (editorState: SerializedPromptEditorValue) => void - onSubmit: (editorState: SerializedPromptEditorValue, intent?: ChatMessage['intent']) => void + onSubmit: (intent?: ChatMessage['intent']) => void onStop: () => void isFirstInteraction?: boolean diff --git a/vscode/webviews/chat/cells/messageCell/human/editor/HumanMessageEditor.tsx b/vscode/webviews/chat/cells/messageCell/human/editor/HumanMessageEditor.tsx index c60db599d2c0..b3a1629b8426 100644 --- a/vscode/webviews/chat/cells/messageCell/human/editor/HumanMessageEditor.tsx +++ b/vscode/webviews/chat/cells/messageCell/human/editor/HumanMessageEditor.tsx @@ -58,7 +58,7 @@ export const HumanMessageEditor: FunctionComponent<{ onEditorFocusChange?: (focused: boolean) => void onChange?: (editorState: SerializedPromptEditorValue) => void - onSubmit: (editorState: SerializedPromptEditorValue, intent?: ChatMessage['intent']) => void + onSubmit: (intent?: ChatMessage['intent']) => void onStop: () => void isFirstInteraction?: boolean @@ -151,7 +151,7 @@ export const HumanMessageEditor: FunctionComponent<{ } const value = editorRef.current.getSerializedValue() - parentOnSubmit(value, intent) + parentOnSubmit(intent) telemetryRecorder.recordEvent('cody.humanMessageEditor', 'submit', { metadata: {