aboutsummaryrefslogtreecommitdiff
path: root/menubar/model.swift
diff options
context:
space:
mode:
authorIgor Soarez <igor@soarez.org>2026-10-23 17:58:24 +0300
committerIgor Soarez <igor@soarez.org>2026-10-23 17:58:24 +0300
commit12ce9f3f8edc84064458b649e8615247641dad36 (patch)
treec4df921d80b16dbd98fde05e3de7b795db5f1ad8 /menubar/model.swift
parent7520141a55e8876824dcb4e2cf5e8e3027efa59d (diff)
list working and idle agents most recent first
within a status, the menu, panel, search, and `dingger status` listed done and blocked agents oldest first (the queue), and the rest by place. now working and idle agents are most recent first: the first idle row is the agent that finished, or that the user looked at, last. @dingger_since now means when the pane entered its current status, for every status (it was set only while the pane needed the user), and survives a daemon restart. the queue selects done and blocked panes by status, no longer by having a stamp. one ordering rule each in Rust (watcher::list_order) and Swift (listedBefore), with tests that fail on the old order; e2e step 11 makes an agent finish while watched and checks it moves to the top of the idle rows. agents idle since before this change share one stamp and keep their place order until they next change.
Diffstat (limited to 'menubar/model.swift')
-rw-r--r--menubar/model.swift19
1 files changed, 14 insertions, 5 deletions
diff --git a/menubar/model.swift b/menubar/model.swift
index da5ad15..a17b009 100644
--- a/menubar/model.swift
+++ b/menubar/model.swift
@@ -219,7 +219,9 @@ func runDinggerInLoginShell(_ args: [String]) -> (ok: Bool, output: String) {
private let home = NSHomeDirectory()
-/// Every agent pane, in herdr's priority order, oldest waiting first.
+/// Every agent pane: herdr's status priority; within a status, done and
+/// blocked oldest first (the queue), working and idle most recent first
+/// (`@dingger_since`: when the pane entered its status); then by place.
func fetchRows() -> [Row] {
let format = [
"#{pane_id}", "#{@agent}", "#{@agent_state}", "#{@dingger_since}", "#{@agent_name}",
@@ -236,11 +238,18 @@ func fetchRows() -> [Row] {
session: f[5], window: window, since: Int(f[3]) ?? Int.max,
path: f[9].hasPrefix(home) ? "~" + f[9].dropFirst(home.count) : f[9])
}
- return rows.sorted {
- if $0.status.priority != $1.status.priority { return $0.status.priority > $1.status.priority }
- if $0.since != $1.since { return $0.since < $1.since }
- return $0.location < $1.location
+ return rows.sorted(by: listedBefore)
+}
+
+/// The list order (see `fetchRows`).
+func listedBefore(_ a: Row, _ b: Row) -> Bool {
+ if a.status.priority != b.status.priority { return a.status.priority > b.status.priority }
+ if a.since != b.since {
+ // Int.max: never stamped; last either way.
+ if a.since == Int.max || b.since == Int.max { return a.since < b.since }
+ return a.waiting ? a.since < b.since : a.since > b.since
}
+ return a.location < b.location
}
/// Show the pane and mark it attended; the same code path as the tmux