@@ -501,3 +501,123 @@ test("deduplicates duplicate plugins from global and local configs", async () =>
501501 } ,
502502 } )
503503} )
504+
505+ test ( "handles TUI configuration with session_list_limit and messages_limit" , async ( ) => {
506+ await using tmp = await tmpdir ( {
507+ init : async ( dir ) => {
508+ await Bun . write (
509+ path . join ( dir , "opencode.json" ) ,
510+ JSON . stringify ( {
511+ $schema : "https://opencode.ai/config.json" ,
512+ tui : {
513+ session_list_limit : 200 ,
514+ messages_limit : 50 ,
515+ } ,
516+ } ) ,
517+ )
518+ } ,
519+ } )
520+ await Instance . provide ( {
521+ directory : tmp . path ,
522+ fn : async ( ) => {
523+ const config = await Config . get ( )
524+ expect ( config . tui ?. session_list_limit ) . toBe ( 200 )
525+ expect ( config . tui ?. messages_limit ) . toBe ( 50 )
526+ } ,
527+ } )
528+ } )
529+
530+ test ( "handles TUI configuration with session_list_limit set to 'none'" , async ( ) => {
531+ await using tmp = await tmpdir ( {
532+ init : async ( dir ) => {
533+ await Bun . write (
534+ path . join ( dir , "opencode.json" ) ,
535+ JSON . stringify ( {
536+ $schema : "https://opencode.ai/config.json" ,
537+ tui : {
538+ session_list_limit : "none" ,
539+ messages_limit : 75 ,
540+ } ,
541+ } ) ,
542+ )
543+ } ,
544+ } )
545+ await Instance . provide ( {
546+ directory : tmp . path ,
547+ fn : async ( ) => {
548+ const config = await Config . get ( )
549+ expect ( config . tui ?. session_list_limit ) . toBe ( "none" )
550+ expect ( config . tui ?. messages_limit ) . toBe ( 75 )
551+ } ,
552+ } )
553+ } )
554+
555+ test ( "validates TUI session_list_limit schema - rejects invalid values" , async ( ) => {
556+ await using tmp = await tmpdir ( {
557+ init : async ( dir ) => {
558+ await Bun . write (
559+ path . join ( dir , "opencode.json" ) ,
560+ JSON . stringify ( {
561+ $schema : "https://opencode.ai/config.json" ,
562+ tui : {
563+ session_list_limit : - 5 , // Invalid: negative number
564+ } ,
565+ } ) ,
566+ )
567+ } ,
568+ } )
569+ await Instance . provide ( {
570+ directory : tmp . path ,
571+ fn : async ( ) => {
572+ await expect ( Config . get ( ) ) . rejects . toThrow ( )
573+ } ,
574+ } )
575+ } )
576+
577+ test ( "validates TUI messages_limit schema - rejects invalid values" , async ( ) => {
578+ await using tmp = await tmpdir ( {
579+ init : async ( dir ) => {
580+ await Bun . write (
581+ path . join ( dir , "opencode.json" ) ,
582+ JSON . stringify ( {
583+ $schema : "https://opencode.ai/config.json" ,
584+ tui : {
585+ messages_limit : 0 , // Invalid: must be >= 1
586+ } ,
587+ } ) ,
588+ )
589+ } ,
590+ } )
591+ await Instance . provide ( {
592+ directory : tmp . path ,
593+ fn : async ( ) => {
594+ await expect ( Config . get ( ) ) . rejects . toThrow ( )
595+ } ,
596+ } )
597+ } )
598+
599+ test ( "handles partial TUI configuration with backward compatibility" , async ( ) => {
600+ await using tmp = await tmpdir ( {
601+ init : async ( dir ) => {
602+ await Bun . write (
603+ path . join ( dir , "opencode.json" ) ,
604+ JSON . stringify ( {
605+ $schema : "https://opencode.ai/config.json" ,
606+ tui : {
607+ scroll_speed : 2.5 ,
608+ // session_list_limit and messages_limit not specified - should inherit from global config
609+ } ,
610+ } ) ,
611+ )
612+ } ,
613+ } )
614+ await Instance . provide ( {
615+ directory : tmp . path ,
616+ fn : async ( ) => {
617+ const config = await Config . get ( )
618+ expect ( config . tui ?. scroll_speed ) . toBe ( 2.5 )
619+ // Note: session_list_limit and messages_limit may be inherited from global config
620+ // The important thing is that the config loads successfully and scroll_speed is set correctly
621+ } ,
622+ } )
623+ } )
0 commit comments