@@ -209,25 +209,27 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
209209 chart . elements ( ) . filter ( el => [ ...p . nodes , ...p . edges ] . some ( e => e . id == el . id ( ) ) ) . layout ( LAYOUT ) . run ( ) ;
210210 } else {
211211 const elements : any = { nodes : [ ] , edges : [ ] } ;
212-
213212 [ ...p . nodes , ...p . edges ] . forEach ( e => {
214213 let element = chart . elements ( `#${ e . id } ` )
215214 if ( element . length === 0 ) {
216- const type = "src_node" in e
215+ const type = e . id . startsWith ( "_" )
217216 e = type ? { ...e , id : e . id . slice ( 1 ) } : e
218217 type
219218 ? elements . edges . push ( e )
220219 : elements . nodes . push ( e )
221220 }
222221 } )
223222
224- chart . add ( graph . extend ( elements ) )
225- chart . elements ( ) . filter ( ( e ) => [ ...p . nodes , ...p . edges ] . some ( ( el ) => el . id == e . id ( ) ) ) . forEach ( ( e ) => {
223+ chart . elements ( ) . filter ( ( e ) => {
224+ console . log ( e . id ( ) ) ;
225+ return [ ...p . nodes , ...p . edges ] . some ( ( el ) => el . id == e . id ( ) )
226+ } ) . forEach ( ( e ) => {
226227 if ( e . id ( ) == p . nodes [ 0 ] . id || e . id ( ) == p . nodes [ p . nodes . length - 1 ] . id ) {
227228 e . removeStyle ( ) . style ( SELECTED_PATH_NODE_STYLE ) ;
228229 } else if ( e . isNode ( ) ) {
229230 e . removeStyle ( ) . style ( PATH_NODE_STYLE ) ;
230231 }
232+
231233 if ( e . isEdge ( ) ) {
232234 e . removeStyle ( ) . style ( SELECTED_PATH_EDGE_STYLE ) ;
233235 }
@@ -455,13 +457,22 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
455457 key = { i }
456458 className = { cn (
457459 "flex text-wrap border p-2 gap-2 rounded-md" ,
458- p . nodes . length === selectedPath ?. nodes . length &&
459- selectedPath ?. nodes . every ( node => p ?. nodes . some ( ( n ) => n . id === node . id ) ) && selectedPath . nodes . length === p . nodes . length && "border-[#FF66B3] bg-[#FFF0F7]" ,
460+ p . nodes . length === selectedPath ?. nodes . length
461+ && selectedPath ?. nodes . every ( node => p ?. nodes . some ( ( n ) => n . id === node . id ) )
462+ && "border-[#FF66B3] bg-[#FFF0F7]" ,
460463 message . graphName !== graph . Id && "opacity-50 bg-gray-200"
461464 ) }
462465 title = { message . graphName !== graph . Id ? `Move to graph ${ message . graphName } to use this path` : undefined }
463466 disabled = { message . graphName !== graph . Id }
464467 onClick = { ( ) => {
468+ if ( message . graphName !== graph . Id ) {
469+ toast ( {
470+ title : "Path Disabled" ,
471+ description : "The path is disabled because it is not from this graph." ,
472+ } ) ;
473+ return ;
474+ }
475+
465476 if ( p . nodes . length === selectedPath ?. nodes . length &&
466477 selectedPath ?. nodes . every ( node => p ?. nodes . some ( ( n ) => n . id === node . id ) ) ) return ;
467478 handleSetSelectedPath ( p ) ;
@@ -470,13 +481,11 @@ export function Chat({ repo, path, setPath, graph, chartRef, selectedPathId, isP
470481 >
471482 < p className = "font-bold" > #{ i + 1 } </ p >
472483 < div className = "flex flex-wrap" >
473- {
474- p . nodes . map ( ( node : any , j : number ) => (
475- < span key = { j } className = { cn ( ( j === 0 || j === p . nodes . length - 1 ) && "font-bold" ) } >
476- { ` - ${ node . properties . name } ` }
477- </ span >
478- ) )
479- }
484+ { p . nodes . map ( ( node : any , j : number ) => (
485+ < span key = { j } className = { cn ( ( j === 0 || j === p . nodes . length - 1 ) && "font-bold" ) } >
486+ { ` - ${ node . properties . name } ` }
487+ </ span >
488+ ) ) }
480489 </ div >
481490 </ button >
482491 ) )
0 commit comments