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

Method render_tool_call

crates/opencode-tui/src/components/message.rs:133–270  ·  view source on GitHub ↗
(
        &self,
        name: &str,
        arguments: &str,
        status: &ToolCallStatus,
        result: Option<&str>,
        theme: &Theme,
    )

Source from the content-addressed store, hash-verified

131 }
132
133 fn render_tool_call(
134 &self,
135 name: &str,
136 arguments: &str,
137 status: &ToolCallStatus,
138 result: Option<&str>,
139 theme: &Theme,
140 ) -> Vec<Line<'static>> {
141 let mut lines = Vec::new();
142
143 let status_icon = match status {
144 ToolCallStatus::Pending => "◯",
145 ToolCallStatus::Running => "◐",
146 ToolCallStatus::Completed => "●",
147 ToolCallStatus::Failed => "✗",
148 };
149
150 let status_color = match status {
151 ToolCallStatus::Pending => theme.text_muted,
152 ToolCallStatus::Running => theme.warning,
153 ToolCallStatus::Completed => theme.success,
154 ToolCallStatus::Failed => theme.error,
155 };
156
157 // Tool header
158 lines.push(Line::from(vec![
159 Span::styled(status_icon, Style::default().fg(status_color)),
160 Span::raw(" "),
161 Span::styled(
162 name.to_string(),
163 Style::default()
164 .fg(theme.primary)
165 .add_modifier(Modifier::BOLD),
166 ),
167 ]));
168
169 // Dispatch to specialized tool views based on tool name
170 match name {
171 "bash" => {
172 if !arguments.is_empty() {
173 let cmd = arguments.lines().next().unwrap_or(arguments).to_string();
174 lines.push(Line::from(vec![
175 Span::styled(
176 "$ ",
177 Style::default()
178 .fg(theme.primary)
179 .add_modifier(Modifier::BOLD),
180 ),
181 Span::styled(cmd, Style::default().fg(theme.text)),
182 ]));
183 }
184 }
185 "edit" | "apply_patch" => {
186 // Show diff if result contains diff content
187 if let Some(res) = result {
188 let diff_view = DiffView::new().with_content(res);
189 let diff_lines = diff_view.to_lines(theme);
190 lines.extend(diff_lines);

Callers 1

renderMethod · 0.80

Calls 5

newFunction · 0.85
is_emptyMethod · 0.80
with_contentMethod · 0.80
countMethod · 0.80
to_linesMethod · 0.45

Tested by

no test coverage detected