@kiberon-labs/behave-graph-flow 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/.fallowrc.json +16 -0
  2. package/.storybook/main.ts +32 -0
  3. package/.storybook/preview.ts +16 -0
  4. package/.storybook/styles.css +10 -0
  5. package/.storybook/vscode.css +814 -0
  6. package/.turbo/turbo-build.log +7 -0
  7. package/LICENSE +6 -0
  8. package/README.md +2 -2
  9. package/data/Polynomial.json +510 -0
  10. package/data/sequence.json +337 -0
  11. package/data/trigger-event.json +241 -0
  12. package/data/variable-change.json +210 -0
  13. package/dist/entry.css +4 -0
  14. package/dist/index.css +39 -0
  15. package/dist/index.css.map +1 -0
  16. package/dist/index.d.ts +2282 -0
  17. package/dist/index.d.ts.map +1 -0
  18. package/dist/index.js +14873 -0
  19. package/dist/index.js.map +1 -0
  20. package/docs/notifications.md +246 -0
  21. package/docs/protocol.md +679 -0
  22. package/docs/specifics.md +191 -0
  23. package/package.json +85 -21
  24. package/postcss.config.ts +3 -4
  25. package/src/annotations/index.ts +32 -0
  26. package/src/components/FloatingToolbar/index.module.css +45 -0
  27. package/src/components/FloatingToolbar/index.tsx +256 -0
  28. package/src/components/Flow.tsx +276 -75
  29. package/src/components/contextMenus/NodePicker.module.css +274 -0
  30. package/src/components/contextMenus/NodePicker.tsx +481 -0
  31. package/src/components/contextMenus/edge.tsx +108 -0
  32. package/src/components/contextMenus/node.tsx +155 -0
  33. package/src/components/contextMenus/selection.tsx +77 -0
  34. package/src/components/controls/any/index.tsx +8 -0
  35. package/src/components/controls/boolean/index.tsx +13 -0
  36. package/src/components/controls/colorPicker/InputPopover.module.css +100 -0
  37. package/src/components/controls/colorPicker/InputPopover.tsx +31 -0
  38. package/src/components/controls/colorPicker/index.module.css +18 -0
  39. package/src/components/controls/colorPicker/index.tsx +61 -0
  40. package/src/components/controls/number/index.tsx +35 -0
  41. package/src/components/controls/string/index.tsx +16 -0
  42. package/src/components/edges/index.tsx +469 -0
  43. package/src/components/edges/offsetBezier.ts +134 -0
  44. package/src/components/hotKeys.tsx +20 -0
  45. package/src/components/layoutController/index.module.css +10 -0
  46. package/src/components/layoutController/index.tsx +117 -0
  47. package/src/components/layoutController/utils.ts +205 -0
  48. package/src/components/menubar/defaults.tsx +480 -0
  49. package/src/components/menubar/index.tsx +49 -0
  50. package/src/components/menubar/menuItem.module.css +16 -0
  51. package/src/components/menubar/menuItem.tsx +32 -0
  52. package/src/components/nodes/behave/Node.module.css +23 -0
  53. package/src/components/nodes/behave/Node.tsx +176 -0
  54. package/src/components/nodes/behave/NodeContainer.module.css +87 -0
  55. package/src/components/nodes/behave/NodeContainer.tsx +46 -0
  56. package/src/components/nodes/behave/index.tsx +14 -0
  57. package/src/components/nodes/comment/FormatToolbar.tsx +118 -0
  58. package/src/components/nodes/comment/comment.tsx +103 -0
  59. package/src/components/nodes/comment/styles.module.css +150 -0
  60. package/src/components/nodes/group/index.tsx +109 -0
  61. package/src/components/nodes/wrapper/index.tsx +73 -0
  62. package/src/components/nodes/wrapper/styles.module.css +113 -0
  63. package/src/components/notifications/NotificationProvider.tsx +81 -0
  64. package/src/components/notifications/index.ts +2 -0
  65. package/src/components/notifications/utils.ts +71 -0
  66. package/src/components/panels/alignment/index.module.css +20 -0
  67. package/src/components/panels/alignment/index.tsx +244 -0
  68. package/src/components/panels/base/index.tsx +5 -0
  69. package/src/components/panels/base/styles.module.css +12 -0
  70. package/src/components/panels/conversation/index.module.css +151 -0
  71. package/src/components/panels/conversation/index.tsx +162 -0
  72. package/src/components/panels/events/CustomEventsEditor.tsx +384 -0
  73. package/src/components/panels/events/EditEventPanel.tsx +315 -0
  74. package/src/components/panels/events/ManageEventsPanel.tsx +98 -0
  75. package/src/components/panels/events/index.tsx +23 -0
  76. package/src/components/panels/events/styles.module.css +236 -0
  77. package/src/components/panels/history/index.tsx +92 -0
  78. package/src/components/panels/history/styles.module.css +106 -0
  79. package/src/components/panels/keymaps/index.module.css +78 -0
  80. package/src/components/panels/keymaps/index.tsx +167 -0
  81. package/src/components/panels/layers/index.tsx +240 -0
  82. package/src/components/panels/layers/styles.module.css +110 -0
  83. package/src/components/panels/legend/index.module.css +6 -0
  84. package/src/components/panels/legend/index.tsx +76 -0
  85. package/src/components/panels/logs/index.module.css +212 -0
  86. package/src/components/panels/logs/index.tsx +288 -0
  87. package/src/components/panels/nodeInputs/InputControl.tsx +63 -0
  88. package/src/components/panels/nodeInputs/InputsGroup.tsx +64 -0
  89. package/src/components/panels/nodeInputs/MultipleNodesView.tsx +37 -0
  90. package/src/components/panels/nodeInputs/NodeSettings.tsx +92 -0
  91. package/src/components/panels/nodeInputs/NodeTitleEditor.tsx +125 -0
  92. package/src/components/panels/nodeInputs/OutputsGroup.tsx +65 -0
  93. package/src/components/panels/nodeInputs/SocketGenerators.tsx +32 -0
  94. package/src/components/panels/nodeInputs/index.module.css +284 -0
  95. package/src/components/panels/nodeInputs/index.tsx +339 -0
  96. package/src/components/panels/nodeInputs/useNodeHandlers.ts +76 -0
  97. package/src/components/panels/nodeInputs/useNodeInputsData.ts +173 -0
  98. package/src/components/panels/nodePicker/index.tsx +115 -0
  99. package/src/components/panels/panel/index.module.css +66 -0
  100. package/src/components/panels/panel/index.tsx +88 -0
  101. package/src/components/panels/search/index.module.css +66 -0
  102. package/src/components/panels/search/index.tsx +215 -0
  103. package/src/components/panels/systemSettings/index.tsx +206 -0
  104. package/src/components/panels/systemSettings/styles.module.css +11 -0
  105. package/src/components/panels/traces/GridLines.tsx +38 -0
  106. package/src/components/panels/traces/TimeGrid.tsx +48 -0
  107. package/src/components/panels/traces/TraceLane.tsx +62 -0
  108. package/src/components/panels/traces/TraceTooltip.tsx +22 -0
  109. package/src/components/panels/traces/TracesHeader.tsx +56 -0
  110. package/src/components/panels/traces/index.module.css +166 -0
  111. package/src/components/panels/traces/index.tsx +294 -0
  112. package/src/components/panels/traces/types.ts +48 -0
  113. package/src/components/panels/traces/useDerivedSpans.ts +212 -0
  114. package/src/components/panels/traces/utils.ts +25 -0
  115. package/src/components/panels/variables/CreateVariableScreen.tsx +162 -0
  116. package/src/components/panels/variables/ManageVariablesScreen.tsx +144 -0
  117. package/src/components/panels/variables/index.tsx +125 -0
  118. package/src/components/panels/variables/styles.module.css +236 -0
  119. package/src/components/primitives/icon.module.css +45 -0
  120. package/src/components/primitives/icon.tsx +38 -0
  121. package/src/components/sockets/input/index.tsx +76 -0
  122. package/src/components/sockets/input/styles.module.css +27 -0
  123. package/src/components/sockets/output/index.tsx +61 -0
  124. package/src/components/sockets/output/styles.module.css +27 -0
  125. package/src/css/prosemirror.css +57 -0
  126. package/src/css/rc-dock.css +112 -0
  127. package/src/css/rc-menu.css +100 -0
  128. package/src/css/vars.css +14 -0
  129. package/src/css/vscode.css +13 -0
  130. package/src/entry.css +4 -0
  131. package/src/generators/CustomEventOnTriggeredGenerator.tsx +85 -0
  132. package/src/generators/SequenceGenerator.tsx +104 -0
  133. package/src/generators/SwitchOnIntegerGenerator.tsx +256 -0
  134. package/src/generators/SwitchOnStringGenerator.tsx +263 -0
  135. package/src/generators/registerDefaultGenerators.ts +34 -0
  136. package/src/hooks/useBehaveGraphFlow.ts +17 -16
  137. package/src/hooks/useDetachNodes.ts +39 -0
  138. package/src/hooks/useFlowHandlers.ts +115 -29
  139. package/src/hooks/useWasdPan.ts +188 -0
  140. package/src/index.css +146 -0
  141. package/src/index.ts +36 -18
  142. package/src/layout/dagre.tsx +119 -0
  143. package/src/layout/elk.ts +200 -0
  144. package/src/plugin/alignment/index.ts +81 -0
  145. package/src/plugin/docs/index.tsx +299 -0
  146. package/src/plugin/docs/panel/index.tsx +200 -0
  147. package/src/plugin/docs/panel/styles.module.css +174 -0
  148. package/src/plugin/graphrunner/actions.ts +253 -0
  149. package/src/plugin/graphrunner/buttons.tsx +87 -0
  150. package/src/plugin/graphrunner/client.ts +704 -0
  151. package/src/plugin/graphrunner/index.tsx +255 -0
  152. package/src/plugin/graphrunner/panel.tsx +386 -0
  153. package/src/plugin/graphrunner/runner.ts +358 -0
  154. package/src/plugin/graphrunner/session.ts +243 -0
  155. package/src/plugin/graphrunner/store.ts +206 -0
  156. package/src/plugin/graphrunner/styles.module.css +211 -0
  157. package/src/plugin/graphrunner/transport.ts +224 -0
  158. package/src/plugin/graphrunner/types.ts +672 -0
  159. package/src/plugin/graphrunner-local/execution-utils.ts +457 -0
  160. package/src/plugin/graphrunner-local/index.tsx +166 -0
  161. package/src/plugin/graphrunner-local/panel.tsx +231 -0
  162. package/src/plugin/graphrunner-local/store.ts +41 -0
  163. package/src/plugin/graphrunner-local/styles.module.css +101 -0
  164. package/src/plugin/graphrunner-local/transport.ts +1372 -0
  165. package/src/plugin/graphrunner-local/types.ts +10 -0
  166. package/src/plugin/graphrunner-webworker/graph-executor.worker.ts +633 -0
  167. package/src/plugin/graphrunner-webworker/index.tsx +146 -0
  168. package/src/plugin/graphrunner-webworker/panel.tsx +173 -0
  169. package/src/plugin/graphrunner-webworker/store.ts +89 -0
  170. package/src/plugin/graphrunner-webworker/types.ts +17 -0
  171. package/src/plugin/graphrunner-webworker/worker-transport.ts +123 -0
  172. package/src/plugin/realtime/realtimeRunner.ts +570 -0
  173. package/src/specifics/CustomEventOnTriggeredSpecific.tsx +92 -0
  174. package/src/specifics/CustomEventTriggerSpecific.tsx +141 -0
  175. package/src/specifics/VariableGetSpecific.tsx +110 -0
  176. package/src/specifics/VariableSetSpecific.tsx +110 -0
  177. package/src/specifics/registerDefaultSpecifics.ts +5 -0
  178. package/src/store/actions.tsx +698 -0
  179. package/src/store/chat.ts +73 -0
  180. package/src/store/controls.tsx +62 -0
  181. package/src/store/documentation.tsx +69 -0
  182. package/src/store/events.tsx +116 -0
  183. package/src/store/flow.tsx +245 -0
  184. package/src/store/graphRunnerClient.ts +110 -0
  185. package/src/store/hotKeys.tsx +323 -0
  186. package/src/store/layers.ts +259 -0
  187. package/src/store/legend.tsx +76 -0
  188. package/src/store/logs.ts +28 -0
  189. package/src/store/menubar.ts +41 -0
  190. package/src/store/refs.ts +84 -0
  191. package/src/store/registry.ts +43 -0
  192. package/src/store/selection.ts +22 -0
  193. package/src/store/settings.ts +99 -0
  194. package/src/store/socketGenerator.tsx +54 -0
  195. package/src/store/specific.tsx +75 -0
  196. package/src/store/specs.tsx +35 -0
  197. package/src/store/tabs.ts +278 -0
  198. package/src/store/toolbar.tsx +45 -0
  199. package/src/store/traces.ts +240 -0
  200. package/src/store/variables.ts +37 -0
  201. package/src/system/graph.ts +134 -0
  202. package/src/system/index.ts +3 -0
  203. package/src/system/notifications.ts +98 -0
  204. package/src/system/plugin.ts +27 -0
  205. package/src/system/provider.tsx +22 -0
  206. package/src/system/pubsub.ts +323 -0
  207. package/src/system/system.ts +223 -0
  208. package/src/system/tabLoader.tsx +265 -0
  209. package/src/system/undoRedo.ts +103 -0
  210. package/src/transformers/Uigraph.ts +60 -0
  211. package/src/transformers/behaveToFlow.ts +16 -4
  212. package/src/transformers/flowToBehave.ts +32 -12
  213. package/src/types/NodeMetadata.ts +27 -0
  214. package/src/types/graph.ts +49 -0
  215. package/src/types/nodes.ts +45 -0
  216. package/src/types.ts +16 -0
  217. package/src/util/colors.ts +1 -29
  218. package/src/util/downloadJson.ts +18 -0
  219. package/src/util/extractNodeMetadata.ts +16 -0
  220. package/src/util/getPickerFilters.ts +1 -1
  221. package/src/util/isBehaveNode.ts +6 -0
  222. package/src/util/isValidConnection.ts +28 -15
  223. package/src/util/mergeSockets.ts +29 -0
  224. package/src/util/serializeVariables.ts +66 -0
  225. package/src/util/sockets.ts +43 -0
  226. package/stories/apex/layoutController/example-graph.worker.ts +39 -0
  227. package/stories/apex/layoutController/index.stories.tsx +48 -0
  228. package/stories/apex/layoutController/webworker.stories.tsx +103 -0
  229. package/stories/apex/menubar/menubar.stories.tsx +19 -0
  230. package/stories/components/colorpicker/index.stories.tsx +20 -0
  231. package/stories/components/contextMenus/edge.stories.tsx +32 -0
  232. package/stories/components/contextMenus/node.stories.tsx +26 -0
  233. package/stories/components/contextMenus/nodePicker.stories.tsx +115 -0
  234. package/stories/components/controls/any/index.stories.tsx +19 -0
  235. package/stories/components/controls/boolean/index.stories.tsx +19 -0
  236. package/stories/components/controls/colorPicker/index.stories.tsx +49 -0
  237. package/stories/components/controls/number/index.stories.tsx +19 -0
  238. package/stories/components/controls/string/index.stories.tsx +19 -0
  239. package/stories/components/nodes/behaveNode.stories.tsx +108 -0
  240. package/stories/components/nodes/comment.stories.tsx +106 -0
  241. package/stories/components/panels/alignment.stories.tsx +24 -0
  242. package/stories/components/panels/events.stories.tsx +38 -0
  243. package/stories/components/panels/graphRunner.stories.tsx +317 -0
  244. package/stories/components/panels/history.stories.tsx +37 -0
  245. package/stories/components/panels/keymaps.stories.tsx +21 -0
  246. package/stories/components/panels/legend.stories.tsx +37 -0
  247. package/stories/components/panels/logs.stories.tsx +24 -0
  248. package/stories/components/panels/nodeInputs.stories.tsx +21 -0
  249. package/stories/components/panels/nodePicker.stories.tsx +37 -0
  250. package/stories/components/panels/panel.stories.tsx +39 -0
  251. package/stories/components/panels/search.stories.tsx +24 -0
  252. package/stories/components/panels/systemSettings.stories.tsx +26 -0
  253. package/stories/components/panels/traces.stories.tsx +225 -0
  254. package/stories/components/panels/variables.stories.tsx +24 -0
  255. package/stories/defaults/defaultStoryProvider.tsx +167 -0
  256. package/stories/defaults/systemGenerator.ts +38 -0
  257. package/tests/components/edges/offsetBezier.test.ts +51 -0
  258. package/tests/components/layoutController/utils.test.ts +68 -0
  259. package/tests/components/panels/traces/utils.test.ts +52 -0
  260. package/tests/flowToBehave.test.ts +26 -4
  261. package/tests/notifications.test.ts +87 -0
  262. package/tests/saveLoad.test.ts +372 -0
  263. package/tests/util/calculateNewEdge.test.ts +98 -0
  264. package/tests/util/getSocketsByNodeTypeAndHandleType.test.ts +31 -0
  265. package/tests/util/hasPositionMetaData.test.ts +33 -0
  266. package/tests/util/isBehaveNode.test.ts +22 -0
  267. package/tests/util/isHandleConnected.test.ts +37 -0
  268. package/tests/util/mergeSockets.test.ts +43 -0
  269. package/tests/visual/README.md +64 -0
  270. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-alignment-chromium-win32.png +0 -0
  271. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-conversation-chromium-win32.png +0 -0
  272. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-events-chromium-win32.png +0 -0
  273. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-history-chromium-win32.png +0 -0
  274. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-keymaps-chromium-win32.png +0 -0
  275. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-layers-chromium-win32.png +0 -0
  276. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-legend-chromium-win32.png +0 -0
  277. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-logs-chromium-win32.png +0 -0
  278. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-nodeInputs-chromium-win32.png +0 -0
  279. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-nodePicker-chromium-win32.png +0 -0
  280. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-panel-chromium-win32.png +0 -0
  281. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-search-chromium-win32.png +0 -0
  282. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-systemSettings-chromium-win32.png +0 -0
  283. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-traces-chromium-win32.png +0 -0
  284. package/tests/visual/__screenshots__/panels.visual.test.tsx/panel-variables-chromium-win32.png +0 -0
  285. package/tests/visual/panels.visual.test.tsx +76 -0
  286. package/tsconfig.base.json +39 -0
  287. package/tsconfig.json +18 -59
  288. package/tsconfig.prod.json +23 -0
  289. package/tsdown.config.ts +15 -3
  290. package/typedoc.json +7 -7
  291. package/vite.config.js +7 -0
  292. package/vitest.config.ts +5 -2
  293. package/vitest.visual.config.ts +48 -0
  294. package/src/components/AutoSizeInput.tsx +0 -65
  295. package/src/components/Controls.tsx +0 -87
  296. package/src/components/InputSocket.tsx +0 -142
  297. package/src/components/Node.tsx +0 -68
  298. package/src/components/NodeContainer.tsx +0 -46
  299. package/src/components/NodePicker.tsx +0 -77
  300. package/src/components/OutputSocket.tsx +0 -58
  301. package/src/components/modals/ClearModal.tsx +0 -40
  302. package/src/components/modals/HelpModal.tsx +0 -36
  303. package/src/components/modals/LoadModal.tsx +0 -96
  304. package/src/components/modals/Modal.tsx +0 -64
  305. package/src/components/modals/SaveModal.tsx +0 -60
  306. package/src/hooks/useCustomNodeTypes.tsx +0 -31
  307. package/src/hooks/useGraphRunner.ts +0 -104
  308. package/src/hooks/useMergeMap.ts +0 -14
  309. package/src/hooks/useNodeSpecJson.ts +0 -20
  310. package/src/hooks/useQueriableDefinitions.ts +0 -22
  311. package/src/styles.css +0 -8
  312. package/tailwind.config.ts +0 -19
  313. package/tests/tsconfig.json +0 -10
  314. /package/src/{types.d.ts → types-declarations.d.ts} +0 -0
@@ -0,0 +1,339 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { useSystem } from '@/system/provider';
3
+ import {
4
+ VscodeTabHeader,
5
+ VscodeTabPanel,
6
+ VscodeTabs,
7
+ VscodeToolbarContainer
8
+ } from '@vscode-elements/react-elements';
9
+ import { useStore } from 'zustand';
10
+ import {
11
+ findTabInLayout,
12
+ removeTabFromLayout,
13
+ addFloatingTab
14
+ } from '@/components/layoutController/utils';
15
+
16
+ import styles from './index.module.css';
17
+ import { BasePanel } from '../base';
18
+ import { NodeTitleEditor } from './NodeTitleEditor';
19
+ import { MultipleNodesView } from './MultipleNodesView';
20
+ import { SocketGenerators } from './SocketGenerators';
21
+ import { InputsGroup } from './InputsGroup';
22
+ import { OutputsGroup } from './OutputsGroup';
23
+ import { NodeSettings } from './NodeSettings';
24
+ import { useNodeInputsData } from './useNodeInputsData';
25
+ import { useNodeHandlers } from './useNodeHandlers';
26
+ import { EyeClosed, EyeSolid } from 'iconoir-react';
27
+ import { Icon } from '@/components/primitives/icon';
28
+
29
+ export function NodeInputsPanel() {
30
+ const system = useSystem();
31
+ const documentation = useStore(system.documentationStore, (x) => x.docs);
32
+
33
+ const {
34
+ allSpecsJson,
35
+ selectedNodes,
36
+ selectedNode,
37
+ nodeSpec,
38
+ inputsWithControls,
39
+ outputsWithInfo,
40
+ matchingGenerators,
41
+ generatorNode,
42
+ controls,
43
+ defaultControl
44
+ } = useNodeInputsData(system);
45
+
46
+ const { handleSaveTitle, handleValueChange } = useNodeHandlers(
47
+ system,
48
+ selectedNode
49
+ );
50
+
51
+ const hiddenInputs = useMemo(() => {
52
+ return selectedNode?.data.annotations?.hiddenInputs ?? {};
53
+ }, [selectedNode]);
54
+
55
+ const hiddenOutputs = useMemo(() => {
56
+ return selectedNode?.data.annotations?.hiddenOutputs ?? {};
57
+ }, [selectedNode]);
58
+
59
+ const handleToggleInput = useCallback(
60
+ (inputName: string) => {
61
+ if (!selectedNode) return;
62
+
63
+ const currentHidden = hiddenInputs[inputName] ?? false;
64
+ const newHiddenInputs = {
65
+ ...hiddenInputs,
66
+ [inputName]: !currentHidden
67
+ };
68
+
69
+ system.nodeStore.getState().setNodes((prev) =>
70
+ prev.map((n) =>
71
+ n.id === selectedNode.id
72
+ ? {
73
+ ...n,
74
+ data: {
75
+ ...(n as any).data,
76
+ annotations: {
77
+ ...(n as any).data.annotations,
78
+ hiddenInputs: newHiddenInputs
79
+ }
80
+ }
81
+ }
82
+ : n
83
+ )
84
+ );
85
+ },
86
+ [selectedNode, hiddenInputs, system]
87
+ );
88
+
89
+ const handleToggleOutput = useCallback(
90
+ (outputName: string) => {
91
+ if (!selectedNode) return;
92
+
93
+ const currentHidden = hiddenOutputs[outputName] ?? false;
94
+ const newHiddenOutputs = {
95
+ ...hiddenOutputs,
96
+ [outputName]: !currentHidden
97
+ };
98
+
99
+ system.nodeStore.getState().setNodes((prev) =>
100
+ prev.map((n) =>
101
+ n.id === selectedNode.id
102
+ ? {
103
+ ...n,
104
+ data: {
105
+ ...(n as any).data,
106
+ annotations: {
107
+ ...(n as any).data.annotations,
108
+ hiddenOutputs: newHiddenOutputs
109
+ }
110
+ }
111
+ }
112
+ : n
113
+ )
114
+ );
115
+ },
116
+ [selectedNode, hiddenOutputs, system]
117
+ );
118
+
119
+ const handleToggleAllInputs = useCallback(() => {
120
+ if (!selectedNode) return;
121
+
122
+ const allHidden = inputsWithControls.every(
123
+ (input) => hiddenInputs[input.name]
124
+ );
125
+ const newHiddenInputs: Record<string, boolean> = {};
126
+
127
+ inputsWithControls.forEach((input) => {
128
+ newHiddenInputs[input.name] = !allHidden;
129
+ });
130
+
131
+ system.nodeStore.getState().setNodes((prev) =>
132
+ prev.map((n) =>
133
+ n.id === selectedNode.id
134
+ ? {
135
+ ...n,
136
+ data: {
137
+ ...(n as any).data,
138
+ annotations: {
139
+ ...(n as any).data.annotations,
140
+ hiddenInputs: newHiddenInputs
141
+ }
142
+ }
143
+ }
144
+ : n
145
+ )
146
+ );
147
+ }, [selectedNode, inputsWithControls, hiddenInputs, system]);
148
+
149
+ const handleToggleAllOutputs = useCallback(() => {
150
+ if (!selectedNode) return;
151
+
152
+ const allHidden = outputsWithInfo.every(
153
+ (output) => hiddenOutputs[output.name]
154
+ );
155
+ const newHiddenOutputs: Record<string, boolean> = {};
156
+
157
+ outputsWithInfo.forEach((output) => {
158
+ newHiddenOutputs[output.name] = !allHidden;
159
+ });
160
+
161
+ system.nodeStore.getState().setNodes((prev) =>
162
+ prev.map((n) =>
163
+ n.id === selectedNode.id
164
+ ? {
165
+ ...n,
166
+ data: {
167
+ ...(n as any).data,
168
+ annotations: {
169
+ ...(n as any).data.annotations,
170
+ hiddenOutputs: newHiddenOutputs
171
+ }
172
+ }
173
+ }
174
+ : n
175
+ )
176
+ );
177
+ }, [selectedNode, outputsWithInfo, hiddenOutputs, system]);
178
+
179
+ const handleShowDocumentation = useCallback(
180
+ (nodeType: string) => {
181
+ // Set the selected documentation type
182
+ system.refStore.getState().setRef('selectedDocumentationType', nodeType);
183
+
184
+ // Open documentation browser panel
185
+ const currentLayout = system.tabStore.getState().layout;
186
+
187
+ // Close existing doc browser if open
188
+ const existingPanel = findTabInLayout(currentLayout, 'docbrowser');
189
+ let layoutToUse = currentLayout;
190
+ if (existingPanel) {
191
+ layoutToUse = removeTabFromLayout(currentLayout, 'docbrowser');
192
+ }
193
+
194
+ // Create new floating panel
195
+ const tabData = {
196
+ id: 'docbrowser'
197
+ };
198
+
199
+ const newLayout = addFloatingTab(layoutToUse, tabData, {
200
+ left: 100,
201
+ top: 100,
202
+ width: 600,
203
+ height: 700
204
+ });
205
+
206
+ system.tabStore.getState().setLayout(newLayout);
207
+ },
208
+ [system]
209
+ );
210
+
211
+ const hasDocumentation = useCallback(
212
+ (nodeType: string) => {
213
+ const doc = documentation?.get(nodeType);
214
+ return !!(doc?.markdownDescription || doc?.shortDescription);
215
+ },
216
+ [documentation]
217
+ );
218
+
219
+ const getNodeIcon = useCallback(
220
+ (nodeType: string) => {
221
+ const doc = documentation?.get(nodeType);
222
+ return doc?.icon;
223
+ },
224
+ [documentation]
225
+ );
226
+
227
+ // Handle multiple node selection
228
+ if (selectedNodes.length > 1) {
229
+ return (
230
+ <MultipleNodesView
231
+ selectedNodes={selectedNodes}
232
+ allSpecsJson={allSpecsJson}
233
+ />
234
+ );
235
+ }
236
+
237
+ if (!selectedNode || !nodeSpec) {
238
+ return (
239
+ <BasePanel>
240
+ <div className={styles.emptyState}>
241
+ No node selected. Select a node to edit its inputs.
242
+ </div>
243
+ </BasePanel>
244
+ );
245
+ }
246
+
247
+ return (
248
+ <BasePanel>
249
+ <NodeTitleEditor
250
+ selectedNode={selectedNode}
251
+ nodeLabel={nodeSpec?.label ?? ''}
252
+ onSave={handleSaveTitle}
253
+ nodeType={selectedNode.data.type}
254
+ nodeIcon={getNodeIcon(selectedNode.data.type)}
255
+ hasDocumentation={hasDocumentation(selectedNode.data.type)}
256
+ onShowDocumentation={handleShowDocumentation}
257
+ />
258
+
259
+ <VscodeToolbarContainer className={styles.toolbar}>
260
+ <VscodeTabs className={styles.tabs}>
261
+ <VscodeTabHeader>Properties</VscodeTabHeader>
262
+ <VscodeTabPanel>
263
+ {inputsWithControls.length > 0 && (
264
+ <div className={styles.panelHeader}>
265
+ <Icon
266
+ onClick={handleToggleAllInputs}
267
+ title="Toggle all input visibility"
268
+ >
269
+ {inputsWithControls.every(
270
+ (input) => hiddenInputs[input.name]
271
+ ) ? (
272
+ <EyeSolid />
273
+ ) : (
274
+ <EyeClosed />
275
+ )}
276
+ </Icon>
277
+ </div>
278
+ )}
279
+
280
+ {generatorNode && (
281
+ <SocketGenerators
282
+ generators={matchingGenerators}
283
+ generatorNode={generatorNode}
284
+ />
285
+ )}
286
+ {inputsWithControls.length === 0 &&
287
+ matchingGenerators.length === 0 && (
288
+ <div className={styles.noInputs}>
289
+ This node has no editable inputs.
290
+ </div>
291
+ )}
292
+ <InputsGroup
293
+ inputs={inputsWithControls}
294
+ controls={controls}
295
+ defaultControl={defaultControl}
296
+ onValueChange={handleValueChange}
297
+ hiddenInputs={hiddenInputs}
298
+ onToggleInput={handleToggleInput}
299
+ />
300
+ </VscodeTabPanel>
301
+ <VscodeTabHeader>Outputs</VscodeTabHeader>
302
+ <VscodeTabPanel>
303
+ {outputsWithInfo.length > 0 && (
304
+ <div className={styles.panelHeader}>
305
+ <Icon
306
+ onClick={handleToggleAllOutputs}
307
+ title="Toggle all output visibility"
308
+ >
309
+ {outputsWithInfo.every(
310
+ (output) => hiddenOutputs[output.name]
311
+ ) ? (
312
+ <EyeSolid />
313
+ ) : (
314
+ <EyeClosed />
315
+ )}
316
+ </Icon>
317
+ </div>
318
+ )}
319
+ {outputsWithInfo.length === 0 && (
320
+ <div className={styles.noInputs}>This node has no outputs.</div>
321
+ )}
322
+ <OutputsGroup
323
+ outputs={outputsWithInfo}
324
+ hiddenOutputs={hiddenOutputs}
325
+ onToggleOutput={handleToggleOutput}
326
+ />
327
+ </VscodeTabPanel>
328
+ <VscodeTabHeader>Settings</VscodeTabHeader>
329
+ <VscodeTabPanel>
330
+ <NodeSettings
331
+ selectedNode={selectedNode}
332
+ onSave={handleSaveTitle}
333
+ />
334
+ </VscodeTabPanel>
335
+ </VscodeTabs>
336
+ </VscodeToolbarContainer>
337
+ </BasePanel>
338
+ );
339
+ }
@@ -0,0 +1,76 @@
1
+ import { useCallback } from 'react';
2
+ import type { IBehaveNode } from '@/types/nodes';
3
+ import type { System } from '@/system';
4
+
5
+ export function useNodeHandlers(
6
+ system: System,
7
+ selectedNode: IBehaveNode | null
8
+ ) {
9
+ const handleSaveTitle = useCallback(
10
+ (annotationKey: string, rawValue: string) => {
11
+ if (!selectedNode) return;
12
+
13
+ const trimmed = rawValue.trim();
14
+
15
+ const currentAnnotations = (selectedNode as any)?.data
16
+ ?.annotations as unknown;
17
+ const isPlainObject =
18
+ !!currentAnnotations &&
19
+ typeof currentAnnotations === 'object' &&
20
+ !Array.isArray(currentAnnotations);
21
+
22
+ const nextAnnotations: Record<string, any> = isPlainObject
23
+ ? { ...(currentAnnotations as any) }
24
+ : {};
25
+ if (!trimmed) {
26
+ delete nextAnnotations[annotationKey];
27
+ } else {
28
+ nextAnnotations[annotationKey] = trimmed;
29
+ }
30
+
31
+ const updatedNode = {
32
+ ...selectedNode,
33
+ data: {
34
+ ...selectedNode.data,
35
+ annotations: nextAnnotations
36
+ }
37
+ };
38
+
39
+ system.nodeStore
40
+ .getState()
41
+ .setNodes((prev) =>
42
+ prev.map((n) => (n.id === selectedNode.id ? updatedNode : n))
43
+ );
44
+ },
45
+ [selectedNode, system.nodeStore]
46
+ );
47
+
48
+ const handleValueChange = useCallback(
49
+ (inputName: string, newValue: any) => {
50
+ if (!selectedNode) return;
51
+
52
+ const updatedNode = {
53
+ ...selectedNode,
54
+ data: {
55
+ ...selectedNode.data,
56
+ ports: {
57
+ ...selectedNode.data.ports,
58
+ [inputName]: newValue
59
+ }
60
+ }
61
+ };
62
+
63
+ system.nodeStore
64
+ .getState()
65
+ .setNodes((prev) =>
66
+ prev.map((n) => (n.id === selectedNode.id ? updatedNode : n))
67
+ );
68
+ },
69
+ [selectedNode, system.nodeStore]
70
+ );
71
+
72
+ return {
73
+ handleSaveTitle,
74
+ handleValueChange
75
+ };
76
+ }
@@ -0,0 +1,173 @@
1
+ import { useMemo } from 'react';
2
+ import { useStore } from 'zustand';
3
+ import { configureSockets } from '@/util/sockets';
4
+ import { isHandleConnected } from '@/util/isHandleConnected';
5
+ import type { IBehaveNode } from '@/types/nodes';
6
+ import type { System } from '@/system';
7
+
8
+ export function useNodeInputsData(system: System) {
9
+ const selectedNodeId = useStore(
10
+ system.selectionStore,
11
+ (x) => x.selectedNodeId
12
+ );
13
+ const nodes = useStore(system.nodeStore, (x) => x.nodes);
14
+ const edges = useStore(system.edgeStore, (x) => x.edges);
15
+ const controls = useStore(system.controlStore, (x) => x.controls);
16
+ const defaultControl = useStore(system.controlStore, (x) => x.defaultControl);
17
+ const generators = useStore(system.socketGeneratorStore, (s) => s.generators);
18
+ const generatorLocation = useStore(
19
+ system.systemSettings,
20
+ (s) => s.generatorLocation
21
+ );
22
+
23
+ const allSpecsJson = useStore(system.specStore, (x) => x.specs);
24
+
25
+ const selectedNodes = useMemo(() => {
26
+ return nodes.filter(
27
+ (n) => (n as IBehaveNode).type == 'behaveNode' && n.selected
28
+ );
29
+ }, [nodes]);
30
+
31
+ const selectedNode = useMemo(() => {
32
+ if (!selectedNodeId) return null;
33
+ return nodes.find(
34
+ (n) => (n as IBehaveNode).type === 'behaveNode' && n.id === selectedNodeId
35
+ ) as IBehaveNode | null;
36
+ }, [selectedNodeId, nodes]);
37
+
38
+ const nodeSpec = useMemo(() => {
39
+ if (!selectedNode) return null;
40
+ return allSpecsJson.find((spec) => spec.type === selectedNode.data.type);
41
+ }, [selectedNode, allSpecsJson]);
42
+
43
+ const inputsWithControls = useMemo(() => {
44
+ if (!selectedNode || !nodeSpec) return [];
45
+
46
+ const { pairs, valueInputs } = configureSockets(
47
+ selectedNode.data.configuration,
48
+ nodeSpec,
49
+ selectedNode.data.dynamicPorts
50
+ );
51
+ const inputs: Array<{
52
+ name: string;
53
+ valueType: string;
54
+ defaultValue?: any;
55
+ choices?: Array<{ text: string; value: any }>;
56
+ value: any;
57
+ connected: boolean;
58
+ }> = [];
59
+
60
+ for (const [input] of pairs) {
61
+ if (input && input.valueType !== 'flow') {
62
+ inputs.push({
63
+ name: input.name,
64
+ valueType: input.valueType,
65
+ defaultValue: input.defaultValue,
66
+ choices: input.choices,
67
+ value: selectedNode.data.ports?.[input.name] ?? input.defaultValue,
68
+ connected: isHandleConnected(
69
+ edges,
70
+ selectedNode.id,
71
+ input.name,
72
+ 'target'
73
+ )
74
+ });
75
+ }
76
+ }
77
+
78
+ for (const input of valueInputs) {
79
+ inputs.push({
80
+ name: input.name,
81
+ valueType: input.valueType,
82
+ defaultValue: input.defaultValue,
83
+ choices: input.choices,
84
+ value: selectedNode.data.ports?.[input.name] ?? input.defaultValue,
85
+ connected: isHandleConnected(
86
+ edges,
87
+ selectedNode.id,
88
+ input.name,
89
+ 'target'
90
+ )
91
+ });
92
+ }
93
+
94
+ return inputs;
95
+ }, [selectedNode, nodeSpec, edges]);
96
+
97
+ const outputsWithInfo = useMemo(() => {
98
+ if (!selectedNode || !nodeSpec) return [];
99
+
100
+ const { pairs, valueOutputs } = configureSockets(
101
+ selectedNode.data.configuration,
102
+ nodeSpec,
103
+ selectedNode.data.dynamicPorts
104
+ );
105
+
106
+ const outputs: Array<{
107
+ name: string;
108
+ valueType: string;
109
+ connected: boolean;
110
+ }> = [];
111
+
112
+ // Collect flow-paired outputs (non-flow)
113
+ for (const [, output] of pairs) {
114
+ if (output && output.valueType !== 'flow') {
115
+ outputs.push({
116
+ name: output.name,
117
+ valueType: output.valueType,
118
+ connected: isHandleConnected(
119
+ edges,
120
+ selectedNode.id,
121
+ output.name,
122
+ 'source'
123
+ )
124
+ });
125
+ }
126
+ }
127
+
128
+ // Value-only outputs
129
+ for (const output of valueOutputs) {
130
+ outputs.push({
131
+ name: output.name,
132
+ valueType: output.valueType,
133
+ connected: isHandleConnected(
134
+ edges,
135
+ selectedNode.id,
136
+ output.name,
137
+ 'source'
138
+ )
139
+ });
140
+ }
141
+
142
+ return outputs;
143
+ }, [selectedNode, nodeSpec, edges]);
144
+
145
+ const matchingGenerators = useMemo(() => {
146
+ if (!nodeSpec || generatorLocation !== 'panel') return [];
147
+ return generators.filter((x) => x.check(nodeSpec));
148
+ }, [nodeSpec, generators, generatorLocation]);
149
+
150
+ const generatorNode = useMemo(() => {
151
+ if (!selectedNode || !nodeSpec) return null;
152
+ return {
153
+ id: selectedNode.id,
154
+ data: selectedNode.data,
155
+ spec: nodeSpec,
156
+ selected: !!selectedNode.selected
157
+ };
158
+ }, [selectedNode, nodeSpec]);
159
+
160
+ return {
161
+ allSpecsJson,
162
+ selectedNodes,
163
+ selectedNode,
164
+ nodeSpec,
165
+ inputsWithControls,
166
+ outputsWithInfo,
167
+
168
+ matchingGenerators,
169
+ generatorNode,
170
+ controls,
171
+ defaultControl
172
+ };
173
+ }
@@ -0,0 +1,115 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { useSystem } from '@/system/provider';
3
+ import { useStore } from 'zustand';
4
+ import { NodePicker } from '@/components/contextMenus/NodePicker';
5
+ import type { ExtendedNodeSpecJSON } from '@/components/contextMenus/NodePicker';
6
+ import type { XYPosition } from 'reactflow';
7
+ import { v4 as uuidv4 } from 'uuid';
8
+ import {
9
+ removeTabFromLayout,
10
+ addFloatingTab,
11
+ findTabInLayout
12
+ } from '@/components/layoutController/utils';
13
+
14
+ export function NodePickerPanel() {
15
+ const sys = useSystem();
16
+ const specJson = useStore(sys.specStore, (x) => x.specs);
17
+ const documentation = useStore(sys.documentationStore, (x) => x.docs);
18
+ const reactflowRef = useStore(sys.refStore, (x) => x.refs.reactflow);
19
+ const screenPosition = useStore(
20
+ sys.refStore,
21
+ (x) => x.refs.nodePickerPosition
22
+ );
23
+
24
+ // Convert screen position to flow position
25
+ const flowPosition = useMemo(() => {
26
+ if (reactflowRef && screenPosition && reactflowRef.screenToFlowPosition) {
27
+ return reactflowRef.screenToFlowPosition(screenPosition);
28
+ }
29
+ return { x: 0, y: 0 };
30
+ }, [reactflowRef, screenPosition]);
31
+
32
+ // For now, we'll use undefined which means no filtering
33
+ const nodePickFilters = undefined;
34
+ const closeNodePicker = useCallback(() => {
35
+ const currentLayout = sys.tabStore.getState().layout;
36
+ const newLayout = removeTabFromLayout(currentLayout, 'nodepicker');
37
+ sys.tabStore.getState().setLayout(newLayout);
38
+ }, [sys]);
39
+
40
+ const handleShowDocumentation = useCallback(
41
+ (nodeType: string) => {
42
+ // Set the selected documentation type
43
+ sys.refStore.getState().setRef('selectedDocumentationType', nodeType);
44
+
45
+ // Open documentation browser panel
46
+ const currentLayout = sys.tabStore.getState().layout;
47
+
48
+ // Close existing doc browser if open
49
+ const existingPanel = findTabInLayout(currentLayout, 'docbrowser');
50
+ let layoutToUse = currentLayout;
51
+ if (existingPanel) {
52
+ layoutToUse = removeTabFromLayout(currentLayout, 'docbrowser');
53
+ }
54
+
55
+ // Create new floating panel
56
+ const tabData = {
57
+ id: 'docbrowser'
58
+ };
59
+
60
+ const newLayout = addFloatingTab(layoutToUse, tabData, {
61
+ left: 100,
62
+ top: 100,
63
+ width: 600,
64
+ height: 700
65
+ });
66
+
67
+ sys.tabStore.getState().setLayout(newLayout);
68
+ },
69
+ [sys]
70
+ );
71
+
72
+ const handleAddNode = useCallback(
73
+ (spec: ExtendedNodeSpecJSON, position: XYPosition) => {
74
+ const newNode = {
75
+ id: uuidv4(),
76
+ type: spec.nodeType ?? 'behaveNode',
77
+ position,
78
+ data: {
79
+ configuration: {},
80
+ type: spec.type,
81
+ ports: {}
82
+ }
83
+ };
84
+
85
+ sys.undoManager.execute({
86
+ name: `Add node (${spec.type})`,
87
+ execute: () => {
88
+ sys.nodeStore.getState().addNode(newNode);
89
+ },
90
+ undo: () => {
91
+ sys.nodeStore
92
+ .getState()
93
+ .setNodes((existing) =>
94
+ existing.filter((n) => n.id !== newNode.id)
95
+ );
96
+ }
97
+ });
98
+
99
+ closeNodePicker();
100
+ },
101
+ [closeNodePicker, sys]
102
+ );
103
+
104
+ return (
105
+ <NodePicker
106
+ position={flowPosition}
107
+ filters={nodePickFilters}
108
+ onPickNode={handleAddNode}
109
+ onClose={closeNodePicker}
110
+ specJSON={specJson}
111
+ documentation={documentation}
112
+ onShowDocumentation={handleShowDocumentation}
113
+ />
114
+ );
115
+ }