Header removals wait for the code editor to be left: autosave saves with drop=false, so follow_header adds and renames from the header but keeps a port or setting whose parameter is gone, and leaving the editor (blur or closing the panel) saves once more with removals; source saves of a flow run one at a time

This commit is contained in:
2026-10-15 21:31:04 +02:00
parent 5ca90ffece
commit ce2ce4e3e7
10 changed files with 105 additions and 24 deletions
+10 -2
View File
@@ -1,5 +1,5 @@
import Editor from "@monaco-editor/react"
import { useEffect, useMemo, useState } from "react"
import { useEffect, useMemo, useRef, useState } from "react"
import { useTheme } from "@/components/theme-provider"
import { Skeleton } from "@/components/ui/skeleton"
@@ -13,12 +13,15 @@ import { monacoFontFamily, setupMonaco } from "./monacoSetup"
export default function NodeEditor({
value,
onChange,
onBlur,
language = "python",
readOnly = false,
autoFocus = false,
}: {
value: string
onChange: (next: string) => void
/** Focus left the editor, its find and suggest widgets included. */
onBlur?: () => void
language?: "python" | "json"
/** Generated code: readable, and not this panel's to change. */
readOnly?: boolean
@@ -27,6 +30,8 @@ export default function NodeEditor({
}) {
const { resolvedTheme } = useTheme()
const [ready, setReady] = useState(false)
const blur = useRef(onBlur)
blur.current = onBlur
useEffect(() => {
setupMonaco()
@@ -43,7 +48,10 @@ export default function NodeEditor({
theme={resolvedTheme === "dark" ? "fluksio-dark" : "fluksio-light"}
value={value}
onChange={(next) => onChange(next ?? "")}
onMount={autoFocus ? (editor) => editor.focus() : undefined}
onMount={(editor) => {
editor.onDidBlurEditorWidget(() => blur.current?.())
if (autoFocus) editor.focus()
}}
loading={<Skeleton className="h-full w-full rounded-md" />}
options={{
readOnly,