Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat: Shows welcome message on empty chat only #3341

Merged
merged 4 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

### Changed

- Chat: Welcome message is only shown on new chat panel. [pull/3341](https://github.com/sourcegraph/cody/pull/3341)

## [1.8.1]

### Added
Expand Down
2 changes: 1 addition & 1 deletion vscode/test/e2e/command-menu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test('Start a new chat from Cody Command Menu', async ({ page, sidebar }) => {

// the question should show up in the chat panel on submit
const chatPanel = page.frameLocator('iframe.webview').last().frameLocator('iframe')
await chatPanel.getByText('new chat submitted from command menu').click()
await chatPanel.getByText('hello from the assistant').hover()

const expectedEvents = [
'CodyVSCodeExtension:menu:command:default:clicked',
Expand Down
3 changes: 2 additions & 1 deletion vscode/test/e2e/update-notice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ test('existing installs should show the update toast when the last dismissed ver
await page.locator('*[aria-label="Tab actions"] *[aria-label~="Close"]').click()

// Reopen the chat; the update notice should be visible.
// Welcome message is removed.
await chatHistoryEntry.click()
chatFrame = page.frameLocator('iframe.webview').last().frameLocator('iframe')
const introChat = chatFrame.getByText(greetingChatText)
await expect(introChat).toBeVisible()
await expect(introChat).not.toBeVisible()
const chatNotice = chatFrame.getByText(updateToastText)
await expect(chatNotice).toBeVisible()

Expand Down
3 changes: 2 additions & 1 deletion vscode/webviews/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,8 @@ export const Chat: React.FunctionComponent<React.PropsWithChildren<ChatboxProps>
<div className={classNames(styles.innerContainer)}>
{
<Transcript
transcript={transcriptWithWelcome}
// Remove welcome message after the first message is submitted
transcript={transcript.length ? transcript : transcriptWithWelcome}
messageInProgress={messageInProgress}
messageBeingEdited={messageBeingEdited}
setMessageBeingEdited={setEditMessageState}
Expand Down
8 changes: 2 additions & 6 deletions vscode/webviews/chat/Transcript.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,16 @@ export const Transcript: React.FunctionComponent<
if (!message?.displayText && !message.error) {
return null
}
// The key index includes the Cody welcome message added to the transcript in the webview
// as it is not included in the transcript returned from the server, the key index is
// offset by 1 to account for this.
const offsetIndex = index + offset === earlierMessages.length
const keyIndex = index + offset
const transcriptIndex = keyIndex - 1

const isItemBeingEdited = messageBeingEdited === transcriptIndex
const isItemBeingEdited = messageBeingEdited === keyIndex

return (
<div key={index}>
{isItemBeingEdited && <div ref={itemBeingEditedRef} />}
<TranscriptItem
index={transcriptIndex}
index={keyIndex}
key={keyIndex}
message={message}
inProgress={
Expand Down
Loading