mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-20 08:01:35 +00:00
Fix menu button on mobile + show accept all when code is applied from script chat (#5872)
* fix menu button on mobile * show accept all when code is applied from script chat * fix
This commit is contained in:
@@ -67,6 +67,7 @@ class AIChatManager {
|
||||
scriptEditorShowDiffMode = $state<(() => void) | undefined>(undefined)
|
||||
flowAiChatHelpers = $state<FlowAIChatHelpers | undefined>(undefined)
|
||||
mode = $state<'script' | 'flow' | 'navigator'>('navigator')
|
||||
pendingNewCode = $state<string | undefined>(undefined)
|
||||
|
||||
allowedModes = $derived({
|
||||
script: this.scriptEditorOptions !== undefined,
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
type VisualChange
|
||||
} from '../shared'
|
||||
import { writable, type Writable } from 'svelte/store'
|
||||
import { aiChatManager } from './AIChatManager.svelte'
|
||||
|
||||
type ExcludeVariant<T, K extends keyof T, V> = T extends Record<K, V> ? never : T
|
||||
type VisualChangeWithDiffIndex = ExcludeVariant<VisualChange, 'type', 'added_inline'> & {
|
||||
@@ -22,7 +23,6 @@ export class AIChatEditorHandler {
|
||||
|
||||
reviewingChanges: Writable<boolean> = 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
|
||||
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-0.5 rounded-lg relative not-prose">
|
||||
{#if aiChatManager.canApplyCode}
|
||||
{#if aiChatManager.canApplyCode && code !== aiChatManager.scriptEditorOptions?.code}
|
||||
<div class="flex justify-end items-end">
|
||||
<Button
|
||||
color="dark"
|
||||
@@ -189,7 +189,7 @@
|
||||
aiChatManager.scriptEditorApplyCode?.(code ?? '')
|
||||
}}
|
||||
>
|
||||
Apply
|
||||
{aiChatManager.pendingNewCode ? 'Accept all' : 'Apply'}
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -672,7 +672,7 @@
|
||||
<div class="relative w-full flex-1 flex flex-col">
|
||||
<div
|
||||
class={classNames(
|
||||
'py-2 px-2 sm:px-4 md:px-8 flex justify-between items-center shadow-sm max-w-7xl mx-auto md:hidden',
|
||||
'pt-2 px-4 sm:px-4 flex flex-row justify-between items-center shadow-sm max-w-7xl md:hidden',
|
||||
devOnly || $userStore?.operator ? 'hidden' : ''
|
||||
)}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user