fix(apps): prevent decision tree graph editor crash on missing graph context (#9602)

NodeWrapper destructured `moveManager` from `getGraphContext()` unconditionally,
but FlowGraphContext is only set by the flow graph. The app decision-tree editor
reuses NodeWrapper without setting that context, so opening its Graph Editor threw
"Cannot destructure property 'moveManager' of getGraphContext(...) as it is undefined".
Guard the context with `?? {}` since `moveManager` is already used optionally.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Diego Imbert
2026-06-16 00:48:27 +02:00
committed by GitHub
parent 4e4b2247ef
commit 24f32596e9
@@ -30,7 +30,9 @@
let resolvedContextMenuItems: ContextMenuItem[] | undefined = $derived(
contextMenuItems ??
menuItems?.flatMap((item) => [
...(item.separatorTop ? [{ id: `${item.displayName}-divider`, label: '', divider: true }] : []),
...(item.separatorTop
? [{ id: `${item.displayName}-divider`, label: '', divider: true }]
: []),
{
id: item.displayName,
label: item.displayName,
@@ -43,11 +45,11 @@
])
)
const { moveManager } = getGraphContext()
// NodeWrapper is reused outside the flow graph (e.g. the app decision-tree
// editor) where FlowGraphContext is never set, so guard against undefined.
const { moveManager } = getGraphContext() ?? {}
let faded = $derived(
nodeId != null && (moveManager?.draggedNodeIds?.has(nodeId) ?? false)
)
let faded = $derived(nodeId != null && (moveManager?.draggedNodeIds?.has(nodeId) ?? false))
let darkMode: boolean = $state(false)
</script>
@@ -72,18 +74,10 @@
{#snippet handles()}
{#if enableSourceHandle}
<Handle
type="source"
isConnectable={false}
position={Position.Bottom}
/>
<Handle type="source" isConnectable={false} position={Position.Bottom} />
{/if}
{#if enableTargetHandle}
<Handle
type="target"
isConnectable={false}
position={Position.Top}
/>
<Handle type="target" isConnectable={false} position={Position.Top} />
{/if}
{/snippet}