From bb03c30ddde8987a065bdbcedffe083645f9197d Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sat, 14 Dec 2024 20:09:25 -0500 Subject: [PATCH 01/11] Update DebugTab.tsx Fixed Check for Update not getting the correct commit --- app/components/settings/debug/DebugTab.tsx | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index e18607d..3f19a48 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -35,6 +35,7 @@ const versionHash = commit.commit; 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: 'https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/main/app/commit.json', }; function getSystemInfo(): SystemInfo { @@ -257,29 +258,22 @@ export default function DebugTab() { setIsCheckingUpdate(true); setUpdateMessage('Checking for updates...'); - const [originalResponse, forkResponse] = await Promise.all([ - fetch(GITHUB_URLS.original), - fetch(GITHUB_URLS.fork), - ]); - - if (!originalResponse.ok || !forkResponse.ok) { + // Fetch the commit data from the specified URL + const localCommitResponse = await fetch(GITHUB_URLS.commitJson); + if (!localCommitResponse.ok) { throw new Error('Failed to fetch repository information'); } - const [originalData, forkData] = await Promise.all([ - originalResponse.json() as Promise<{ sha: string }>, - forkResponse.json() as Promise<{ sha: string }>, - ]); + const localCommitData = await localCommitResponse.json(); + const originalCommitHash = localCommitData.commit; // Use the fetched commit hash - const originalCommitHash = originalData.sha; - const forkCommitHash = forkData.sha; - const isForked = versionHash === forkCommitHash && forkCommitHash !== originalCommitHash; + const currentLocalCommitHash = commit.commit; // Your current local commit hash - if (originalCommitHash !== versionHash) { + if (originalCommitHash !== currentLocalCommitHash) { setUpdateMessage( `Update available from original repository!\n` + - `Current: ${versionHash.slice(0, 7)}${isForked ? ' (forked)' : ''}\n` + - `Latest: ${originalCommitHash.slice(0, 7)}`, + `Current: ${currentLocalCommitHash.slice(0, 7)}\n` + + `Latest: ${originalCommitHash.slice(0, 7)}` ); } else { setUpdateMessage('You are on the latest version from the original repository'); From a976a25094b4a683178168660dc2e631716848ca Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sat, 14 Dec 2024 20:11:20 -0500 Subject: [PATCH 02/11] Update DebugTab.tsx fixed the Local LLM Status not showing BaseURL's --- app/components/settings/debug/DebugTab.tsx | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index 3f19a48..9b2a1b3 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -27,6 +27,7 @@ interface IProviderConfig { name: string; settings: { enabled: boolean; + baseUrl?: string; }; } @@ -213,29 +214,30 @@ export default function DebugTab() { try { const entries = Object.entries(providers) as [string, IProviderConfig][]; - const statuses = entries - .filter(([, provider]) => LOCAL_PROVIDERS.includes(provider.name)) - .map(async ([, provider]) => { - const envVarName = - provider.name.toLowerCase() === 'ollama' - ? 'OLLAMA_API_BASE_URL' - : provider.name.toLowerCase() === 'lmstudio' + const statuses = await Promise.all( + entries + .filter(([, provider]) => LOCAL_PROVIDERS.includes(provider.name)) + .map(async ([, provider]) => { + const envVarName = + provider.name.toLowerCase() === 'ollama' + ? 'OLLAMA_API_BASE_URL' + : provider.name.toLowerCase() === 'lmstudio' ? 'LMSTUDIO_API_BASE_URL' : `REACT_APP_${provider.name.toUpperCase()}_URL`; - // Access environment variables through import.meta.env - const url = import.meta.env[envVarName] || null; - console.log(`[Debug] Using URL for ${provider.name}:`, url, `(from ${envVarName})`); + // Access environment variables through import.meta.env + const url = import.meta.env[envVarName] || provider.settings.baseUrl || null; // Ensure baseUrl is used + console.log(`[Debug] Using URL for ${provider.name}:`, url, `(from ${envVarName})`); - const status = await checkProviderStatus(url, provider.name); + const status = await checkProviderStatus(url, provider.name); + return { + ...status, + enabled: provider.settings.enabled ?? false, + }; + }) + ); - return { - ...status, - enabled: provider.settings.enabled ?? false, - }; - }); - - Promise.all(statuses).then(setActiveProviders); + setActiveProviders(statuses); } catch (error) { console.error('[Debug] Failed to update provider statuses:', error); } From aa3559149f7db835bbbdd5b7cc896031ecb18f06 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sat, 14 Dec 2024 20:35:41 -0500 Subject: [PATCH 03/11] Update DebugTab.tsx --- app/components/settings/debug/DebugTab.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index 9b2a1b3..1eacd11 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -266,7 +266,12 @@ export default function DebugTab() { throw new Error('Failed to fetch repository information'); } - const localCommitData = await localCommitResponse.json(); + // Define the expected structure of the commit data + interface CommitData { + commit: string; + } + + const localCommitData: CommitData = await localCommitResponse.json(); // Explicitly define the type here const originalCommitHash = localCommitData.commit; // Use the fetched commit hash const currentLocalCommitHash = commit.commit; // Your current local commit hash From a698fba1c74aacb6b89dfd97e81053030af61973 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 11:00:23 -0500 Subject: [PATCH 04/11] feat: start update by branch Here is a start to the update by branch --- .github/workflows/commit.yaml | 7 +++++-- app/commit.json | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index d5db06b..fc41e67 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -20,14 +20,17 @@ jobs: - name: Get the latest commit hash run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV + - name: Get the current branch name + run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV + - name: Update commit file run: | - echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json + echo "{ \"commit\": \"$COMMIT_HASH\", \"branch\": \"$BRANCH_NAME\" }" > app/commit.json - name: Commit and push the update run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add app/commit.json - git commit -m "chore: update commit hash to $COMMIT_HASH" + git commit -m "chore: update commit hash to $COMMIT_HASH on branch $BRANCH_NAME" git push \ No newline at end of file diff --git a/app/commit.json b/app/commit.json index 1636c99..aba90c6 100644 --- a/app/commit.json +++ b/app/commit.json @@ -1 +1 @@ -{ "commit": "ece0213500a94a6b29e29512c5040baf57884014" } +{ "commit": "87a90718d31bd8ec501cb32f863efd26156fb1e2", "branch": "main" } From b160d23b4822b935f465c338c71892cff44adb42 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 11:06:33 -0500 Subject: [PATCH 05/11] update by branch --- app/components/settings/debug/DebugTab.tsx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index 1eacd11..30f0fb4 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -36,7 +36,7 @@ const versionHash = commit.commit; 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: 'https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/main/app/commit.json', + commitJson: (branch: string) => `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`, }; function getSystemInfo(): SystemInfo { @@ -260,8 +260,11 @@ export default function DebugTab() { setIsCheckingUpdate(true); setUpdateMessage('Checking for updates...'); - // Fetch the commit data from the specified URL - const localCommitResponse = await fetch(GITHUB_URLS.commitJson); + // Get current branch from commit.json + const currentBranch = commit.branch || 'main'; + + // Fetch the commit data from the specified URL for the current branch + const localCommitResponse = await fetch(GITHUB_URLS.commitJson(currentBranch)); if (!localCommitResponse.ok) { throw new Error('Failed to fetch repository information'); } @@ -269,21 +272,22 @@ export default function DebugTab() { // Define the expected structure of the commit data interface CommitData { commit: string; + branch: string; } - const localCommitData: CommitData = await localCommitResponse.json(); // Explicitly define the type here - const originalCommitHash = localCommitData.commit; // Use the fetched commit hash + const localCommitData: CommitData = await localCommitResponse.json(); + const originalCommitHash = localCommitData.commit; - const currentLocalCommitHash = commit.commit; // Your current local commit hash + const currentLocalCommitHash = commit.commit; if (originalCommitHash !== currentLocalCommitHash) { setUpdateMessage( - `Update available from original repository!\n` + + `Update available from original repository (${currentBranch} branch)!\n` + `Current: ${currentLocalCommitHash.slice(0, 7)}\n` + `Latest: ${originalCommitHash.slice(0, 7)}` ); } else { - setUpdateMessage('You are on the latest version from the original repository'); + setUpdateMessage(`You are on the latest version from the original repository (${currentBranch} branch)`); } } catch (error) { setUpdateMessage('Failed to check for updates'); From 253e37f901f915867990f50ae75ff881f2234749 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 12:06:42 -0500 Subject: [PATCH 06/11] Update commit.yaml now runs on all branches for auto update to work correctly --- .github/workflows/commit.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index fc41e67..03ea02c 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -3,7 +3,7 @@ name: Update Commit Hash File on: push: branches: - - main + - '**' permissions: contents: write @@ -33,4 +33,4 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git add app/commit.json git commit -m "chore: update commit hash to $COMMIT_HASH on branch $BRANCH_NAME" - git push \ No newline at end of file + git push From 348f396d32ef7b2ea96f9963737089770b8e61ec Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 12:10:44 -0500 Subject: [PATCH 07/11] Update commit.yaml --- .github/workflows/commit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index 03ea02c..f6c9a6e 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -3,7 +3,7 @@ name: Update Commit Hash File on: push: branches: - - '**' + - 'main' permissions: contents: write From 69b1dc4c9a218046a994ba681c98be54a3ad7fb8 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 12:56:25 -0500 Subject: [PATCH 08/11] updated to use settings for branch selection --- .github/workflows/commit.yaml | 11 ++--- app/commit.json | 2 +- app/components/settings/debug/DebugTab.tsx | 41 ++++++++----------- .../settings/features/FeaturesTab.tsx | 17 ++++++-- app/lib/hooks/useSettings.tsx | 17 ++++++++ app/lib/stores/settings.ts | 2 + 6 files changed, 55 insertions(+), 35 deletions(-) diff --git a/.github/workflows/commit.yaml b/.github/workflows/commit.yaml index f6c9a6e..d5db06b 100644 --- a/.github/workflows/commit.yaml +++ b/.github/workflows/commit.yaml @@ -3,7 +3,7 @@ name: Update Commit Hash File on: push: branches: - - 'main' + - main permissions: contents: write @@ -20,17 +20,14 @@ jobs: - name: Get the latest commit hash run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV - - name: Get the current branch name - run: echo "BRANCH_NAME=${GITHUB_REF##*/}" >> $GITHUB_ENV - - name: Update commit file run: | - echo "{ \"commit\": \"$COMMIT_HASH\", \"branch\": \"$BRANCH_NAME\" }" > app/commit.json + echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json - name: Commit and push the update run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" git add app/commit.json - git commit -m "chore: update commit hash to $COMMIT_HASH on branch $BRANCH_NAME" - git push + git commit -m "chore: update commit hash to $COMMIT_HASH" + git push \ No newline at end of file diff --git a/app/commit.json b/app/commit.json index aba90c6..5311377 100644 --- a/app/commit.json +++ b/app/commit.json @@ -1 +1 @@ -{ "commit": "87a90718d31bd8ec501cb32f863efd26156fb1e2", "branch": "main" } +{ "commit": "87a90718d31bd8ec501cb32f863efd26156fb1e2" } diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index d827652..9a8b12f 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -202,7 +202,7 @@ const checkProviderStatus = async (url: string | null, providerName: string): Pr }; export default function DebugTab() { - const { providers } = useSettings(); + const { providers, useLatestBranch } = useSettings(); const [activeProviders, setActiveProviders] = useState([]); const [updateMessage, setUpdateMessage] = useState(''); const [systemInfo] = useState(getSystemInfo()); @@ -261,34 +261,26 @@ export default function DebugTab() { setIsCheckingUpdate(true); setUpdateMessage('Checking for updates...'); - // Get current branch from commit.json - const currentBranch = commit.branch || 'main'; + const branchToCheck = useLatestBranch ? 'main' : 'stable'; + console.log(`[Debug] Checking for updates against ${branchToCheck} branch`); - // Fetch the commit data from the specified URL for the current branch - const localCommitResponse = await fetch(GITHUB_URLS.commitJson(currentBranch)); + const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck)); if (!localCommitResponse.ok) { throw new Error('Failed to fetch repository information'); } - // Define the expected structure of the commit data - interface CommitData { - commit: string; - branch: string; - } + const localCommitData = await localCommitResponse.json(); + const remoteCommitHash = localCommitData.commit; + const currentCommitHash = versionHash; - const localCommitData: CommitData = await localCommitResponse.json(); - const originalCommitHash = localCommitData.commit; - - const currentLocalCommitHash = commit.commit; - - if (originalCommitHash !== currentLocalCommitHash) { + if (remoteCommitHash !== currentCommitHash) { setUpdateMessage( - `Update available from original repository (${currentBranch} branch)!\n` + - `Current: ${currentLocalCommitHash.slice(0, 7)}\n` + - `Latest: ${originalCommitHash.slice(0, 7)}` + `Update available from ${branchToCheck} branch!\n` + + `Current: ${currentCommitHash.slice(0, 7)}\n` + + `Latest: ${remoteCommitHash.slice(0, 7)}` ); } else { - setUpdateMessage(`You are on the latest version from the original repository (${currentBranch} branch)`); + setUpdateMessage(`You are on the latest version from the ${branchToCheck} branch`); } } catch (error) { setUpdateMessage('Failed to check for updates'); @@ -296,7 +288,7 @@ export default function DebugTab() { } finally { setIsCheckingUpdate(false); } - }, [isCheckingUpdate]); + }, [isCheckingUpdate, useLatestBranch]); const handleCopyToClipboard = useCallback(() => { const debugInfo = { @@ -311,14 +303,17 @@ export default function DebugTab() { responseTime: provider.responseTime, url: provider.url, })), - Version: versionHash, + Version: { + hash: versionHash.slice(0, 7), + branch: useLatestBranch ? 'main' : 'stable' + }, Timestamp: new Date().toISOString(), }; navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => { toast.success('Debug information copied to clipboard!'); }); - }, [activeProviders, systemInfo]); + }, [activeProviders, systemInfo, useLatestBranch]); return (
diff --git a/app/components/settings/features/FeaturesTab.tsx b/app/components/settings/features/FeaturesTab.tsx index 0ef7a5d..c0b33ad 100644 --- a/app/components/settings/features/FeaturesTab.tsx +++ b/app/components/settings/features/FeaturesTab.tsx @@ -3,7 +3,7 @@ import { Switch } from '~/components/ui/Switch'; import { useSettings } from '~/lib/hooks/useSettings'; export default function FeaturesTab() { - const { debug, enableDebugMode, isLocalModel, enableLocalModels, eventLogs, enableEventLogs } = useSettings(); + const { debug, enableDebugMode, isLocalModel, enableLocalModels, eventLogs, enableEventLogs, useLatestBranch, enableLatestBranch } = useSettings(); const handleToggle = (enabled: boolean) => { enableDebugMode(enabled); @@ -14,9 +14,18 @@ export default function FeaturesTab() {

Optional Features

-
- Debug Features - +
+
+ Debug Features + +
+
+
+ Use Main Branch +

Check for updates against the main branch instead of stable

+
+ +
diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index 0e79651..52bfbaa 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -5,6 +5,7 @@ import { isLocalModelsEnabled, LOCAL_PROVIDERS, providersStore, + useLatestBranch, } from '~/lib/stores/settings'; import { useCallback, useEffect, useState } from 'react'; import Cookies from 'js-cookie'; @@ -16,6 +17,7 @@ export function useSettings() { const debug = useStore(isDebugMode); const eventLogs = useStore(isEventLogsEnabled); const isLocalModel = useStore(isLocalModelsEnabled); + const useLatest = useStore(useLatestBranch); const [activeProviders, setActiveProviders] = useState([]); // reading values from cookies on mount @@ -60,6 +62,13 @@ export function useSettings() { if (savedLocalModels) { isLocalModelsEnabled.set(savedLocalModels === 'true'); } + + // load latest branch setting from cookies + const savedLatestBranch = Cookies.get('useLatestBranch'); + + if (savedLatestBranch) { + useLatestBranch.set(savedLatestBranch === 'true'); + } }, []); // writing values to cookies on change @@ -111,6 +120,12 @@ export function useSettings() { Cookies.set('isLocalModelsEnabled', String(enabled)); }, []); + const enableLatestBranch = useCallback((enabled: boolean) => { + useLatestBranch.set(enabled); + logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`); + Cookies.set('useLatestBranch', String(enabled)); + }, []); + return { providers, activeProviders, @@ -121,5 +136,7 @@ export function useSettings() { enableEventLogs, isLocalModel, enableLocalModels, + useLatestBranch: useLatest, + enableLatestBranch, }; } diff --git a/app/lib/stores/settings.ts b/app/lib/stores/settings.ts index abbb825..2d34270 100644 --- a/app/lib/stores/settings.ts +++ b/app/lib/stores/settings.ts @@ -46,3 +46,5 @@ export const isDebugMode = atom(false); export const isEventLogsEnabled = atom(false); export const isLocalModelsEnabled = atom(true); + +export const useLatestBranch = atom(false); From c5c3eee2675cb83774a1238735fd481e52851316 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 13:04:50 -0500 Subject: [PATCH 09/11] Update useSettings.tsx if it has not been set by the user yet set it correctly for them --- app/lib/hooks/useSettings.tsx | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index 52bfbaa..e4716cd 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -11,6 +11,7 @@ import { useCallback, useEffect, useState } from 'react'; import Cookies from 'js-cookie'; import type { IProviderSetting, ProviderInfo } from '~/types/model'; import { logStore } from '~/lib/stores/logs'; // assuming logStore is imported from this location +import commit from '~/commit.json'; export function useSettings() { const providers = useStore(providersStore); @@ -20,6 +21,22 @@ export function useSettings() { const useLatest = useStore(useLatestBranch); const [activeProviders, setActiveProviders] = useState([]); + // 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/stable/app/commit.json'); + if (!stableResponse.ok) { + console.warn('Failed to fetch stable commit info'); + return false; + } + const stableData = await stableResponse.json(); + return commit.commit === stableData.commit; + } catch (error) { + console.warn('Error checking stable version:', error); + return false; + } + }; + // reading values from cookies on mount useEffect(() => { const savedProviders = Cookies.get('providers'); @@ -63,10 +80,16 @@ export function useSettings() { isLocalModelsEnabled.set(savedLocalModels === 'true'); } - // load latest branch setting from cookies + // load latest branch setting from cookies or determine based on version const savedLatestBranch = Cookies.get('useLatestBranch'); - - if (savedLatestBranch) { + if (savedLatestBranch === undefined) { + // If setting hasn't been set by user, check version + checkIsStableVersion().then(isStable => { + const shouldUseLatest = !isStable; + useLatestBranch.set(shouldUseLatest); + Cookies.set('useLatestBranch', String(shouldUseLatest)); + }); + } else { useLatestBranch.set(savedLatestBranch === 'true'); } }, []); From 51347edd28692934c4b4e72253a71607a5bde2fd Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 13:08:16 -0500 Subject: [PATCH 10/11] quick fix --- app/components/settings/debug/DebugTab.tsx | 8 ++++++-- app/lib/hooks/useSettings.tsx | 6 +++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index 9a8b12f..fea78c8 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -32,6 +32,10 @@ interface IProviderConfig { }; } +interface CommitData { + commit: string; +} + const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike']; const versionHash = commit.commit; const GITHUB_URLS = { @@ -266,10 +270,10 @@ export default function DebugTab() { const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck)); if (!localCommitResponse.ok) { - throw new Error('Failed to fetch repository information'); + throw new Error('Failed to fetch local commit info'); } - const localCommitData = await localCommitResponse.json(); + const localCommitData = await localCommitResponse.json() as CommitData; const remoteCommitHash = localCommitData.commit; const currentCommitHash = versionHash; diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index e4716cd..038222c 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -13,6 +13,10 @@ import type { IProviderSetting, ProviderInfo } from '~/types/model'; import { logStore } from '~/lib/stores/logs'; // assuming logStore is imported from this location import commit from '~/commit.json'; +interface CommitData { + commit: string; +} + export function useSettings() { const providers = useStore(providersStore); const debug = useStore(isDebugMode); @@ -29,7 +33,7 @@ export function useSettings() { console.warn('Failed to fetch stable commit info'); return false; } - const stableData = await stableResponse.json(); + const stableData = await stableResponse.json() as CommitData; return commit.commit === stableData.commit; } catch (error) { console.warn('Error checking stable version:', error); From b5c8d43d9e172d5efb271539268bccf79f6b60c9 Mon Sep 17 00:00:00 2001 From: Dustin Loring Date: Sun, 15 Dec 2024 14:06:37 -0500 Subject: [PATCH 11/11] quick fix --- app/lib/hooks/useSettings.tsx | 10 +++++----- app/lib/stores/settings.ts | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index 038222c..0a7d65e 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -5,7 +5,7 @@ import { isLocalModelsEnabled, LOCAL_PROVIDERS, providersStore, - useLatestBranch, + latestBranch, } from '~/lib/stores/settings'; import { useCallback, useEffect, useState } from 'react'; import Cookies from 'js-cookie'; @@ -22,7 +22,7 @@ export function useSettings() { const debug = useStore(isDebugMode); const eventLogs = useStore(isEventLogsEnabled); const isLocalModel = useStore(isLocalModelsEnabled); - const useLatest = useStore(useLatestBranch); + const useLatest = useStore(latestBranch); const [activeProviders, setActiveProviders] = useState([]); // Function to check if we're on stable version @@ -90,11 +90,11 @@ export function useSettings() { // If setting hasn't been set by user, check version checkIsStableVersion().then(isStable => { const shouldUseLatest = !isStable; - useLatestBranch.set(shouldUseLatest); + latestBranch.set(shouldUseLatest); Cookies.set('useLatestBranch', String(shouldUseLatest)); }); } else { - useLatestBranch.set(savedLatestBranch === 'true'); + latestBranch.set(savedLatestBranch === 'true'); } }, []); @@ -148,7 +148,7 @@ export function useSettings() { }, []); const enableLatestBranch = useCallback((enabled: boolean) => { - useLatestBranch.set(enabled); + latestBranch.set(enabled); logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`); Cookies.set('useLatestBranch', String(enabled)); }, []); diff --git a/app/lib/stores/settings.ts b/app/lib/stores/settings.ts index 2d34270..2e410a6 100644 --- a/app/lib/stores/settings.ts +++ b/app/lib/stores/settings.ts @@ -47,4 +47,4 @@ export const isEventLogsEnabled = atom(false); export const isLocalModelsEnabled = atom(true); -export const useLatestBranch = atom(false); +export const latestBranch = atom(false);