MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / render

Method render

crates/opencode-tui/src/components/dialogs/subagent.rs:68–121  ·  view source on GitHub ↗
(&self, frame: &mut Frame, area: Rect, theme: &Theme)

Source from the content-addressed store, hash-verified

66 }
67
68 pub fn render(&self, frame: &mut Frame, area: Rect, theme: &Theme) {
69 if !self.open {
70 return;
71 }
72
73 let subagent = match &self.subagent {
74 Some(s) => s,
75 None => return,
76 };
77
78 let height = area.height.saturating_sub(4).min(20);
79 let width = area.width.saturating_sub(4).min(80);
80 let popup_area = super::centered_rect(width, height, area);
81
82 let title = format!(" Subagent: {} [{}] ", subagent.name, subagent.category);
83
84 let mut lines = Vec::new();
85 lines.push(Line::from(Span::styled(
86 &title,
87 Style::default().fg(theme.primary).bold(),
88 )));
89 lines.push(Line::from(""));
90
91 for msg in &subagent.messages {
92 let role_style = if msg.role == "user" {
93 Style::default().fg(theme.primary)
94 } else {
95 Style::default().fg(theme.success)
96 };
97 lines.push(Line::from(vec![
98 Span::styled(&msg.role, role_style.bold()),
99 Span::raw(":"),
100 ]));
101 lines.push(Line::from(Span::styled(
102 &msg.content,
103 Style::default().fg(theme.text),
104 )));
105 lines.push(Line::from(""));
106 }
107
108 let block = Block::default()
109 .title(" Subagent ")
110 .borders(Borders::ALL)
111 .border_style(Style::default().fg(theme.border))
112 .style(Style::default().bg(theme.background_panel));
113 let content_area = super::dialog_inner(block.inner(popup_area));
114 frame.render_widget(block, popup_area);
115
116 let paragraph = Paragraph::new(lines)
117 .style(Style::default().bg(theme.background_panel))
118 .scroll((self.scroll_offset, 0));
119
120 frame.render_widget(paragraph, content_area);
121 }
122}
123
124impl Default for SubagentDialog {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
dialog_innerFunction · 0.85
centered_rectFunction · 0.70
titleMethod · 0.45

Tested by

no test coverage detected