diff options
Diffstat (limited to 'subagents/progress.lua')
| -rw-r--r-- | subagents/progress.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/subagents/progress.lua b/subagents/progress.lua index 7cad2fa..fc86935 100644 --- a/subagents/progress.lua +++ b/subagents/progress.lua @@ -202,9 +202,21 @@ function card_mt:event(event) repaint(self) end +local function sort_cards(board) + local positions = {} + for index, card in ipairs(board.cards) do positions[card] = index end + table.sort(board.cards, function(a, b) + local a_done, b_done = a.status ~= "running", b.status ~= "running" + if a_done ~= b_done then return a_done end + if a.sequence ~= b.sequence then return a.sequence < b.sequence end + return positions[a] < positions[b] + end) +end + function card_mt:done(status, message) self.status = GLYPHS[status] and status or "failed" if self.status ~= "completed" then marker(self, message) else self.partial = false end + if self.board then sort_cards(self.board) end repaint(self) end |
