Skip to content

feat: add export/import for provider configurations#1450

Open
yudanmao123 wants to merge 1 commit intomoeru-ai:mainfrom
yudanmao123:main
Open

feat: add export/import for provider configurations#1450
yudanmao123 wants to merge 1 commit intomoeru-ai:mainfrom
yudanmao123:main

Conversation

@yudanmao123
Copy link
Copy Markdown

Adds exportProviderConfigs() and importProviderConfigs() functions to the providers store.

This allows users to export their provider configurations to a JSON file and import them later, useful during development when data gets purged.

Usage:

import { exportProviderConfigs, importProviderConfigs } from 
  @proj-airi/stage-ui/stores/providers

// Export
const configJson = exportProviderConfigs()

// Import
importProviderConfigs(configJson)

Closes #973

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces functionality to export and import provider configurations within the application. This enhancement allows developers to easily save and restore their configurations, which is especially useful during development cycles where data loss may occur. The changes involve adding two new functions, exportProviderConfigs and importProviderConfigs, to the providers store.

Highlights

  • Export/Import Functionality: Introduces exportProviderConfigs() and importProviderConfigs() functions to the providers store, enabling users to save and restore their provider configurations.
  • Data Persistence: Addresses the need to persist provider configurations, particularly useful during development when data is frequently purged.
  • Usage: Provides example code snippets demonstrating how to export provider configurations to a JSON string and import them back into the application.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6cf8085caa

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +2250 to +2252
const providerIds = store.configuredChatProviders.map(p => p.id)
providerIds.forEach(id => {
config[id] = store.getProviderConfig(id) || {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Export every persisted provider, not just configured chat ones

This loop only serializes chat providers that are currently marked configured. In the same store we already track configured speech/transcription providers (configuredSpeechProvidersMetadata, configuredTranscriptionProvidersMetadata at packages/stage-ui/src/stores/providers.ts:2158-2168) and persisted-but-not-yet-configured entries via shouldListProvider() (packages/stage-ui/src/stores/providers.ts:2179-2184). As a result, backing up a setup with TTS/STT providers or a chat provider that is temporarily failing validation/manual testing will silently omit those credentials, so the subsequent import cannot restore the user's full provider setup.

Useful? React with 👍 / 👎.

Comment on lines +2263 to +2264
Object.entries(config).forEach(([providerId, providerConfig]) => {
store.setProviderConfig(providerId, providerConfig)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve added-provider state during import

importProviderConfigs() restores only the credential object, but visibility is gated by addedProviders or a non-default config (shouldListProvider() in packages/stage-ui/src/stores/providers.ts:2179-2184). That is why useProviderValidation() explicitly calls markProviderAdded() for valid providers such as LM Studio whose working config can exactly match the defaults (packages/stage-ui/src/composables/use-provider-validation.ts:83-89). After exporting and re-importing one of those providers, the credentials come back but addedProviders stays empty, so the provider disappears from selectors/settings until the user opens the page and revalidates it manually.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds functionality to export and import provider configurations. There are a couple of issues in the implementation. The exportProviderConfigs function attempts to access a non-existent property on the store and only exports chat providers, which is inconsistent with the feature's goal. The importProviderConfigs function calls a method that doesn't exist, which will cause a runtime error. Suggestions have been provided to fix these bugs and improve the feature's correctness and completeness.

Comment on lines +2263 to +2265
Object.entries(config).forEach(([providerId, providerConfig]) => {
store.setProviderConfig(providerId, providerConfig)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The method store.setProviderConfig does not exist on the providers store. This will cause a runtime error. You should directly modify the providers state. Since store.providers is a ref, you need to assign to its .value property. A safe and efficient way to do this is to merge the imported configurations with the existing ones.

Suggested change
Object.entries(config).forEach(([providerId, providerConfig]) => {
store.setProviderConfig(providerId, providerConfig)
})
store.providers.value = {
...store.providers.value,
...config,
};

Comment on lines +2250 to +2253
const providerIds = store.configuredChatProviders.map(p => p.id)
providerIds.forEach(id => {
config[id] = store.getProviderConfig(id) || {}
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The property store.configuredChatProviders does not exist. It seems you intended to use store.configuredChatProvidersMetadata. Additionally, this function only exports chat provider configurations, while the function name and PR description imply all provider configurations should be exported. To fix this and make it more robust, you could iterate over store.availableProviders which contains all configured providers regardless of their category.

Suggested change
const providerIds = store.configuredChatProviders.map(p => p.id)
providerIds.forEach(id => {
config[id] = store.getProviderConfig(id) || {}
})
for (const providerId of store.availableProviders) {
const providerConfig = store.getProviderConfig(providerId);
if (providerConfig) {
config[providerId] = providerConfig;
}
}

@nekomeowww nekomeowww added scope/providers Scope related to providers we support scope/ui Scope related to UI/UX, or interface improve, perf, and bugs labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/providers Scope related to providers we support scope/ui Scope related to UI/UX, or interface improve, perf, and bugs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feature request: export and import for provider configurations

2 participants