@@ -7,18 +7,16 @@ module HUD
77 # Renders pipeline DAG as animated ASCII flow diagram with boxes and connections
88 class FlowDiagram
99
10- def initialize ( width , height )
11- @width = width
12- @height = height
10+ def initialize ( _frame_width , _frame_height )
1311 @animation_frame = 0
1412 @diagram_width = 0 # Actual width of diagram content
1513 @diagram_height = 0 # Actual height of diagram content
1614 end
1715
1816 # Update dimensions (called on resize)
19- def resize ( width , height )
20- @width = width
21- @height = height
17+ def resize ( _frame_width , _frame_height )
18+ # Dimensions not used - diagram renders in coordinate space starting at (0,0)
19+ # FlowDiagramFrame handles viewport sizing and clipping via ClippedTerminal
2220 end
2321
2422 # Calculate layout and return diagram dimensions
@@ -89,15 +87,20 @@ def calculate_layout(stages, dag)
8987 # Calculate layers based on DAG topological depth
9088 layers = calculate_layers_from_dag ( stages , dag )
9189
90+ # Find maximum layer width to center layers relative to each other
91+ max_layer_width = layers . map do |layer_stages |
92+ ( layer_stages . size * box_width ) + ( ( layer_stages . size - 1 ) * box_spacing )
93+ end . max || 0
94+
9295 # Position stages in each layer (centered relative to each other)
9396 layers . each_with_index do |layer_stages , layer_idx |
9497 y = 0 + ( layer_idx * layer_height )
9598
9699 # Calculate total width needed for this layer
97100 total_width = ( layer_stages . size * box_width ) + ( ( layer_stages . size - 1 ) * box_spacing )
98101
99- # Center this layer horizontally (within a large virtual canvas)
100- start_x = ( @width - total_width ) / 2
102+ # Center this layer relative to the widest layer
103+ start_x = ( max_layer_width - total_width ) / 2
101104
102105 # Position each stage in the layer horizontally
103106 layer_stages . each_with_index do |stage_name , stage_idx |
0 commit comments