From 070e911be17e1e1f3994220c3ed89b0060c67bd2 Mon Sep 17 00:00:00 2001 From: eduardruzga Date: Mon, 16 Dec 2024 11:09:35 +0200 Subject: [PATCH] Lint fix --- app/components/chat/BaseChat.tsx | 6 +----- .../settings/chat-history/ChatHistoryTab.tsx | 6 +++++- app/components/settings/debug/DebugTab.tsx | 19 +++++++++++-------- .../settings/features/FeaturesTab.tsx | 14 ++++++++++++-- .../settings/providers/ProvidersTab.tsx | 3 ++- app/lib/hooks/useSettings.tsx | 12 +++++++++--- 6 files changed, 40 insertions(+), 20 deletions(-) diff --git a/app/components/chat/BaseChat.tsx b/app/components/chat/BaseChat.tsx index 162241d..edefe05 100644 --- a/app/components/chat/BaseChat.tsx +++ b/app/components/chat/BaseChat.tsx @@ -77,7 +77,6 @@ export const BaseChat = React.forwardRef( input = '', enhancingPrompt, handleInputChange, - promptEnhanced, enhancePrompt, sendMessage, handleStop, @@ -490,10 +489,7 @@ export const BaseChat = React.forwardRef( { enhancePrompt?.(); toast.success('Prompt enhanced!'); diff --git a/app/components/settings/chat-history/ChatHistoryTab.tsx b/app/components/settings/chat-history/ChatHistoryTab.tsx index bd98f3d..ea5187b 100644 --- a/app/components/settings/chat-history/ChatHistoryTab.tsx +++ b/app/components/settings/chat-history/ChatHistoryTab.tsx @@ -22,7 +22,8 @@ export default function ChatHistoryTab() { }; const handleDeleteAllChats = async () => { - const confirmDelete = window.confirm("Are you sure you want to delete all chats? This action cannot be undone."); + const confirmDelete = window.confirm('Are you sure you want to delete all chats? This action cannot be undone.'); + if (!confirmDelete) { return; // Exit if the user cancels } @@ -31,11 +32,13 @@ export default function ChatHistoryTab() { const error = new Error('Database is not available'); logStore.logError('Failed to delete chats - DB unavailable', error); toast.error('Database is not available'); + return; } try { setIsDeleting(true); + const allChats = await getAll(db); await Promise.all(allChats.map((chat) => deleteById(db!, chat.id))); logStore.logSystem('All chats deleted successfully', { count: allChats.length }); @@ -55,6 +58,7 @@ export default function ChatHistoryTab() { const error = new Error('Database is not available'); logStore.logError('Failed to export chats - DB unavailable', error); toast.error('Database is not available'); + return; } diff --git a/app/components/settings/debug/DebugTab.tsx b/app/components/settings/debug/DebugTab.tsx index fea78c8..a7021f7 100644 --- a/app/components/settings/debug/DebugTab.tsx +++ b/app/components/settings/debug/DebugTab.tsx @@ -41,7 +41,8 @@ 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: (branch: string) => `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`, + commitJson: (branch: string) => + `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`, }; function getSystemInfo(): SystemInfo { @@ -227,19 +228,20 @@ export default function DebugTab() { provider.name.toLowerCase() === 'ollama' ? 'OLLAMA_API_BASE_URL' : provider.name.toLowerCase() === 'lmstudio' - ? 'LMSTUDIO_API_BASE_URL' - : `REACT_APP_${provider.name.toUpperCase()}_URL`; + ? 'LMSTUDIO_API_BASE_URL' + : `REACT_APP_${provider.name.toUpperCase()}_URL`; // 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); + return { ...status, enabled: provider.settings.enabled ?? false, }; - }) + }), ); setActiveProviders(statuses); @@ -269,19 +271,20 @@ export default function DebugTab() { console.log(`[Debug] Checking for updates against ${branchToCheck} branch`); const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck)); + if (!localCommitResponse.ok) { throw new Error('Failed to fetch local commit info'); } - const localCommitData = await localCommitResponse.json() as CommitData; + const localCommitData = (await localCommitResponse.json()) as CommitData; const remoteCommitHash = localCommitData.commit; const currentCommitHash = versionHash; if (remoteCommitHash !== currentCommitHash) { setUpdateMessage( `Update available from ${branchToCheck} branch!\n` + - `Current: ${currentCommitHash.slice(0, 7)}\n` + - `Latest: ${remoteCommitHash.slice(0, 7)}` + `Current: ${currentCommitHash.slice(0, 7)}\n` + + `Latest: ${remoteCommitHash.slice(0, 7)}`, ); } else { setUpdateMessage(`You are on the latest version from the ${branchToCheck} branch`); @@ -309,7 +312,7 @@ export default function DebugTab() { })), Version: { hash: versionHash.slice(0, 7), - branch: useLatestBranch ? 'main' : 'stable' + branch: useLatestBranch ? 'main' : 'stable', }, Timestamp: new Date().toISOString(), }; diff --git a/app/components/settings/features/FeaturesTab.tsx b/app/components/settings/features/FeaturesTab.tsx index c0b33ad..d16d685 100644 --- a/app/components/settings/features/FeaturesTab.tsx +++ b/app/components/settings/features/FeaturesTab.tsx @@ -3,7 +3,15 @@ import { Switch } from '~/components/ui/Switch'; import { useSettings } from '~/lib/hooks/useSettings'; export default function FeaturesTab() { - const { debug, enableDebugMode, isLocalModel, enableLocalModels, eventLogs, enableEventLogs, useLatestBranch, enableLatestBranch } = useSettings(); + const { + debug, + enableDebugMode, + isLocalModel, + enableLocalModels, + enableEventLogs, + useLatestBranch, + enableLatestBranch, + } = useSettings(); const handleToggle = (enabled: boolean) => { enableDebugMode(enabled); @@ -22,7 +30,9 @@ export default function FeaturesTab() {
Use Main Branch -

Check for updates against the main branch instead of stable

+

+ Check for updates against the main branch instead of stable +

diff --git a/app/components/settings/providers/ProvidersTab.tsx b/app/components/settings/providers/ProvidersTab.tsx index 926a3c8..281b4c8 100644 --- a/app/components/settings/providers/ProvidersTab.tsx +++ b/app/components/settings/providers/ProvidersTab.tsx @@ -56,7 +56,8 @@ export default function ProvidersTab() {
{ // Fallback to default icon on error + onError={(e) => { + // Fallback to default icon on error e.currentTarget.src = DefaultIcon; }} alt={`${provider.name} icon`} diff --git a/app/lib/hooks/useSettings.tsx b/app/lib/hooks/useSettings.tsx index 0a7d65e..c8b1968 100644 --- a/app/lib/hooks/useSettings.tsx +++ b/app/lib/hooks/useSettings.tsx @@ -28,12 +28,17 @@ 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/stable/app/commit.json'); + 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() as CommitData; + + const stableData = (await stableResponse.json()) as CommitData; + return commit.commit === stableData.commit; } catch (error) { console.warn('Error checking stable version:', error); @@ -86,9 +91,10 @@ export function useSettings() { // load latest branch setting from cookies or determine based on version const savedLatestBranch = Cookies.get('useLatestBranch'); + if (savedLatestBranch === undefined) { // If setting hasn't been set by user, check version - checkIsStableVersion().then(isStable => { + checkIsStableVersion().then((isStable) => { const shouldUseLatest = !isStable; latestBranch.set(shouldUseLatest); Cookies.set('useLatestBranch', String(shouldUseLatest));