Class: TUI::Decorators::ThinkDecorator

Inherits:
BaseDecorator show all
Defined in:
lib/tui/decorators/think_decorator.rb

Overview

Renders think tool events — the agent’s inner reasoning. Both “aloud” and “inner” thoughts use grey (dark_gray) to visually de-emphasize reasoning content vs. actual conversation output.

Constant Summary collapse

THOUGHT_BUBBLE =

thought balloon

"\u{1F4AD}"

Constants inherited from BaseDecorator

BaseDecorator::CHECKMARK, BaseDecorator::ERROR_ICON, BaseDecorator::ICON, BaseDecorator::RETURN_ARROW

Instance Attribute Summary

Attributes inherited from BaseDecorator

#data

Instance Method Summary collapse

Methods inherited from BaseDecorator

#color, for, #initialize, #render, #render_call, #render_response, #response_color

Methods included from Formatting

#format_ns_timestamp, #format_token_label, #preserve_indentation, #token_count_color

Constructor Details

This class inherits a constructor from TUI::Decorators::BaseDecorator

Instance Method Details

#iconObject



11
12
13
# File 'lib/tui/decorators/think_decorator.rb', line 11

def icon
  THOUGHT_BUBBLE
end

#render_think(tui) ⇒ Array<RatatuiRuby::Widgets::Line>

Think events always dispatch here via BaseDecorator#render.

Parameters:

  • tui (RatatuiRuby)

    TUI rendering API

Returns:

  • (Array<RatatuiRuby::Widgets::Line>)


19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/tui/decorators/think_decorator.rb', line 19

def render_think(tui)
  style = tui.style(fg: Settings.theme_color_muted)
  ts = data["timestamp"]

  meta = []
  meta << "[#{format_ns_timestamp(ts)}]" if ts
  header = meta.empty? ? icon : "#{meta.join(" ")} #{icon}"

  content_lines = data["content"].to_s.split("\n", -1)
  lines = [tui.line(spans: [tui.span(content: "#{header} #{content_lines.first}", style: style)])]
  content_lines.drop(1).each { |line| lines << tui.line(spans: [tui.span(content: preserve_indentation("  #{line}"), style: style)]) }
  lines
end