mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-18 16:02:10 +00:00
keep AI settings editor in sync with the config it just saved (#10503)
* fix: keep AI settings editor in sync with the config it just saved Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix: skip the post-save reload and record why the saved config is cloned Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -145,5 +145,8 @@
|
||||
link="https://www.windmill.dev/docs/core_concepts/ai_generation"
|
||||
promptScope="instance"
|
||||
customSave={handleCustomSave}
|
||||
onSave={(savedConfig) => {
|
||||
initialConfig = savedConfig
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
usesInstanceAiConfig?: boolean
|
||||
instanceAiSummary?: InstanceAISummary
|
||||
customSave?: (config: AIConfig) => Promise<void>
|
||||
onSave?: (info?: GetCopilotSettingsStateResponse) => void | Promise<void>
|
||||
onSave?: (savedConfig: AIConfig, info?: GetCopilotSettingsStateResponse) => void | Promise<void>
|
||||
title?: string
|
||||
description?: string
|
||||
link?: string
|
||||
@@ -332,7 +332,14 @@
|
||||
sendUserToast('AI settings updated')
|
||||
}
|
||||
storeInitialState()
|
||||
await onSave?.(settingsState)
|
||||
// Hand the parent what was persisted: it owns `initialConfig`, and this component is
|
||||
// destroyed on a settings tab switch, so a stale prop returns as editor state on remount
|
||||
// and is written back by the next save. Clone it, since `providers` aliases our `$state`
|
||||
// and the `lastLoadedConfigKey` guard would then track our own edits; pre-arm that guard
|
||||
// so the prop update does not re-apply the config over what the editor now shows.
|
||||
const savedConfig = clone(config)
|
||||
lastLoadedConfigKey = JSON.stringify(savedConfig)
|
||||
await onSave?.(savedConfig, settingsState)
|
||||
}
|
||||
|
||||
async function onAiProviderChange(provider: AIProvider) {
|
||||
|
||||
@@ -2029,7 +2029,8 @@ export async function main(
|
||||
{hasInstanceAiConfig}
|
||||
{usesInstanceAiConfig}
|
||||
{instanceAiSummary}
|
||||
onSave={(copilotSettingsState) => {
|
||||
onSave={(savedConfig, copilotSettingsState) => {
|
||||
aiInitialConfig = savedConfig
|
||||
if (!copilotSettingsState) {
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user