Class: Aidp::Harness::UI::ProgressDisplay
Overview
Handles progress display using CLI UI progress bars
Defined Under Namespace
Classes: DisplayError, InvalidProgressError, ProgressError
Constant Summary
MessageDisplay::COLOR_MAP
Instance Attribute Summary collapse
Instance Method Summary
collapse
included, #message_display_prompt
Constructor Details
#initialize(ui_components = {}) ⇒ ProgressDisplay
Returns a new instance of ProgressDisplay.
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 23
def initialize(ui_components = {})
super()
@output = ui_components[:output]
@progress = ui_components[:progress] || TTY::ProgressBar
@pastel = if @output&.respond_to?(:tty?) && @output.tty?
Pastel.new(enabled: true)
else
Pastel.new(enabled: false)
end
@formatter = ui_components[:formatter] || ProgressFormatter.new
@display_history = []
@auto_refresh_enabled = false
@refresh_interval = 1.0
@refresh_thread = nil
@prompt = ui_components[:prompt] || TTY::Prompt.new
@spinner_class = begin
ui_components[:spinner] || TTY::Spinner
rescue
nil
end
@spinner = nil
end
|
Instance Attribute Details
#refresh_interval ⇒ Object
Returns the value of attribute refresh_interval.
21
22
23
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 21
def refresh_interval
@refresh_interval
end
|
Instance Method Details
#auto_refresh_enabled? ⇒ Boolean
164
165
166
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 164
def auto_refresh_enabled?
@auto_refresh_enabled
end
|
#clear_display_history ⇒ Object
141
142
143
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 141
def clear_display_history
@display_history = []
end
|
#display_multiple_progress(progress_items, display_type = :standard) ⇒ Object
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 124
def display_multiple_progress(progress_items, display_type = :standard)
raise ArgumentError, "Progress items must be an array" unless progress_items.is_a?(Array)
if progress_items.empty?
display_message(@pastel.dim("No progress items to display."), type: :muted)
return
end
progress_items.each do |item|
display_progress(item, display_type)
end
end
|
#display_progress(progress_data, display_type = :standard) ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 104
def display_progress(progress_data, display_type = :standard)
validate_progress_data(progress_data)
validate_display_type(display_type)
case display_type
when :standard
display_standard_progress(progress_data)
when :detailed
display_detailed_progress(progress_data)
when :minimal
display_minimal_progress(progress_data)
end
record_display_history(progress_data, display_type)
rescue InvalidProgressError => e
raise e
rescue => e
raise DisplayError, "Failed to display progress: #{e.message}"
end
|
#get_display_history ⇒ Object
137
138
139
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 137
def get_display_history
@display_history.dup
end
|
#show_indeterminate_progress(message) ⇒ Object
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 93
def show_indeterminate_progress(message)
validate_message(message)
@progress.progress do |bar|
bar.update_title(message)
yield(bar) if block_given?
end
rescue => e
raise DisplayError, "Failed to display indeterminate progress: #{e.message}"
end
|
#show_progress(total_steps, &block) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 58
def show_progress(total_steps, &block)
validate_total_steps(total_steps)
progress_bar = @progress.new(
"[:bar] :percent% :current/:total",
total: total_steps,
width: 30,
output: @output
)
execute_progress_steps(progress_bar, total_steps, &block)
rescue => e
raise DisplayError, "Failed to display progress: #{e.message}"
end
|
#show_step_progress(step_name, total_substeps, &block) ⇒ Object
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 82
def show_step_progress(step_name, total_substeps, &block)
validate_step_inputs(step_name, total_substeps)
formatted_title = @formatter.format_step_title(step_name)
@progress.progress do |bar|
execute_substeps(bar, total_substeps, formatted_title, &block)
end
rescue => e
raise DisplayError, "Failed to display step progress: #{e.message}"
end
|
#start_auto_refresh(interval) ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 145
def start_auto_refresh(interval)
return if @auto_refresh_enabled
@refresh_interval = interval
@auto_refresh_enabled = true
@refresh_thread = Thread.new do
while @auto_refresh_enabled
yield if block_given?
sleep @refresh_interval
end
end
end
|
#start_spinner(message = "Loading...") ⇒ Object
Simple spinner management used by component specs
47
48
49
50
51
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 47
def start_spinner(message = "Loading...")
return unless @spinner_class
@spinner = @spinner_class.new("#{message} :spinner", format: :dots, output: @output)
@spinner.start
end
|
#stop_auto_refresh ⇒ Object
158
159
160
161
162
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 158
def stop_auto_refresh
@auto_refresh_enabled = false
@refresh_thread&.join
@refresh_thread = nil
end
|
#stop_spinner ⇒ Object
53
54
55
56
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 53
def stop_spinner
@spinner&.stop
@spinner = nil
end
|
#update_progress(bar, message = nil) ⇒ Object
73
74
75
76
77
78
79
80
|
# File 'lib/aidp/harness/ui/progress_display.rb', line 73
def update_progress(bar, message = nil)
validate_progress_bar(bar)
bar.tick
bar.update_title(message) if message
rescue => e
raise DisplayError, "Failed to update progress: #{e.message}"
end
|