From 53947c687711116c74ec59cff6895e30e2d3111c Mon Sep 17 00:00:00 2001 From: t Date: Sat, 31 Oct 2026 09:28:40 -0600 Subject: Sanitize Herdr status text only at the OSC boundary Stop rewriting tool and command names into ASCII labels before Herdr sees them, so its label selection and truncation work on the real names. Replace non-printable characters only when encoding the OSC 7501 msg field, whose free-text payload forbids controls. --- panto-report-status/init.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'panto-report-status/init.lua') 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() -- cgit v1.3