MCPcopy Create free account
hub / github.com/GCWing/BitFun / render_task_block

Function render_task_block

src/apps/cli/src/ui/tool_cards.rs:1384–1460  ·  view source on GitHub ↗

Render a Task tool as a block (sub-agent type + description + real-time progress)

(
    tool_state: &ToolDisplayState,
    theme: &Theme,
    focused: bool,
    spinner_frame: &str,
    available_width: u16,
)

Source from the content-addressed store, hash-verified

1382
1383/// Render a Task tool as a block (sub-agent type + description + real-time progress)
1384fn render_task_block(
1385 tool_state: &ToolDisplayState,
1386 theme: &Theme,
1387 focused: bool,
1388 spinner_frame: &str,
1389 available_width: u16,
1390) -> ToolCardRenderOutput {
1391 let subagent_type = param_str_opt(&tool_state.parameters, &["subagent_type"])
1392 .unwrap_or_else(|| "Unknown".to_string());
1393 let description = param_str_opt(&tool_state.parameters, &["description"])
1394 .unwrap_or_else(|| "Task".to_string());
1395 let is_running = matches!(
1396 tool_state.status,
1397 ToolDisplayStatus::Running | ToolDisplayStatus::Streaming
1398 );
1399
1400 let title = format!("{} Task", capitalize_first(&subagent_type));
1401
1402 // Build description line with tool call count (if available)
1403 let desc_text = if let Some(ref progress) = tool_state.subagent_progress {
1404 if progress.tool_count > 0 {
1405 format!("{} ({} toolcalls)", description, progress.tool_count)
1406 } else {
1407 description.clone()
1408 }
1409 } else {
1410 description.clone()
1411 };
1412
1413 let mut content_lines = vec![Line::from(Span::styled(
1414 desc_text,
1415 theme.style(StyleKind::Muted),
1416 ))];
1417
1418 // Show real-time subagent progress (current tool being executed)
1419 if is_running {
1420 if let Some(ref progress) = tool_state.subagent_progress {
1421 if let Some(ref tool_name) = progress.current_tool_name {
1422 let progress_text = if let Some(ref title) = progress.current_tool_title {
1423 format!("\u{2514} {} {}", capitalize_first(tool_name), title)
1424 // └
1425 } else {
1426 format!("\u{2514} {}", capitalize_first(tool_name)) // └
1427 };
1428 content_lines.push(Line::from(Span::styled(
1429 progress_text,
1430 theme.style(StyleKind::Muted),
1431 )));
1432 }
1433 }
1434 }
1435
1436 // Show final result when completed
1437 if let Some(ref result) = tool_state.result {
1438 let max_width = block_content_max_width(available_width)
1439 .saturating_sub(2)
1440 .max(1);
1441 for line in wrap_display_lines(result, max_width) {

Callers 1

render_block_dispatchFunction · 0.85

Calls 7

param_str_optFunction · 0.85
block_content_max_widthFunction · 0.85
wrap_display_linesFunction · 0.85
assemble_blockFunction · 0.85
styleMethod · 0.80
cloneMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected