Module: Ace::Overseer::Atoms::StatusFormatter

Defined in:
lib/ace/overseer/atoms/status_formatter.rb

Constant Summary collapse

COL_LOCATION =

Location header columns

15
COL_PR =
10
COL_GIT =
6
COL_ASSIGN_ID =

Assignment sub-row columns

8
COL_ASSIGN_NAME =
25
COL_STATE =
3
COL_PROGRESS =
30
PROGRESS_BAR_WIDTH =
10
COLOR =

ANSI color helpers

{
  green: "\e[32m",
  red: "\e[31m",
  blue: "\e[34m",
  yellow: "\e[33m",
  dim: "\e[2m",
  reset: "\e[0m"
}.freeze
STATE_DISPLAY =

Assignment state icons

{
  "completed" => {icon: "\u2713", color: :green},   # ✓
  "running" => {icon: "\u25B6", color: :blue},    # ►
  "failed" => {icon: "\u2717", color: :red},     # ✗
  "stalled" => {icon: "\u25FC", color: :yellow},  # ◼
  "paused" => {icon: "\u2016", color: :dim},     # ‖
  "none" => {icon: "-", color: :dim}
}.freeze
PR_STATE_COLORS =

PR state colors

{
  "OPN" => :green,
  "MRG" => :blue,
  "CLS" => :dim,
  "DFT" => :yellow
}.freeze

Class Method Summary collapse

Class Method Details

.format_assignment_row(assignment) ⇒ Object



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/ace/overseer/atoms/status_formatter.rb', line 79

def self.format_assignment_row(assignment)
  id = assignment.dig("assignment", "id") || "-"
  name = assignment.dig("assignment", "name") || "-"
  state_str = assignment.dig("assignment", "state") || "none"
  display = STATE_DISPLAY[state_str] || STATE_DISPLAY["none"]

  state_icon = colorize(display[:icon].to_s.ljust(COL_STATE), display[:color])
  progress_str = format_progress(assignment)

  format(
    "  %-#{COL_ASSIGN_ID}s %-#{COL_ASSIGN_NAME}s %s %-#{COL_PROGRESS}s",
    id,
    truncate(name, COL_ASSIGN_NAME),
    state_icon,
    progress_str
  )
end

.format_dashboard(contexts) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ace/overseer/atoms/status_formatter.rb', line 47

def self.format_dashboard(contexts)
  return "No active assignments." if contexts.empty?

  rows = []
  rows << format_header
  rows << separator_line
  sorted = sort_contexts(contexts)
  sorted.each_with_index do |context, idx|
    rows << "" if idx > 0
    rows << format_location_row(context)
    context.assignments.each do |assignment|
      rows << format_assignment_row(assignment)
    end
  end
  rows.join("\n")
end

.format_location_row(context) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ace/overseer/atoms/status_formatter.rb', line 64

def self.format_location_row(context)
  location = if context.location_type == :main
    colorize("main".ljust(COL_LOCATION), :dim)
  else
    File.basename(context.worktree_path).ljust(COL_LOCATION)
  end

  format(
    "%s %s %s",
    location,
    colorized_pr(context),
    colorized_git(context)
  )
end


227
228
229
230
231
232
# File 'lib/ace/overseer/atoms/status_formatter.rb', line 227

def self.format_watch_footer(next_full_refresh_secs)
  now = Time.now.strftime("%H:%M:%S")
  mins, secs = next_full_refresh_secs.divmod(60)
  remaining = (mins > 0) ? "#{mins}m #{secs}s" : "#{secs}s"
  colorize("Updated: #{now} \u00B7 full refresh in #{remaining}", :dim)
end