Skip to content

Commit d77dad2

Browse files
committed
feat: improve real-time updates and prevent duplicate edges
- Reduce polling interval from 5s to 100ms for near real-time updates - Add awaitRefetchQueries to CREATE_WORK_ITEM mutation for immediate cache updates - Fix isRelationshipDisabled function to properly validate duplicate edges - Implement comprehensive duplicate prevention using validateNewConnection - Enhance edge creation validation in ConnectNodeModal
1 parent a7b200f commit d77dad2

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

packages/web/src/components/ConnectNodeModal.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,18 @@ export function ConnectNodeModal({ isOpen, onClose, sourceNode, initialTab = 'co
10421042
// Check if any relationship type is disabled (any relationship already exists with selected nodes)
10431043
const isRelationshipDisabled = (relationshipType: string) => {
10441044
if (selectedNodes.size === 0) return false;
1045-
// With one-relationship-at-a-time policy, disable if ANY relationship exists
1046-
return false; // Simplified for now
1045+
1046+
// Check if this relationship type would create duplicates for ANY selected node
1047+
return Array.from(selectedNodes).some(targetId => {
1048+
const validation = validateNewConnection(
1049+
sourceNode.id,
1050+
targetId,
1051+
relationshipType,
1052+
existingEdges,
1053+
workItems
1054+
);
1055+
return !validation.isValid;
1056+
});
10471057
};
10481058

10491059
// Filter out the source node and apply search/filters

packages/web/src/components/GraphVisualization.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ export function GraphVisualization() {
7070
options: { limit: 100 }
7171
},
7272
fetchPolicy: 'cache-and-network',
73-
pollInterval: 5000,
73+
pollInterval: 100,
7474
notifyOnNetworkStatusChange: true,
7575
errorPolicy: 'all'
7676
});
7777

7878
const { data: edgesData, loading: edgesLoading } = useQuery(GET_EDGES, {
7979
fetchPolicy: 'cache-and-network',
80-
pollInterval: 5000, // Also poll edges for consistency
80+
pollInterval: 100, // Also poll edges for consistency
8181
notifyOnNetworkStatusChange: true
8282
});
8383

packages/web/src/components/InteractiveGraphVisualization.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function InteractiveGraphVisualization() {
7373
}
7474
} : { where: {} },
7575
fetchPolicy: currentGraph ? 'cache-and-network' : 'cache-only',
76-
pollInterval: currentGraph ? 5000 : 0,
76+
pollInterval: currentGraph ? 100 : 0,
7777
errorPolicy: 'all'
7878
});
7979

@@ -88,7 +88,7 @@ export function InteractiveGraphVisualization() {
8888
}
8989
} : { where: {} },
9090
fetchPolicy: currentGraph ? 'cache-and-network' : 'cache-only',
91-
pollInterval: currentGraph ? 5000 : 0,
91+
pollInterval: currentGraph ? 100 : 0,
9292
errorPolicy: 'all'
9393
});
9494

@@ -105,7 +105,8 @@ export function InteractiveGraphVisualization() {
105105
}
106106
} : { where: {} }
107107
}
108-
]
108+
],
109+
awaitRefetchQueries: true
109110
});
110111

111112
// Mutation for creating edges

0 commit comments

Comments
 (0)