Module: TUI::Decorators::FileCallBehavior
- Included in:
- EditDecorator, ReadDecorator, WriteDecorator
- Defined in:
- lib/tui/decorators/base_decorator.rb
Overview
Client-side decorator layer for per-tool TUI rendering.
Mirrors the server’s Draper architecture but with a different specialization axis: server decorators are uniform per EVENT TYPE (tool_call, tool_result, message), while client decorators are unique per TOOL NAME (bash, read_file, web_get) — determining how each tool looks on screen.
The factory dispatches on the tool field in the structured data hash received from the server. Unknown tools fall back to generic rendering provided by this base class.
Shared rendering for file-related tool decorators (read, write, edit). Extracts the file path from input and displays it in the header line, making the target file immediately visible — like bash shows its command.
Instance Method Summary collapse
Instance Method Details
#render_call(tui) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/tui/decorators/base_decorator.rb', line 26 def render_call(tui) style = tui.style(fg: color) input_lines = data["input"].to_s.split("\n", -1) path_line = input_lines.first.to_s header = build_call_header header = "#{header} #{path_line}" unless path_line.empty? lines = [tui.line(spans: [tui.span(content: header, style: style)])] input_lines.drop(1).each do |line| lines << tui.line(spans: [tui.span(content: preserve_indentation(" #{line}"), style: style)]) end lines end |