Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rsamf committed Nov 15, 2024
1 parent 3934507 commit 6883af1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions graphbook/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,6 @@ def set_resource_value(resource_id, resource_data):
queues[step_id] = MultiConsumerStateDictionaryQueue()
step_states[step_id] = set()
logger_param_pool[id(step)] = (step_id, step_name)
step_graph["parent"][step_id] = set()
step_graph["child"][step_id] = set()

# Remove old consumers from parents
previous_obj = self._steps.get(step_id)
Expand All @@ -265,6 +263,8 @@ def set_resource_value(resource_id, resource_data):
for parent_id in parent_ids:
if parent_id in self._queues:
self._queues[parent_id].remove_consumer(id(previous_obj))
step_graph["parent"][step_id] = set()
step_graph["child"][step_id] = set()

# Next, connect the steps
for step_id, step_data in graph.items():
Expand Down
17 changes: 10 additions & 7 deletions web/src/components/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,21 @@ export function NodeContextMenu({ nodeId, top, left, close }) {
name: 'Duplicate',
disabled: () => runState !== 'stopped',
action: () => {
const { addNodes } = reactFlowInstance;
const { setNodes } = reactFlowInstance;
const position = {
x: node.position.x + 50,
y: node.position.y + 50,
};

addNodes({
...node,
selected: false,
dragging: false,
id: `${node.id}-copy`,
position,
setNodes(nodes => {
const copy = { ...node } as any;
delete copy.id;
return Graph.addNode({
...copy,
selected: false,
dragging: false,
position
}, nodes);
});
}
},
Expand Down
4 changes: 3 additions & 1 deletion web/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ export const evalDragData = async (reactFlowInstance: ReactFlowInstance, API: Se
...data.node
};
Object.values<any>(node.data.parameters).forEach((p) => {
p.value = p.default;
if (p.default !== undefined) {
p.value = p.default;
}
});
setNodes(Graph.addNode(node, nodes));
} else if (data.text) {
Expand Down

0 comments on commit 6883af1

Please sign in to comment.