@@ -86,6 +86,7 @@ function captureOpenCodeSessionRegistrations(pluginConfig: unknown = {}) {
8686async function installFakeOpenCode (
8787 assistantText = "hi" ,
8888 sessionTitle = "Catalog session" ,
89+ toolInput : unknown = { command : "pwd" } ,
8990) : Promise < string > {
9091 const directory = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-opencode-catalog-" ) ) ;
9192 temporaryDirectories . push ( directory ) ;
@@ -125,7 +126,7 @@ async function installFakeOpenCode(
125126 id : "prt_tool" ,
126127 type : "tool" ,
127128 tool : "bash" ,
128- state : { status : "completed" , input : { command : "pwd" } , output : "/workspace" } ,
129+ state : { status : "completed" , input : toolInput , output : "/workspace" } ,
129130 } ,
130131 ] ,
131132 } ,
@@ -299,6 +300,25 @@ describe("OpenCode session catalog", () => {
299300 } ,
300301 ) ;
301302
303+ it . runIf ( process . platform !== "win32" ) (
304+ "keeps truncated tool input on a valid UTF-16 boundary" ,
305+ async ( ) => {
306+ await installFakeOpenCode ( "hi" , "Catalog session" , {
307+ value : `${ "x" . repeat ( 19_989 ) } 🎉` ,
308+ } ) ;
309+ const transcript = await readLocalOpenCodeTranscriptPage ( {
310+ threadId : "ses_test" ,
311+ limit : 20 ,
312+ } ) ;
313+ const toolCall = transcript . items . find ( ( item ) => item . type === "toolCall" ) ;
314+
315+ expect ( toolCall ?. text ) . toMatch ( / … $ / u) ;
316+ expect ( toolCall ?. text ) . not . toMatch (
317+ / [ \uD800 - \uDBFF ] (? ! [ \uDC00 - \uDFFF ] ) | (?< ! [ \uD800 - \uDBFF ] ) [ \uDC00 - \uDFFF ] / u,
318+ ) ;
319+ } ,
320+ ) ;
321+
302322 it . runIf ( process . platform !== "win32" ) (
303323 "auto-detects the CLI and honors the node-local Web UI switch" ,
304324 async ( ) => {
0 commit comments