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);