MCPcopy Create free account
hub / github.com/evilsocket/cake / render_node

Function render_node

cake-cli/src/chat.rs:636–728  ·  view source on GitHub ↗
(
    lines: &mut Vec<Line<'static>>,
    name: &str,
    backend: &str,
    os: &str,
    vram_bytes: u64,
    tflops: f64,
    layers: &[String],
    max_vram: u64,
    bar_max_width: usize,
    col

Source from the content-addressed store, hash-verified

634
635#[allow(clippy::too_many_arguments)]
636fn render_node(
637 lines: &mut Vec<Line<'static>>,
638 name: &str,
639 backend: &str,
640 os: &str,
641 vram_bytes: u64,
642 tflops: f64,
643 layers: &[String],
644 max_vram: u64,
645 bar_max_width: usize,
646 color: Color,
647 is_master: bool,
648) {
649 lines.push(Line::from(""));
650
651 // Node header
652 let role = if is_master { " (master)" } else { "" };
653 lines.push(Line::from(vec![
654 Span::styled(
655 format!(" {}{}", name, role),
656 Style::default().fg(color).add_modifier(Modifier::BOLD),
657 ),
658 ]));
659
660 // Backend + OS
661 let mut info_spans = vec![Span::raw(" ")];
662 if !backend.is_empty() {
663 info_spans.push(Span::styled(
664 backend.to_string(),
665 Style::default().fg(Color::White),
666 ));
667 }
668 if !os.is_empty() {
669 if !backend.is_empty() {
670 info_spans.push(Span::styled(" / ", Style::default().fg(Color::DarkGray)));
671 }
672 info_spans.push(Span::styled(
673 os.to_string(),
674 Style::default().fg(Color::DarkGray),
675 ));
676 }
677 if !info_spans.is_empty() {
678 lines.push(Line::from(info_spans));
679 }
680
681 // VRAM bar
682 if vram_bytes > 0 {
683 let bar_filled = ((vram_bytes as f64 / max_vram as f64) * bar_max_width as f64) as usize;
684 let bar_filled = bar_filled.max(1).min(bar_max_width);
685 let bar_empty = bar_max_width.saturating_sub(bar_filled);
686 lines.push(Line::from(vec![
687 Span::styled(" VRAM ", Style::default().fg(Color::DarkGray)),
688 Span::styled(
689 "\u{2588}".repeat(bar_filled),
690 Style::default().fg(color),
691 ),
692 Span::styled(
693 "\u{2591}".repeat(bar_empty),

Callers 1

build_cluster_linesFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected