@@ -3937,7 +3937,7 @@ describe("PreviewManager", () => {
39373937 ) ,
39383938 ) ;
39393939
3940- effectIt . effect ( "keeps annotation send grants isolated and updates an active pick " , ( ) =>
3940+ effectIt . effect ( "keeps annotation IDs and send grants isolated across tabs " , ( ) =>
39413941 withManager ( ( manager ) =>
39423942 Effect . gen ( function * ( ) {
39433943 const picked = new Map < number , ( event : unknown , ...args : unknown [ ] ) => void > ( ) ;
@@ -3985,6 +3985,8 @@ describe("PreviewManager", () => {
39853985 screenshot : null ,
39863986 createdAt : "2026-09-05T00:00:00.000Z" ,
39873987 } ;
3988+ // Guest counters restart after navigation and collide across tabs.
3989+ const annotationIds = new Set < string > ( ) ;
39883990 for ( const [ tabId , id , nextGrant , expected ] of [
39893991 [ "tab_b" , 43 , undefined , "attach" ] ,
39903992 [ "tab_a" , 42 , false , "attach" ] ,
@@ -3997,21 +3999,29 @@ describe("PreviewManager", () => {
39973999 }
39984000 picked . get ( id ) ?.( { } , annotation , null , "send" ) ;
39994001 const result = yield * Fiber . join ( pick ) ;
4000- expect ( result ?. annotation . id ) . toBe ( annotation . id ) ;
4002+ expect ( result ) . not . toBeNull ( ) ;
4003+ expect ( annotationIds . has ( result ! . annotation . id ) ) . toBe ( false ) ;
4004+ annotationIds . add ( result ! . annotation . id ) ;
4005+ expect ( result ?. annotation . comment ) . toBe ( annotation . comment ) ;
40014006 expect ( result ?. submission ) . toBe ( expected ) ;
40024007 }
40034008 yield * manager . registerWebview ( "tab_a" , 44 ) ;
40044009 const replacementPick = yield * manager . pickElement ( "tab_a" ) . pipe ( Effect . forkChild ) ;
40054010 yield * Effect . yieldNow ;
40064011 picked . get ( 44 ) ?.( { } , annotation , null , "send" ) ;
4007- expect ( ( yield * Fiber . join ( replacementPick ) ) ?. submission ) . toBe ( "send" ) ;
4012+ const replacementResult = yield * Fiber . join ( replacementPick ) ;
4013+ expect ( replacementResult ?. submission ) . toBe ( "send" ) ;
4014+ expect ( annotationIds . has ( replacementResult ! . annotation . id ) ) . toBe ( false ) ;
4015+ annotationIds . add ( replacementResult ! . annotation . id ) ;
40084016 yield * manager . closeTab ( "tab_a" ) ;
40094017 yield * manager . createTab ( "tab_a" ) ;
40104018 yield * manager . registerWebview ( "tab_a" , 44 ) ;
40114019 const reopenedPick = yield * manager . pickElement ( "tab_a" ) . pipe ( Effect . forkChild ) ;
40124020 yield * Effect . yieldNow ;
40134021 picked . get ( 44 ) ?.( { } , annotation , null , "send" ) ;
4014- expect ( ( yield * Fiber . join ( reopenedPick ) ) ?. submission ) . toBe ( "attach" ) ;
4022+ const reopenedResult = yield * Fiber . join ( reopenedPick ) ;
4023+ expect ( reopenedResult ?. submission ) . toBe ( "attach" ) ;
4024+ expect ( annotationIds . has ( reopenedResult ! . annotation . id ) ) . toBe ( false ) ;
40154025 } ) ,
40164026 ) ,
40174027 ) ;
@@ -4168,10 +4178,15 @@ describe("PreviewManager", () => {
41684178 expect ( webviewSend ) . not . toHaveBeenCalledWith ( "preview:annotation-captured" ) ;
41694179 expect ( secondPick . pollUnsafe ( ) ) . toBeUndefined ( ) ;
41704180
4171- onPicked ?.( { } , { ...annotation , id : "annotation_2" } , null , "attach" ) ;
4181+ onPicked ?.(
4182+ { } ,
4183+ { ...annotation , id : "annotation_2" , comment : "Second pick" } ,
4184+ null ,
4185+ "attach" ,
4186+ ) ;
41724187 yield * TestClock . adjust ( "6 seconds" ) ;
41734188 const result = yield * Fiber . join ( secondPick ) ;
4174- expect ( result ?. annotation . id ) . toBe ( "annotation_2 " ) ;
4189+ expect ( result ?. annotation . comment ) . toBe ( "Second pick " ) ;
41754190 expect ( result ?. submission ) . toBe ( "attach" ) ;
41764191 } ) ,
41774192 ) ,
0 commit comments