Merge branch 'main' into token-usage

This commit is contained in:
Anirban Kar 2024-12-16 19:56:20 +05:30 committed by GitHub
commit a15544749a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 49 additions and 55 deletions

View File

@ -20,9 +20,17 @@ jobs:
- name: Get the latest commit hash - name: Get the latest commit hash
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Update commit file - name: Update commit file
run: | run: |
echo "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json echo CURRENT_VERSION=$(node -p "require('./package.json').version") >> $GITHUB_ENV
echo "{ \"commit\": \"$COMMIT_HASH\" , \"version\": \"$CURRENT_VERSION\" }" > app/commit.json
- name: Commit and push the update - name: Commit and push the update
run: | run: |

View File

@ -9,30 +9,7 @@ permissions:
contents: write contents: write
jobs: jobs:
update-commit:
if: contains(github.event.head_commit.message, '#release')
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Get the latest commit hash
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Update commit file
run: |
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"
git push
prepare-release: prepare-release:
needs: update-commit
if: contains(github.event.head_commit.message, '#release') if: contains(github.event.head_commit.message, '#release')
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -183,8 +160,11 @@ jobs:
- name: Commit and Tag Release - name: Commit and Tag Release
run: | run: |
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "CURRENT_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
git pull git pull
git add package.json pnpm-lock.yaml changelog.md echo "{ \"commit\": \"$COMMIT_HASH\" , \"version\": \"$CURRENT_VERSION\" }" > app/commit.json
git add package.json pnpm-lock.yaml changelog.md app/commit.json
git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}" git commit -m "chore: release version ${{ steps.bump_version.outputs.new_version }}"
git tag "v${{ steps.bump_version.outputs.new_version }}" git tag "v${{ steps.bump_version.outputs.new_version }}"
git push git push

View File

@ -1 +1,2 @@
{ "commit": "070e911be17e1e1f3994220c3ed89b0060c67bd2" } { "commit": "77073a5e7f759ae8e5752628131d0c56df6b5c34" , "version": "0.0.1" }

View File

@ -34,10 +34,14 @@ interface IProviderConfig {
interface CommitData { interface CommitData {
commit: string; commit: string;
version?: string;
} }
const connitJson: CommitData = commit;
const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike']; const LOCAL_PROVIDERS = ['Ollama', 'LMStudio', 'OpenAILike'];
const versionHash = commit.commit; const versionHash = connitJson.commit;
const versionTag = connitJson.version;
const GITHUB_URLS = { const GITHUB_URLS = {
original: 'https://api.github.com/repos/stackblitz-labs/bolt.diy/commits/main', 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', fork: 'https://api.github.com/repos/Stijnus/bolt.new-any-llm/commits/main',
@ -207,7 +211,7 @@ const checkProviderStatus = async (url: string | null, providerName: string): Pr
}; };
export default function DebugTab() { export default function DebugTab() {
const { providers, useLatestBranch } = useSettings(); const { providers, latestBranch } = useSettings();
const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]); const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]);
const [updateMessage, setUpdateMessage] = useState<string>(''); const [updateMessage, setUpdateMessage] = useState<string>('');
const [systemInfo] = useState<SystemInfo>(getSystemInfo()); const [systemInfo] = useState<SystemInfo>(getSystemInfo());
@ -267,7 +271,7 @@ export default function DebugTab() {
setIsCheckingUpdate(true); setIsCheckingUpdate(true);
setUpdateMessage('Checking for updates...'); setUpdateMessage('Checking for updates...');
const branchToCheck = useLatestBranch ? 'main' : 'stable'; const branchToCheck = latestBranch ? 'main' : 'stable';
console.log(`[Debug] Checking for updates against ${branchToCheck} branch`); console.log(`[Debug] Checking for updates against ${branchToCheck} branch`);
const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck)); const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck));
@ -295,7 +299,7 @@ export default function DebugTab() {
} finally { } finally {
setIsCheckingUpdate(false); setIsCheckingUpdate(false);
} }
}, [isCheckingUpdate, useLatestBranch]); }, [isCheckingUpdate, latestBranch]);
const handleCopyToClipboard = useCallback(() => { const handleCopyToClipboard = useCallback(() => {
const debugInfo = { const debugInfo = {
@ -312,7 +316,7 @@ export default function DebugTab() {
})), })),
Version: { Version: {
hash: versionHash.slice(0, 7), hash: versionHash.slice(0, 7),
branch: useLatestBranch ? 'main' : 'stable', branch: latestBranch ? 'main' : 'stable',
}, },
Timestamp: new Date().toISOString(), Timestamp: new Date().toISOString(),
}; };
@ -320,7 +324,7 @@ export default function DebugTab() {
navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => { navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => {
toast.success('Debug information copied to clipboard!'); toast.success('Debug information copied to clipboard!');
}); });
}, [activeProviders, systemInfo, useLatestBranch]); }, [activeProviders, systemInfo, latestBranch]);
return ( return (
<div className="p-4 space-y-6"> <div className="p-4 space-y-6">
@ -406,7 +410,7 @@ export default function DebugTab() {
<p className="text-sm font-medium text-bolt-elements-textPrimary font-mono"> <p className="text-sm font-medium text-bolt-elements-textPrimary font-mono">
{versionHash.slice(0, 7)} {versionHash.slice(0, 7)}
<span className="ml-2 text-xs text-bolt-elements-textSecondary"> <span className="ml-2 text-xs text-bolt-elements-textSecondary">
({new Date().toLocaleDateString()}) (v{versionTag || '0.0.1'}) - {latestBranch ? 'nightly' : 'stable'}
</span> </span>
</p> </p>
</div> </div>

View File

@ -3,15 +3,8 @@ import { Switch } from '~/components/ui/Switch';
import { useSettings } from '~/lib/hooks/useSettings'; import { useSettings } from '~/lib/hooks/useSettings';
export default function FeaturesTab() { export default function FeaturesTab() {
const {
debug, const { debug, enableDebugMode, isLocalModel, enableLocalModels, enableEventLogs, latestBranch, enableLatestBranch } = useSettings();
enableDebugMode,
isLocalModel,
enableLocalModels,
enableEventLogs,
useLatestBranch,
enableLatestBranch,
} = useSettings();
const handleToggle = (enabled: boolean) => { const handleToggle = (enabled: boolean) => {
enableDebugMode(enabled); enableDebugMode(enabled);
@ -34,7 +27,7 @@ export default function FeaturesTab() {
Check for updates against the main branch instead of stable Check for updates against the main branch instead of stable
</p> </p>
</div> </div>
<Switch className="ml-auto" checked={useLatestBranch} onCheckedChange={enableLatestBranch} /> <Switch className="ml-auto" checked={latestBranch} onCheckedChange={enableLatestBranch} />
</div> </div>
</div> </div>
</div> </div>

View File

@ -5,7 +5,7 @@ import {
isLocalModelsEnabled, isLocalModelsEnabled,
LOCAL_PROVIDERS, LOCAL_PROVIDERS,
providersStore, providersStore,
latestBranch, latestBranchStore,
} from '~/lib/stores/settings'; } from '~/lib/stores/settings';
import { useCallback, useEffect, useState } from 'react'; import { useCallback, useEffect, useState } from 'react';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
@ -15,21 +15,24 @@ import commit from '~/commit.json';
interface CommitData { interface CommitData {
commit: string; commit: string;
version?: string;
} }
const commitJson: CommitData = commit;
export function useSettings() { export function useSettings() {
const providers = useStore(providersStore); const providers = useStore(providersStore);
const debug = useStore(isDebugMode); const debug = useStore(isDebugMode);
const eventLogs = useStore(isEventLogsEnabled); const eventLogs = useStore(isEventLogsEnabled);
const isLocalModel = useStore(isLocalModelsEnabled); const isLocalModel = useStore(isLocalModelsEnabled);
const useLatest = useStore(latestBranch); const latestBranch = useStore(latestBranchStore);
const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]); const [activeProviders, setActiveProviders] = useState<ProviderInfo[]>([]);
// Function to check if we're on stable version // Function to check if we're on stable version
const checkIsStableVersion = async () => { const checkIsStableVersion = async () => {
try { try {
const stableResponse = await fetch( const stableResponse = await fetch(
'https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/stable/app/commit.json', `https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/refs/tags/v${commitJson.version}/app/commit.json`,
); );
if (!stableResponse.ok) { if (!stableResponse.ok) {
@ -90,17 +93,22 @@ export function useSettings() {
} }
// load latest branch setting from cookies or determine based on version // load latest branch setting from cookies or determine based on version
const savedLatestBranch = Cookies.get('useLatestBranch'); const savedLatestBranch = Cookies.get('latestBranch');
let checkCommit = Cookies.get('commitHash');
if (savedLatestBranch === undefined) { if (checkCommit === undefined) {
checkCommit = commit.commit;
}
if (savedLatestBranch === undefined || checkCommit !== commit.commit) {
// If setting hasn't been set by user, check version // If setting hasn't been set by user, check version
checkIsStableVersion().then((isStable) => { checkIsStableVersion().then((isStable) => {
const shouldUseLatest = !isStable; const shouldUseLatest = !isStable;
latestBranch.set(shouldUseLatest); latestBranchStore.set(shouldUseLatest);
Cookies.set('useLatestBranch', String(shouldUseLatest)); Cookies.set('latestBranch', String(shouldUseLatest));
Cookies.set('commitHash', String(commit.commit));
}); });
} else { } else {
latestBranch.set(savedLatestBranch === 'true'); latestBranchStore.set(savedLatestBranch === 'true');
} }
}, []); }, []);
@ -154,9 +162,9 @@ export function useSettings() {
}, []); }, []);
const enableLatestBranch = useCallback((enabled: boolean) => { const enableLatestBranch = useCallback((enabled: boolean) => {
latestBranch.set(enabled); latestBranchStore.set(enabled);
logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`); logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`);
Cookies.set('useLatestBranch', String(enabled)); Cookies.set('latestBranch', String(enabled));
}, []); }, []);
return { return {
@ -169,7 +177,7 @@ export function useSettings() {
enableEventLogs, enableEventLogs,
isLocalModel, isLocalModel,
enableLocalModels, enableLocalModels,
useLatestBranch: useLatest, latestBranch,
enableLatestBranch, enableLatestBranch,
}; };
} }

View File

@ -47,4 +47,4 @@ export const isEventLogsEnabled = atom(false);
export const isLocalModelsEnabled = atom(true); export const isLocalModelsEnabled = atom(true);
export const latestBranch = atom(false); export const latestBranchStore = atom(false);