mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-23 08:00:45 +00:00
feat: optimize accept all button display in AI chat
- 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 <rubenfiszel@users.noreply.github.com>
This commit is contained in:
@@ -80,6 +80,7 @@ class AIChatManager {
|
||||
flowAiChatHelpers = $state<FlowAIChatHelpers | undefined>(undefined)
|
||||
pendingNewCode = $state<string | undefined>(undefined)
|
||||
apiTools = $state<Tool<any>[]>([])
|
||||
acceptAllClicked = $state<boolean>(false)
|
||||
|
||||
allowedModes: Record<AIMode, boolean> = $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()
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-0.5 rounded-lg relative not-prose">
|
||||
{#if aiChatManager.canApplyCode && code !== aiChatManager.scriptEditorOptions?.code}
|
||||
{#if aiChatManager.canApplyCode}
|
||||
<div class="flex justify-end items-end">
|
||||
<Button
|
||||
color="dark"
|
||||
|
||||
Reference in New Issue
Block a user