Skip to content

Commit 3fdf961

Browse files
authored
Merge pull request #140 from badaitech/fix/default-categoryMetadata
default category metadata
2 parents c5189d8 + 503c0e8 commit 3fdf961

17 files changed

Lines changed: 90 additions & 20 deletions

File tree

apps/chaingraph-backend/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @badaitech/chaingraph-backend
22

3+
## 0.1.22
4+
5+
### Patch Changes
6+
7+
- default category metadata
8+
- Updated dependencies
9+
- @badaitech/chaingraph-nodes@0.1.22
10+
- @badaitech/chaingraph-trpc@0.1.22
11+
- @badaitech/chaingraph-types@0.1.22
12+
313
## 0.1.21
414

515
### Patch Changes

apps/chaingraph-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-backend",
33
"type": "module",
4-
"version": "0.1.21",
4+
"version": "0.1.22",
55
"private": false,
66
"description": "Backend server for the Chaingraph project",
77
"license": "BUSL-1.1",

apps/chaingraph-frontend/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# @badaitech/chaingraph-frontend
22

3+
## 0.1.22
4+
5+
### Patch Changes
6+
7+
- default category metadata
8+
- Updated dependencies
9+
- @badaitech/chaingraph-nodes@0.1.22
10+
- @badaitech/chaingraph-trpc@0.1.22
11+
- @badaitech/chaingraph-types@0.1.22
12+
313
## 0.1.21
414

515
### Patch Changes

apps/chaingraph-frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph-frontend",
33
"type": "module",
4-
"version": "0.1.21",
4+
"version": "0.1.22",
55
"private": false,
66
"description": "Frontend application for the Chaingraph project",
77
"license": "BUSL-1.1",

apps/chaingraph-frontend/src/components/flow/nodes/ChaingraphNode/ChaingraphNode.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,35 @@ import {
3333
} from '@/store/ports'
3434
import { NodeResizeControl, ResizeControlVariant } from '@xyflow/react'
3535
import { useUnit } from 'effector-react'
36-
import { memo, useCallback, useEffect, useMemo, useState } from 'react'
36+
import { memo, useCallback, useMemo } from 'react'
3737
import { BreakpointButton } from '../debug/BreakpointButton'
3838
import { useElementResize } from './hooks/useElementResize'
3939
import NodeBody from './NodeBody'
4040
import NodeErrorPorts from './NodeErrorPorts'
4141
import { NodeHeader } from './NodeHeader'
4242

43+
const defaultCategoryMetadata = {
44+
id: 'other',
45+
label: 'Other',
46+
description: 'Other nodes',
47+
icon: 'Package',
48+
style: {
49+
light: {
50+
primary: '#F5F5F5', // Soft gray
51+
secondary: '#FAFAFA',
52+
background: '#FFFFFF',
53+
text: '#616161', // Darker gray
54+
},
55+
dark: {
56+
primary: '#2C2C2C',
57+
secondary: '#1F1F1F',
58+
background: '#1C1C1C',
59+
text: '#BDBDBD',
60+
},
61+
},
62+
order: 7,
63+
}
64+
4365
function ChaingraphNodeComponent({
4466
data,
4567
selected,
@@ -62,9 +84,11 @@ function ChaingraphNodeComponent({
6284
const nodeEdges = useEdgesForNode(id)
6385
const highlightedNodeId = useUnit($highlightedNodeId)
6486

65-
const [style, setStyle] = useState(
66-
theme === 'dark' ? data.categoryMetadata.style.dark : data.categoryMetadata.style.light,
67-
)
87+
const categoryMetadata = data.categoryMetadata ?? defaultCategoryMetadata
88+
89+
const style = useMemo(() => {
90+
return theme === 'dark' ? categoryMetadata.style.dark : categoryMetadata.style.light
91+
}, [categoryMetadata, theme])
6892

6993
const isHighlighted = useMemo(
7094
() => highlightedNodeId && highlightedNodeId.includes(id),
@@ -105,12 +129,6 @@ function ChaingraphNodeComponent({
105129
}
106130
}, [isBreakpointSet, dispatch, id])
107131

108-
useEffect(() => {
109-
setStyle(
110-
theme === 'dark' ? data.categoryMetadata.style.dark : data.categoryMetadata.style.light,
111-
)
112-
}, [theme, data.categoryMetadata, id])
113-
114132
// Use throttled/memoized version of execution state style to reduce renders
115133
const executionStateStyle = useMemo(() => {
116134
// Calculate the style based on node state
@@ -252,7 +270,7 @@ function ChaingraphNodeComponent({
252270
<NodeHeader
253271
node={nodeExecution?.node ?? node}
254272
context={portContextValue}
255-
icon={data.categoryMetadata.icon}
273+
icon={categoryMetadata.icon}
256274
style={style}
257275
onDelete={() => removeNodeFromFlow({
258276
flowId: activeFlow.id!,

apps/chaingraph-frontend/src/components/flow/nodes/ChaingraphNode/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ import type { Node } from '@xyflow/react'
1111

1212
export type ChaingraphNode = Node<{
1313
node: INode
14-
categoryMetadata: CategoryMetadata
14+
categoryMetadata?: CategoryMetadata
1515
}, 'chaingraphNode'>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/chaingraph",
33
"type": "module",
4-
"version": "0.1.21",
4+
"version": "0.1.22",
55
"private": false,
66
"packageManager": "pnpm@10.5.2",
77
"license": "BUSL-1.1",

packages/badai-api/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @badaitech/badai-api
22

3+
## 0.1.22
4+
5+
### Patch Changes
6+
7+
- default category metadata
8+
39
## 0.1.21
410

511
### Patch Changes

packages/badai-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@badaitech/badai-api",
33
"type": "module",
4-
"version": "0.1.21",
4+
"version": "0.1.22",
55
"private": false,
66
"description": "Bad AI GraphQL API client",
77
"license": "BUSL-1.1",

packages/chaingraph-nodes/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# @badaitech/chaingraph-nodes
22

3+
## 0.1.22
4+
5+
### Patch Changes
6+
7+
- default category metadata
8+
- Updated dependencies
9+
- @badaitech/chaingraph-types@0.1.22
10+
311
## 0.1.21
412

513
### Patch Changes

0 commit comments

Comments
 (0)