@@ -189,6 +189,13 @@ describe("buildBeamMirrorItems", () => {
189189 const reduced = buildBeamMirrorItems ( [ { type : "userMessage" , text : "x" . repeat ( 10_000 ) } ] ) ;
190190 expect ( reduced . items [ 0 ] ?. text . length ) . toBe ( 6_000 ) ;
191191 } ) ;
192+
193+ it ( "does not split a surrogate pair when clipping message text" , ( ) => {
194+ const reduced = buildBeamMirrorItems ( [
195+ { type : "userMessage" , text : `${ "x" . repeat ( 5_999 ) } 🙂tail` } ,
196+ ] ) ;
197+ expect ( reduced . items [ 0 ] ?. text ) . toBe ( "x" . repeat ( 5_999 ) ) ;
198+ } ) ;
192199} ) ;
193200
194201describe ( "fitBeamMirrorUpload" , ( ) => {
@@ -248,6 +255,24 @@ describe("createBeamMirrorRunner", () => {
248255 expect ( cancel ) . toHaveBeenCalledOnce ( ) ;
249256 } ) ;
250257
258+ it ( "does not split a surrogate pair when clipping the session title" , async ( ) => {
259+ const sent : SentRequest [ ] = [ ] ;
260+ const catalog = fakeCatalog ( {
261+ id : "claude" ,
262+ sessions : [ { threadId : "t-emoji" , name : `${ "x" . repeat ( 159 ) } 🙂` , recencyAt : NOW - 60_000 } ] ,
263+ } ) ;
264+ const runner = createBeamMirrorRunner ( {
265+ runtime : fakeRuntime ( mirrorConfig ( ) ) ,
266+ logger : silentLogger ,
267+ fetchFn : captureFetch ( sent ) ,
268+ now : ( ) => NOW ,
269+ listCatalogs : ( ) => [ catalog ] ,
270+ } ) ;
271+ await runner . tick ( ) ;
272+ expect ( sent ) . toHaveLength ( 1 ) ;
273+ expect ( sent [ 0 ] ?. payload . title ) . toBe ( "x" . repeat ( 159 ) ) ;
274+ } ) ;
275+
251276 it ( "keeps successful uploads successful when response cancellation rejects" , async ( ) => {
252277 const sent : SentRequest [ ] = [ ] ;
253278 const warnings : string [ ] = [ ] ;
0 commit comments