@@ -11,6 +11,7 @@ import { useCallback, useEffect, useState } from 'react';
1111import Cookies from 'js-cookie' ;
1212import type { IProviderSetting , ProviderInfo } from '~/types/model' ;
1313import { logStore } from '~/lib/stores/logs' ; // assuming logStore is imported from this location
14+ import commit from '~/commit.json' ;
1415
1516export function useSettings ( ) {
1617 const providers = useStore ( providersStore ) ;
@@ -20,6 +21,22 @@ export function useSettings() {
2021 const useLatest = useStore ( useLatestBranch ) ;
2122 const [ activeProviders , setActiveProviders ] = useState < ProviderInfo [ ] > ( [ ] ) ;
2223
24+ // Function to check if we're on stable version
25+ const checkIsStableVersion = async ( ) => {
26+ try {
27+ const stableResponse = await fetch ( 'https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/stable/app/commit.json' ) ;
28+ if ( ! stableResponse . ok ) {
29+ console . warn ( 'Failed to fetch stable commit info' ) ;
30+ return false ;
31+ }
32+ const stableData = await stableResponse . json ( ) ;
33+ return commit . commit === stableData . commit ;
34+ } catch ( error ) {
35+ console . warn ( 'Error checking stable version:' , error ) ;
36+ return false ;
37+ }
38+ } ;
39+
2340 // reading values from cookies on mount
2441 useEffect ( ( ) => {
2542 const savedProviders = Cookies . get ( 'providers' ) ;
@@ -63,10 +80,16 @@ export function useSettings() {
6380 isLocalModelsEnabled . set ( savedLocalModels === 'true' ) ;
6481 }
6582
66- // load latest branch setting from cookies
83+ // load latest branch setting from cookies or determine based on version
6784 const savedLatestBranch = Cookies . get ( 'useLatestBranch' ) ;
68-
69- if ( savedLatestBranch ) {
85+ if ( savedLatestBranch === undefined ) {
86+ // If setting hasn't been set by user, check version
87+ checkIsStableVersion ( ) . then ( isStable => {
88+ const shouldUseLatest = ! isStable ;
89+ useLatestBranch . set ( shouldUseLatest ) ;
90+ Cookies . set ( 'useLatestBranch' , String ( shouldUseLatest ) ) ;
91+ } ) ;
92+ } else {
7093 useLatestBranch . set ( savedLatestBranch === 'true' ) ;
7194 }
7295 } , [ ] ) ;
0 commit comments