updated to use settings for branch selection

This commit is contained in:
Dustin Loring
2024-12-15 12:56:25 -05:00
parent 348f396d32
commit 69b1dc4c9a
6 changed files with 55 additions and 35 deletions

View File

@@ -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<ProviderInfo[]>([]);
// 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,
};
}