Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions assets/nvim/lua/user/stallwatch_picker/spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ M.NOT_ENABLED_MARK = "[disabled]"
M.WAKE_PENDING_MARK = "⏳"
M.COORD_MARK = { live = "●", dir_missing = "✗", unresolved = "?", none = "○", unsupported = "○" }
M.PREVIEW_TITLE = "Program brief"
M.BRIEF_UPDATE_MAX_LINES = 8
M.BRIEF_WORKERS_MAX = 5

local function oneline(s)
Expand Down Expand Up @@ -327,6 +326,10 @@ end

local function brief_status_line(prow, now_ms)
local parts = {}
local tag = nonempty(prow.tag)
if tag then
table.insert(parts, tag)
end
local c = type(prow.coord) == "table" and prow.coord or {}
if type(c.row) == "table" then
table.insert(parts, nonempty(c.row.effective_state) or "?")
Expand Down Expand Up @@ -521,13 +524,7 @@ function M.program_brief_lines(prow, now_ms, live_workers)
local age = iso_age(lu.at, now_ms)
table.insert(block, age and ("LAST UPDATE (" .. age .. " ago)") or "LAST UPDATE")
local cleaned = (lu_text:gsub("\r", ""):gsub("%s+$", ""))
local n = 0
for line in (cleaned .. "\n"):gmatch("([^\n]*)\n") do
n = n + 1
if n > M.BRIEF_UPDATE_MAX_LINES then
table.insert(block, "…")
break
end
table.insert(block, line)
end
end
Expand Down
36 changes: 33 additions & 3 deletions assets/nvim/test-stallwatch-picker-init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ do
previewer.define_preview({ state = { bufnr = buf1 } }, { value = alpha_prog })
local body1 = table.concat(vim.api.nvim_buf_get_lines(buf1, 0, -1, false), "\n")
check(#spawns == 0, "hovering alpha spawns zero subprocesses (no goose export)")
check(body1:find("idle · 3 unread", 1, true) ~= nil, "status strip shows state and unread")
check(body1:find("alpha · idle · 3 unread", 1, true) ~= nil, "status strip shows tag, state, and unread")
check(body1:find("~$1.50 today", 1, true) ~= nil, "status strip shows spend today")
check(body1:find("NEEDS YOU", 1, true) ~= nil, "shows NEEDS YOU section")
check(body1:find("ALERTS FIRING", 1, true) ~= nil, "shows ALERTS FIRING section")
Expand All @@ -650,13 +650,43 @@ do
check(body1:find("quiet tick", 1, true) ~= nil, "shows quiet tick note")
check(body1:find("Shipped %(24h%): PR #10 merged") ~= nil, "shows 24h completions")

-- Missing brief degrades cleanly without error or spawns.
-- Switching selection to beta re-renders the preview to beta (not cached on alpha).
local buf2 = vim.api.nvim_create_buf(false, true)
previewer.define_preview({ state = { bufnr = buf2 } }, { value = beta_prog })
local body2 = table.concat(vim.api.nvim_buf_get_lines(buf2, 0, -1, false), "\n")
check(#spawns == 0, "hovering beta spawns zero subprocesses")
check(body2:find("no coord", 1, true) ~= nil, "beta without brief shows status strip")
check(body2:find("beta · no coord", 1, true) ~= nil, "beta without brief shows tag + status strip")
check(body2:find("Nothing waiting on you", 1, true) ~= nil, "beta with no items shows Nothing waiting on you")
check(not body2:find("alpha", 1, true), "beta preview does not leak alpha content")
end

-- init.open joins coordinator rows via model.index_rows(snap.rows) so live
-- coordinators render their real effective_state + unread (never "coord ?").
do
local snap = vim.deepcopy(SNAP)
table.insert(snap.rows, {
id = "goose:20990101_1",
pigeon_session_id = "gse_42ee2165-0000-4000-8000-00000000abcd",
effective_state = "working",
unread_state = "counted",
unread = 7,
dir_missing = false,
})
local before = #new_calls
init.open({
flow = ctrl,
fetch = function(_o, cb) cb(snap, nil) end,
system = function() return { pid = 1, kill = function() end } end,
})
local p1 = new_calls[before + 1]
local previewer = p1.defaults.previewer
local alpha_row = p1.defaults.finder.results[1]
local buf = vim.api.nvim_create_buf(false, true)
previewer.define_preview({ state = { bufnr = buf } }, { value = alpha_row })
local line1 = vim.api.nvim_buf_get_lines(buf, 0, 1, false)[1]
check(line1:find("alpha · working · 7 unread", 1, true) ~= nil,
"init.open resolves live coordinator state instead of 'coord ?', got: " .. tostring(line1))
check(not line1:find("coord ?", 1, true), "live coordinator never renders 'coord ?'")
end

-- ID SEARCH (workstation-klqw): typing a coordinator's id on Screen 1 finds its
Expand Down
33 changes: 31 additions & 2 deletions assets/nvim/test-stallwatch-picker-spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ do
local lines = spec.program_brief_lines(live_prow, NOW, workers)
local body = table.concat(lines, "\n")

check(lines[1] == "idle · 4 unread · ran 10m ago · ~$2.50 today · ⚠ 2 alerts (1 novel)",
check(lines[1] == "alpha · idle · 4 unread · ran 10m ago · ~$2.50 today · ⚠ 2 alerts (1 novel)",
"status strip, got: " .. lines[1])
check(body:find("NEEDS YOU\n", 1, true) ~= nil, "NEEDS YOU header (top_reason pins to top item)")
check(body:find("why: Top urgent decision.", 1, true) ~= nil, "top_reason shown under top item")
Expand All @@ -344,11 +344,40 @@ do
check(body:find("Shipped %(24h%): PR #10 shipped") ~= nil, "Shipped (24h) line")
check(body:find("%+1 blocker, 1 follow_up, 1 info") ~= nil, "footer counts remaining items across all kinds")

-- No line/character truncation: long multi-line LAST UPDATE and long quiet_tick render in full.
local long_lines = {}
for i = 1, 20 do
table.insert(long_lines, string.format("Update line %02d with full text preserved", i))
end
local long_quiet = "Nothing new in this wake. " .. string.rep("detail ", 30) .. "end-marker."
local full_prow = {
tag = "longprog",
coord = {
state = "live",
goose_id = "20990101_2",
row = { effective_state = "working", unread_state = "counted", unread = 0 },
},
items = {},
brief = {
last_update = { text = table.concat(long_lines, "\n"), at = "2026-01-01T11:50:00+00:00" },
quiet_tick = { text = long_quiet, at = "2026-01-01T11:58:00+00:00" },
},
}
local full_out = spec.program_brief_lines(full_prow, NOW, {})
local full_body = table.concat(full_out, "\n")
check(full_out[1] == "longprog · working · 0 unread", "live working coord status strip, got: " .. full_out[1])
check(full_body:find("Update line 01 with full text preserved", 1, true) ~= nil, "first line of long update present")
check(full_body:find("Update line 20 with full text preserved", 1, true) ~= nil, "20th line of long update present (not clipped at 8 lines)")
check(not full_body:find("\n…\n", 1, true), "no ellipsis truncation line in LAST UPDATE")
check(full_body:find("end-marker.", 1, true) ~= nil, "long quiet_tick rendered in full without clipping")

-- Degrades gracefully when brief is nil/missing (older items.sh) and when no items need user.
local quiet_lines = spec.program_brief_lines({ tag = "empty", coord = { state = "none" }, items = {} }, NOW, {})
local quiet_body = table.concat(quiet_lines, "\n")
check(quiet_lines[1] == "no coord", "missing brief still renders status strip")
check(quiet_lines[1] == "empty · no coord", "missing brief still renders status strip, got: " .. quiet_lines[1])
check(quiet_body:find("Nothing waiting on you", 1, true) ~= nil, "empty items -> Nothing waiting on you")
local unres_lines = spec.program_brief_lines({ tag = "ghost", coord = { state = "unresolved", goose_id = "20990101_9" }, items = {} }, NOW, {})
check(unres_lines[1] == "ghost · coord ?", "unresolved coord shows coord ?, got: " .. unres_lines[1])
check(spec.program_brief_lines(nil, NOW, nil)[1] == "(unnamed)", "nil prow degrades safely")
end

Expand Down
8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3194,16 +3194,16 @@
echo "GATE FAILURE: stallwatch_picker.model did not report expected 183 assertions." >&2
exit 1
}
grep -q '^PASS stallwatch_picker\.spec unit tests (159 assertions via nvim -l)' "$TMPDIR/out.txt" || {
echo "GATE FAILURE: stallwatch_picker.spec did not report expected 159 assertions." >&2
grep -q '^PASS stallwatch_picker\.spec unit tests (165 assertions via nvim -l)' "$TMPDIR/out.txt" || {
echo "GATE FAILURE: stallwatch_picker.spec did not report expected 165 assertions." >&2
exit 1
}
grep -q '^PASS stallwatch_picker\.source unit tests (110 assertions via nvim -l)' "$TMPDIR/out.txt" || {
echo "GATE FAILURE: stallwatch_picker.source did not report expected 110 assertions." >&2
exit 1
}
grep -q '^PASS stallwatch_picker\.init unit tests (144 assertions via nvim -l)' "$TMPDIR/out.txt" || {
echo "GATE FAILURE: stallwatch_picker.init did not report expected 144 assertions." >&2
grep -q '^PASS stallwatch_picker\.init unit tests (147 assertions via nvim -l)' "$TMPDIR/out.txt" || {
echo "GATE FAILURE: stallwatch_picker.init did not report expected 147 assertions." >&2
exit 1
}
touch $out
Expand Down
Loading