diff --git a/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts b/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts index d17f2cf6f7..ed7f25acd5 100644 --- a/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts +++ b/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts @@ -67,6 +67,7 @@ class AIChatManager { scriptEditorShowDiffMode = $state<(() => void) | undefined>(undefined) flowAiChatHelpers = $state(undefined) mode = $state<'script' | 'flow' | 'navigator'>('navigator') + pendingNewCode = $state(undefined) allowedModes = $derived({ script: this.scriptEditorOptions !== undefined, diff --git a/frontend/src/lib/components/copilot/chat/monaco-adapter.ts b/frontend/src/lib/components/copilot/chat/monaco-adapter.ts index a8168fdba2..300fe88696 100644 --- a/frontend/src/lib/components/copilot/chat/monaco-adapter.ts +++ b/frontend/src/lib/components/copilot/chat/monaco-adapter.ts @@ -8,6 +8,7 @@ import { type VisualChange } from '../shared' import { writable, type Writable } from 'svelte/store' +import { aiChatManager } from './AIChatManager.svelte' type ExcludeVariant = T extends Record ? never : T type VisualChangeWithDiffIndex = ExcludeVariant & { @@ -22,7 +23,6 @@ export class AIChatEditorHandler { reviewingChanges: Writable = writable(false) groupChanges: { changes: VisualChangeWithDiffIndex[]; groupIndex: number }[] = [] - pendingNewCode: string | undefined = undefined constructor(editor: meditor.IStandaloneCodeEditor) { this.editor = editor @@ -30,7 +30,7 @@ export class AIChatEditorHandler { clear() { this.groupChanges = [] - this.pendingNewCode = undefined + aiChatManager.pendingNewCode = undefined for (const collection of this.decorationsCollections) { collection.clear() } @@ -168,12 +168,13 @@ export class AIChatEditorHandler { } async reviewAndApply(newCode: string) { - if (this.pendingNewCode === newCode) { + if (aiChatManager.pendingNewCode === newCode) { + this.acceptAll() return - } else if (this.pendingNewCode) { + } else if (aiChatManager.pendingNewCode) { this.clear() } - this.pendingNewCode = newCode + aiChatManager.pendingNewCode = newCode const changedLines = await this.calculateVisualChanges(newCode) if (changedLines.length === 0) return diff --git a/frontend/src/lib/components/copilot/chat/script/CodeDisplay.svelte b/frontend/src/lib/components/copilot/chat/script/CodeDisplay.svelte index c3154f4919..5b11fcaef5 100644 --- a/frontend/src/lib/components/copilot/chat/script/CodeDisplay.svelte +++ b/frontend/src/lib/components/copilot/chat/script/CodeDisplay.svelte @@ -180,7 +180,7 @@
- {#if aiChatManager.canApplyCode} + {#if aiChatManager.canApplyCode && code !== aiChatManager.scriptEditorOptions?.code}
{/if} diff --git a/frontend/src/routes/(root)/(logged)/+layout.svelte b/frontend/src/routes/(root)/(logged)/+layout.svelte index 1d47469fe2..5f98044ebf 100644 --- a/frontend/src/routes/(root)/(logged)/+layout.svelte +++ b/frontend/src/routes/(root)/(logged)/+layout.svelte @@ -672,7 +672,7 @@