Skip to content

Commit 20b166e

Browse files
committed
Addressing comments
1 parent 8d6467b commit 20b166e

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

packages/core/src/codewhispererChat/clients/chat/v0/chat.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ import { UserWrittenCodeTracker } from '../../../../codewhisperer/tracker/userWr
1313

1414
export class ChatSession {
1515
private sessionId?: string
16+
/**
17+
* _listOfReadFiles = list of files read from the project to gather context before generating response.
18+
* _filePath = The path helps the system locate exactly where to make the necessary changes in the project structure
19+
* _tempFilePath = Used to show the code diff view in the editor including LLM changes.
20+
*/
1621
private _listOfReadFiles: string[] = []
1722
private _filePath: string | undefined
1823
private _tempFilePath: string | undefined
@@ -41,10 +46,10 @@ export class ChatSession {
4146
public get listOfReadFiles(): string[] {
4247
return this._listOfReadFiles
4348
}
44-
public get getFilePath(): string | undefined {
49+
public get filePath(): string | undefined {
4550
return this._filePath
4651
}
47-
public get getTempFilePath(): string | undefined {
52+
public get tempFilePath(): string | undefined {
4853
return this._tempFilePath
4954
}
5055
public setFilePath(filePath: string | undefined) {
@@ -53,12 +58,11 @@ export class ChatSession {
5358
public setTempFilePath(tempFilePath: string | undefined) {
5459
this._tempFilePath = tempFilePath
5560
}
56-
public pushToListOfReadFiles(filePath?: string) {
57-
if (filePath) {
58-
this._listOfReadFiles.push(filePath)
59-
} else {
60-
this._listOfReadFiles = []
61-
}
61+
public pushToListOfReadFiles(filePath: string) {
62+
this._listOfReadFiles.push(filePath)
63+
}
64+
public clearListOfReadFiles() {
65+
this._listOfReadFiles = []
6266
}
6367
async chatIam(chatRequest: SendMessageRequest): Promise<SendMessageCommandOutput> {
6468
const client = await createQDeveloperStreamingClient()

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,23 +398,23 @@ export class ChatController {
398398

399399
private async processOpenDiff(message: OpenDiff) {
400400
const session = this.sessionStorage.getSession(message.tabID)
401-
const filePath = session.getFilePath ?? message.filePath
401+
const filePath = session.filePath ?? message.filePath
402402
const fileExists = await fs.existsFile(filePath)
403403
// Check if fileExists=false, If yes, return instead of showing broken diff experience.
404-
if (!session.getTempFilePath) {
404+
if (!session.tempFilePath) {
405405
return
406406
}
407407
const leftUri = fileExists ? vscode.Uri.file(filePath) : vscode.Uri.from({ scheme: 'untitled' })
408-
const rightUri = vscode.Uri.file(session.getTempFilePath ?? filePath)
408+
const rightUri = vscode.Uri.file(session.tempFilePath ?? filePath)
409409
const fileName = path.basename(filePath)
410410
await vscode.commands.executeCommand('vscode.diff', leftUri, rightUri, `${fileName} ${amazonQTabSuffix}`)
411411
}
412412

413413
private async processAcceptCodeDiff(message: CustomFormActionMessage) {
414414
const session = this.sessionStorage.getSession(message.tabID ?? '')
415-
const filePath = session.getFilePath ?? ''
415+
const filePath = session.filePath ?? ''
416416
const fileExists = await fs.existsFile(filePath)
417-
const tempFilePath = session.getTempFilePath
417+
const tempFilePath = session.tempFilePath
418418
const tempFileExists = await fs.existsFile(tempFilePath ?? '')
419419
if (fileExists && tempFileExists) {
420420
const fileContent = await fs.readFileText(filePath)
@@ -889,7 +889,7 @@ export class ChatController {
889889

890890
private async processPromptMessageAsNewThread(message: PromptMessage) {
891891
const session = this.sessionStorage.getSession(message.tabID)
892-
session.pushToListOfReadFiles(undefined)
892+
session.clearListOfReadFiles()
893893
this.editorContextExtractor
894894
.extractContextForTrigger('ChatMessage')
895895
.then((context) => {

0 commit comments

Comments
 (0)