@@ -28,14 +28,20 @@ interface IProviderConfig {
2828 name : string ;
2929 settings : {
3030 enabled : boolean ;
31+ baseUrl ?: string ;
3132 } ;
3233}
3334
35+ interface CommitData {
36+ commit : string ;
37+ }
38+
3439const LOCAL_PROVIDERS = [ 'Ollama' , 'LMStudio' , 'OpenAILike' ] ;
3540const versionHash = commit . commit ;
3641const GITHUB_URLS = {
3742 original : 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main' ,
3843 fork : 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main' ,
44+ commitJson : ( branch : string ) => `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${ branch } /app/commit.json` ,
3945} ;
4046
4147function getSystemInfo ( ) : SystemInfo {
@@ -200,7 +206,7 @@ const checkProviderStatus = async (url: string | null, providerName: string): Pr
200206} ;
201207
202208export default function DebugTab ( ) {
203- const { providers } = useSettings ( ) ;
209+ const { providers, useLatestBranch } = useSettings ( ) ;
204210 const [ activeProviders , setActiveProviders ] = useState < ProviderStatus [ ] > ( [ ] ) ;
205211 const [ updateMessage , setUpdateMessage ] = useState < string > ( '' ) ;
206212 const [ systemInfo ] = useState < SystemInfo > ( getSystemInfo ( ) ) ;
@@ -213,29 +219,30 @@ export default function DebugTab() {
213219
214220 try {
215221 const entries = Object . entries ( providers ) as [ string , IProviderConfig ] [ ] ;
216- const statuses = entries
217- . filter ( ( [ , provider ] ) => LOCAL_PROVIDERS . includes ( provider . name ) )
218- . map ( async ( [ , provider ] ) => {
219- const envVarName =
220- provider . name . toLowerCase ( ) === 'ollama'
221- ? 'OLLAMA_API_BASE_URL'
222- : provider . name . toLowerCase ( ) === 'lmstudio'
222+ const statuses = await Promise . all (
223+ entries
224+ . filter ( ( [ , provider ] ) => LOCAL_PROVIDERS . includes ( provider . name ) )
225+ . map ( async ( [ , provider ] ) => {
226+ const envVarName =
227+ provider . name . toLowerCase ( ) === 'ollama'
228+ ? 'OLLAMA_API_BASE_URL'
229+ : provider . name . toLowerCase ( ) === 'lmstudio'
223230 ? 'LMSTUDIO_API_BASE_URL'
224231 : `REACT_APP_${ provider . name . toUpperCase ( ) } _URL` ;
225232
226- // Access environment variables through import.meta.env
227- const url = import . meta. env [ envVarName ] || null ;
228- console . log ( `[Debug] Using URL for ${ provider . name } :` , url , `(from ${ envVarName } )` ) ;
233+ // Access environment variables through import.meta.env
234+ const url = import . meta. env [ envVarName ] || provider . settings . baseUrl || null ; // Ensure baseUrl is used
235+ console . log ( `[Debug] Using URL for ${ provider . name } :` , url , `(from ${ envVarName } )` ) ;
229236
230- const status = await checkProviderStatus ( url , provider . name ) ;
237+ const status = await checkProviderStatus ( url , provider . name ) ;
238+ return {
239+ ...status ,
240+ enabled : provider . settings . enabled ?? false ,
241+ } ;
242+ } )
243+ ) ;
231244
232- return {
233- ...status ,
234- enabled : provider . settings . enabled ?? false ,
235- } ;
236- } ) ;
237-
238- Promise . all ( statuses ) . then ( setActiveProviders ) ;
245+ setActiveProviders ( statuses ) ;
239246 } catch ( error ) {
240247 console . error ( '[Debug] Failed to update provider statuses:' , error ) ;
241248 }
@@ -258,40 +265,34 @@ export default function DebugTab() {
258265 setIsCheckingUpdate ( true ) ;
259266 setUpdateMessage ( 'Checking for updates...' ) ;
260267
261- const [ originalResponse , forkResponse ] = await Promise . all ( [
262- fetch ( GITHUB_URLS . original ) ,
263- fetch ( GITHUB_URLS . fork ) ,
264- ] ) ;
268+ const branchToCheck = useLatestBranch ? 'main' : 'stable' ;
269+ console . log ( `[Debug] Checking for updates against ${ branchToCheck } branch` ) ;
265270
266- if ( ! originalResponse . ok || ! forkResponse . ok ) {
267- throw new Error ( 'Failed to fetch repository information' ) ;
271+ const localCommitResponse = await fetch ( GITHUB_URLS . commitJson ( branchToCheck ) ) ;
272+ if ( ! localCommitResponse . ok ) {
273+ throw new Error ( 'Failed to fetch local commit info' ) ;
268274 }
269275
270- const [ originalData , forkData ] = await Promise . all ( [
271- originalResponse . json ( ) as Promise < { sha : string } > ,
272- forkResponse . json ( ) as Promise < { sha : string } > ,
273- ] ) ;
274-
275- const originalCommitHash = originalData . sha ;
276- const forkCommitHash = forkData . sha ;
277- const isForked = versionHash === forkCommitHash && forkCommitHash !== originalCommitHash ;
276+ const localCommitData = await localCommitResponse . json ( ) as CommitData ;
277+ const remoteCommitHash = localCommitData . commit ;
278+ const currentCommitHash = versionHash ;
278279
279- if ( originalCommitHash !== versionHash ) {
280+ if ( remoteCommitHash !== currentCommitHash ) {
280281 setUpdateMessage (
281- `Update available from original repository !\n` +
282- `Current: ${ versionHash . slice ( 0 , 7 ) } ${ isForked ? ' (forked)' : '' } \n` +
283- `Latest: ${ originalCommitHash . slice ( 0 , 7 ) } ` ,
282+ `Update available from ${ branchToCheck } branch !\n` +
283+ `Current: ${ currentCommitHash . slice ( 0 , 7 ) } \n` +
284+ `Latest: ${ remoteCommitHash . slice ( 0 , 7 ) } `
284285 ) ;
285286 } else {
286- setUpdateMessage ( ' You are on the latest version from the original repository' ) ;
287+ setUpdateMessage ( ` You are on the latest version from the ${ branchToCheck } branch` ) ;
287288 }
288289 } catch ( error ) {
289290 setUpdateMessage ( 'Failed to check for updates' ) ;
290291 console . error ( '[Debug] Failed to check for updates:' , error ) ;
291292 } finally {
292293 setIsCheckingUpdate ( false ) ;
293294 }
294- } , [ isCheckingUpdate ] ) ;
295+ } , [ isCheckingUpdate , useLatestBranch ] ) ;
295296
296297 const handleCopyToClipboard = useCallback ( ( ) => {
297298 const debugInfo = {
@@ -306,14 +307,17 @@ export default function DebugTab() {
306307 responseTime : provider . responseTime ,
307308 url : provider . url ,
308309 } ) ) ,
309- Version : versionHash ,
310+ Version : {
311+ hash : versionHash . slice ( 0 , 7 ) ,
312+ branch : useLatestBranch ? 'main' : 'stable'
313+ } ,
310314 Timestamp : new Date ( ) . toISOString ( ) ,
311315 } ;
312316
313317 navigator . clipboard . writeText ( JSON . stringify ( debugInfo , null , 2 ) ) . then ( ( ) => {
314318 toast . success ( 'Debug information copied to clipboard!' ) ;
315319 } ) ;
316- } , [ activeProviders , systemInfo ] ) ;
320+ } , [ activeProviders , systemInfo , useLatestBranch ] ) ;
317321
318322 return (
319323 < div className = "p-4 space-y-6" >
0 commit comments