Class: ToolCallDecorator

Inherits:
MessageDecorator show all
Defined in:
app/decorators/tool_call_decorator.rb

Overview

Decorates tool_call records for display in the TUI. Hidden in basic mode — tool activity is represented by the aggregated tool counter instead. Verbose mode returns tool name and a formatted preview of the input arguments. Debug mode shows full untruncated input with tool_use_id — TOON format for most tools, but write_file tool content preserves actual newlines.

Think tool calls are special: “aloud” thoughts are shown in all view modes (with a thought bubble), while “inner” thoughts are visible only in verbose and debug modes.

Constant Summary collapse

THINK_TOOL =
"think"

Constants inherited from MessageDecorator

MessageDecorator::ERROR_ICON, MessageDecorator::MIDDLE_TRUNCATION_MARKER, MessageDecorator::RETURN_ARROW, MessageDecorator::TOOL_ICON

Instance Method Summary collapse

Methods inherited from MessageDecorator

for, #render

Instance Method Details

#render_basicHash?

In basic mode, only “aloud” think calls are visible. All other tool calls are hidden (represented by the tool counter).

Returns:

  • (Hash, nil)

    structured think data for aloud thoughts, nil otherwise



22
23
24
25
26
27
# File 'app/decorators/tool_call_decorator.rb', line 22

def render_basic
  return unless think?
  return unless aloud?

  {role: :think, content: thoughts, visibility: "aloud"}
end

#render_brainString

Think calls get full text — the agent’s reasoning IS the signal. Other tool calls show tool name + params (compact JSON).

Returns:

  • (String)

    transcript line for the analytical brain



54
55
56
57
58
59
60
# File 'app/decorators/tool_call_decorator.rb', line 54

def render_brain
  if think?
    "Think: #{thoughts}"
  else
    "Tool call: #{payload["tool_name"]}(#{tool_input.to_json})"
  end
end

#render_debugHash

Returns full tool call data with untruncated input and tool_use_id ‘:tool_call, tool: String, input: String, tool_use_id: String|nil, timestamp: Integer|nil`.

Returns:

  • (Hash)

    full tool call data with untruncated input and tool_use_id ‘:tool_call, tool: String, input: String, tool_use_id: String|nil, timestamp: Integer|nil`



39
40
41
42
43
44
45
46
47
48
49
# File 'app/decorators/tool_call_decorator.rb', line 39

def render_debug
  return render_think_debug if think?

  {
    role: :tool_call,
    tool: payload["tool_name"],
    input: format_debug_input,
    tool_use_id: payload["tool_use_id"],
    timestamp: timestamp
  }
end

#render_verboseHash

Returns structured tool call data ‘:tool_call, tool: String, input: String, timestamp: Integer|nil`.

Returns:

  • (Hash)

    structured tool call data ‘:tool_call, tool: String, input: String, timestamp: Integer|nil`



31
32
33
34
35
# File 'app/decorators/tool_call_decorator.rb', line 31

def render_verbose
  return render_think_verbose if think?

  {role: :tool_call, tool: payload["tool_name"], input: format_input, timestamp: timestamp}
end