Class: EnhanceSwarm::VisualDashboard
- Inherits:
-
Object
- Object
- EnhanceSwarm::VisualDashboard
- Includes:
- Singleton
- Defined in:
- lib/enhance_swarm/visual_dashboard.rb
Class Method Summary collapse
- .add_agent(*args) ⇒ Object
- .instance ⇒ Object
- .remove_agent(*args) ⇒ Object
- .start_dashboard(*args) ⇒ Object
- .stop_dashboard ⇒ Object
- .update_agent(*args) ⇒ Object
- .update_coordination(*args) ⇒ Object
Instance Method Summary collapse
-
#add_agent(agent) ⇒ Object
Add new agent to dashboard.
-
#display_snapshot(agents = []) ⇒ Object
Display a static snapshot of agent status.
-
#initialize ⇒ VisualDashboard
constructor
A new instance of VisualDashboard.
-
#remove_agent(agent_id) ⇒ Object
Remove agent from dashboard.
-
#start_dashboard(agents = []) ⇒ Object
Start the visual dashboard.
- #stop_dashboard ⇒ Object
-
#update_agent(agent_id, updates) ⇒ Object
Update agent status.
-
#update_coordination(status) ⇒ Object
Update coordination status.
Constructor Details
#initialize ⇒ VisualDashboard
Returns a new instance of VisualDashboard.
11 12 13 14 15 16 17 18 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 11 def initialize @agents = {} @coordination_status = {} @dashboard_active = false @refresh_rate = 2 # seconds @last_update = Time.now @terminal_size = get_terminal_size end |
Class Method Details
.add_agent(*args) ⇒ Object
547 548 549 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 547 def add_agent(*args) instance.add_agent(*args) end |
.instance ⇒ Object
527 528 529 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 527 def instance @instance ||= new end |
.remove_agent(*args) ⇒ Object
551 552 553 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 551 def remove_agent(*args) instance.remove_agent(*args) end |
.start_dashboard(*args) ⇒ Object
531 532 533 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 531 def start_dashboard(*args) instance.start_dashboard(*args) end |
.stop_dashboard ⇒ Object
535 536 537 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 535 def stop_dashboard instance.stop_dashboard end |
.update_agent(*args) ⇒ Object
539 540 541 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 539 def update_agent(*args) instance.update_agent(*args) end |
.update_coordination(*args) ⇒ Object
543 544 545 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 543 def update_coordination(*args) instance.update_coordination(*args) end |
Instance Method Details
#add_agent(agent) ⇒ Object
Add new agent to dashboard
53 54 55 56 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 53 def add_agent(agent) @agents[agent[:id]] = agent @last_update = Time.now end |
#display_snapshot(agents = []) ⇒ Object
Display a static snapshot of agent status
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 65 def display_snapshot(agents = []) @agents = agents.each_with_object({}) { |agent, hash| hash[agent[:id]] = agent } puts "šø EnhanceSwarm Dashboard Snapshot".colorize(:cyan) puts "ā" * 50 puts "Timestamp: #{Time.now.strftime('%Y-%m-%d %H:%M:%S')}" puts if @agents.empty? puts "No agents currently running".colorize(:light_black) return end puts "š¤ Agent Status:".colorize(:blue) @agents.each do |id, agent| role = agent[:role] || 'unknown' status = format_agent_status(agent) progress = agent[:progress_percentage] || agent[:progress] || 0 duration = format_duration(agent) puts " #{role.ljust(10)} ā #{status} ā #{progress}% ā #{duration}" end puts puts "System Resources:".colorize(:blue) memory_info = get_memory_info puts " Memory: #{memory_info[:used_gb]}GB/#{memory_info[:total_gb]}GB (#{memory_info[:used_percent]}%)" puts " Active Processes: #{@agents.count { |_, agent| agent[:pid] }}" puts "\nš Summary:".colorize(:green) puts " Total Agents: #{@agents.count}" puts " Active: #{@agents.count { |_, agent| agent[:status] == 'active' || agent[:status] == 'running' }}" puts " Completed: #{@agents.count { |_, agent| agent[:status] == 'completed' }}" puts " Failed: #{@agents.count { |_, agent| agent[:status] == 'failed' }}" end |
#remove_agent(agent_id) ⇒ Object
Remove agent from dashboard
59 60 61 62 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 59 def remove_agent(agent_id) @agents.delete(agent_id) @last_update = Time.now end |
#start_dashboard(agents = []) ⇒ Object
Start the visual dashboard
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 21 def start_dashboard(agents = []) @dashboard_active = true @agents = agents.each_with_object({}) { |agent, hash| hash[agent[:id]] = agent } puts "š„ļø Starting Visual Agent Dashboard...".colorize(:green) puts "Press 'q' to quit, 'r' to refresh, 'p' to pause".colorize(:light_black) setup_terminal display_loop end |
#stop_dashboard ⇒ Object
32 33 34 35 36 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 32 def stop_dashboard @dashboard_active = false restore_terminal puts "\nš„ļø Dashboard stopped".colorize(:yellow) end |
#update_agent(agent_id, updates) ⇒ Object
Update agent status
39 40 41 42 43 44 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 39 def update_agent(agent_id, updates) return unless @agents[agent_id] @agents[agent_id].merge!(updates) @last_update = Time.now end |
#update_coordination(status) ⇒ Object
Update coordination status
47 48 49 50 |
# File 'lib/enhance_swarm/visual_dashboard.rb', line 47 def update_coordination(status) @coordination_status = status @last_update = Time.now end |