| 31 | * Apply a partial patch to a declared model. Top-level `label` and the |
| 32 | * `arguments` record merge separately. `type` is fixed at creation. |
| 33 | */ |
| 34 | export function updateModel(id: string, patch: { label?: string; arguments?: Record<string, unknown> }): void { |
| 35 | const key = id; |
| 36 | useEditorStore.getState().setModels((models) => { |
| 37 | const existing = models[key]; |
| 38 | if (!existing) return models; |
| 39 | return { |
| 40 | ...models, |
| 41 | [key]: { |
| 42 | ...existing, |
| 43 | ...(patch.label !== undefined ? { label: patch.label } : {}), |
| 44 | ...(patch.arguments ? { arguments: { ...existing.arguments, ...patch.arguments } } : {}), |
| 45 | }, |
| 46 | }; |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | export function deleteModel(id: string): void { |