Skip to content

Commit

Permalink
Fix something in Chat and ChatService (#403)
Browse files Browse the repository at this point in the history
* Adjust the order of save and request in handleSubmitForm

* Fix issue when filePaths is undefined.
  • Loading branch information
fishshi authored Nov 17, 2024
1 parent c792f1e commit 0445098
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/extension/chat-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export class ChatService extends Base {
return combinedContext.trim() || null
}

private async loadFileContents(files: FileItem[]): Promise<string> {
private async loadFileContents(files?: FileItem[]): Promise<string> {
if (!files?.length) return ""
let fileContents = ""
for (const file of files) {
Expand All @@ -546,7 +546,7 @@ export class ChatService extends Base {

public async streamChatCompletion(
messages: Message[],
filePaths: FileItem[]
filePaths?: FileItem[]
) {
this._completion = ""
this.sendEditorLanguage()
Expand Down Expand Up @@ -577,7 +577,7 @@ export class ChatService extends Base {
additionalContext += `Additional Context:\n${ragContext}\n\n`
}

filePaths = filePaths.filter((filepath) =>
filePaths = filePaths?.filter((filepath) =>
filepath.name !== "workspace" && filepath.name !== "problems"
)
const fileContents = await this.loadFileContents(filePaths)
Expand Down
5 changes: 3 additions & 2 deletions src/webview/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,12 +305,13 @@ export const Chat = (props: ChatProps): JSX.Element => {
meta: mentions,
}

global.vscode.postMessage(clientMessage)

saveLastConversation({
...conversation,
messages: updatedMessages,
})

global.vscode.postMessage(clientMessage)

return updatedMessages
})

Expand Down

0 comments on commit 0445098

Please sign in to comment.