✨ feat(desktop): add secure provider import protocol - #18347
Conversation
|
@houko is attempting to deploy a commit to the LobeHub OSS Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8e7114bf2
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const store = useAiInfraStore.getState(); | ||
| await Promise.all([store.refreshAiProviderList(), store.refreshAiProviderRuntimeState()]); |
There was a problem hiding this comment.
Refresh the provider’s model/detail caches after import
When importing into a provider whose settings page is already open, this only revalidates the provider list and runtime state, but the settings UI reads the active provider detail from [AiProviderSwrKey.fetchAiProviderItem, id] and the model table from aiModelKeys.list(id). After the new endpoint/models are written, those SWR caches can continue showing the old endpoint and model list until a manual reload or later revalidation, making a successful import look incomplete on the exact surface users are likely viewing. Revalidate the imported provider detail and model-list key as part of this success path.
Useful? React with 👍 / 👎.
| danger={isOverwrite} | ||
| disabled={isBuiltinConflict} |
There was a problem hiding this comment.
Gate provider import by provider-management permission
In a workspace where the current member lacks manage_provider_key, the backend mutations used by applyProviderImport reject, but this protocol modal still presents an enabled primary Import/Replace action and then falls back to a generic “could not import” toast. The existing provider settings surfaces disable the same provider/model configuration actions with a permission reason, so this new entry point should preflight usePermission('manage_provider_key') and disable/explain the action before the user confirms.
Useful? React with 👍 / 👎.
Summary
Add a secure desktop protocol for importing an OpenAI-compatible provider and its model catalog from a trusted local application:
lobehub://provider/importwith a short-lived, tokenized loopback callbackScreenshots are pending a packaged desktop build; this is opened as a draft so the upstream CI matrix can validate the implementation first.
Test
Local full dependency installation was intentionally skipped; formatting, JSON parsing, and diff checks passed. The new tests cover callback validation and bounds, proxy bypass, credential redaction and one-shot consent, overwrite protection, partial-import retry, model persistence limits, and protocol-log redaction.
🔗 Related Issue
No existing issue or duplicate provider-import PR found.