Skip to content

Commit

Permalink
fix conversation reset
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Jan 16, 2025
1 parent a6d943d commit 5ceaba4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 4 additions & 0 deletions src/extension/chat-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ export class ChatService extends Base {
})
}

public resetConversation () {
this._conversation = []
}

public async getTemplateMessages(
template: string,
context?: string,
Expand Down
14 changes: 7 additions & 7 deletions src/extension/providers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
} from "../utils"

export class BaseProvider {
private _chatService: ChatService | undefined
private _diffManager = new DiffManager()
private _embeddingDatabase: EmbeddingDatabase | undefined
private _fileTreeProvider: FileTreeProvider
Expand All @@ -51,6 +50,7 @@ export class BaseProvider {
private _symmetryService?: SymmetryService
private _templateDir: string | undefined
private _templateProvider: TemplateProvider
public chatService: ChatService | undefined
public context: vscode.ExtensionContext
public conversationHistory: ConversationHistory | undefined
public reviewService: ReviewService | undefined
Expand Down Expand Up @@ -87,7 +87,7 @@ export class BaseProvider {
this.context
)

this._chatService = new ChatService(
this.chatService = new ChatService(
this._statusBarItem,
this._templateDir,
this.context,
Expand Down Expand Up @@ -208,7 +208,7 @@ export class BaseProvider {
}

public destroyStream = () => {
this._chatService?.abort()
this.chatService?.abort()
this.reviewService?.abort()
this.webView?.postMessage({
type: EVENT_NAME.twinnyStopGeneration
Expand All @@ -219,8 +219,8 @@ export class BaseProvider {
const symmetryConnected = this._sessionManager?.get(
EXTENSION_SESSION_NAME.twinnySymmetryConnection
)
if (symmetryConnected && this._chatService) {
const messages = await this._chatService.getTemplateMessages(template)
if (symmetryConnected && this.chatService) {
const messages = await this.chatService.getTemplateMessages(template)
logger.log(`
Using symmetry for inference
Messages: ${JSON.stringify(messages)}
Expand All @@ -232,7 +232,7 @@ export class BaseProvider {
})
)
}
this._chatService?.streamTemplateCompletion(template)
this.chatService?.streamTemplateCompletion(template)
}

public getGitCommitMessage = async () => {
Expand Down Expand Up @@ -363,7 +363,7 @@ export class BaseProvider {
)
}

this._chatService?.streamChatCompletion(
this.chatService?.streamChatCompletion(
data.data || [],
data.meta as FileItem[]
)
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ export async function activate(context: ExtensionContext) {
}),
commands.registerCommand(TWINNY_COMMAND_NAME.newConversation, () => {
sidebarProvider.conversationHistory?.resetConversation()
sidebarProvider.chatService?.resetConversation()
sidebarProvider.newSymmetryConversation()
sidebarProvider.webView?.postMessage({
type: EVENT_NAME.twinnyNewConversation
Expand Down

0 comments on commit 5ceaba4

Please sign in to comment.