ui-ux: debug-tab
Browse filesdebug tab check for update is now branch specific.
fixed bug with getting URLs for experimental models
app/components/settings/debug/DebugTab.tsx
CHANGED
|
@@ -28,14 +28,20 @@ interface IProviderConfig {
|
|
| 28 |
name: string;
|
| 29 |
settings: {
|
| 30 |
enabled: boolean;
|
|
|
|
| 31 |
};
|
| 32 |
}
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
|
| 35 |
const versionHash = commit.commit;
|
| 36 |
const GITHUB_URLS = {
|
| 37 |
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
|
| 38 |
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
|
|
|
|
| 39 |
};
|
| 40 |
|
| 41 |
function getSystemInfo(): SystemInfo {
|
|
@@ -200,7 +206,7 @@ const checkProviderStatus = async (url: string | null, providerName: string): Pr
|
|
| 200 |
};
|
| 201 |
|
| 202 |
export default function DebugTab() {
|
| 203 |
-
const { providers } = useSettings();
|
| 204 |
const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]);
|
| 205 |
const [updateMessage, setUpdateMessage] = useState<string>('');
|
| 206 |
const [systemInfo] = useState<SystemInfo>(getSystemInfo());
|
|
@@ -213,29 +219,30 @@ export default function DebugTab() {
|
|
| 213 |
|
| 214 |
try {
|
| 215 |
const entries = Object.entries(providers) as [string, IProviderConfig][];
|
| 216 |
-
const statuses =
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
|
|
|
| 223 |
? 'LMSTUDIO_API_BASE_URL'
|
| 224 |
: `REACT_APP_${provider.name.toUpperCase()}_URL`;
|
| 225 |
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
-
|
| 233 |
-
...status,
|
| 234 |
-
enabled: provider.settings.enabled ?? false,
|
| 235 |
-
};
|
| 236 |
-
});
|
| 237 |
-
|
| 238 |
-
Promise.all(statuses).then(setActiveProviders);
|
| 239 |
} catch (error) {
|
| 240 |
console.error('[Debug] Failed to update provider statuses:', error);
|
| 241 |
}
|
|
@@ -258,32 +265,26 @@ export default function DebugTab() {
|
|
| 258 |
setIsCheckingUpdate(true);
|
| 259 |
setUpdateMessage('Checking for updates...');
|
| 260 |
|
| 261 |
-
const
|
| 262 |
-
|
| 263 |
-
fetch(GITHUB_URLS.fork),
|
| 264 |
-
]);
|
| 265 |
|
| 266 |
-
|
| 267 |
-
|
|
|
|
| 268 |
}
|
| 269 |
|
| 270 |
-
const
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
]);
|
| 274 |
-
|
| 275 |
-
const originalCommitHash = originalData.sha;
|
| 276 |
-
const forkCommitHash = forkData.sha;
|
| 277 |
-
const isForked = versionHash === forkCommitHash && forkCommitHash !== originalCommitHash;
|
| 278 |
|
| 279 |
-
if (
|
| 280 |
setUpdateMessage(
|
| 281 |
-
`Update available from
|
| 282 |
-
|
| 283 |
-
|
| 284 |
);
|
| 285 |
} else {
|
| 286 |
-
setUpdateMessage(
|
| 287 |
}
|
| 288 |
} catch (error) {
|
| 289 |
setUpdateMessage('Failed to check for updates');
|
|
@@ -291,7 +292,7 @@ export default function DebugTab() {
|
|
| 291 |
} finally {
|
| 292 |
setIsCheckingUpdate(false);
|
| 293 |
}
|
| 294 |
-
}, [isCheckingUpdate]);
|
| 295 |
|
| 296 |
const handleCopyToClipboard = useCallback(() => {
|
| 297 |
const debugInfo = {
|
|
@@ -306,14 +307,17 @@ export default function DebugTab() {
|
|
| 306 |
responseTime: provider.responseTime,
|
| 307 |
url: provider.url,
|
| 308 |
})),
|
| 309 |
-
Version:
|
|
|
|
|
|
|
|
|
|
| 310 |
Timestamp: new Date().toISOString(),
|
| 311 |
};
|
| 312 |
|
| 313 |
navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => {
|
| 314 |
toast.success('Debug information copied to clipboard!');
|
| 315 |
});
|
| 316 |
-
}, [activeProviders, systemInfo]);
|
| 317 |
|
| 318 |
return (
|
| 319 |
<div className="p-4 space-y-6">
|
|
|
|
| 28 |
name: string;
|
| 29 |
settings: {
|
| 30 |
enabled: boolean;
|
| 31 |
+
baseUrl?: string;
|
| 32 |
};
|
| 33 |
}
|
| 34 |
|
| 35 |
+
interface CommitData {
|
| 36 |
+
commit: string;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
|
| 40 |
const versionHash = commit.commit;
|
| 41 |
const GITHUB_URLS = {
|
| 42 |
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
|
| 43 |
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
|
| 44 |
+
commitJson: (branch: string) => `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`,
|
| 45 |
};
|
| 46 |
|
| 47 |
function getSystemInfo(): SystemInfo {
|
|
|
|
| 206 |
};
|
| 207 |
|
| 208 |
export default function DebugTab() {
|
| 209 |
+
const { providers, useLatestBranch } = useSettings();
|
| 210 |
const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]);
|
| 211 |
const [updateMessage, setUpdateMessage] = useState<string>('');
|
| 212 |
const [systemInfo] = useState<SystemInfo>(getSystemInfo());
|
|
|
|
| 219 |
|
| 220 |
try {
|
| 221 |
const entries = Object.entries(providers) as [string, IProviderConfig][];
|
| 222 |
+
const statuses = await Promise.all(
|
| 223 |
+
entries
|
| 224 |
+
.filter(([, provider]) => LOCAL_PROVIDERS.includes(provider.name))
|
| 225 |
+
.map(async ([, provider]) => {
|
| 226 |
+
const envVarName =
|
| 227 |
+
provider.name.toLowerCase() === 'ollama'
|
| 228 |
+
? 'OLLAMA_API_BASE_URL'
|
| 229 |
+
: provider.name.toLowerCase() === 'lmstudio'
|
| 230 |
? 'LMSTUDIO_API_BASE_URL'
|
| 231 |
: `REACT_APP_${provider.name.toUpperCase()}_URL`;
|
| 232 |
|
| 233 |
+
// Access environment variables through import.meta.env
|
| 234 |
+
const url = import.meta.env[envVarName] || provider.settings.baseUrl || null; // Ensure baseUrl is used
|
| 235 |
+
console.log(`[Debug] Using URL for ${provider.name}:`, url, `(from ${envVarName})`);
|
| 236 |
|
| 237 |
+
const status = await checkProviderStatus(url, provider.name);
|
| 238 |
+
return {
|
| 239 |
+
...status,
|
| 240 |
+
enabled: provider.settings.enabled ?? false,
|
| 241 |
+
};
|
| 242 |
+
})
|
| 243 |
+
);
|
| 244 |
|
| 245 |
+
setActiveProviders(statuses);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
} catch (error) {
|
| 247 |
console.error('[Debug] Failed to update provider statuses:', error);
|
| 248 |
}
|
|
|
|
| 265 |
setIsCheckingUpdate(true);
|
| 266 |
setUpdateMessage('Checking for updates...');
|
| 267 |
|
| 268 |
+
const branchToCheck = useLatestBranch ? 'main' : 'stable';
|
| 269 |
+
console.log(`[Debug] Checking for updates against ${branchToCheck} branch`);
|
|
|
|
|
|
|
| 270 |
|
| 271 |
+
const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck));
|
| 272 |
+
if (!localCommitResponse.ok) {
|
| 273 |
+
throw new Error('Failed to fetch local commit info');
|
| 274 |
}
|
| 275 |
|
| 276 |
+
const localCommitData = await localCommitResponse.json() as CommitData;
|
| 277 |
+
const remoteCommitHash = localCommitData.commit;
|
| 278 |
+
const currentCommitHash = versionHash;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
|
| 280 |
+
if (remoteCommitHash !== currentCommitHash) {
|
| 281 |
setUpdateMessage(
|
| 282 |
+
`Update available from ${branchToCheck} branch!\n` +
|
| 283 |
+
`Current: ${currentCommitHash.slice(0, 7)}\n` +
|
| 284 |
+
`Latest: ${remoteCommitHash.slice(0, 7)}`
|
| 285 |
);
|
| 286 |
} else {
|
| 287 |
+
setUpdateMessage(`You are on the latest version from the ${branchToCheck} branch`);
|
| 288 |
}
|
| 289 |
} catch (error) {
|
| 290 |
setUpdateMessage('Failed to check for updates');
|
|
|
|
| 292 |
} finally {
|
| 293 |
setIsCheckingUpdate(false);
|
| 294 |
}
|
| 295 |
+
}, [isCheckingUpdate, useLatestBranch]);
|
| 296 |
|
| 297 |
const handleCopyToClipboard = useCallback(() => {
|
| 298 |
const debugInfo = {
|
|
|
|
| 307 |
responseTime: provider.responseTime,
|
| 308 |
url: provider.url,
|
| 309 |
})),
|
| 310 |
+
Version: {
|
| 311 |
+
hash: versionHash.slice(0, 7),
|
| 312 |
+
branch: useLatestBranch ? 'main' : 'stable'
|
| 313 |
+
},
|
| 314 |
Timestamp: new Date().toISOString(),
|
| 315 |
};
|
| 316 |
|
| 317 |
navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => {
|
| 318 |
toast.success('Debug information copied to clipboard!');
|
| 319 |
});
|
| 320 |
+
}, [activeProviders, systemInfo, useLatestBranch]);
|
| 321 |
|
| 322 |
return (
|
| 323 |
<div className="p-4 space-y-6">
|
app/components/settings/features/FeaturesTab.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { Switch } from '~/components/ui/Switch';
|
|
| 3 |
import { useSettings } from '~/lib/hooks/useSettings';
|
| 4 |
|
| 5 |
export default function FeaturesTab() {
|
| 6 |
-
const { debug, enableDebugMode, isLocalModel, enableLocalModels, eventLogs, enableEventLogs } = useSettings();
|
| 7 |
|
| 8 |
const handleToggle = (enabled: boolean) => {
|
| 9 |
enableDebugMode(enabled);
|
|
@@ -14,9 +14,18 @@ export default function FeaturesTab() {
|
|
| 14 |
<div className="p-4 bg-bolt-elements-bg-depth-2 border border-bolt-elements-borderColor rounded-lg mb-4">
|
| 15 |
<div className="mb-6">
|
| 16 |
<h3 className="text-lg font-medium text-bolt-elements-textPrimary mb-4">Optional Features</h3>
|
| 17 |
-
<div className="
|
| 18 |
-
<
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
</div>
|
| 21 |
</div>
|
| 22 |
|
|
|
|
| 3 |
import { useSettings } from '~/lib/hooks/useSettings';
|
| 4 |
|
| 5 |
export default function FeaturesTab() {
|
| 6 |
+
const { debug, enableDebugMode, isLocalModel, enableLocalModels, eventLogs, enableEventLogs, useLatestBranch, enableLatestBranch } = useSettings();
|
| 7 |
|
| 8 |
const handleToggle = (enabled: boolean) => {
|
| 9 |
enableDebugMode(enabled);
|
|
|
|
| 14 |
<div className="p-4 bg-bolt-elements-bg-depth-2 border border-bolt-elements-borderColor rounded-lg mb-4">
|
| 15 |
<div className="mb-6">
|
| 16 |
<h3 className="text-lg font-medium text-bolt-elements-textPrimary mb-4">Optional Features</h3>
|
| 17 |
+
<div className="space-y-4">
|
| 18 |
+
<div className="flex items-center justify-between">
|
| 19 |
+
<span className="text-bolt-elements-textPrimary">Debug Features</span>
|
| 20 |
+
<Switch className="ml-auto" checked={debug} onCheckedChange={handleToggle} />
|
| 21 |
+
</div>
|
| 22 |
+
<div className="flex items-center justify-between">
|
| 23 |
+
<div>
|
| 24 |
+
<span className="text-bolt-elements-textPrimary">Use Main Branch</span>
|
| 25 |
+
<p className="text-sm text-bolt-elements-textSecondary">Check for updates against the main branch instead of stable</p>
|
| 26 |
+
</div>
|
| 27 |
+
<Switch className="ml-auto" checked={useLatestBranch} onCheckedChange={enableLatestBranch} />
|
| 28 |
+
</div>
|
| 29 |
</div>
|
| 30 |
</div>
|
| 31 |
|
app/lib/hooks/useSettings.tsx
CHANGED
|
@@ -5,19 +5,42 @@ import {
|
|
| 5 |
isLocalModelsEnabled,
|
| 6 |
LOCAL_PROVIDERS,
|
| 7 |
providersStore,
|
|
|
|
| 8 |
} from '~/lib/stores/settings';
|
| 9 |
import { useCallback, useEffect, useState } from 'react';
|
| 10 |
import Cookies from 'js-cookie';
|
| 11 |
import type { IProviderSetting, ProviderInfo } from '~/types/model';
|
| 12 |
import { logStore } from '~/lib/stores/logs'; // assuming logStore is imported from this location
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
export function useSettings() {
|
| 15 |
const providers = useStore(providersStore);
|
| 16 |
const debug = useStore(isDebugMode);
|
| 17 |
const eventLogs = useStore(isEventLogsEnabled);
|
| 18 |
const isLocalModel = useStore(isLocalModelsEnabled);
|
|
|
|
| 19 |
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
// reading values from cookies on mount
|
| 22 |
useEffect(() => {
|
| 23 |
const savedProviders = Cookies.get('providers');
|
|
@@ -60,6 +83,19 @@ export function useSettings() {
|
|
| 60 |
if (savedLocalModels) {
|
| 61 |
isLocalModelsEnabled.set(savedLocalModels === 'true');
|
| 62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}, []);
|
| 64 |
|
| 65 |
// writing values to cookies on change
|
|
@@ -111,6 +147,12 @@ export function useSettings() {
|
|
| 111 |
Cookies.set('isLocalModelsEnabled', String(enabled));
|
| 112 |
}, []);
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
return {
|
| 115 |
providers,
|
| 116 |
activeProviders,
|
|
@@ -121,5 +163,7 @@ export function useSettings() {
|
|
| 121 |
enableEventLogs,
|
| 122 |
isLocalModel,
|
| 123 |
enableLocalModels,
|
|
|
|
|
|
|
| 124 |
};
|
| 125 |
}
|
|
|
|
| 5 |
isLocalModelsEnabled,
|
| 6 |
LOCAL_PROVIDERS,
|
| 7 |
providersStore,
|
| 8 |
+
latestBranch,
|
| 9 |
} from '~/lib/stores/settings';
|
| 10 |
import { useCallback, useEffect, useState } from 'react';
|
| 11 |
import Cookies from 'js-cookie';
|
| 12 |
import type { IProviderSetting, ProviderInfo } from '~/types/model';
|
| 13 |
import { logStore } from '~/lib/stores/logs'; // assuming logStore is imported from this location
|
| 14 |
+
import commit from '~/commit.json';
|
| 15 |
+
|
| 16 |
+
interface CommitData {
|
| 17 |
+
commit: string;
|
| 18 |
+
}
|
| 19 |
|
| 20 |
export function useSettings() {
|
| 21 |
const providers = useStore(providersStore);
|
| 22 |
const debug = useStore(isDebugMode);
|
| 23 |
const eventLogs = useStore(isEventLogsEnabled);
|
| 24 |
const isLocalModel = useStore(isLocalModelsEnabled);
|
| 25 |
+
const useLatest = useStore(latestBranch);
|
| 26 |
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
| 27 |
|
| 28 |
+
// Function to check if we're on stable version
|
| 29 |
+
const checkIsStableVersion = async () => {
|
| 30 |
+
try {
|
| 31 |
+
const stableResponse = await fetch('https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/stable/app/commit.json');
|
| 32 |
+
if (!stableResponse.ok) {
|
| 33 |
+
console.warn('Failed to fetch stable commit info');
|
| 34 |
+
return false;
|
| 35 |
+
}
|
| 36 |
+
const stableData = await stableResponse.json() as CommitData;
|
| 37 |
+
return commit.commit === stableData.commit;
|
| 38 |
+
} catch (error) {
|
| 39 |
+
console.warn('Error checking stable version:', error);
|
| 40 |
+
return false;
|
| 41 |
+
}
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
// reading values from cookies on mount
|
| 45 |
useEffect(() => {
|
| 46 |
const savedProviders = Cookies.get('providers');
|
|
|
|
| 83 |
if (savedLocalModels) {
|
| 84 |
isLocalModelsEnabled.set(savedLocalModels === 'true');
|
| 85 |
}
|
| 86 |
+
|
| 87 |
+
// load latest branch setting from cookies or determine based on version
|
| 88 |
+
const savedLatestBranch = Cookies.get('useLatestBranch');
|
| 89 |
+
if (savedLatestBranch === undefined) {
|
| 90 |
+
// If setting hasn't been set by user, check version
|
| 91 |
+
checkIsStableVersion().then(isStable => {
|
| 92 |
+
const shouldUseLatest = !isStable;
|
| 93 |
+
latestBranch.set(shouldUseLatest);
|
| 94 |
+
Cookies.set('useLatestBranch', String(shouldUseLatest));
|
| 95 |
+
});
|
| 96 |
+
} else {
|
| 97 |
+
latestBranch.set(savedLatestBranch === 'true');
|
| 98 |
+
}
|
| 99 |
}, []);
|
| 100 |
|
| 101 |
// writing values to cookies on change
|
|
|
|
| 147 |
Cookies.set('isLocalModelsEnabled', String(enabled));
|
| 148 |
}, []);
|
| 149 |
|
| 150 |
+
const enableLatestBranch = useCallback((enabled: boolean) => {
|
| 151 |
+
latestBranch.set(enabled);
|
| 152 |
+
logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`);
|
| 153 |
+
Cookies.set('useLatestBranch', String(enabled));
|
| 154 |
+
}, []);
|
| 155 |
+
|
| 156 |
return {
|
| 157 |
providers,
|
| 158 |
activeProviders,
|
|
|
|
| 163 |
enableEventLogs,
|
| 164 |
isLocalModel,
|
| 165 |
enableLocalModels,
|
| 166 |
+
useLatestBranch: useLatest,
|
| 167 |
+
enableLatestBranch,
|
| 168 |
};
|
| 169 |
}
|
app/lib/stores/settings.ts
CHANGED
|
@@ -46,3 +46,5 @@ export const isDebugMode = atom(false);
|
|
| 46 |
export const isEventLogsEnabled = atom(false);
|
| 47 |
|
| 48 |
export const isLocalModelsEnabled = atom(true);
|
|
|
|
|
|
|
|
|
| 46 |
export const isEventLogsEnabled = atom(false);
|
| 47 |
|
| 48 |
export const isLocalModelsEnabled = atom(true);
|
| 49 |
+
|
| 50 |
+
export const latestBranch = atom(false);
|