Class: Aidp::Harness::StatusDisplay
- Inherits:
-
Object
- Object
- Aidp::Harness::StatusDisplay
- Includes:
- MessageDisplay
- Defined in:
- lib/aidp/harness/status_display.rb
Overview
Real-time status updates and monitoring interface
Defined Under Namespace
Classes: AlertManager, DisplayAnimator, MetricsCalculator, StatusFormatter
Constant Summary
Constants included from MessageDisplay
Instance Method Summary collapse
-
#cleanup ⇒ Object
Cleanup display.
-
#configure_display(config) ⇒ Object
Configure display settings.
-
#display_mode(mode) ⇒ Object
Set display mode.
-
#export_status_data(format = :json) ⇒ Object
Export status data.
-
#initialize(provider_manager = nil, metrics_manager = nil, circuit_breaker_manager = nil, error_logger = nil, prompt: TTY::Prompt.new) ⇒ StatusDisplay
constructor
A new instance of StatusDisplay.
-
#show_completion_status(duration, steps_completed, total_steps) ⇒ Object
Show completion status.
-
#show_error_status(error_message) ⇒ Object
Show error status.
-
#show_paused_status ⇒ Object
Show paused status.
-
#show_rate_limit_wait(reset_time) ⇒ Object
Show rate limit wait.
-
#show_resumed_status ⇒ Object
Show resumed status.
-
#show_stopped_status ⇒ Object
Show stopped status.
-
#start_status_updates(display_mode = :compact, async_updates: true) ⇒ Object
Start real-time status updates.
-
#status_data ⇒ Object
Get comprehensive status data.
-
#stop_status_updates ⇒ Object
Stop status updates.
-
#update_current_model(_provider_name, model_name) ⇒ Object
Update current model.
-
#update_current_provider(provider_name) ⇒ Object
Update current provider.
-
#update_current_step(step_name) ⇒ Object
Update current step.
-
#update_error_summary(error_summary) ⇒ Object
Update error summary.
-
#update_interval(interval) ⇒ Object
Set update interval.
-
#update_performance_metrics(metrics) ⇒ Object
Update performance metrics.
-
#update_rate_limit_countdown(remaining_seconds) ⇒ Object
Update rate limit countdown.
-
#update_rate_limit_status(provider, model, rate_limit_info) ⇒ Object
Update rate limit status.
-
#update_recovery_status(recovery_type, status, details = {}) ⇒ Object
Update recovery status.
-
#update_token_usage(provider, model, tokens_used, tokens_remaining = nil) ⇒ Object
Update token usage.
-
#update_user_feedback_status(feedback_type, status, details = {}) ⇒ Object
Update user feedback status.
-
#update_work_completion_status(completion_info) ⇒ Object
Update work completion status.
Methods included from MessageDisplay
#display_message, included, #message_display_prompt
Constructor Details
#initialize(provider_manager = nil, metrics_manager = nil, circuit_breaker_manager = nil, error_logger = nil, prompt: TTY::Prompt.new) ⇒ StatusDisplay
Returns a new instance of StatusDisplay.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/aidp/harness/status_display.rb', line 12 def initialize(provider_manager = nil, metrics_manager = nil, circuit_breaker_manager = nil, error_logger = nil, prompt: TTY::Prompt.new) @provider_manager = provider_manager @metrics_manager = metrics_manager @circuit_breaker_manager = circuit_breaker_manager @error_logger = error_logger @prompt = prompt @cursor = TTY::Cursor @start_time = nil @current_step = nil @current_provider = nil @current_model = nil @status_thread = nil @running = false @display_mode = :compact @update_interval = 2 @last_update = Time.now @status_data = {} @performance_metrics = {} @error_summary = {} @provider_status = {} @model_status = {} @circuit_breaker_status = {} @token_usage = {} @rate_limit_status = {} @recovery_status = {} @user_feedback_status = {} @work_completion_status = {} @configuration = {} @display_config = initialize_display_config @status_formatter = StatusFormatter.new @metrics_calculator = MetricsCalculator.new @alert_manager = AlertManager.new @display_animator = DisplayAnimator.new end |
Instance Method Details
#cleanup ⇒ Object
Cleanup display
248 249 250 251 |
# File 'lib/aidp/harness/status_display.rb', line 248 def cleanup stop_status_updates clear_display end |
#configure_display(config) ⇒ Object
Configure display settings
183 184 185 |
# File 'lib/aidp/harness/status_display.rb', line 183 def configure_display(config) @display_config.merge!(config) end |
#display_mode(mode) ⇒ Object
Set display mode
171 172 173 174 |
# File 'lib/aidp/harness/status_display.rb', line 171 def display_mode(mode) @display_mode = mode @display_config[:mode] = mode end |
#export_status_data(format = :json) ⇒ Object
Export status data
271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/aidp/harness/status_display.rb', line 271 def export_status_data(format = :json) case format when :json JSON.pretty_generate(status_data) when :yaml status_data.to_yaml when :text format_status_as_text else raise ArgumentError, "Unsupported format: #{format}" end end |
#show_completion_status(duration, steps_completed, total_steps) ⇒ Object
Show completion status
231 232 233 234 235 236 237 |
# File 'lib/aidp/harness/status_display.rb', line 231 def show_completion_status(duration, steps_completed, total_steps) clear_display ("\n✅ Harness COMPLETED", type: :success) (" Duration: #{format_duration(duration)}", type: :info) (" Steps completed: #{steps_completed}/#{total_steps}", type: :info) (" All workflows finished successfully!", type: :success) end |
#show_error_status(error_message) ⇒ Object
Show error status
240 241 242 243 244 245 |
# File 'lib/aidp/harness/status_display.rb', line 240 def show_error_status() clear_display ("\n❌ Harness ERROR", type: :error) (" Error: #{error_message}", type: :error) (" Check logs for details", type: :info) end |
#show_paused_status ⇒ Object
Show paused status
188 189 190 191 192 193 194 195 196 |
# File 'lib/aidp/harness/status_display.rb', line 188 def show_paused_status clear_display ("\n⏸️ Harness PAUSED", type: :warning) (" Press 'r' to resume, 's' to stop", type: :info) (" Current step: #{@current_step}", type: :info) if @current_step (" Current provider: #{@current_provider}", type: :info) if @current_provider (" Current model: #{@current_model}", type: :info) if @current_model (" Duration: #{format_duration(Time.now - @start_time)}", type: :info) if @start_time end |
#show_rate_limit_wait(reset_time) ⇒ Object
Show rate limit wait
213 214 215 216 217 218 219 220 |
# File 'lib/aidp/harness/status_display.rb', line 213 def show_rate_limit_wait(reset_time) clear_display remaining = reset_time - Time.now ("\n🚫 Rate limit reached", type: :error) (" Waiting for reset at #{reset_time.strftime("%H:%M:%S")}", type: :info) (" Remaining: #{format_duration(remaining)}", type: :info) (" Press Ctrl+C to cancel", type: :info) end |
#show_resumed_status ⇒ Object
Show resumed status
199 200 201 202 203 |
# File 'lib/aidp/harness/status_display.rb', line 199 def show_resumed_status clear_display ("\n▶️ Harness RESUMED", type: :success) (" Continuing execution...", type: :info) end |
#show_stopped_status ⇒ Object
Show stopped status
206 207 208 209 210 |
# File 'lib/aidp/harness/status_display.rb', line 206 def show_stopped_status clear_display ("\n⏹️ Harness STOPPED", type: :error) (" Execution terminated by user", type: :info) end |
#start_status_updates(display_mode = :compact, async_updates: true) ⇒ Object
Start real-time status updates
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/aidp/harness/status_display.rb', line 49 def start_status_updates(display_mode = :compact, async_updates: true) return if @running @running = true @start_time = Time.now @display_mode = display_mode @last_update = Time.now if async_updates begin require "concurrent" @status_future = Concurrent::Future.execute do while @running begin collect_status_data display_status check_alerts sleep(@update_interval) rescue => e handle_display_error(e) end end end rescue LoadError # Fallback: perform single synchronous update if concurrent not available collect_status_data display_status end else # Synchronous single update mode (useful for tests) collect_status_data display_status end end |
#status_data ⇒ Object
Get comprehensive status data
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/aidp/harness/status_display.rb', line 254 def status_data { basic_info: basic_status, provider_info: provider_status, performance_info: performance_status, error_info: error_status, circuit_breaker_info: circuit_breaker_status, token_info: token_status, rate_limit_info: rate_limit_status, recovery_info: recovery_status, user_feedback_info: user_feedback_status, work_completion_info: work_completion_status, alerts: alerts } end |
#stop_status_updates ⇒ Object
Stop status updates
85 86 87 88 89 |
# File 'lib/aidp/harness/status_display.rb', line 85 def stop_status_updates @running = false @status_future&.wait(5) clear_display end |
#update_current_model(_provider_name, model_name) ⇒ Object
Update current model
106 107 108 109 110 |
# File 'lib/aidp/harness/status_display.rb', line 106 def update_current_model(_provider_name, model_name) @current_model = model_name @status_data[:current_model] = model_name @status_data[:model_switch_time] = Time.now end |
#update_current_provider(provider_name) ⇒ Object
Update current provider
99 100 101 102 103 |
# File 'lib/aidp/harness/status_display.rb', line 99 def update_current_provider(provider_name) @current_provider = provider_name @status_data[:current_provider] = provider_name @status_data[:provider_switch_time] = Time.now end |
#update_current_step(step_name) ⇒ Object
Update current step
92 93 94 95 96 |
# File 'lib/aidp/harness/status_display.rb', line 92 def update_current_step(step_name) @current_step = step_name @status_data[:current_step] = step_name @status_data[:step_start_time] = Time.now end |
#update_error_summary(error_summary) ⇒ Object
Update error summary
165 166 167 168 |
# File 'lib/aidp/harness/status_display.rb', line 165 def update_error_summary(error_summary) @error_summary.merge!(error_summary) @error_summary[:last_updated] = Time.now end |
#update_interval(interval) ⇒ Object
Set update interval
177 178 179 180 |
# File 'lib/aidp/harness/status_display.rb', line 177 def update_interval(interval) @update_interval = interval @display_config[:update_interval] = interval end |
#update_performance_metrics(metrics) ⇒ Object
Update performance metrics
159 160 161 162 |
# File 'lib/aidp/harness/status_display.rb', line 159 def update_performance_metrics(metrics) @performance_metrics.merge!(metrics) @performance_metrics[:last_updated] = Time.now end |
#update_rate_limit_countdown(remaining_seconds) ⇒ Object
Update rate limit countdown
223 224 225 226 227 228 |
# File 'lib/aidp/harness/status_display.rb', line 223 def update_rate_limit_countdown(remaining_seconds) clear_display ("\n🚫 Rate limit - waiting...", type: :warning) (" Resets in: #{format_duration(remaining_seconds)}", type: :info) (" Press Ctrl+C to cancel", type: :info) end |
#update_rate_limit_status(provider, model, rate_limit_info) ⇒ Object
Update rate limit status
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/aidp/harness/status_display.rb', line 123 def update_rate_limit_status(provider, model, rate_limit_info) @rate_limit_status[provider] ||= {} @rate_limit_status[provider][model] = { rate_limited: true, reset_time: rate_limit_info[:reset_time], retry_after: rate_limit_info[:retry_after], quota_remaining: rate_limit_info[:quota_remaining], quota_limit: rate_limit_info[:quota_limit], last_updated: Time.now } end |
#update_recovery_status(recovery_type, status, details = {}) ⇒ Object
Update recovery status
136 137 138 139 140 141 142 |
# File 'lib/aidp/harness/status_display.rb', line 136 def update_recovery_status(recovery_type, status, details = {}) @recovery_status[recovery_type] = { status: status, details: details, last_updated: Time.now } end |
#update_token_usage(provider, model, tokens_used, tokens_remaining = nil) ⇒ Object
Update token usage
113 114 115 116 117 118 119 120 |
# File 'lib/aidp/harness/status_display.rb', line 113 def update_token_usage(provider, model, tokens_used, tokens_remaining = nil) @token_usage[provider] ||= {} @token_usage[provider][model] = { used: tokens_used, remaining: tokens_remaining, last_updated: Time.now } end |
#update_user_feedback_status(feedback_type, status, details = {}) ⇒ Object
Update user feedback status
145 146 147 148 149 150 151 |
# File 'lib/aidp/harness/status_display.rb', line 145 def update_user_feedback_status(feedback_type, status, details = {}) @user_feedback_status[feedback_type] = { status: status, details: details, last_updated: Time.now } end |
#update_work_completion_status(completion_info) ⇒ Object
Update work completion status
154 155 156 |
# File 'lib/aidp/harness/status_display.rb', line 154 def update_work_completion_status(completion_info) @work_completion_status = completion_info.merge(last_updated: Time.now) end |