Class: Clacky::UI2::ViewRenderer
- Inherits:
-
Object
- Object
- Clacky::UI2::ViewRenderer
- Defined in:
- lib/clacky/ui2/view_renderer.rb
Overview
ViewRenderer coordinates all UI components and provides a unified rendering interface
Instance Method Summary collapse
-
#initialize ⇒ ViewRenderer
constructor
A new instance of ViewRenderer.
-
#render_assistant_message(content, timestamp: nil) ⇒ String
Render an assistant message.
-
#render_error(message) ⇒ String
Render error message.
-
#render_progress(message) ⇒ String
Render progress message (stopped state, gray).
-
#render_success(message) ⇒ String
Render success message.
-
#render_system_message(content, timestamp: nil, prefix_newline: true) ⇒ String
Render a system message.
-
#render_task_complete(iterations:, cost:, duration: nil, cache_tokens: nil, cache_requests: nil, cache_hits: nil) ⇒ String
Render task completion summary.
-
#render_thinking ⇒ String
Render thinking indicator.
-
#render_tool_call(tool_name:, formatted_call:) ⇒ String
Render a tool call.
-
#render_tool_denied(tool_name:) ⇒ String
Render a tool denied message.
-
#render_tool_error(error:) ⇒ String
Render a tool error.
-
#render_tool_planned(tool_name:) ⇒ String
Render a tool planned message.
-
#render_tool_result(result:) ⇒ String
Render a tool result.
-
#render_user_message(content, timestamp: nil, files: []) ⇒ String
Render a user message.
-
#render_warning(message) ⇒ String
Render warning message.
-
#render_working(message) ⇒ String
Render working message (active state, yellow).
Constructor Details
#initialize ⇒ ViewRenderer
Returns a new instance of ViewRenderer.
12 13 14 15 16 |
# File 'lib/clacky/ui2/view_renderer.rb', line 12 def initialize @message_component = Components::MessageComponent.new @tool_component = Components::ToolComponent.new @common_component = Components::CommonComponent.new end |
Instance Method Details
#render_assistant_message(content, timestamp: nil) ⇒ String
Render an assistant message
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/clacky/ui2/view_renderer.rb', line 36 def (content, timestamp: nil) # Render markdown if content contains markdown syntax rendered_content = if MarkdownRenderer.markdown?(content) MarkdownRenderer.render(content) else content end @message_component.render( role: "assistant", content: rendered_content, timestamp: ) end |
#render_error(message) ⇒ String
Render error message
147 148 149 |
# File 'lib/clacky/ui2/view_renderer.rb', line 147 def render_error() @common_component.render_error() end |
#render_progress(message) ⇒ String
Render progress message (stopped state, gray)
126 127 128 |
# File 'lib/clacky/ui2/view_renderer.rb', line 126 def render_progress() @common_component.render_progress() end |
#render_success(message) ⇒ String
Render success message
140 141 142 |
# File 'lib/clacky/ui2/view_renderer.rb', line 140 def render_success() @common_component.render_success() end |
#render_system_message(content, timestamp: nil, prefix_newline: true) ⇒ String
Render a system message
56 57 58 59 60 61 62 63 |
# File 'lib/clacky/ui2/view_renderer.rb', line 56 def (content, timestamp: nil, prefix_newline: true) @message_component.render( role: "system", content: content, timestamp: , prefix_newline: prefix_newline ) end |
#render_task_complete(iterations:, cost:, duration: nil, cache_tokens: nil, cache_requests: nil, cache_hits: nil) ⇒ String
Render task completion summary
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/clacky/ui2/view_renderer.rb', line 166 def render_task_complete(iterations:, cost:, duration: nil, cache_tokens: nil, cache_requests: nil, cache_hits: nil) @common_component.render_task_complete( iterations: iterations, cost: cost, duration: duration, cache_tokens: cache_tokens, cache_requests: cache_requests, cache_hits: cache_hits ) end |
#render_thinking ⇒ String
Render thinking indicator
119 120 121 |
# File 'lib/clacky/ui2/view_renderer.rb', line 119 def render_thinking @common_component.render_thinking end |
#render_tool_call(tool_name:, formatted_call:) ⇒ String
Render a tool call
69 70 71 72 73 74 75 |
# File 'lib/clacky/ui2/view_renderer.rb', line 69 def render_tool_call(tool_name:, formatted_call:) @tool_component.render( type: :call, tool_name: tool_name, formatted_call: formatted_call ) end |
#render_tool_denied(tool_name:) ⇒ String
Render a tool denied message
100 101 102 103 104 105 |
# File 'lib/clacky/ui2/view_renderer.rb', line 100 def render_tool_denied(tool_name:) @tool_component.render( type: :denied, tool_name: tool_name ) end |
#render_tool_error(error:) ⇒ String
Render a tool error
90 91 92 93 94 95 |
# File 'lib/clacky/ui2/view_renderer.rb', line 90 def render_tool_error(error:) @tool_component.render( type: :error, error: error ) end |
#render_tool_planned(tool_name:) ⇒ String
Render a tool planned message
110 111 112 113 114 115 |
# File 'lib/clacky/ui2/view_renderer.rb', line 110 def render_tool_planned(tool_name:) @tool_component.render( type: :planned, tool_name: tool_name ) end |
#render_tool_result(result:) ⇒ String
Render a tool result
80 81 82 83 84 85 |
# File 'lib/clacky/ui2/view_renderer.rb', line 80 def render_tool_result(result:) @tool_component.render( type: :result, result: result ) end |
#render_user_message(content, timestamp: nil, files: []) ⇒ String
Render a user message
23 24 25 26 27 28 29 30 |
# File 'lib/clacky/ui2/view_renderer.rb', line 23 def (content, timestamp: nil, files: []) @message_component.render( role: "user", content: content, timestamp: , files: files ) end |
#render_warning(message) ⇒ String
Render warning message
154 155 156 |
# File 'lib/clacky/ui2/view_renderer.rb', line 154 def render_warning() @common_component.render_warning() end |
#render_working(message) ⇒ String
Render working message (active state, yellow)
133 134 135 |
# File 'lib/clacky/ui2/view_renderer.rb', line 133 def render_working() @common_component.render_working() end |