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

fix: update DataTab.tsx for import, export settings, api key #1463

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Stijnus
Copy link
Collaborator

@Stijnus Stijnus commented Mar 5, 2025

API Key Import Fix

We identified and fixed an issue with the API key import functionality in the DataTab component. The problem was that API keys were being stored in localStorage instead of cookies, and the key format was being incorrectly processed.

Changes Made:

  1. Updated handleImportAPIKeys function:

    • Changed to store API keys in cookies instead of localStorage
    • Modified to use provider names directly as keys (e.g., "OpenAI", "Google")
    • Added logic to skip comment fields (keys starting with "_")
    • Added page reload after successful import to apply changes immediately
  2. Updated handleDownloadTemplate function:

    • Changed template format to use provider names as keys
    • Added explanatory comment in the template
    • Removed URL-related keys that weren't being used properly
  3. Fixed template format:

    • Template now uses the correct format with provider names as keys
    • Added support for all available providers including Hyperbolic

These changes ensure that when users download the template, fill it with their API keys, and import it back, the keys are properly stored in cookies with the correct format that the application expects.

## API Key Import Fix

We identified and fixed an issue with the API key import functionality in the DataTab component. The problem was that API keys were being stored in localStorage instead of cookies, and the key format was being incorrectly processed.

### Changes Made:

1. **Updated `handleImportAPIKeys` function**:
   - Changed to store API keys in cookies instead of localStorage
   - Modified to use provider names directly as keys (e.g., "OpenAI", "Google")
   - Added logic to skip comment fields (keys starting with "_")
   - Added page reload after successful import to apply changes immediately

2. **Updated `handleDownloadTemplate` function**:
   - Changed template format to use provider names as keys
   - Added explanatory comment in the template
   - Removed URL-related keys that weren't being used properly

3. **Fixed template format**:
   - Template now uses the correct format with provider names as keys
   - Added support for all available providers including Hyperbolic

These changes ensure that when users download the template, fill it with their API keys, and import it back, the keys are properly stored in cookies with the correct format that the application expects.
@leex279
Copy link
Collaborator

leex279 commented Mar 5, 2025

@Stijnus dont know if I did something wrong, but its not working for me.

Here is a sample import file (fake keys), but it should use it, what is not happening for me.
bolt-api-keys-template.json

@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 5, 2025

@leex279 did you download the new template and used this for import?

New template structure :

{
"_comment": "Fill in your API keys for each provider. Keys will be stored with the provider name (e.g., 'OpenAI').",
"Anthropic": "",
"OpenAI": "",
"Google": "",
"Groq": "",
"HuggingFace": "",
"OpenRouter": "",
"Deepseek": "",
"Mistral": "",
"OpenAILike": "",
"Together": "",
"xAI": "",
"Perplexity": "",
"Cohere": "",
"AzureOpenAI": ""
}

@leex279
Copy link
Collaborator

leex279 commented Mar 5, 2025

No, I used the old one, cause this was the inital requirement, to work with that :D

I think it should be backwards comaptible and as far as I see just the comment is new, so you could ignore if not present, right?

@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 5, 2025

Can you test again please i have made it backwards compatible with the old template.

Stijnus added 2 commits March 6, 2025 00:28
Settings Export/Import Improvements
We've completely redesigned the settings export and import functionality to ensure all application settings are properly backed up and restored:
Key Improvements
Comprehensive Export Format: Now captures ALL settings from both localStorage and cookies, organized into logical categories (core, providers, features, UI, connections, debug, updates)
Robust Import System: Automatically detects format version and handles both new and legacy formats with detailed error handling
Complete Settings Coverage: Properly exports and imports settings from ALL tabs including:
Local provider configurations (Ollama, LMStudio, etc.)
Cloud provider API keys (OpenAI, Anthropic, etc.)
Feature toggles and preferences
UI configurations and tab settings
Connection settings (GitHub, Netlify)
Debug configurations and logs
Technical Details
Added version tracking to export files for better compatibility
Implemented fallback mechanisms if primary import methods fail
Added detailed logging for troubleshooting import/export issues
Created helper functions for safer data handling
Maintained backward compatibility with older export formats

Feature Settings:
Feature flags and viewed features
Developer mode settings
Energy saver mode configurations
User Preferences:
User profile information
Theme settings
Tab configurations
Connection Settings:
Netlify connections
Git authentication credentials
Any other service connections
Debug and System Settings:
Debug flags and acknowledged issues
Error logs and event logs
Update settings and preferences
@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 6, 2025

🔄 Enhanced Settings Export/Import System

We've completely redesigned the settings backup system to ensure a seamless experience:

✨ What's New

  • Complete Settings Backup: Now captures ALL settings from localStorage and cookies
  • Organized Export Format: Settings are neatly categorized (core, providers, features, UI, connections)
  • Smart Import System: Automatically detects format version and handles both new and legacy formats
  • Comprehensive Coverage: Properly handles all settings from all tabs:
    • 🤖 Local AI providers (Ollama, LMStudio)
    • 🔑 Cloud API keys (OpenAI, Anthropic, etc.)
    • 🚀 Feature toggles and preferences
    • 🎨 UI configurations and tab settings
    • 🔌 Connection settings (GitHub, Netlify)

🛠️ Technical Improvements

  • Added version tracking for better compatibility
  • Implemented fallback mechanisms for reliable imports
  • Enhanced error handling and detailed logging
  • Maintained backward compatibility with older exports

Now you can easily transfer your complete setup between devices or create reliable backups!

Enhanced Settings Reset Functionality

This update improves the "Reset Settings" functionality to ensure a complete reset to default values, similar to a fresh installation:

Key Improvements:

  • Complete Settings Reset: Now clears all localStorage items, cookies, IndexedDB data, and chat snapshots
  • Comprehensive Coverage: Ensures all application settings are properly reset, not just a few specific keys
  • Improved Error Handling: Added granular try/catch blocks with detailed error reporting
  • Better Debugging: Added extensive logging throughout the reset process
  • Enhanced User Experience: More descriptive success messages and smoother page reload timing

The reset function now systematically clears all storage mechanisms used by the application while providing flexibility to preserve specific items if needed in the future. This ensures users get a truly fresh start when resetting their settings.

@Stijnus Stijnus requested review from xKevIsDev and thecodacus March 6, 2025 00:12
@Stijnus Stijnus changed the title fix: update DataTab.tsx import api key fix: update DataTab.tsx for import, export settings, api key Mar 6, 2025
@thecodacus
Copy link
Collaborator

I think you can revert all the changes in GithubConnection.tsx file I just made similar PR which is doing the similar think while keeping the cookies intact. #1461

@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 6, 2025

Yes i know, but when i tested my PR and it keeps failing that is why i did the code change...

revert the code back as asked
@Stijnus
Copy link
Collaborator Author

Stijnus commented Mar 7, 2025

@thecodacus i have made the changes as requested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants