codacus commited on
Commit
a155447
·
unverified ·
2 Parent(s): 3b8d251 dd24ccc

Merge branch 'main' into token-usage

Browse files
.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 "{ \"commit\": \"$COMMIT_HASH\" }" > app/commit.json
 
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
- git add package.json pnpm-lock.yaml changelog.md
 
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,2 @@
1
- { "commit": "070e911be17e1e1f3994220c3ed89b0060c67bd2" }
 
 
1
+ { "commit": "77073a5e7f759ae8e5752628131d0c56df6b5c34" , "version": "0.0.1" }
2
+
app/components/settings/debug/DebugTab.tsx CHANGED
@@ -34,10 +34,14 @@ interface IProviderConfig {
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',
@@ -207,7 +211,7 @@ const checkProviderStatus = async (url: string | null, providerName: string): Pr
207
  };
208
 
209
  export default function DebugTab() {
210
- const { providers, useLatestBranch } = useSettings();
211
  const [activeProviders, setActiveProviders] = useState<ProviderStatus[]>([]);
212
  const [updateMessage, setUpdateMessage] = useState<string>('');
213
  const [systemInfo] = useState<SystemInfo>(getSystemInfo());
@@ -267,7 +271,7 @@ export default function DebugTab() {
267
  setIsCheckingUpdate(true);
268
  setUpdateMessage('Checking for updates...');
269
 
270
- const branchToCheck = useLatestBranch ? 'main' : 'stable';
271
  console.log(`[Debug] Checking for updates against ${branchToCheck} branch`);
272
 
273
  const localCommitResponse = await fetch(GITHUB_URLS.commitJson(branchToCheck));
@@ -295,7 +299,7 @@ export default function DebugTab() {
295
  } finally {
296
  setIsCheckingUpdate(false);
297
  }
298
- }, [isCheckingUpdate, useLatestBranch]);
299
 
300
  const handleCopyToClipboard = useCallback(() => {
301
  const debugInfo = {
@@ -312,7 +316,7 @@ export default function DebugTab() {
312
  })),
313
  Version: {
314
  hash: versionHash.slice(0, 7),
315
- branch: useLatestBranch ? 'main' : 'stable',
316
  },
317
  Timestamp: new Date().toISOString(),
318
  };
@@ -320,7 +324,7 @@ export default function DebugTab() {
320
  navigator.clipboard.writeText(JSON.stringify(debugInfo, null, 2)).then(() => {
321
  toast.success('Debug information copied to clipboard!');
322
  });
323
- }, [activeProviders, systemInfo, useLatestBranch]);
324
 
325
  return (
326
  <div className="p-4 space-y-6">
@@ -406,7 +410,7 @@ export default function DebugTab() {
406
  <p className="text-sm font-medium text-bolt-elements-textPrimary font-mono">
407
  {versionHash.slice(0, 7)}
408
  <span className="ml-2 text-xs text-bolt-elements-textSecondary">
409
- ({new Date().toLocaleDateString()})
410
  </span>
411
  </p>
412
  </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',
 
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());
 
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));
 
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,15 +3,8 @@ import { Switch } from '~/components/ui/Switch';
3
  import { useSettings } from '~/lib/hooks/useSettings';
4
 
5
  export default function FeaturesTab() {
6
- const {
7
- debug,
8
- enableDebugMode,
9
- isLocalModel,
10
- enableLocalModels,
11
- enableEventLogs,
12
- useLatestBranch,
13
- enableLatestBranch,
14
- } = useSettings();
15
 
16
  const handleToggle = (enabled: boolean) => {
17
  enableDebugMode(enabled);
@@ -34,7 +27,7 @@ export default function FeaturesTab() {
34
  Check for updates against the main branch instead of stable
35
  </p>
36
  </div>
37
- <Switch className="ml-auto" checked={useLatestBranch} onCheckedChange={enableLatestBranch} />
38
  </div>
39
  </div>
40
  </div>
 
3
  import { useSettings } from '~/lib/hooks/useSettings';
4
 
5
  export default function FeaturesTab() {
6
+
7
+ const { debug, enableDebugMode, isLocalModel, enableLocalModels, enableEventLogs, latestBranch, enableLatestBranch } = useSettings();
 
 
 
 
 
 
 
8
 
9
  const handleToggle = (enabled: boolean) => {
10
  enableDebugMode(enabled);
 
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/lib/hooks/useSettings.tsx CHANGED
@@ -5,7 +5,7 @@ import {
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';
@@ -15,21 +15,24 @@ 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(
32
- 'https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/stable/app/commit.json',
33
  );
34
 
35
  if (!stableResponse.ok) {
@@ -90,17 +93,22 @@ export function useSettings() {
90
  }
91
 
92
  // load latest branch setting from cookies or determine based on version
93
- const savedLatestBranch = Cookies.get('useLatestBranch');
 
94
 
95
- if (savedLatestBranch === undefined) {
 
 
 
96
  // If setting hasn't been set by user, check version
97
  checkIsStableVersion().then((isStable) => {
98
  const shouldUseLatest = !isStable;
99
- latestBranch.set(shouldUseLatest);
100
- Cookies.set('useLatestBranch', String(shouldUseLatest));
 
101
  });
102
  } else {
103
- latestBranch.set(savedLatestBranch === 'true');
104
  }
105
  }, []);
106
 
@@ -154,9 +162,9 @@ export function useSettings() {
154
  }, []);
155
 
156
  const enableLatestBranch = useCallback((enabled: boolean) => {
157
- latestBranch.set(enabled);
158
  logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`);
159
- Cookies.set('useLatestBranch', String(enabled));
160
  }, []);
161
 
162
  return {
@@ -169,7 +177,7 @@ export function useSettings() {
169
  enableEventLogs,
170
  isLocalModel,
171
  enableLocalModels,
172
- useLatestBranch: useLatest,
173
  enableLatestBranch,
174
  };
175
  }
 
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) {
 
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
+ if (savedLatestBranch === undefined || checkCommit !== commit.commit) {
103
  // If setting hasn't been set by user, check version
104
  checkIsStableVersion().then((isStable) => {
105
  const shouldUseLatest = !isStable;
106
+ latestBranchStore.set(shouldUseLatest);
107
+ Cookies.set('latestBranch', String(shouldUseLatest));
108
+ Cookies.set('commitHash', String(commit.commit));
109
  });
110
  } else {
111
+ latestBranchStore.set(savedLatestBranch === 'true');
112
  }
113
  }, []);
114
 
 
162
  }, []);
163
 
164
  const enableLatestBranch = useCallback((enabled: boolean) => {
165
+ latestBranchStore.set(enabled);
166
  logStore.logSystem(`Main branch updates ${enabled ? 'enabled' : 'disabled'}`);
167
+ Cookies.set('latestBranch', String(enabled));
168
  }, []);
169
 
170
  return {
 
177
  enableEventLogs,
178
  isLocalModel,
179
  enableLocalModels,
180
+ latestBranch,
181
  enableLatestBranch,
182
  };
183
  }
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 latestBranch = atom(false);
 
47
 
48
  export const isLocalModelsEnabled = atom(true);
49
 
50
+ export const latestBranchStore = atom(false);