Merge pull request #755 from thecodacus/fix-variable-name
Browse filesfix: Added auto detect branch name and version tag for Debug Tab
- .github/workflows/commit.yaml +9 -1
- .github/workflows/update-stable.yml +4 -24
- app/commit.json +1 -1
- app/components/chat/BaseChat.tsx +1 -5
- app/components/settings/chat-history/ChatHistoryTab.tsx +5 -1
- app/components/settings/debug/DebugTab.tsx +21 -14
- app/components/settings/features/FeaturesTab.tsx +6 -3
- app/components/settings/providers/ProvidersTab.tsx +2 -1
- app/lib/hooks/useSettings.tsx +28 -13
- app/lib/stores/settings.ts +1 -1
- app/utils/constants.ts +1 -1
.github/workflows/commit.yaml
CHANGED
@@ -20,9 +20,17 @@ jobs:
|
|
20 |
- name: Get the latest commit hash
|
21 |
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
- name: Update commit file
|
24 |
run: |
|
25 |
-
echo
|
|
|
26 |
|
27 |
- name: Commit and push the update
|
28 |
run: |
|
|
|
20 |
- name: Get the latest commit hash
|
21 |
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
22 |
|
23 |
+
|
24 |
+
- name: Setup Node.js
|
25 |
+
uses: actions/setup-node@v4
|
26 |
+
with:
|
27 |
+
node-version: '20'
|
28 |
+
|
29 |
+
|
30 |
- name: Update commit file
|
31 |
run: |
|
32 |
+
echo CURRENT_VERSION=$(node -p "require('./package.json').version") >> $GITHUB_ENV
|
33 |
+
echo "{ \"commit\": \"$COMMIT_HASH\" , \"version\": \"$CURRENT_VERSION\" }" > app/commit.json
|
34 |
|
35 |
- name: Commit and push the update
|
36 |
run: |
|
.github/workflows/update-stable.yml
CHANGED
@@ -9,30 +9,7 @@ permissions:
|
|
9 |
contents: write
|
10 |
|
11 |
jobs:
|
12 |
-
update-commit:
|
13 |
-
if: contains(github.event.head_commit.message, '#release')
|
14 |
-
runs-on: ubuntu-latest
|
15 |
-
|
16 |
-
steps:
|
17 |
-
- name: Checkout the code
|
18 |
-
uses: actions/checkout@v3
|
19 |
-
|
20 |
-
- name: Get the latest commit hash
|
21 |
-
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
22 |
-
|
23 |
-
- name: Update commit file
|
24 |
-
run: |
|
25 |
-
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
|
26 |
-
|
27 |
-
- name: Commit and push the update
|
28 |
-
run: |
|
29 |
-
git config --global user.name "github-actions[bot]"
|
30 |
-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
31 |
-
git add app/commit.json
|
32 |
-
git commit -m "chore: update commit hash to $COMMIT_HASH"
|
33 |
-
git push
|
34 |
prepare-release:
|
35 |
-
needs: update-commit
|
36 |
if: contains(github.event.head_commit.message, '#release')
|
37 |
runs-on: ubuntu-latest
|
38 |
|
@@ -183,8 +160,11 @@ jobs:
|
|
183 |
|
184 |
- name: Commit and Tag Release
|
185 |
run: |
|
|
|
|
|
186 |
git pull
|
187 |
-
|
|
|
188 |
git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
|
189 |
git tag "v${{ steps.bump_version.outputs.new_version }}"
|
190 |
git push
|
|
|
9 |
contents: write
|
10 |
|
11 |
jobs:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
prepare-release:
|
|
|
13 |
if: contains(github.event.head_commit.message, '#release')
|
14 |
runs-on: ubuntu-latest
|
15 |
|
|
|
160 |
|
161 |
- name: Commit and Tag Release
|
162 |
run: |
|
163 |
+
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
|
164 |
+
echo "CURRENT_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
|
165 |
git pull
|
166 |
+
echo "{ \"commit\": \"$COMMIT_HASH\" , \"version\": \"$CURRENT_VERSION\" }" > app/commit.json
|
167 |
+
git add package.json pnpm-lock.yaml changelog.md app/commit.json
|
168 |
git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
|
169 |
git tag "v${{ steps.bump_version.outputs.new_version }}"
|
170 |
git push
|
app/commit.json
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{ "commit": "6ba93974a02a98c83badf2f0002ff4812b8f75a9" }
|
|
|
1 |
+
{ "commit": "6ba93974a02a98c83badf2f0002ff4812b8f75a9" }
|
app/components/chat/BaseChat.tsx
CHANGED
@@ -77,7 +77,6 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
77 |
input = '',
|
78 |
enhancingPrompt,
|
79 |
handleInputChange,
|
80 |
-
promptEnhanced,
|
81 |
enhancePrompt,
|
82 |
sendMessage,
|
83 |
handleStop,
|
@@ -490,10 +489,7 @@ export const BaseChat = React.forwardRef<HTMLDivElement, BaseChatProps>(
|
|
490 |
<IconButton
|
491 |
title="Enhance prompt"
|
492 |
disabled={input.length === 0 || enhancingPrompt}
|
493 |
-
className={classNames(
|
494 |
-
'transition-all',
|
495 |
-
enhancingPrompt ? 'opacity-100' : '',
|
496 |
-
)}
|
497 |
onClick={() => {
|
498 |
enhancePrompt?.();
|
499 |
toast.success('Prompt enhanced!');
|
|
|
77 |
input = '',
|
78 |
enhancingPrompt,
|
79 |
handleInputChange,
|
|
|
80 |
enhancePrompt,
|
81 |
sendMessage,
|
82 |
handleStop,
|
|
|
489 |
<IconButton
|
490 |
title="Enhance prompt"
|
491 |
disabled={input.length === 0 || enhancingPrompt}
|
492 |
+
className={classNames('transition-all', enhancingPrompt ? 'opacity-100' : '')}
|
|
|
|
|
|
|
493 |
onClick={() => {
|
494 |
enhancePrompt?.();
|
495 |
toast.success('Prompt enhanced!');
|
app/components/settings/chat-history/ChatHistoryTab.tsx
CHANGED
@@ -22,7 +22,8 @@ export default function ChatHistoryTab() {
|
|
22 |
};
|
23 |
|
24 |
const handleDeleteAllChats = async () => {
|
25 |
-
const confirmDelete = window.confirm(
|
|
|
26 |
if (!confirmDelete) {
|
27 |
return; // Exit if the user cancels
|
28 |
}
|
@@ -31,11 +32,13 @@ export default function ChatHistoryTab() {
|
|
31 |
const error = new Error('Database is not available');
|
32 |
logStore.logError('Failed to delete chats - DB unavailable', error);
|
33 |
toast.error('Database is not available');
|
|
|
34 |
return;
|
35 |
}
|
36 |
|
37 |
try {
|
38 |
setIsDeleting(true);
|
|
|
39 |
const allChats = await getAll(db);
|
40 |
await Promise.all(allChats.map((chat) => deleteById(db!, chat.id)));
|
41 |
logStore.logSystem('All chats deleted successfully', { count: allChats.length });
|
@@ -55,6 +58,7 @@ export default function ChatHistoryTab() {
|
|
55 |
const error = new Error('Database is not available');
|
56 |
logStore.logError('Failed to export chats - DB unavailable', error);
|
57 |
toast.error('Database is not available');
|
|
|
58 |
return;
|
59 |
}
|
60 |
|
|
|
22 |
};
|
23 |
|
24 |
const handleDeleteAllChats = async () => {
|
25 |
+
const confirmDelete = window.confirm('Are you sure you want to delete all chats? This action cannot be undone.');
|
26 |
+
|
27 |
if (!confirmDelete) {
|
28 |
return; // Exit if the user cancels
|
29 |
}
|
|
|
32 |
const error = new Error('Database is not available');
|
33 |
logStore.logError('Failed to delete chats - DB unavailable', error);
|
34 |
toast.error('Database is not available');
|
35 |
+
|
36 |
return;
|
37 |
}
|
38 |
|
39 |
try {
|
40 |
setIsDeleting(true);
|
41 |
+
|
42 |
const allChats = await getAll(db);
|
43 |
await Promise.all(allChats.map((chat) => deleteById(db!, chat.id)));
|
44 |
logStore.logSystem('All chats deleted successfully', { count: allChats.length });
|
|
|
58 |
const error = new Error('Database is not available');
|
59 |
logStore.logError('Failed to export chats - DB unavailable', error);
|
60 |
toast.error('Database is not available');
|
61 |
+
|
62 |
return;
|
63 |
}
|
64 |
|
app/components/settings/debug/DebugTab.tsx
CHANGED
@@ -34,14 +34,19 @@ interface IProviderConfig {
|
|
34 |
|
35 |
interface CommitData {
|
36 |
commit: string;
|
|
|
37 |
}
|
38 |
|
|
|
|
|
39 |
const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
|
40 |
-
const versionHash =
|
|
|
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) =>
|
|
|
45 |
};
|
46 |
|
47 |
function getSystemInfo(): SystemInfo {
|
@@ -206,7 +211,7 @@ const checkProviderStatus = async (url: string | null, providerName: string): Pr
|
|
206 |
};
|
207 |
|
208 |
export default function DebugTab() {
|
209 |
-
const { providers,
|
210 |
const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]);
|
211 |
const [updateMessage, setUpdateMessage] = useState<string>('');
|
212 |
const [systemInfo] = useState<SystemInfo>(getSystemInfo());
|
@@ -227,19 +232,20 @@ export default function DebugTab() {
|
|
227 |
provider.name.toLowerCase() === 'ollama'
|
228 |
? 'OLLAMA_API_BASE_URL'
|
229 |
: provider.name.toLowerCase() === 'lmstudio'
|
230 |
-
|
231 |
-
|
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);
|
@@ -265,23 +271,24 @@ export default function DebugTab() {
|
|
265 |
setIsCheckingUpdate(true);
|
266 |
setUpdateMessage('Checking for updates...');
|
267 |
|
268 |
-
const branchToCheck =
|
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 |
-
|
284 |
-
|
285 |
);
|
286 |
} else {
|
287 |
setUpdateMessage(`You are on the latest version from the ${branchToCheck} branch`);
|
@@ -292,7 +299,7 @@ export default function DebugTab() {
|
|
292 |
} finally {
|
293 |
setIsCheckingUpdate(false);
|
294 |
}
|
295 |
-
}, [isCheckingUpdate,
|
296 |
|
297 |
const handleCopyToClipboard = useCallback(() => {
|
298 |
const debugInfo = {
|
@@ -309,7 +316,7 @@ export default function DebugTab() {
|
|
309 |
})),
|
310 |
Version: {
|
311 |
hash: versionHash.slice(0, 7),
|
312 |
-
branch:
|
313 |
},
|
314 |
Timestamp: new Date().toISOString(),
|
315 |
};
|
@@ -317,7 +324,7 @@ export default function DebugTab() {
|
|
317 |
navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => {
|
318 |
toast.success('Debug information copied to clipboard!');
|
319 |
});
|
320 |
-
}, [activeProviders, systemInfo,
|
321 |
|
322 |
return (
|
323 |
<div className="p-4 space-y-6">
|
@@ -403,7 +410,7 @@ export default function DebugTab() {
|
|
403 |
<p className="text-sm font-medium text-bolt-elements-textPrimary font-mono">
|
404 |
{versionHash.slice(0, 7)}
|
405 |
<span className="ml-2 text-xs text-bolt-elements-textSecondary">
|
406 |
-
({
|
407 |
</span>
|
408 |
</p>
|
409 |
</div>
|
|
|
34 |
|
35 |
interface CommitData {
|
36 |
commit: string;
|
37 |
+
version?: string;
|
38 |
}
|
39 |
|
40 |
+
const connitJson: CommitData = commit;
|
41 |
+
|
42 |
const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
|
43 |
+
const versionHash = connitJson.commit;
|
44 |
+
const versionTag = connitJson.version;
|
45 |
const GITHUB_URLS = {
|
46 |
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main',
|
47 |
fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
|
48 |
+
commitJson: (branch: string) =>
|
49 |
+
`https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/${branch}/app/commit.json`,
|
50 |
};
|
51 |
|
52 |
function getSystemInfo(): SystemInfo {
|
|
|
211 |
};
|
212 |
|
213 |
export default function DebugTab() {
|
214 |
+
const { providers, latestBranch } = useSettings();
|
215 |
const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]);
|
216 |
const [updateMessage, setUpdateMessage] = useState<string>('');
|
217 |
const [systemInfo] = useState<SystemInfo>(getSystemInfo());
|
|
|
232 |
provider.name.toLowerCase() === 'ollama'
|
233 |
? 'OLLAMA_API_BASE_URL'
|
234 |
: provider.name.toLowerCase() === 'lmstudio'
|
235 |
+
? 'LMSTUDIO_API_BASE_URL'
|
236 |
+
: `REACT_APP_${provider.name.toUpperCase()}_URL`;
|
237 |
|
238 |
// Access environment variables through import.meta.env
|
239 |
const url = import.meta.env[envVarName] || provider.settings.baseUrl || null; // Ensure baseUrl is used
|
240 |
console.log(`[Debug] Using URL for ${provider.name}:`, url, `(from ${envVarName})`);
|
241 |
|
242 |
const status = await checkProviderStatus(url, provider.name);
|
243 |
+
|
244 |
return {
|
245 |
...status,
|
246 |
enabled: provider.settings.enabled ?? false,
|
247 |
};
|
248 |
+
}),
|
249 |
);
|
250 |
|
251 |
setActiveProviders(statuses);
|
|
|
271 |
setIsCheckingUpdate(true);
|
272 |
setUpdateMessage('Checking for updates...');
|
273 |
|
274 |
+
const branchToCheck = latestBranch ? 'main' : 'stable';
|
275 |
console.log(`[Debug] Checking for updates against ${branchToCheck} branch`);
|
276 |
|
277 |
const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck));
|
278 |
+
|
279 |
if (!localCommitResponse.ok) {
|
280 |
throw new Error('Failed to fetch local commit info');
|
281 |
}
|
282 |
|
283 |
+
const localCommitData = (await localCommitResponse.json()) as CommitData;
|
284 |
const remoteCommitHash = localCommitData.commit;
|
285 |
const currentCommitHash = versionHash;
|
286 |
|
287 |
if (remoteCommitHash !== currentCommitHash) {
|
288 |
setUpdateMessage(
|
289 |
`Update available from ${branchToCheck} branch!\n` +
|
290 |
+
`Current: ${currentCommitHash.slice(0, 7)}\n` +
|
291 |
+
`Latest: ${remoteCommitHash.slice(0, 7)}`,
|
292 |
);
|
293 |
} else {
|
294 |
setUpdateMessage(`You are on the latest version from the ${branchToCheck} branch`);
|
|
|
299 |
} finally {
|
300 |
setIsCheckingUpdate(false);
|
301 |
}
|
302 |
+
}, [isCheckingUpdate, latestBranch]);
|
303 |
|
304 |
const handleCopyToClipboard = useCallback(() => {
|
305 |
const debugInfo = {
|
|
|
316 |
})),
|
317 |
Version: {
|
318 |
hash: versionHash.slice(0, 7),
|
319 |
+
branch: latestBranch ? 'main' : 'stable',
|
320 |
},
|
321 |
Timestamp: new Date().toISOString(),
|
322 |
};
|
|
|
324 |
navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => {
|
325 |
toast.success('Debug information copied to clipboard!');
|
326 |
});
|
327 |
+
}, [activeProviders, systemInfo, latestBranch]);
|
328 |
|
329 |
return (
|
330 |
<div className="p-4 space-y-6">
|
|
|
410 |
<p className="text-sm font-medium text-bolt-elements-textPrimary font-mono">
|
411 |
{versionHash.slice(0, 7)}
|
412 |
<span className="ml-2 text-xs text-bolt-elements-textSecondary">
|
413 |
+
(v{versionTag || '0.0.1'}) - {latestBranch ? 'nightly' : 'stable'}
|
414 |
</span>
|
415 |
</p>
|
416 |
</div>
|
app/components/settings/features/FeaturesTab.tsx
CHANGED
@@ -3,7 +3,8 @@ 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,
|
|
|
7 |
|
8 |
const handleToggle = (enabled: boolean) => {
|
9 |
enableDebugMode(enabled);
|
@@ -22,9 +23,11 @@ export default function FeaturesTab() {
|
|
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">
|
|
|
|
|
26 |
</div>
|
27 |
-
<Switch className="ml-auto" checked={
|
28 |
</div>
|
29 |
</div>
|
30 |
</div>
|
|
|
3 |
import { useSettings } from '~/lib/hooks/useSettings';
|
4 |
|
5 |
export default function FeaturesTab() {
|
6 |
+
const { debug, enableDebugMode, isLocalModel, enableLocalModels, enableEventLogs, latestBranch, enableLatestBranch } =
|
7 |
+
useSettings();
|
8 |
|
9 |
const handleToggle = (enabled: boolean) => {
|
10 |
enableDebugMode(enabled);
|
|
|
23 |
<div className="flex items-center justify-between">
|
24 |
<div>
|
25 |
<span className="text-bolt-elements-textPrimary">Use Main Branch</span>
|
26 |
+
<p className="text-sm text-bolt-elements-textSecondary">
|
27 |
+
Check for updates against the main branch instead of stable
|
28 |
+
</p>
|
29 |
</div>
|
30 |
+
<Switch className="ml-auto" checked={latestBranch} onCheckedChange={enableLatestBranch} />
|
31 |
</div>
|
32 |
</div>
|
33 |
</div>
|
app/components/settings/providers/ProvidersTab.tsx
CHANGED
@@ -56,7 +56,8 @@ export default function ProvidersTab() {
|
|
56 |
<div className="flex items-center gap-2">
|
57 |
<img
|
58 |
src={`/icons/${provider.name}.svg`} // Attempt to load the specific icon
|
59 |
-
onError={(e) => {
|
|
|
60 |
e.currentTarget.src = DefaultIcon;
|
61 |
}}
|
62 |
alt={`${provider.name} icon`}
|
|
|
56 |
<div className="flex items-center gap-2">
|
57 |
<img
|
58 |
src={`/icons/${provider.name}.svg`} // Attempt to load the specific icon
|
59 |
+
onError={(e) => {
|
60 |
+
// Fallback to default icon on error
|
61 |
e.currentTarget.src = DefaultIcon;
|
62 |
}}
|
63 |
alt={`${provider.name} icon`}
|
app/lib/hooks/useSettings.tsx
CHANGED
@@ -5,7 +5,7 @@ import {
|
|
5 |
isLocalModelsEnabled,
|
6 |
LOCAL_PROVIDERS,
|
7 |
providersStore,
|
8 |
-
|
9 |
} from '~/lib/stores/settings';
|
10 |
import { useCallback, useEffect, useState } from 'react';
|
11 |
import Cookies from 'js-cookie';
|
@@ -15,25 +15,33 @@ 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
|
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(
|
|
|
|
|
|
|
32 |
if (!stableResponse.ok) {
|
33 |
console.warn('Failed to fetch stable commit info');
|
34 |
return false;
|
35 |
}
|
36 |
-
|
|
|
|
|
37 |
return commit.commit === stableData.commit;
|
38 |
} catch (error) {
|
39 |
console.warn('Error checking stable version:', error);
|
@@ -85,16 +93,23 @@ export function useSettings() {
|
|
85 |
}
|
86 |
|
87 |
// load latest branch setting from cookies or determine based on version
|
88 |
-
const savedLatestBranch = Cookies.get('
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
// If setting hasn't been set by user, check version
|
91 |
-
checkIsStableVersion().then(isStable => {
|
92 |
const shouldUseLatest = !isStable;
|
93 |
-
|
94 |
-
Cookies.set('
|
|
|
95 |
});
|
96 |
} else {
|
97 |
-
|
98 |
}
|
99 |
}, []);
|
100 |
|
@@ -148,9 +163,9 @@ export function useSettings() {
|
|
148 |
}, []);
|
149 |
|
150 |
const enableLatestBranch = useCallback((enabled: boolean) => {
|
151 |
-
|
152 |
logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`);
|
153 |
-
Cookies.set('
|
154 |
}, []);
|
155 |
|
156 |
return {
|
@@ -163,7 +178,7 @@ export function useSettings() {
|
|
163 |
enableEventLogs,
|
164 |
isLocalModel,
|
165 |
enableLocalModels,
|
166 |
-
|
167 |
enableLatestBranch,
|
168 |
};
|
169 |
}
|
|
|
5 |
isLocalModelsEnabled,
|
6 |
LOCAL_PROVIDERS,
|
7 |
providersStore,
|
8 |
+
latestBranchStore,
|
9 |
} from '~/lib/stores/settings';
|
10 |
import { useCallback, useEffect, useState } from 'react';
|
11 |
import Cookies from 'js-cookie';
|
|
|
15 |
|
16 |
interface CommitData {
|
17 |
commit: string;
|
18 |
+
version?: string;
|
19 |
}
|
20 |
|
21 |
+
const commitJson: CommitData = commit;
|
22 |
+
|
23 |
export function useSettings() {
|
24 |
const providers = useStore(providersStore);
|
25 |
const debug = useStore(isDebugMode);
|
26 |
const eventLogs = useStore(isEventLogsEnabled);
|
27 |
const isLocalModel = useStore(isLocalModelsEnabled);
|
28 |
+
const latestBranch = useStore(latestBranchStore);
|
29 |
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
|
30 |
|
31 |
// Function to check if we're on stable version
|
32 |
const checkIsStableVersion = async () => {
|
33 |
try {
|
34 |
+
const stableResponse = await fetch(
|
35 |
+
`https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/refs/tags/v${commitJson.version}/app/commit.json`,
|
36 |
+
);
|
37 |
+
|
38 |
if (!stableResponse.ok) {
|
39 |
console.warn('Failed to fetch stable commit info');
|
40 |
return false;
|
41 |
}
|
42 |
+
|
43 |
+
const stableData = (await stableResponse.json()) as CommitData;
|
44 |
+
|
45 |
return commit.commit === stableData.commit;
|
46 |
} catch (error) {
|
47 |
console.warn('Error checking stable version:', error);
|
|
|
93 |
}
|
94 |
|
95 |
// load latest branch setting from cookies or determine based on version
|
96 |
+
const savedLatestBranch = Cookies.get('latestBranch');
|
97 |
+
let checkCommit = Cookies.get('commitHash');
|
98 |
+
|
99 |
+
if (checkCommit === undefined) {
|
100 |
+
checkCommit = commit.commit;
|
101 |
+
}
|
102 |
+
|
103 |
+
if (savedLatestBranch === undefined || checkCommit !== commit.commit) {
|
104 |
// If setting hasn't been set by user, check version
|
105 |
+
checkIsStableVersion().then((isStable) => {
|
106 |
const shouldUseLatest = !isStable;
|
107 |
+
latestBranchStore.set(shouldUseLatest);
|
108 |
+
Cookies.set('latestBranch', String(shouldUseLatest));
|
109 |
+
Cookies.set('commitHash', String(commit.commit));
|
110 |
});
|
111 |
} else {
|
112 |
+
latestBranchStore.set(savedLatestBranch === 'true');
|
113 |
}
|
114 |
}, []);
|
115 |
|
|
|
163 |
}, []);
|
164 |
|
165 |
const enableLatestBranch = useCallback((enabled: boolean) => {
|
166 |
+
latestBranchStore.set(enabled);
|
167 |
logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`);
|
168 |
+
Cookies.set('latestBranch', String(enabled));
|
169 |
}, []);
|
170 |
|
171 |
return {
|
|
|
178 |
enableEventLogs,
|
179 |
isLocalModel,
|
180 |
enableLocalModels,
|
181 |
+
latestBranch,
|
182 |
enableLatestBranch,
|
183 |
};
|
184 |
}
|
app/lib/stores/settings.ts
CHANGED
@@ -47,4 +47,4 @@ export const isEventLogsEnabled = atom(false);
|
|
47 |
|
48 |
export const isLocalModelsEnabled = atom(true);
|
49 |
|
50 |
-
export const
|
|
|
47 |
|
48 |
export const isLocalModelsEnabled = atom(true);
|
49 |
|
50 |
+
export const latestBranchStore = atom(false);
|
app/utils/constants.ts
CHANGED
@@ -141,7 +141,7 @@ const PROVIDER_LIST: ProviderInfo[] = [
|
|
141 |
staticModels: [
|
142 |
{ name: 'llama-3.1-8b-instant', label: 'Llama 3.1 8b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
143 |
{ name: 'llama-3.2-11b-vision-preview', label: 'Llama 3.2 11b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
144 |
-
{ name: 'llama-3.2-90b-vision-preview', label: 'Llama 3.2 90b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
145 |
{ name: 'llama-3.2-3b-preview', label: 'Llama 3.2 3b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
146 |
{ name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
147 |
{ name: 'llama-3.3-70b-versatile', label: 'Llama 3.3 70b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
|
|
141 |
staticModels: [
|
142 |
{ name: 'llama-3.1-8b-instant', label: 'Llama 3.1 8b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
143 |
{ name: 'llama-3.2-11b-vision-preview', label: 'Llama 3.2 11b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
144 |
+
{ name: 'llama-3.2-90b-vision-preview', label: 'Llama 3.2 90b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
145 |
{ name: 'llama-3.2-3b-preview', label: 'Llama 3.2 3b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
146 |
{ name: 'llama-3.2-1b-preview', label: 'Llama 3.2 1b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|
147 |
{ name: 'llama-3.3-70b-versatile', label: 'Llama 3.3 70b (Groq)', provider: 'Groq', maxTokenAllowed: 8000 },
|