@@ -3134,7 +3134,7 @@ describe("codex command", () => {
31343134 } ) ;
31353135 } ) ;
31363136
3137- it ( "bounds diagnostics notes before upload" , async ( ) => {
3137+ it ( "keeps diagnostics notes UTF-16 safe at the upload boundary " , async ( ) => {
31383138 const sessionFile = path . join ( tempDir , "session.jsonl" ) ;
31393139 await writeTestBinding (
31403140 { kind : "session" , agentId : "main" , sessionId : "session-1" } ,
@@ -3146,19 +3146,30 @@ describe("codex command", () => {
31463146 value : { threadId : "thread-789" } ,
31473147 } ) ,
31483148 ) ;
3149- const note = "x" . repeat ( 2050 ) ;
3149+ // The emoji's surrogate pair straddles the 2048-unit feedback limit.
3150+ const expectedReason = "x" . repeat ( 2047 ) ;
3151+ const note = `${ expectedReason } 😀tail` ;
31503152 const deps = createDeps ( { safeCodexControlRequest } ) ;
31513153
31523154 const request = await handleCodexCommand ( createContext ( `diagnostics ${ note } ` , sessionFile ) , {
31533155 deps,
31543156 } ) ;
3157+ expect ( requireResultText ( request ) . split ( "\n" ) ) . toContain ( `Note: ${ expectedReason } ` ) ;
31553158 const token = readDiagnosticsConfirmationToken ( request ) ;
31563159 await handleCodexCommand ( createContext ( `diagnostics confirm ${ token } ` , sessionFile ) , { deps } ) ;
31573160
31583161 expect ( mockArg ( safeCodexControlRequest , 0 , 0 ) ) . toBeUndefined ( ) ;
31593162 expect ( mockArg ( safeCodexControlRequest , 0 , 1 ) ) . toBe ( CODEX_CONTROL_METHODS . feedback ) ;
3160- const feedbackParams = requestParams ( safeCodexControlRequest ) ;
3161- expect ( feedbackParams . reason ) . toBe ( "x" . repeat ( 2048 ) ) ;
3163+ expect ( requestParams ( safeCodexControlRequest ) ) . toEqual ( {
3164+ classification : "bug" ,
3165+ reason : expectedReason ,
3166+ threadId : "thread-789" ,
3167+ includeLogs : true ,
3168+ tags : {
3169+ source : "openclaw-diagnostics" ,
3170+ channel : "test" ,
3171+ } ,
3172+ } ) ;
31623173 } ) ;
31633174
31643175 it ( "escapes diagnostics notes before showing approval text" , async ( ) => {
@@ -3441,6 +3452,35 @@ describe("codex command", () => {
34413452 } ) ;
34423453 } ) ;
34433454
3455+ it ( "keeps diagnostics upload errors UTF-16 safe at the display boundary" , async ( ) => {
3456+ const sessionFile = path . join ( tempDir , "session.jsonl" ) ;
3457+ await writeTestBinding (
3458+ { kind : "session" , agentId : "main" , sessionId : "session-1" } ,
3459+ { threadId : "thread-error-boundary" , cwd : "/repo" } ,
3460+ ) ;
3461+ // The emoji's surrogate pair straddles the 500-unit display limit.
3462+ const expectedError = "x" . repeat ( 499 ) ;
3463+ const safeCodexControlRequest = vi . fn ( async ( ) => ( {
3464+ ok : false as const ,
3465+ error : `${ expectedError } 😀tail` ,
3466+ } ) ) ;
3467+ const deps = createDeps ( { safeCodexControlRequest } ) ;
3468+
3469+ const request = await handleCodexCommand ( createContext ( "diagnostics" , sessionFile ) , { deps } ) ;
3470+ const token = readDiagnosticsConfirmationToken ( request ) ;
3471+
3472+ await expect (
3473+ handleCodexCommand ( createContext ( `diagnostics confirm ${ token } ` , sessionFile ) , { deps } ) ,
3474+ ) . resolves . toEqual ( {
3475+ text : [
3476+ "Could not send Codex diagnostics:" ,
3477+ `- channel test, OpenClaw session session-1, Codex thread thread-error-boundary: ${ expectedError } ` ,
3478+ "Inspect locally:" ,
3479+ "- `codex resume thread-error-boundary`" ,
3480+ ] . join ( "\n" ) ,
3481+ } ) ;
3482+ } ) ;
3483+
34443484 it ( "does not throttle diagnostics retries after upload failures" , async ( ) => {
34453485 const sessionFile = path . join ( tempDir , "session.jsonl" ) ;
34463486 await writeTestBinding (
0 commit comments