@@ -2,7 +2,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
22
33vi . mock ( 'electron' , ( ) => import ( '@/test/electron-mock' ) )
44
5- import { MAX_BROWSER_TABS } from '@sim/browser-protocol'
65import { sleep } from '@sim/utils/helpers'
76import { BrowserWindow , session as electronSession } from 'electron'
87import * as panel from '@/main/browser-agent/panel'
@@ -306,6 +305,33 @@ describe('browser-agent session', () => {
306305 )
307306 } )
308307
308+ it ( 'restores more than eight persisted tabs' , ( ) => {
309+ const tabs = Array . from ( { length : 12 } , ( _ , index ) => ( {
310+ url : `https://tab-${ index } .example/` ,
311+ pinned : index < 2 ,
312+ } ) )
313+ const { persistence } = memoryBrowserPersistence ( {
314+ 'chat-many-tabs' : {
315+ v : 1 ,
316+ tabs,
317+ activeIndex : tabs . length - 1 ,
318+ } ,
319+ } )
320+ session = freshSession ( win , { } , undefined , persistence )
321+
322+ const restored = session . withBrowserScope ( 'chat-many-tabs' , ( ) => {
323+ session . restoreBrowserSession ( )
324+ return session . getTabsState ( )
325+ } )
326+
327+ expect ( restored . tabs ) . toHaveLength ( 12 )
328+ expect ( restored . activeTabId ) . toBe ( '12' )
329+ expect ( restored . tabs . at ( - 1 ) ) . toMatchObject ( {
330+ url : 'https://tab-11.example/' ,
331+ active : true ,
332+ } )
333+ } )
334+
309335 it ( 'quiesces live scopes without publishing session closure' , ( ) => {
310336 const onTabsChanged = vi . fn ( )
311337 const onSessionClosed = vi . fn ( )
@@ -1034,16 +1060,22 @@ describe('browser-agent session', () => {
10341060 ] )
10351061 } )
10361062
1037- it ( 'limits the browser session to the shared tab cap ' , ( ) => {
1038- session . ensureTab ( )
1039- for ( let index = 1 ; index < MAX_BROWSER_TABS ; index ++ ) {
1063+ it ( 'allows creation, duplication, and reopening beyond eight browser tabs ' , ( ) => {
1064+ const first = session . ensureTab ( )
1065+ for ( let index = 1 ; index < 12 ; index ++ ) {
10401066 session . addTab ( )
10411067 }
10421068
1043- expect ( session . listTabs ( ) ) . toHaveLength ( MAX_BROWSER_TABS )
1044- expect ( ( ) => session . addTab ( ) ) . toThrow (
1045- `The browser supports up to ${ MAX_BROWSER_TABS } open tabs.`
1046- )
1069+ expect ( session . listTabs ( ) ) . toHaveLength ( 12 )
1070+ const duplicate = session . duplicateTab ( first . id )
1071+ expect ( duplicate ) . not . toBeNull ( )
1072+ expect ( session . listTabs ( ) ) . toHaveLength ( 13 )
1073+ if ( ! duplicate ) throw new Error ( 'expected the tab to be duplicated' )
1074+
1075+ session . closeTab ( duplicate . id )
1076+ expect ( session . listTabs ( ) ) . toHaveLength ( 12 )
1077+ expect ( session . reopenClosedTab ( ) ) . not . toBeNull ( )
1078+ expect ( session . listTabs ( ) ) . toHaveLength ( 13 )
10471079 } )
10481080
10491081 it ( 'embeds the active view in the MAIN window only while panel bounds are reported' , ( ) => {
0 commit comments