@@ -1440,6 +1440,104 @@ describeControlUiE2e("Control UI mocked Gateway E2E", () => {
14401440 }
14411441 } ) ;
14421442
1443+ it ( "restores the selected agent model after clearing a session override" , async ( ) => {
1444+ const context = await newBrowserContext ( {
1445+ locale : "en-US" ,
1446+ serviceWorkers : "block" ,
1447+ viewport : { height : 900 , width : 1280 } ,
1448+ } ) ;
1449+ const page = await context . newPage ( ) ;
1450+ const agentsList = {
1451+ agents : [
1452+ {
1453+ id : "ops" ,
1454+ model : { primary : "anthropic/claude-opus-4-5" } ,
1455+ name : "Operations" ,
1456+ } ,
1457+ ] ,
1458+ defaultId : "ops" ,
1459+ mainKey : "main" ,
1460+ scope : "agent" ,
1461+ } ;
1462+ const sessionsList = {
1463+ count : 1 ,
1464+ defaults : {
1465+ contextTokens : null ,
1466+ model : "gpt-5.5" ,
1467+ modelProvider : "openai" ,
1468+ } ,
1469+ path : "" ,
1470+ sessions : [
1471+ {
1472+ key : "agent:ops:session-a" ,
1473+ kind : "direct" ,
1474+ label : "Operations" ,
1475+ updatedAt : Date . now ( ) ,
1476+ } ,
1477+ ] ,
1478+ ts : Date . now ( ) ,
1479+ } ;
1480+ const gateway = await installMockGateway ( page , {
1481+ assistantAgentId : "ops" ,
1482+ defaultAgentId : "ops" ,
1483+ methodResponses : {
1484+ "agents.list" : agentsList ,
1485+ "chat.startup" : {
1486+ agentsList,
1487+ messages : [ ] ,
1488+ metadata : {
1489+ models : [
1490+ { id : "gpt-5.5" , name : "GPT-5.5" , provider : "openai" } ,
1491+ {
1492+ id : "claude-opus-4-5" ,
1493+ name : "Claude Opus 4.5" ,
1494+ provider : "anthropic" ,
1495+ } ,
1496+ ] ,
1497+ } ,
1498+ sessionId : "control-ui-e2e-session" ,
1499+ thinkingLevel : null ,
1500+ } ,
1501+ "sessions.list" : sessionsList ,
1502+ } ,
1503+ models : [
1504+ { id : "gpt-5.5" , name : "GPT-5.5" , provider : "openai" } ,
1505+ { id : "claude-opus-4-5" , name : "Claude Opus 4.5" , provider : "anthropic" } ,
1506+ ] ,
1507+ sessionKey : "agent:ops:session-a" ,
1508+ } ) ;
1509+
1510+ try {
1511+ await page . goto ( `${ server . baseUrl } chat` ) ;
1512+ const main = page . getByRole ( "main" ) ;
1513+ const modelSelect = main . locator ( '[data-chat-model-select="true"]' ) . first ( ) ;
1514+ await modelSelect . waitFor ( { state : "visible" , timeout : 10_000 } ) ;
1515+ expect ( await modelSelect . textContent ( ) ) . toContain ( "Claude Opus 4.5" ) ;
1516+ expect ( await modelSelect . getAttribute ( "data-chat-select-value" ) ) . toBe ( "" ) ;
1517+
1518+ await modelSelect . click ( ) ;
1519+ await main . locator ( '[data-chat-model-option="openai/gpt-5.5"]' ) . click ( ) ;
1520+ const firstPatch = await gateway . waitForRequest ( "sessions.patch" ) ;
1521+ expect ( requireRecord ( firstPatch . params ) ) . toMatchObject ( {
1522+ key : "agent:ops:session-a" ,
1523+ model : "openai/gpt-5.5" ,
1524+ } ) ;
1525+ expect ( await modelSelect . textContent ( ) ) . toContain ( "GPT-5.5" ) ;
1526+
1527+ await modelSelect . click ( ) ;
1528+ await main . locator ( '[data-chat-model-option=""]' ) . click ( ) ;
1529+ const patches = await waitForRequests ( gateway , "sessions.patch" , 2 ) ;
1530+ expect ( requireRecord ( patches [ 1 ] ?. params ) ) . toMatchObject ( {
1531+ key : "agent:ops:session-a" ,
1532+ model : null ,
1533+ } ) ;
1534+ expect ( await modelSelect . textContent ( ) ) . toContain ( "Claude Opus 4.5" ) ;
1535+ expect ( await modelSelect . getAttribute ( "data-chat-select-value" ) ) . toBe ( "" ) ;
1536+ } finally {
1537+ await closeBrowserContext ( context ) ;
1538+ }
1539+ } ) ;
1540+
14431541 it ( "clears hover marquee state when a session switch reshuffles recent rows" , async ( ) => {
14441542 const context = await newBrowserContext ( {
14451543 locale : "en-US" ,
0 commit comments