From 1671ea6a09a5c65dff237023653b390b2f1ddccf Mon Sep 17 00:00:00 2001
From: George Buciuman <georgebuciuman@gmail.com>
Date: Wed, 12 Jun 2024 15:41:35 +0300
Subject: [PATCH] fix(1013): Subgraph ouput

---
 .../graph-editor/src/components/flow/wrapper/nodeV2.tsx   | 4 ++--
 packages/graph-engine/src/nodes/generic/subgraph.ts       | 8 ++++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/packages/graph-editor/src/components/flow/wrapper/nodeV2.tsx b/packages/graph-editor/src/components/flow/wrapper/nodeV2.tsx
index df79a2c9..4813e98e 100644
--- a/packages/graph-editor/src/components/flow/wrapper/nodeV2.tsx
+++ b/packages/graph-editor/src/components/flow/wrapper/nodeV2.tsx
@@ -15,7 +15,7 @@ import { useLocalGraph } from '@/context/graph.js';
 
 const isHexColor = (str) => {
   if (typeof str !== 'string') return false;
-  return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(str);;
+  return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(str);;
 };
 
 export type UiNodeDefinition = {
@@ -156,7 +156,7 @@ const getColorPreview = (color: string, showValue = false) => {
   return (
     <Stack direction="row" gap={2}>
       {colorSwatch}    
-      {showValue ? <Text css={{ fontSize: '$small', color: '$gray12' }}>{color}</Text> : null}
+      {showValue ? <Text css={{ fontSize: '$small', color: '$gray12' }}>{color.toUpperCase()}</Text> : null}
     </Stack>
   );
 }
diff --git a/packages/graph-engine/src/nodes/generic/subgraph.ts b/packages/graph-engine/src/nodes/generic/subgraph.ts
index edf9c7e4..82bcd00b 100644
--- a/packages/graph-engine/src/nodes/generic/subgraph.ts
+++ b/packages/graph-engine/src/nodes/generic/subgraph.ts
@@ -39,6 +39,11 @@ export default class SubgraphNode extends Node {
     this._innerGraph.addNode(input);
     this._innerGraph.addNode(output);
 
+    this.addOutput("value", {
+      type: AnySchema,
+      visible: true,
+    });
+
     autorun(() => {
 
       //Get the existing inputs 
@@ -94,11 +99,10 @@ export default class SubgraphNode extends Node {
       return acc;
     }, {});
 
-
     const result = await this._innerGraph.execute({
       inputs
     });
 
-    this.setOutput("value", result.output?.value, result.output?.type);
+    this.setOutput("value", result.output?.value.value, result.output?.value.type);
   }
 }