@@ -13,7 +13,7 @@ import {
1313 permissionChoices ,
1414 type ProductHostConfig ,
1515} from "./product-host.js"
16- import { buildModelsFirstCatalog } from "./model-catalog.js"
16+ import { buildModelsFirstCatalog , modelOptionId } from "./model-catalog.js"
1717
1818function makeFakeSessionPort ( ) : {
1919 readonly sends : string [ ]
@@ -383,6 +383,7 @@ describe("provider-first model picker", () => {
383383 interrupt : port . interrupt ,
384384 createRenderer : async ( ) => harness . renderer ,
385385 models : catalog ,
386+ activeModelId : ( ) => modelOptionId ( "xai/thegreataxios" , "grok-4.5" ) ,
386387 onModelSelect : ( ) => { } ,
387388 } )
388389 try {
@@ -396,6 +397,46 @@ describe("provider-first model picker", () => {
396397 }
397398 } )
398399
400+ test ( "stale recents pointing at a different model do not steal the (current) marker" , async ( ) => {
401+ // Recents still name the model a *previous* session last switched to;
402+ // this session has run codex/abk-labs / gpt-5.5 all along without ever
403+ // touching the picker. The live model, not the recents list, decides
404+ // which row reads "(current)".
405+ const harness = await createHarness ( { width : 80 , height : 24 } )
406+ const port = makeFakeSessionPort ( )
407+ const catalog = buildModelsFirstCatalog ( {
408+ providers,
409+ recent : [ { provider : "xai/thegreataxios" , model : "grok-4.5" } ] ,
410+ } )
411+ const host = await mountProductHost ( {
412+ title : "test-session" ,
413+ eventEmitter : new EventEmitter ( ) ,
414+ send : port . send ,
415+ interrupt : port . interrupt ,
416+ createRenderer : async ( ) => harness . renderer ,
417+ models : catalog ,
418+ activeModelId : ( ) => modelOptionId ( "codex/abk-labs" , "gpt-5.5" ) ,
419+ onModelSelect : ( ) => { } ,
420+ } )
421+ try {
422+ host . openModels ?.( )
423+ await harness . renderOnce ( )
424+ const frame = harness . captureCharFrame ( )
425+ expect ( frame ) . not . toContain ( "xai/thegreataxios / grok-4.5 (current)" )
426+ const items = host . shell . overlayItems
427+ const codexIndex = items . findIndex ( ( label ) => label . includes ( "codex/abk-labs" ) )
428+ expect ( codexIndex ) . toBeGreaterThanOrEqual ( 0 )
429+ moveOverlaySelection ( host . shell , codexIndex )
430+ acceptOverlaySelection ( host . shell )
431+ await harness . renderOnce ( )
432+ const modelFrame = harness . captureCharFrame ( )
433+ expect ( modelFrame ) . toContain ( "gpt-5.5 (current)" )
434+ } finally {
435+ host . dispose ( )
436+ harness . destroy ( )
437+ }
438+ } )
439+
399440 test ( "fits and scrolls within a short terminal instead of overflowing it" , async ( ) => {
400441 const port = makeFakeSessionPort ( )
401442 const harness = await createHarness ( { width : 80 , height : 10 } )
0 commit comments