diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index 3d186031..aca22e10 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -56,8 +56,25 @@ const versionTag = connitJson.version; const GITHUB_URLS = { original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main', fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main', - commitJson: (branch: string) => - `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`, + commitJson: async (branch: string) => { + try { + const response = await fetch(`https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/${branch}`); + const data: { sha: string } = await response.json(); + + const packageJsonResp = await fetch( + `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/package.json`, + ); + const packageJson: { version: string } = await packageJsonResp.json(); + + return { + commit: data.sha.slice(0, 7), + version: packageJson.version, + }; + } catch (error) { + console.log('Failed to fetch local commit info:', error); + throw new Error('Failed to fetch local commit info'); + } + }, }; function getSystemInfo(): SystemInfo { @@ -373,14 +390,9 @@ export default function DebugTab() { const branchToCheck = isLatestBranch ? 'main' : 'stable'; console.log(`[Debug] Checking for updates against ${branchToCheck} branch`); - const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck)); + const latestCommitResp = await GITHUB_URLS.commitJson(branchToCheck); - if (!localCommitResponse.ok) { - throw new Error('Failed to fetch local commit info'); - } - - const localCommitData = (await localCommitResponse.json()) as CommitData; - const remoteCommitHash = localCommitData.commit; + const remoteCommitHash = latestCommitResp.commit; const currentCommitHash = versionHash; if (remoteCommitHash !== currentCommitHash) { diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index 3f551510..28548329 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -35,18 +35,12 @@ export function useSettings() { // Function to check if we're on stable version const checkIsStableVersion = async () => { try { - const stableResponse = await fetch( - `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/refs/tags/v${versionData.version}/app/commit.json`, + const response = await fetch( + `https://api.github.com/repos/stackblitz-labs/bolt.diy/git/refs/tags/v${versionData.version}`, ); + const data: { object: { sha: string } } = await response.json(); - if (!stableResponse.ok) { - console.warn('Failed to fetch stable commit info'); - return false; - } - - const stableData = (await stableResponse.json()) as CommitData; - - return versionData.commit === stableData.commit; + return versionData.commit.slice(0, 7) === data.object.sha.slice(0, 7); } catch (error) { console.warn('Error checking stable version:', error); return false;