summaryrefslogtreecommitdiff
path: root/panto-report-status
diff options
context:
space:
mode:
authort <t@tjp.lol>2026-10-31 09:28:40 -0600
committert <t@tjp.lol>2026-10-31 12:48:14 -0600
commit53947c687711116c74ec59cff6895e30e2d3111c (patch)
treeb98d968839a5eeb13bb09399177771f031b3d38e /panto-report-status
parent9e9eb15555d9a657b36ee6ae9ef208c0049588f5 (diff)
Sanitize Herdr status text only at the OSC boundaryv0.1.0
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.
Diffstat (limited to 'panto-report-status')
-rw-r--r--panto-report-status/init.lua18
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()