Skip to content

✨ feat(desktop): add secure provider import protocol - #18347

Open
houko wants to merge 6 commits into
lobehub:canaryfrom
houko:feat/provider-import-protocol
Open

✨ feat(desktop): add secure provider import protocol#18347
houko wants to merge 6 commits into
lobehub:canaryfrom
houko:feat/provider-import-protocol

Conversation

@houko

@houko houko commented Aug 15, 2026

Copy link
Copy Markdown

Summary

Add a secure desktop protocol for importing an OpenAI-compatible provider and its model catalog from a trusted local application:

  • accept lobehub://provider/import with a short-lived, tokenized loopback callback
  • keep API keys out of custom-protocol URLs, argv, logs, and renderer broadcasts
  • bypass the global proxy for the literal-loopback callback, reject redirects, and bound the response size and schema
  • show a global confirmation dialog on every desktop route, including explicit overwrite identity for existing custom providers
  • keep built-in providers protected and make partial new-provider imports safely retryable
  • document the versioned protocol for integrations
Before After
Desktop integrations had to guide users through manual provider, credential, and model setup. A local integration can open a reviewed confirmation dialog that imports the provider and models in one action.

Screenshots are pending a packaged desktop build; this is opened as a draft so the upstream CI matrix can validate the implementation first.

Test

  • Tested locally
  • Added/updated tests
  • No tests needed

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.

@vercel

vercel Bot commented Aug 15, 2026

Copy link
Copy Markdown

@houko is attempting to deploy a commit to the LobeHub OSS Team on Vercel.

A member of the Team first needs to authorize it.

@houko
houko marked this pull request as ready for review August 15, 2026 14:52
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. platform:desktop Desktop client trigger:build-desktop Trigger Desktop build labels Aug 15, 2026

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

Copy link
Copy Markdown

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: 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".

Comment on lines +81 to +82
const store = useAiInfraStore.getState();
await Promise.all([store.refreshAiProviderList(), store.refreshAiProviderRuntimeState()]);

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 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 👍 / 👎.

Comment on lines +129 to +130
danger={isOverwrite}
disabled={isBuiltinConflict}

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 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

platform:desktop Desktop client size:XL This PR changes 500-999 lines, ignoring generated files. trigger:build-desktop Trigger Desktop build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant