Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: fixed Debug Menu and added Check for Updates #650

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 36 additions & 12 deletions app/components/settings/debug/DebugTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const versionHash = commit.commit; // Get the version hash from commit.json
export default function DebugTab() {
const { providers } = useSettings();
const [activeProviders, setActiveProviders] = useState<string[]>([]);
const [updateMessage, setUpdateMessage] = useState<string>('');

useEffect(() => {
setActiveProviders(
Object.entries(providers)
Expand All @@ -15,6 +17,23 @@ export default function DebugTab() {
);
}, [providers]);

const handleCheckForUpdate = useCallback(async () => {
try {
const response = await fetch('https://raw.githubusercontent.com/stackblitz-labs/bolt.diy/main/app/commit.json');
const data: { commit: string } = await response.json();
const latestCommitHash = data.commit;

if (latestCommitHash !== versionHash) {
setUpdateMessage('An update is available!');
} else {
setUpdateMessage('You are on the latest version.');
}
} catch (error) {
console.error('Error fetching commit version:', error);
setUpdateMessage('Failed to check for updates.');
}
}, []);

const handleCopyToClipboard = useCallback(() => {
const debugInfo = {
OS: navigator.platform,
Expand All @@ -35,33 +54,38 @@ export default function DebugTab() {
return (
<div className="p-4">
<h3 className="text-lg font-medium text-bolt-elements-textPrimary mb-4">Debug Tab</h3>
<button
onClick={handleCopyToClipboard}
className="bg-blue-500 text-white rounded-lg px-4 py-2 hover:bg-blue-600 mb-4 transition-colors duration-200"
>
Copy to Clipboard
</button>

<h4 className="text-md font-medium text-bolt-elements-textPrimary">System Information</h4>
<div className="flex flex-col space-y-4">
<button
onClick={handleCheckForUpdate}
className="bg-bolt-elements-button-primary-background rounded-lg px-4 py-2 transition-colors duration-200 hover:bg-bolt-elements-button-primary-backgroundHover text-bolt-elements-button-primary-text"
>
Check for Updates
</button>
{updateMessage && <p className="text-bolt-elements-textSecondary">{updateMessage}</p>}
<button
onClick={handleCopyToClipboard}
className="bg-bolt-elements-button-primary-background rounded-lg px-4 py-2 transition-colors duration-200 hover:bg-bolt-elements-button-primary-backgroundHover text-bolt-elements-button-primary-text"
>
Copy to Clipboard
</button>
</div>
<h4 className="text-md font-medium text-bolt-elements-textPrimary mt-4">System Information</h4>
<p className="text-bolt-elements-textSecondary">OS: {navigator.platform}</p>
<p className="text-bolt-elements-textSecondary">Browser: {navigator.userAgent}</p>

<h4 className="text-md font-medium text-bolt-elements-textPrimary mt-4">Active Features</h4>
<h4 className="text-md font-medium text-bolt-elements-textPrimary mt-4">Active Providers</h4>
<ul>
{activeProviders.map((name) => (
<li key={name} className="text-bolt-elements-textSecondary">
{name}
</li>
))}
</ul>

<h4 className="text-md font-medium text-bolt-elements-textPrimary mt-4">Base URLs</h4>
<ul>
<li className="text-bolt-elements-textSecondary">Ollama: {process.env.REACT_APP_OLLAMA_URL}</li>
<li className="text-bolt-elements-textSecondary">OpenAI: {process.env.REACT_APP_OPENAI_URL}</li>
<li className="text-bolt-elements-textSecondary">LM Studio: {process.env.REACT_APP_LM_STUDIO_URL}</li>
</ul>

<h4 className="text-md font-medium text-bolt-elements-textPrimary mt-4">Version Information</h4>
<p className="text-bolt-elements-textSecondary">Version Hash: {versionHash}</p>
</div>
Expand Down
Loading