From fd2b3dfd85d8d87716481425216abc5e8cdd9c1b Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Sep 2026 09:30:11 -0600 Subject: Sort completed subagents above active ones --- subagents/progress.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'subagents') 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 -- cgit v1.3