@@ -42,7 +42,7 @@ import {
4242 isNil ,
4343 isTrue ,
4444} from '../../../utils'
45- import { EnumSize , EnumVariant } from '~/types/enum'
45+ import { EnumSide , EnumSize , EnumVariant , type Side } from '~/types/enum'
4646import {
4747 ArrowRightCircleIcon ,
4848 InformationCircleIcon ,
@@ -139,13 +139,13 @@ const ModelColumnDisplay = memo(function ModelColumnDisplay({
139139 < CodeEditor . SQLMeshDialect
140140 content = { source }
141141 type = { EnumFileExtensions . SQL }
142- className = "scrollbar--vertical-md scrollbar--horizontal-md !h-[25vh] !max-w-[30rem]"
142+ className = "scrollbar--vertical-md scrollbar--horizontal-md overflow-auto !h-[25vh] !max-w-[30rem]"
143143 >
144144 { ( { extensions, content } ) => (
145145 < CodeEditor
146146 extensions = { extensions . concat ( modelExtensions ) }
147147 content = { content }
148- className = "text-xs"
148+ className = "text-xs pr-2 "
149149 />
150150 ) }
151151 </ CodeEditor . SQLMeshDialect >
@@ -209,23 +209,23 @@ const ModelNodeHandles = memo(function ModelNodeHandles({
209209 className ,
210210 ) }
211211 >
212- { hasRight && (
212+ { hasLeft && (
213213 < Handle
214214 type = "target"
215- id = { toNodeOrEdgeId ( 'right' , id ) }
216- position = { Position . Right }
215+ id = { toNodeOrEdgeId ( EnumSide . Left , id ) }
216+ position = { Position . Left }
217217 isConnectable = { false }
218218 className = { clsx (
219219 'w-2 h-2 rounded-full !bg-secondary-500 dark:!bg-primary-500' ,
220220 ) }
221221 />
222222 ) }
223223 { children }
224- { hasLeft && (
224+ { hasRight && (
225225 < Handle
226226 type = "source"
227- id = { toNodeOrEdgeId ( 'left' , id ) }
228- position = { Position . Left }
227+ id = { toNodeOrEdgeId ( EnumSide . Right , id ) }
228+ position = { Position . Right }
229229 isConnectable = { false }
230230 className = { clsx (
231231 'w-2 h-2 rounded-full !bg-secondary-500 dark:!bg-primary-500' ,
@@ -261,16 +261,16 @@ const ModelNodeHeaderHandles = memo(function ModelNodeHeaderHandles({
261261 className ,
262262 ) }
263263 >
264- { hasRight && (
264+ { hasLeft && (
265265 < Handle
266266 type = "target"
267- id = { toNodeOrEdgeId ( 'right' , id ) }
268- position = { Position . Right }
267+ id = { toNodeOrEdgeId ( EnumSide . Left , id ) }
268+ position = { Position . Left }
269269 isConnectable = { false }
270- className = { clsx (
271- 'w-2 h-2 rounded-full !bg-secondary-500 dark:!bg-primary-500' ,
272- ) }
273- / >
270+ className = { clsx ( '!bg-transparent -ml-2 dark:text-primary-500' ) }
271+ >
272+ < ArrowRightCircleIcon className = "w-5 bg-theme rounded-full" />
273+ </ Handle >
274274 ) }
275275 < span className = "inline-block w-full" >
276276 { type != null && (
@@ -288,6 +288,7 @@ const ModelNodeHeaderHandles = memo(function ModelNodeHeaderHandles({
288288 { type === 'sql' && 'SQL' }
289289 { type === 'seed' && 'Seed' }
290290 { type === 'cte' && 'CTE' }
291+ { type === 'external' && 'External' }
291292 </ span >
292293 ) }
293294 < span
@@ -300,16 +301,16 @@ const ModelNodeHeaderHandles = memo(function ModelNodeHeaderHandles({
300301 { label }
301302 </ span >
302303 </ span >
303- { hasLeft && (
304+ { hasRight && (
304305 < Handle
305306 type = "source"
306- id = { toNodeOrEdgeId ( 'left' , id ) }
307- position = { Position . Left }
307+ id = { toNodeOrEdgeId ( EnumSide . Right , id ) }
308+ position = { Position . Right }
308309 isConnectable = { false }
309- className = { clsx ( '!bg-transparent -ml-2 dark:text-primary-500' ) }
310- >
311- < ArrowRightCircleIcon className = "w-5 bg-theme rounded-full" />
312- </ Handle >
310+ className = { clsx (
311+ 'w-2 h-2 rounded-full !bg-secondary-500 dark:!bg-primary-500' ,
312+ ) }
313+ / >
313314 ) }
314315 </ div >
315316 )
@@ -388,7 +389,7 @@ const ModelColumn = memo(function ModelColumn({
388389
389390 debouncedGetColumnLineage ( column . name )
390391 . then ( data => {
391- setIsEmpty ( hasNoModels ( ) )
392+ setIsEmpty ( hasNoModels ( data ) )
392393 updateColumnLineage ( data )
393394 } )
394395 . catch ( error => {
@@ -577,13 +578,23 @@ const ModelColumns = memo(function ModelColumns({
577578
578579 const removeEdges = useCallback (
579580 function removeEdges ( columnId : string ) : void {
581+ const visited = new Set < string > ( )
582+
580583 removeActiveEdges (
581- [ columnId , walk ( columnId , 'left' ) , walk ( columnId , 'right' ) ] . flat ( ) ,
584+ [
585+ columnId ,
586+ walk ( columnId , EnumSide . Left ) ,
587+ walk ( columnId , EnumSide . Right ) ,
588+ ] . flat ( ) ,
582589 )
583590
584- function walk ( id : string , side : 'left' | 'right' ) : string [ ] {
591+ function walk ( id : string , side : Side ) : string [ ] {
592+ if ( visited . has ( id ) ) return [ ]
593+
585594 const edges = connections . get ( id ) ?. [ side ] ?? [ ]
586595
596+ visited . add ( id )
597+
587598 return [ id , edges . map ( edge => walk ( edge , side ) ) ] . flat (
588599 Infinity ,
589600 ) as string [ ]
@@ -768,7 +779,6 @@ function ModelColumnLineage({
768779 void createGraphLayout ( nodesAndEdges )
769780 . then ( layout => {
770781 toggleEdgeAndNodes ( layout . edges , layout . nodes )
771-
772782 setIsBuildingLayout (
773783 isArrayEmpty ( layout . nodes ) || isArrayEmpty ( layout . edges ) ,
774784 )
@@ -806,7 +816,7 @@ function ModelColumnLineage({
806816
807817 visibility . set (
808818 edge . source ,
809- isFalse ( visibility . get ( edge . source ) ) ? false : edge . hidden ,
819+ isFalse ( visibility . has ( edge . source ) ) ? false : edge . hidden ,
810820 )
811821 }
812822
@@ -944,8 +954,8 @@ function ModelNode({
944954 showColumns ? 'rounded-t-lg' : 'rounded-lg' ,
945955 isCTE ? 'bg-accent-500' : 'bg-secondary-100 dark:bg-primary-900' ,
946956 ) }
947- hasLeft = { sourcePosition === Position . Left }
948- hasRight = { targetPosition === Position . Right }
957+ hasLeft = { targetPosition === Position . Left }
958+ hasRight = { sourcePosition === Position . Right }
949959 handleClick = { isInteractive ? handleClick : undefined }
950960 />
951961 </ div >
0 commit comments