Skip to content

Commit a9615df

Browse files
committed
feat(cli): move scheduled lane to full-width bottom box in flow
1 parent 122183b commit a9615df

1 file changed

Lines changed: 58 additions & 20 deletions

File tree

src/cli/presentation/flow/display.rs

Lines changed: 58 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -301,34 +301,73 @@ pub fn render_lane_boxes(lane_flow: &LaneFlowProjection, width: usize, theme: &T
301301
return String::new();
302302
}
303303

304-
let max_source_lines = lane_flow
305-
.lanes
306-
.iter()
307-
.map(|l| {
308-
let count = l.source_counts.iter().filter(|s| s.count > 0).count();
309-
if count == 0 { 1 } else { count }
310-
})
311-
.max()
312-
.unwrap_or(0);
304+
let mut regular_lanes = Vec::new();
305+
let mut scheduled_lane = None;
313306

314-
if width >= 80 {
315-
render_lane_boxes_grid(lane_flow, width, theme, max_source_lines)
316-
} else {
317-
render_lane_boxes_stacked(lane_flow, width, theme, max_source_lines)
307+
for lane in &lane_flow.lanes {
308+
if lane.name == "scheduled" {
309+
scheduled_lane = Some(lane);
310+
} else {
311+
regular_lanes.push(lane);
312+
}
313+
}
314+
315+
let mut output = String::new();
316+
317+
if !regular_lanes.is_empty() {
318+
let max_source_lines = regular_lanes
319+
.iter()
320+
.map(|l| {
321+
let count = l.source_counts.iter().filter(|s| s.count > 0).count();
322+
if count == 0 {
323+
1
324+
} else {
325+
count
326+
}
327+
})
328+
.max()
329+
.unwrap_or(0);
330+
331+
if width >= 80 {
332+
output.push_str(&render_lane_boxes_grid(
333+
&regular_lanes,
334+
width,
335+
theme,
336+
max_source_lines,
337+
));
338+
} else {
339+
output.push_str(&render_lane_boxes_stacked(
340+
&regular_lanes,
341+
width,
342+
theme,
343+
max_source_lines,
344+
));
345+
}
346+
}
347+
348+
if let Some(scheduled) = scheduled_lane {
349+
if !output.is_empty() {
350+
output.push_str("\n\n");
351+
}
352+
let scheduled_box = build_lane_box(scheduled, width, theme, 0);
353+
for line in scheduled_box.render() {
354+
writeln!(output, "{}", line).unwrap();
355+
}
318356
}
357+
358+
output.trim_end().to_string()
319359
}
320360

321361
fn render_lane_boxes_grid(
322-
lane_flow: &LaneFlowProjection,
362+
lanes: &[&LaneFlowCard],
323363
width: usize,
324364
theme: &Theme,
325365
max_source_lines: usize,
326366
) -> String {
327367
let mut output = String::new();
328368
let col_width = (width - 2) / 2;
329369

330-
let boxes: Vec<_> = lane_flow
331-
.lanes
370+
let boxes: Vec<_> = lanes
332371
.iter()
333372
.map(|lane| build_lane_box(lane, col_width, theme, max_source_lines))
334373
.collect();
@@ -364,19 +403,18 @@ fn render_lane_boxes_grid(
364403
}
365404
}
366405

367-
output.trim_end().to_string()
406+
output
368407
}
369408

370409
fn render_lane_boxes_stacked(
371-
lane_flow: &LaneFlowProjection,
410+
lanes: &[&LaneFlowCard],
372411
width: usize,
373412
theme: &Theme,
374413
max_source_lines: usize,
375414
) -> String {
376415
let mut output = String::new();
377416

378-
let boxes: Vec<_> = lane_flow
379-
.lanes
417+
let boxes: Vec<_> = lanes
380418
.iter()
381419
.map(|lane| build_lane_box(lane, width, theme, max_source_lines))
382420
.collect();

0 commit comments

Comments
 (0)