Files
windmill/frontend/src/lib/components/copilot/chat/flow/flowValueSettings.ts
T
Diego ImbertandClaude Fable 5 a544dfde9a fix(frontend): preserve top-level flow settings in AI flow tools (#10369)
* fix(frontend): preserve top-level flow settings in AI flow tools

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaNkfh3YH8VoTNebkRuunB

* fix(frontend): treat degenerate agent transforms as unconfigured in chat mode toggle

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaNkfh3YH8VoTNebkRuunB

* fix(frontend): treat persisted static-null agent transforms as unconfigured

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DaNkfh3YH8VoTNebkRuunB

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-28 10:48:18 +02:00

53 lines
1.7 KiB
TypeScript

import { z } from 'zod'
import type { FlowValue } from '$lib/gen'
/**
* Non-structural top-level FlowValue settings exposed in the compact view so
* they round-trip through patch/write tools instead of being silently dropped.
* Must stay in sync with the top-level scalar/config fields of `FlowValue`.
*/
export const flowValueSettingsSchema = z
.object({
same_worker: z.boolean(),
preserve_step_tags: z.boolean(),
concurrent_limit: z.number(),
concurrency_key: z.string(),
concurrency_time_window_s: z.number(),
debounce_delay_s: z.number(),
debounce_key: z.string(),
debounce_args_to_accumulate: z.array(z.string()),
max_total_debouncing_time: z.number(),
max_total_debounces_amount: z.number(),
skip_expr: z.string(),
cache_ttl: z.number(),
cache_ignore_s3_path: z.boolean(),
delete_after_secs: z.number(),
flow_env: z.record(z.string(), z.any()),
priority: z.number(),
early_return: z.string(),
chat_input_enabled: z.boolean()
})
.partial()
type FlowValueSettingsKey = keyof z.infer<typeof flowValueSettingsSchema> & keyof FlowValue
export const FLOW_VALUE_SETTINGS_KEYS = Object.keys(
flowValueSettingsSchema.shape
) as FlowValueSettingsKey[]
export type FlowValueSettings = Pick<FlowValue, FlowValueSettingsKey>
/**
* Extract the defined non-structural settings from a FlowValue (or an
* EditableFlowJson, which carries the same keys).
*/
export function pickFlowValueSettings(source: Record<string, unknown>): FlowValueSettings {
const settings: Record<string, unknown> = {}
for (const key of FLOW_VALUE_SETTINGS_KEYS) {
if (source[key] !== undefined) {
settings[key] = source[key]
}
}
return settings as FlowValueSettings
}