diff options
Diffstat (limited to 'panto-report-status/init.lua')
| -rw-r--r-- | panto-report-status/init.lua | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/panto-report-status/init.lua b/panto-report-status/init.lua index 07c6110..e2fe5c6 100644 --- a/panto-report-status/init.lua +++ b/panto-report-status/init.lua @@ -13,16 +13,16 @@ local function base64(text) return table.concat(out) end --- Names are diagnostic labels, not arbitrary terminal text. Keep messages short, --- ASCII and control-free even when a tool or command supplies an unusual name. -local function label(name) - return (name or "?"):gsub("[^ -~]", "?"):sub(1, 27) +local function tool_status(name) + name = name or "?" + return "tool:" .. name:sub(1, 27) end local function command_status(name) + name = name or "?" if name == "compact" then return "compacting" end if name == "!" or name == "!!" then return "shell" end - return "cmd:" .. label(name) + return "cmd:" .. name:sub(1, 28) end return { @@ -56,7 +56,11 @@ return { -- put control sequences in a pipe, file, or a different terminal. if terminal_key() ~= terminal then return end local sequence = "\27]7501;state=" .. state .. ":app=panto" - if status then sequence = sequence .. ":msg=" .. base64(status) end + if status then + -- Preserve Herdr's label selection/truncation; sanitize only at + -- the OSC boundary, whose free-text fields forbid controls. + sequence = sequence .. ":msg=" .. base64((status:gsub("[^ -~]", "?"))) + end sequence = sequence .. "\27\\" local offset = 0 while offset < #sequence do @@ -105,7 +109,7 @@ return { panto.ext.on("render_compaction", function() if foreground_working then foreground("compacting") end end) - panto.ext.on("render_tool_details", function(event) foreground("tool:" .. label(event.tool_name)) end) + panto.ext.on("render_tool_details", function(event) foreground(tool_status(event.tool_name)) end) panto.ext.on("render_assistant_text", function() foreground("responding") end) panto.ext.on("turn_end", finish) panto.ext.on("background_work_start", function() |
