From d2b17a2ef1056f74b7b3ba71ef6ed609524ec701 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 13:54:41 +0000 Subject: [PATCH] feat: optimize accept all button display in AI chat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add acceptAllClicked state to AIChatManager to track when accept all was clicked - Update canApplyCode logic to hide buttons after accept all is clicked - Simplify CodeDisplay button visibility to remove code comparison logic - Add editor change listener to reset state when user manually edits code - Show buttons again when editor content changes as requested Addresses issue #5999 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Ruben Fiszel --- .../components/copilot/chat/AIChatManager.svelte.ts | 11 ++++++++++- .../src/lib/components/copilot/chat/monaco-adapter.ts | 8 ++++++++ .../components/copilot/chat/script/CodeDisplay.svelte | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) 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}