Skip to content

ENG-502: Add direct OpenAI provider support#388

Merged
Farhan (fkb032) merged 5 commits into
developfrom
fkb/eng-502-openai-clean
Jun 13, 2026
Merged

ENG-502: Add direct OpenAI provider support#388
Farhan (fkb032) merged 5 commits into
developfrom
fkb/eng-502-openai-clean

Conversation

@fkb032

Copy link
Copy Markdown
Contributor

Summary

Replaces the closed OpenAI provider PR with a focused branch rebased onto current develop. Anthropic work is intentionally omitted per PM direction.

This adds direct OpenAI support alongside OpenRouter:

  • Adds a first-class OpenAI provider option in settings, model selection, summary, and evolve flows.
  • Adds direct OpenAI API key input/verification with separate OpenAI vs OpenRouter validation and credential routing.
  • Preserves legacy openai UI preference behavior by migrating/falling back to OpenRouter where needed.
  • Handles OpenAI-specific model behavior, including openai/ prefix stripping, GPT-4o max-output limits, and no custom temperature for reasoning/GPT-5-family models.

Test Plan

  • bunx vitest run --project=unit src/lib/ai-provider-validation.test.ts src/lib/ai-provider-migration.test.ts src/lib/api-key-verification.test.ts src/ipc/api.test.ts
  • cargo test --manifest-path apps/native/src-tauri/Cargo.toml direct_openai_
  • cargo test --manifest-path apps/native/src-tauri/Cargo.toml model_capabilities
  • bun run build
  • cargo test --manifest-path apps/native/src-tauri/Cargo.toml
  • git diff --check
  • $claude-review via single outer Fable 5 call; accepted and fixed the blocking GPT-5 temperature-gating finding.

Known unrelated local gate: npx ultracite check currently stops before file linting because the existing biome.json contains rule keys this Biome version does not recognize. This PR does not touch that config.

Docs

  • No docs update needed

Refs ENG-502

@linear-code

linear-code Bot commented Jun 10, 2026

Copy link
Copy Markdown

ENG-502

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor
Warnings
⚠️ ❗ Big PR (1802 lines changed). Consider splitting it into smaller, focused changes.
Messages
📖 No docs update needed — acknowledged.

📋 PR Overview

Lines changed 1802 (+1561 / -241)
Files 6 added, 21 modified, 0 deleted
Draft / WIP no
Has Test Plan yes
No Test Plan Needed no
New UI components no
New Storybook stories no
New Rust modules yes (1)
New TS source files yes (2)
New tests yes (2)
package.json touched no
Cargo.toml touched no
Infra / CI touched no

🔬 Coverage

Report Lines Statements Functions Branches
apps/native/coverage/coverage-summary.json 27.0% 27.0% 25.3% 19.4%

Generated by 🚫 dangerJS against 5a67a6d

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@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: 86002f30f3

ℹ️ 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 (@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 (@codex) address that feedback".

};

let (key, base_url) = if let Some(app) = app_handle {
crate::storage::store::get_effective_openrouter_provider_credential(app)?

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 legacy OpenAI-key fallback

This OpenRouter branch now only accepts an OpenRouter credential, so existing installs with summaryProvider/evolveProvider already stored as openrouter but only an OPENAI_API_KEY/stored OpenAI key stop working with “No OpenRouter API key found.” The previous code path used get_effective_openai_compatible_credential, which explicitly fell back to OpenAI credentials for the same provider value; the new auto-detection only helps when the provider is unset, and the same break applies to generate_evolution's OpenRouter branch.

Useful? React with 👍 / 👎.

@@ -0,0 +1,51 @@
fn normalized_model_name(model: &str) -> String {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think there should probably be a "ModelCapabilities" structure, and the context limit (like I saw elsewhere in this PR) should be part of that as well as temperature support and probably some other things. Longer-term we probably want to have a server-based model registry which can expose those things as JSON so we don't have to hard-code all this stuff.

@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: 41878e62e5

ℹ️ 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 (@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 (@codex) address that feedback".

Comment on lines +184 to +185
has_openai_provider_credential(app_handle)?,
has_openrouter_provider_credential(app_handle)?,

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 Defer credential probes until cloud providers need them

When a summary provider is explicitly configured as ollama, vllm, or a CLI provider, these new calls still read both OpenAI/OpenRouter credentials before the match selects the local provider. Those helpers go through get_effective_*_api_key and can return keychain errors, so a user with a locked/unavailable keychain can no longer use a configured non-cloud summary provider even though it does not need either cloud credential. Compute these booleans only when the provider is absent or when resolving legacy openai compatibility.

Useful? React with 👍 / 👎.

Comment thread apps/native/src-tauri/src/evolve/mod.rs Outdated
Comment on lines +727 to +730
let has_openai_provider_credential =
store::get_effective_openai_provider_credential(app)?.is_some();
let has_openrouter_provider_credential =
store::get_effective_openrouter_provider_credential(app)?.is_some();

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 Avoid keychain reads before selecting evolve provider

This now probes both OpenAI/OpenRouter credentials before checking whether the configured evolve provider is ollama, vllm, or a CLI provider. Since get_effective_*_provider_credential can fail while reading the keychain, a user whose keychain is unavailable will fail to start evolution even when their selected provider is fully local and doesn't require cloud credentials. The credential checks should be delayed until the provider is unset or needs legacy openai resolution.

Useful? React with 👍 / 👎.

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.

Code LGTM, modulo the remark from Scott McMaster (@scottmcmaster) which I think is sensible.

I haven't tested it all the way through (I didn't have an OpenAI key at hand). I did test the preferences part. I found a, unrelated, I think, issue:

https://linear.app/darkmatterlabs/issue/ENG-567/empty-list-when-chosing-a-model-with-the-drop-down-a-second-time

@fkb032 Farhan (fkb032) added this pull request to the merge queue Jun 13, 2026
Merged via the queue into develop with commit ea04eb9 Jun 13, 2026
10 checks passed
@fkb032 Farhan (fkb032) deleted the fkb/eng-502-openai-clean branch June 13, 2026 03:39
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