diff --git a/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts b/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts index 450939ea58..ee5bbf3b0f 100644 --- a/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts +++ b/frontend/src/lib/components/copilot/chat/AIChatManager.svelte.ts @@ -80,6 +80,7 @@ class AIChatManager { flowAiChatHelpers = $state(undefined) pendingNewCode = $state(undefined) apiTools = $state[]>([]) + acceptAllClicked = $state(false) allowedModes: Record = $derived({ script: this.scriptEditorOptions !== undefined, @@ -149,7 +150,7 @@ class AIChatManager { } } - canApplyCode = $derived(this.allowedModes.script && this.mode === AIMode.SCRIPT) + canApplyCode = $derived(this.allowedModes.script && this.mode === AIMode.SCRIPT && !this.acceptAllClicked) private changeModeTool = { def: { @@ -664,6 +665,14 @@ class AIChatManager { this.flowAiChatHelpers = undefined } } + + markAcceptAllClicked = () => { + this.acceptAllClicked = true + } + + resetAcceptAllClicked = () => { + this.acceptAllClicked = false + } } export const aiChatManager = new AIChatManager() diff --git a/frontend/src/lib/components/copilot/chat/monaco-adapter.ts b/frontend/src/lib/components/copilot/chat/monaco-adapter.ts index 300fe88696..8a70e6236a 100644 --- a/frontend/src/lib/components/copilot/chat/monaco-adapter.ts +++ b/frontend/src/lib/components/copilot/chat/monaco-adapter.ts @@ -26,6 +26,13 @@ export class AIChatEditorHandler { constructor(editor: meditor.IStandaloneCodeEditor) { this.editor = editor + + // Reset acceptAllClicked when user manually edits the code + this.editor.onDidChangeModelContent(() => { + if (aiChatManager.acceptAllClicked) { + aiChatManager.resetAcceptAllClicked() + } + }) } clear() { @@ -79,6 +86,7 @@ export class AIChatEditorHandler { for (const group of this.groupChanges) { this.applyGroup(group) } + aiChatManager.markAcceptAllClicked() this.finish() } diff --git a/frontend/src/lib/components/copilot/chat/script/CodeDisplay.svelte b/frontend/src/lib/components/copilot/chat/script/CodeDisplay.svelte index 998a0a166d..ab8425f0e6 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 && code !== aiChatManager.scriptEditorOptions?.code} + {#if aiChatManager.canApplyCode}