Skip to content

Config: fix Google provider models via dynamic multi-provider config#239

Merged
Ayush8923 merged 5 commits into
mainfrom
feat/dynamic-model-config-providers-google
Jul 2, 2026
Merged

Config: fix Google provider models via dynamic multi-provider config#239
Ayush8923 merged 5 commits into
mainfrom
feat/dynamic-model-config-providers-google

Conversation

@vprashrex

@vprashrex vprashrex commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Issue

Closes #240

Summary

  • Enhance provider and type handling in ConfigEditorPane
  • Improve error handling and completion type assignment
  • Update provider type handling in configToBlob function
  • Simplify model flattening and add completion type retrieval
  • Allow dynamic provider types in CompletionConfig interface
  • Remove unused SUPPORTED_PARAMS constant from utils

Checklist

Before submitting a pull request, please ensure that you mark these task.

  • Ran npm run dev and npm run build in the repository root and test.
  • If you've fixed a bug or added code that is tested

Notes

  • Prompt editor now renders providers, models, and completion types dynamically from the models API (/grouped) — no hardcoded lists anymore.
  • Type dropdown is filtered per provider, so only completion types a provider actually supports are shown (e.g. Google shows STT/TTS, not Text).
  • Adding a new provider/model/param on the backend now flows through automatically — no frontend changes required.

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • ready-for-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d8cb4d43-d6e0-4108-94cd-8e9f75315acd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR generalizes the prompt editor's completion config to support multiple providers (adding google-aistudio) instead of OpenAI-only. It introduces a shared ProviderType, provider-aware type/model reconciliation in ConfigEditorPane, expanded model schema params/labels, refined save/error messaging, and structured validation error parsing.

Changes

Multi-provider completion config support

Layer / File(s) Summary
Shared ProviderType contract
app/lib/types/configs.ts, app/lib/types/assessment/config.ts, app/lib/chatClient.ts
Introduces exported ProviderType union and applies it to CompletionConfig.provider, AssessmentModelConfig.provider, and configToBlob's provider cast.
Schema support for providers/types/params
app/lib/modelSchema.ts
Adds google-aistudio to SUPPORTED_PROVIDERS/PROVIDER_LABELS, expands SUPPORTED_PARAMS/PARAM_LABELS with summary, voice, thinking_level, and adds getCompletionTypesForProvider.
ConfigEditorPane provider/type/model reconciliation
app/components/prompt-editor/ConfigEditorPane.tsx
Derives typeOptions per provider via getCompletionTypesForProvider, adds applyProviderTypeModel that reconciles params via reconcileParamsForModel, refactors provider/type/model change handlers, and updates the Type selector to use typeOptions.
Config save and error messaging
app/hooks/useConfigPersistence.ts, app/lib/apiClient.ts
saveConfig conditionally omits instructions for tts type and surfaces thrown error messages in toasts; apiClient.ts adds stringifyValidationDetail and updates extractErrorMessage to combine primary and structured validation error details.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ConfigEditorPane
  participant modelSchema
  participant useConfigPersistence

  User->>ConfigEditorPane: Select provider/type/model
  ConfigEditorPane->>modelSchema: getCompletionTypesForProvider(provider)
  modelSchema-->>ConfigEditorPane: available completion types
  ConfigEditorPane->>modelSchema: reconcileParamsForModel(provider, model, params)
  modelSchema-->>ConfigEditorPane: reconciled params
  ConfigEditorPane->>User: Render updated Type/Model/Params UI
  User->>useConfigPersistence: Save config
  useConfigPersistence->>useConfigPersistence: Derive completionType, build payload
  useConfigPersistence-->>User: Success or error toast
Loading

Possibly related PRs

Suggested reviewers: AkhileshNegi

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: dynamic multi-provider config and Google provider support.
Linked Issues check ✅ Passed The PR aligns with #240 by adding provider-agnostic config, filtering completion types by provider, and supporting multiple providers.
Out of Scope Changes check ✅ Passed The additional changes are supporting updates for the same multi-provider configuration work and do not appear unrelated.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dynamic-model-config-providers-google

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@vprashrex vprashrex requested a review from Ayush8923 July 1, 2026 02:37
@vprashrex vprashrex self-assigned this Jul 1, 2026

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/components/prompt-editor/ConfigEditorPane.tsx (1)

87-94: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Gate availableTypes/typeOptions on schemasLoaded like providerOptions.

providerOptions explicitly falls back to [] when !schemasLoaded (Line 87), but availableTypes/typeOptions call getCompletionTypesForProvider(provider) unconditionally. Since that function reads from the same schema cache, the Type <select> can momentarily render with zero options before schemas finish loading, causing a mismatch between the controlled value and available options.

🩹 Proposed fix
-  const availableTypes = getCompletionTypesForProvider(provider);
+  const availableTypes = schemasLoaded
+    ? getCompletionTypesForProvider(provider)
+    : [];
   const typeOptions = PROVIDER_TYPES.filter((t) =>
     availableTypes.includes(t.value as ConfigType),
   );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/components/prompt-editor/ConfigEditorPane.tsx` around lines 87 - 94,
`ConfigEditorPane` should gate the Type options on `schemasLoaded` the same way
`providerOptions` does. Update the `availableTypes`/`typeOptions` logic so
`getCompletionTypesForProvider(provider)` is only used after schemas are loaded,
and fall back to an empty list before then. Keep the fix localized to the
`ConfigEditorPane` render logic so the Type `<select>` doesn’t briefly show a
controlled value with no matching options.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/lib/apiClient.ts`:
- Around line 61-74: The error text assembly in extractErrorMessage is
duplicating plain-string body.detail because it is used both as msg and detail.
Update the logic so body.detail is only included once in the final message,
preferably by making the detail branch ignore plain strings or by removing the
string fallback from msg. Keep the combined output from extractErrorMessage and
its callers like useConfigPersistence from surfacing repeated text.

---

Outside diff comments:
In `@app/components/prompt-editor/ConfigEditorPane.tsx`:
- Around line 87-94: `ConfigEditorPane` should gate the Type options on
`schemasLoaded` the same way `providerOptions` does. Update the
`availableTypes`/`typeOptions` logic so
`getCompletionTypesForProvider(provider)` is only used after schemas are loaded,
and fall back to an empty list before then. Keep the fix localized to the
`ConfigEditorPane` render logic so the Type `<select>` doesn’t briefly show a
controlled value with no matching options.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: aee6761f-5048-4c82-af44-5e945b5ece69

📥 Commits

Reviewing files that changed from the base of the PR and between 7b313f3 and a93e340.

📒 Files selected for processing (7)
  • app/components/prompt-editor/ConfigEditorPane.tsx
  • app/hooks/useConfigPersistence.ts
  • app/lib/apiClient.ts
  • app/lib/chatClient.ts
  • app/lib/modelSchema.ts
  • app/lib/types/configs.ts
  • app/lib/utils.ts
💤 Files with no reviewable changes (1)
  • app/lib/utils.ts

Comment thread app/lib/apiClient.ts
Comment thread app/lib/apiClient.ts Outdated
Comment thread app/lib/utils.ts

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
app/lib/types/configs.ts (1)

19-19: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

SavedConfig.provider still typed as string, while CompletionConfig.provider is now ProviderType.

configToBlob (app/lib/chatClient.ts) and applyProviderTypeModel (ConfigEditorPane.tsx) both do config.provider as ProviderType / nextProvider as ProviderType, unsafely widening from string. Since SavedConfig is the round-trip persisted shape that feeds directly into CompletionConfig, narrowing it to ProviderType here would let the compiler catch invalid provider values instead of relying on unchecked casts downstream.

♻️ Proposed fix
 export interface SavedConfig {
   ...
-  provider: string;
+  provider: ProviderType;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/lib/types/configs.ts` at line 19, SavedConfig.provider is still typed too
broadly as string, which forces unsafe casts later in configToBlob and
applyProviderTypeModel. Update SavedConfig in configs.ts so provider uses
ProviderType like CompletionConfig, and then remove the downstream as
ProviderType casts in chatClient.ts and ConfigEditorPane.tsx where the persisted
config is converted or updated.
app/lib/modelSchema.ts (1)

28-58: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

max_output_tokens should not be dropped from model schema config. acceptsTools in ConfigEditorPane.tsx and useConfigPersistence.ts depends on "max_output_tokens" in modelSchema.config, but flattenGroupedModels() filters it out because it isn’t in SUPPORTED_PARAMS. That makes tool support look unavailable for every loaded schema and prevents max_num_results from being persisted. Add max_output_tokens to the allowlist, or move this capability check to separate schema metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/lib/modelSchema.ts` around lines 28 - 58, The model schema flattening
logic is dropping max_output_tokens from config, which breaks downstream
capability checks. Update flattenGroupedModels() in modelSchema.ts so the
SUPPORTED_PARAMS allowlist includes max_output_tokens, or otherwise preserve
that field when copying entry.config into ModelSchema.config. Keep the existing
filtering for other params intact so acceptsTools in ConfigEditorPane.tsx and
persistence in useConfigPersistence.ts can still detect tool support correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@app/lib/modelSchema.ts`:
- Around line 28-58: The model schema flattening logic is dropping
max_output_tokens from config, which breaks downstream capability checks. Update
flattenGroupedModels() in modelSchema.ts so the SUPPORTED_PARAMS allowlist
includes max_output_tokens, or otherwise preserve that field when copying
entry.config into ModelSchema.config. Keep the existing filtering for other
params intact so acceptsTools in ConfigEditorPane.tsx and persistence in
useConfigPersistence.ts can still detect tool support correctly.

In `@app/lib/types/configs.ts`:
- Line 19: SavedConfig.provider is still typed too broadly as string, which
forces unsafe casts later in configToBlob and applyProviderTypeModel. Update
SavedConfig in configs.ts so provider uses ProviderType like CompletionConfig,
and then remove the downstream as ProviderType casts in chatClient.ts and
ConfigEditorPane.tsx where the persisted config is converted or updated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8b387cae-72f6-4868-b75e-86bced374259

📥 Commits

Reviewing files that changed from the base of the PR and between a93e340 and 0a5b498.

📒 Files selected for processing (6)
  • app/components/prompt-editor/ConfigEditorPane.tsx
  • app/lib/apiClient.ts
  • app/lib/chatClient.ts
  • app/lib/modelSchema.ts
  • app/lib/types/assessment/config.ts
  • app/lib/types/configs.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/lib/chatClient.ts
  • app/lib/apiClient.ts
  • app/components/prompt-editor/ConfigEditorPane.tsx

@vprashrex vprashrex requested a review from Ayush8923 July 2, 2026 04:44
@Ayush8923 Ayush8923 merged commit 341e5f4 into main Jul 2, 2026
1 of 2 checks passed
@Ayush8923 Ayush8923 deleted the feat/dynamic-model-config-providers-google branch July 2, 2026 05:15
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 0.3.0-main.5 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic Provider: Support multiple providers

2 participants