@@ -349,16 +349,44 @@ describe("rightPanelStore", () => {
349349 const nextTurn = { ...completedDiff , turnId : RunId . make ( "turn-2" ) } ;
350350 expect ( store . openProactive ( refA , nextTurn , store . getUserActionRevision ( refA ) ) ) . toBe ( true ) ;
351351 expect ( selectActiveRightPanel ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toBe ( "diff" ) ;
352+
353+ const completedWhileOpen = { ...completedDiff , turnId : RunId . make ( "turn-3" ) } ;
354+ const existingDiff = selectActiveRightPanelSurface (
355+ useRightPanelStore . getState ( ) . byThreadKey ,
356+ refA ,
357+ ) ;
358+ expect ( store . openProactive ( refA , completedWhileOpen , store . getUserActionRevision ( refA ) ) ) . toBe (
359+ false ,
360+ ) ;
361+ expect ( selectActiveRightPanelSurface ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toEqual (
362+ existingDiff ,
363+ ) ;
352364 store . closeSurface ( refA , "diff" ) ;
365+ await reloadRightPanelStore ( ) ;
366+ expect ( store . openProactive ( refA , completedWhileOpen , store . getUserActionRevision ( refA ) ) ) . toBe (
367+ false ,
368+ ) ;
369+ expect ( selectActiveRightPanel ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toBeNull ( ) ;
353370
354371 // A later storage migration must preserve the dismissal, just like an ordinary reload.
355372 const { storage, name, version } = useRightPanelStore . persist . getOptions ( ) ;
356373 const persisted = await storage ! . getItem ( name ! ) ;
357374 await storage ! . setItem ( name ! , { ...persisted ! , version : version ! - 1 } ) ;
358375 await reloadRightPanelStore ( ) ;
359- expect ( store . openProactive ( refA , nextTurn , store . getUserActionRevision ( refA ) ) ) . toBe ( false ) ;
376+ expect ( store . openProactive ( refA , completedWhileOpen , store . getUserActionRevision ( refA ) ) ) . toBe (
377+ false ,
378+ ) ;
360379 expect ( selectActiveRightPanel ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toBeNull ( ) ;
361380
381+ expect (
382+ store . openProactive (
383+ refA ,
384+ { ...completedDiff , turnId : RunId . make ( "turn-4" ) } ,
385+ store . getUserActionRevision ( refA ) ,
386+ ) ,
387+ ) . toBe ( true ) ;
388+ expect ( selectActiveRightPanel ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toBe ( "diff" ) ;
389+ store . closeSurface ( refA , "diff" ) ;
362390 store . open ( refA , "diff" ) ;
363391 expect ( selectActiveRightPanel ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toBe ( "diff" ) ;
364392 } ) ;
@@ -382,6 +410,14 @@ describe("rightPanelStore", () => {
382410 expect ( selectActiveRightPanelSurface ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toEqual (
383411 linkedPullRequest ,
384412 ) ;
413+ expect (
414+ selectThreadRightPanelState ( useRightPanelStore . getState ( ) . byThreadKey , refA ) . surfaces ,
415+ ) . toEqual ( [ linkedPullRequest ] ) ;
416+ await reloadRightPanelStore ( ) ;
417+ expect ( store . openProactive ( refA , nextTurn , store . getUserActionRevision ( refA ) ) ) . toBe ( false ) ;
418+ expect ( selectActiveRightPanelSurface ( useRightPanelStore . getState ( ) . byThreadKey , refA ) ) . toEqual (
419+ linkedPullRequest ,
420+ ) ;
385421 store . closeSurface ( refA , linkedPullRequest . id ) ;
386422 await reloadRightPanelStore ( ) ;
387423 expect ( store . openProactive ( refA , nextTurn , store . getUserActionRevision ( refA ) ) ) . toBe ( false ) ;
0 commit comments