mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-26 08:01:38 +00:00
fix double apply on ai chat (#5671)
This commit is contained in:
@@ -22,6 +22,7 @@ export class AIChatEditorHandler {
|
||||
|
||||
reviewingChanges: Writable<boolean> = writable(false)
|
||||
groupChanges: { changes: VisualChangeWithDiffIndex[]; groupIndex: number }[] = []
|
||||
pendingNewCode: string | undefined = undefined
|
||||
|
||||
constructor(editor: meditor.IStandaloneCodeEditor) {
|
||||
this.editor = editor
|
||||
@@ -29,6 +30,7 @@ export class AIChatEditorHandler {
|
||||
|
||||
clear() {
|
||||
this.groupChanges = []
|
||||
this.pendingNewCode = undefined
|
||||
for (const collection of this.decorationsCollections) {
|
||||
collection.clear()
|
||||
}
|
||||
@@ -166,6 +168,12 @@ export class AIChatEditorHandler {
|
||||
}
|
||||
|
||||
async reviewAndApply(newCode: string) {
|
||||
if (this.pendingNewCode === newCode) {
|
||||
return
|
||||
} else if (this.pendingNewCode) {
|
||||
this.clear()
|
||||
}
|
||||
this.pendingNewCode = newCode
|
||||
const changedLines = await this.calculateVisualChanges(newCode)
|
||||
if (changedLines.length === 0) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user