@@ -1008,19 +1008,27 @@ describe("board gateway methods", () => {
10081008 expect ( triggerCronJob ) . toHaveBeenCalledWith ( "job-1" , expect . any ( Object ) ) ;
10091009 } ) ;
10101010
1011- it ( "caps board.event payloads at 8KB and notices at 500 characters " , async ( ) => {
1011+ it ( "caps board.event payloads and preserves Unicode at the notice boundary " , async ( ) => {
10121012 const { invoke } = createHarness ( ) ;
10131013 await invoke ( "board.widget.put" , {
10141014 sessionKey : "session" ,
10151015 name : "counter" ,
10161016 content : { kind : "html" , html : "ok" } ,
10171017 } ) ;
1018+ const clippedCodeUnits = 500 - "[dashboard] " . length - " on widget counter" . length - 1 ;
1019+ // JSON's opening quote places the emoji across the legacy slice boundary.
1020+ const payload = `${ "x" . repeat ( clippedCodeUnits - 2 ) } 😀tail` ;
1021+ await invoke ( "board.event" , { sessionKey : "session" , widget : "counter" , payload } ) ;
1022+ const unicodeNotice = peekSystemEvents ( "session" ) [ 0 ] ?? "" ;
1023+ expect ( unicodeNotice . length ) . toBeLessThanOrEqual ( 500 ) ;
1024+ expect ( unicodeNotice ) . not . toContain ( String . fromCharCode ( 0xd83d ) ) ;
1025+ expect ( unicodeNotice ) . toMatch ( / … o n w i d g e t c o u n t e r $ / u) ;
10181026 await invoke ( "board.event" , {
10191027 sessionKey : "session" ,
10201028 widget : "counter" ,
10211029 payload : "x" . repeat ( 1_000 ) ,
10221030 } ) ;
1023- expect ( peekSystemEvents ( "session" ) [ 0 ] ) . toHaveLength ( 500 ) ;
1031+ expect ( peekSystemEvents ( "session" ) [ 1 ] ) . toHaveLength ( 500 ) ;
10241032 const oversized = await invoke ( "board.event" , {
10251033 sessionKey : "session" ,
10261034 widget : "counter" ,
@@ -1029,31 +1037,6 @@ describe("board gateway methods", () => {
10291037 expect ( oversized . mock . calls [ 0 ] ?. [ 0 ] ) . toBe ( false ) ;
10301038 } ) ;
10311039
1032- it ( "does not split surrogate pairs when truncating board.event notices" , async ( ) => {
1033- const { invoke } = createHarness ( ) ;
1034- await invoke ( "board.widget.put" , {
1035- sessionKey : "session" ,
1036- name : "counter" ,
1037- content : { kind : "html" , html : "ok" } ,
1038- } ) ;
1039- const prefix = "[dashboard] " ;
1040- const suffix = " on widget counter" ;
1041- const clippedCodeUnits = 500 - prefix . length - suffix . length - 1 ;
1042-
1043- // JSON serialization adds a leading quote, placing the emoji's high surrogate
1044- // at the old slice boundary when the payload contains clippedCodeUnits - 2 ASCII units.
1045- await invoke ( "board.event" , {
1046- sessionKey : "session" ,
1047- widget : "counter" ,
1048- payload : `${ "x" . repeat ( clippedCodeUnits - 2 ) } 😀tail` ,
1049- } ) ;
1050-
1051- const notice = peekSystemEvents ( "session" ) [ 0 ] ?? "" ;
1052- expect ( notice . length ) . toBeLessThanOrEqual ( 500 ) ;
1053- expect ( notice ) . not . toContain ( String . fromCharCode ( 0xd83d ) ) ;
1054- expect ( notice ) . toMatch ( / … o n w i d g e t c o u n t e r $ / u) ;
1055- } ) ;
1056-
10571040 it ( "keeps board state across the real sessions.reset handler" , async ( ) => {
10581041 const sessionKey = "agent:main:board-reset-proof" ;
10591042 const stateDir = tempDirs . make ( "openclaw-board-reset-" ) ;
0 commit comments