Class: Clacky::UI2::Components::CommonComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Clacky::UI2::Components::CommonComponent
- Defined in:
- lib/clacky/ui2/components/common_component.rb
Overview
CommonComponent renders common UI elements (progress, success, error, warning)
Instance Method Summary collapse
-
#render_error(message) ⇒ String
Render error message.
-
#render_progress(message) ⇒ String
Render progress indicator (stopped state, gray).
-
#render_success(message) ⇒ String
Render success 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_warning(message) ⇒ String
Render warning message.
-
#render_working(message) ⇒ String
Render working indicator (active state, yellow).
Methods inherited from BaseComponent
Constructor Details
This class inherits a constructor from Clacky::UI2::Components::BaseComponent
Instance Method Details
#render_error(message) ⇒ String
Render error message
48 49 50 51 52 |
# File 'lib/clacky/ui2/components/common_component.rb', line 48 def render_error() symbol = format_symbol(:error) text = format_text(, :error) "#{symbol} #{text}" end |
#render_progress(message) ⇒ String
Render progress indicator (stopped state, gray)
21 22 23 24 25 |
# File 'lib/clacky/ui2/components/common_component.rb', line 21 def render_progress() symbol = format_symbol(:thinking) text = format_text(, :thinking) "#{symbol} #{text}" end |
#render_success(message) ⇒ String
Render success message
39 40 41 42 43 |
# File 'lib/clacky/ui2/components/common_component.rb', line 39 def render_success() symbol = format_symbol(:success) text = format_text(, :success) "#{symbol} #{text}" end |
#render_task_complete(iterations:, cost:, duration: nil, cache_tokens: nil, cache_requests: nil, cache_hits: nil) ⇒ String
Render task completion summary
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/clacky/ui2/components/common_component.rb', line 71 def render_task_complete(iterations:, cost:, duration: nil, cache_tokens: nil, cache_requests: nil, cache_hits: nil) lines = [] lines << "" lines << @pastel.dim("─" * 60) lines << render_success("Task Complete") lines << "" # Display each stat on a separate line lines << " Iterations: #{iterations}" lines << " Cost: $#{cost.round(4)}" lines << " Duration: #{duration.round(1)}s" if duration # Display cache information if available if cache_tokens && cache_tokens > 0 lines << " Cache Tokens: #{cache_tokens} tokens" end if cache_requests && cache_requests > 0 hit_rate = cache_hits > 0 ? ((cache_hits.to_f / cache_requests) * 100).round(1) : 0 lines << " Cache Requests: #{cache_requests} (#{cache_hits} hits, #{hit_rate}% hit rate)" end lines.join("\n") end |
#render_thinking ⇒ String
Render thinking indicator
12 13 14 15 16 |
# File 'lib/clacky/ui2/components/common_component.rb', line 12 def render_thinking symbol = format_symbol(:thinking) text = format_text("Thinking...", :thinking) "#{symbol} #{text}" end |
#render_warning(message) ⇒ String
Render warning message
57 58 59 60 61 |
# File 'lib/clacky/ui2/components/common_component.rb', line 57 def render_warning() symbol = format_symbol(:warning) text = format_text(, :warning) "#{symbol} #{text}" end |
#render_working(message) ⇒ String
Render working indicator (active state, yellow)
30 31 32 33 34 |
# File 'lib/clacky/ui2/components/common_component.rb', line 30 def render_working() symbol = format_symbol(:working) text = format_text(, :working) "#{symbol} #{text}" end |