summaryrefslogtreecommitdiff
path: root/subagents
diff options
context:
space:
mode:
Diffstat (limited to 'subagents')
-rw-r--r--subagents/progress.lua28
1 files changed, 3 insertions, 25 deletions
diff --git a/subagents/progress.lua b/subagents/progress.lua
index b39fe00..aee198b 100644
--- a/subagents/progress.lua
+++ b/subagents/progress.lua
@@ -51,31 +51,9 @@ local function display_tool_name(name)
return type(name) == "string" and name:gsub("__", ".") or "tool"
end
-local function prefix(text, width)
- if width < 1 then return "" end
- local count, stop = 0, 0
- local ok = pcall(function()
- for pos in utf8.codes(text) do
- if count == width then break end
- stop = pos
- count = count + 1
- end
- if count > 0 then stop = (utf8.offset(text, count + 1) or (#text + 1)) - 1 end
- end)
- if not ok then return text:sub(1, width) end
- return text:sub(1, stop)
-end
-
local function wrap(text, width, emit)
- width = math.max(1, width)
- text = sanitize(text)
- if text == "" then emit(""); return end
- local rest = text
- while rest ~= "" do
- local piece = prefix(rest, width)
- if piece == "" then piece = rest:sub(1, 1) end
- emit(piece)
- rest = rest:sub(#piece + 1)
+ for _, row in ipairs(require("panto").text.wrap(sanitize(text), math.max(1, width))) do
+ emit(row)
end
end
@@ -267,7 +245,7 @@ local function render(board, width)
for _, card in ipairs(board.cards) do
local sid = card.sid ~= "" and (" " .. card.sid:sub(1, sid_width) ..
(sid_width < #card.sid and "…" or "")) or ""
- out[#out + 1] = prefix(sanitize(string.format("%s %s%s — %s",
+ out[#out + 1] = require("panto").text.truncate(sanitize(string.format("%s %s%s — %s",
GLYPHS[card.status] or GLYPHS.running, card.label, sid, card.status)), width)
local lines = body_lines(card, width - #BODY_INDENT, board.collapsed)
for _, line in ipairs(lines) do out[#out + 1] = line end