@@ -50,9 +50,9 @@ func TestOpenCodeChatServerAndEvents(t *testing.T) {
5050 emittedMu .Unlock ()
5151 },
5252 findOpencode : func () (string , error ) { return "opencode-test" , nil },
53- opencodeMajor : func (context.Context , string , []string ) (int , error ) {
53+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) {
5454 versionChecks .Add (1 )
55- return 1 , nil
55+ return [ 3 ] int { 1 } , nil
5656 },
5757 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) {
5858 return fake .start (args , env )
@@ -590,9 +590,9 @@ func TestOpenCodeV2ChatAndMissingSessionFallback(t *testing.T) {
590590 server := New (database , "local" , false , "dev" , root , Options {
591591 DBPath : filepath .Join (root , "test.db" ),
592592 findOpencode : func () (string , error ) { return "opencode-v2-test" , nil },
593- opencodeMajor : func (context.Context , string , []string ) (int , error ) {
593+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) {
594594 versionChecks .Add (1 )
595- return 2 , nil
595+ return [ 3 ] int { 2 } , nil
596596 },
597597 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) {
598598 return fake .start (args , env )
@@ -740,7 +740,7 @@ func TestOpenCodeV2WaitsForMCPAndNotesFailure(t *testing.T) {
740740 var emitted []map [string ]any
741741 server := New (database , "local" , false , "dev" , root , Options {
742742 DBPath : filepath .Join (root , "test.db" ), findOpencode : func () (string , error ) { return "opencode-v2-test" , nil },
743- opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 2 , nil },
743+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 2 } , nil },
744744 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) },
745745 Emit : func (_ string , event any ) {
746746 emittedMu .Lock ()
@@ -808,7 +808,7 @@ func TestOpenCodeV2LaterPromptDoesNotWaitForMCP(t *testing.T) {
808808 fake .mcpMode = "failed"
809809 server := New (database , "local" , false , "dev" , root , Options {
810810 DBPath : filepath .Join (root , "test.db" ), findOpencode : func () (string , error ) { return "opencode-v2-test" , nil },
811- opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 2 , nil },
811+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 2 } , nil },
812812 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) },
813813 })
814814 addChatMCPTestServers (t , server )
@@ -850,7 +850,7 @@ func TestOpenCodeV2PendingMCPRefreshesAndReconnects(t *testing.T) {
850850 fake .mcpMode = "hang"
851851 server := New (database , "local" , false , "dev" , root , Options {
852852 DBPath : filepath .Join (root , "test.db" ), findOpencode : func () (string , error ) { return "opencode-v2-test" , nil },
853- opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 2 , nil },
853+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 2 } , nil },
854854 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) },
855855 })
856856 addChatMCPTestServers (t , server )
@@ -890,7 +890,7 @@ func TestOpenCodeV1ReconnectsFailedMCPBeforePrompt(t *testing.T) {
890890 fake .mcpFailed = "stdio-test"
891891 server := New (database , "local" , false , "dev" , root , Options {
892892 DBPath : filepath .Join (root , "test.db" ), findOpencode : func () (string , error ) { return "opencode-test" , nil },
893- opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 1 , nil },
893+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 1 } , nil },
894894 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) },
895895 })
896896 addChatMCPTestServers (t , server )
@@ -926,7 +926,7 @@ func TestOpenCodeV2ReconnectsFailedMCPBeforePrompt(t *testing.T) {
926926 fake .mcpMode = "recover"
927927 server := New (database , "local" , false , "dev" , root , Options {
928928 DBPath : filepath .Join (root , "test.db" ), findOpencode : func () (string , error ) { return "opencode-v2-test" , nil },
929- opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 2 , nil },
929+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 2 } , nil },
930930 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) },
931931 })
932932 addChatMCPTestServers (t , server )
@@ -1329,7 +1329,7 @@ func TestOpenCodeV2QueueDrainResumesSessionWithoutDeadlock(t *testing.T) {
13291329 fake := newOpenCodeV2Fake (t )
13301330 server := New (database , "local" , false , "dev" , root , Options {
13311331 DBPath : filepath .Join (root , "test.db" ), findOpencode : func () (string , error ) { return "opencode-v2-test" , nil },
1332- opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 2 , nil },
1332+ opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 2 } , nil },
13331333 opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) },
13341334 })
13351335 addChatMCPTestServers (t , server )
@@ -1383,7 +1383,7 @@ func TestReloadMCPRetiresSharedOpenCodeServer(t *testing.T) {
13831383 }
13841384 a , b := createDriverTestChat (t , database , connectorID , root ), createDriverTestChat (t , database , connectorID , root )
13851385 fake := newOpenCodeFake (t )
1386- server := New (database , "local" , false , "dev" , root , Options {DBPath : filepath .Join (root , "test.db" ), mcpExecutable : "/usr/bin/patio" , findOpencode : func () (string , error ) { return "opencode-test" , nil }, opencodeMajor : func (context.Context , string , []string ) (int , error ) { return 1 , nil }, opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) }})
1386+ server := New (database , "local" , false , "dev" , root , Options {DBPath : filepath .Join (root , "test.db" ), mcpExecutable : "/usr/bin/patio" , findOpencode : func () (string , error ) { return "opencode-test" , nil }, opencodeVersion : func (context.Context , string , []string ) ([ 3 ] int , error ) { return [ 3 ] int { 1 } , nil }, opencodeStarter : func (_ string , args , env []string ) (opencodeProcess , error ) { return fake .start (args , env ) }})
13871387 addChatMCPTestServers (t , server )
13881388 t .Cleanup (func () {
13891389 if err := server .Close (); err != nil {
@@ -1427,3 +1427,18 @@ func TestReloadMCPRetiresSharedOpenCodeServer(t *testing.T) {
14271427 t .Fatalf ("starts=%d kills=%d after B restart" , starts , kills )
14281428 }
14291429}
1430+
1431+ func TestOpencodeCatalogLags (t * testing.T ) {
1432+ for version , want := range map [[3 ]int ]bool {
1433+ {1 , 18 , 35 }: true ,
1434+ {2 , 1 , 2 }: true ,
1435+ {2 , 2 , 5 }: true ,
1436+ {2 , 2 , 6 }: false ,
1437+ {2 , 3 , 0 }: false ,
1438+ {3 , 0 , 0 }: false ,
1439+ } {
1440+ if got := opencodeCatalogLags (version ); got != want {
1441+ t .Errorf ("opencodeCatalogLags(%v) = %v, want %v" , version , got , want )
1442+ }
1443+ }
1444+ }
0 commit comments