Skip to content

feat(ui): add bedrock provider#55

Merged
bzp2010 merged 2 commits intomainfrom
bzp/feat-bedrock-provider-ui
Apr 23, 2026
Merged

feat(ui): add bedrock provider#55
bzp2010 merged 2 commits intomainfrom
bzp/feat-bedrock-provider-ui

Conversation

@bzp2010
Copy link
Copy Markdown
Collaborator

@bzp2010 bzp2010 commented Apr 23, 2026

Summary by CodeRabbit

  • New Features

    • Provider selection added to the model creation form.
    • Dynamic provider-specific credential fields appear based on chosen provider.
    • Preserves per-provider draft inputs when switching providers.
  • UI Updates

    • Model input split into separate Provider + Provider Model fields.
    • English and Chinese form labels, placeholders, and hints updated (includes AWS Bedrock fields: region, keys, session token, endpoint).
    • Validates provider selection and surfaces client-side errors.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

📝 Walkthrough

Walkthrough

Model creation UI split into provider selection and provider-model fields. The form derives provider/providerModel from initial data, initializes and renders provider-specific credential inputs from per-provider schemas, re-normalizes drafts on provider change, and builds payload.model and payload.provider_config on submit.

Changes

Cohort / File(s) Summary
Model Form Component
ui/src/components/models/model-form.tsx
Parses initial.model into provider and providerModel; initializes provider-specific credential state by normalizing initial.provider_config against per-provider schemas; renders a provider <Select>; dynamically generates credential inputs from the selected provider schema; re-normalizes stored per-provider drafts on provider change; validates and composes payload.model as ${provider}/${trimmedModel} and payload.provider_config by trimming/serializing only schema-defined fields; removes fixed api_key/api_base fields; updates grid/gap layout classes and prefers clientError over error prop for error display.
Localization (English)
ui/src/i18n/locales/en.json
Replaces single model copy with provider-first flow: adds provider and provider-model labels/placeholders/validation, hint about loading provider config on selection, Bedrock-specific labels/placeholders/hints (region, access key, secret, session token, endpoint), and a providers mapping for provider display names.
Localization (Chinese)
ui/src/i18n/locales/zh-CN.json
Mirrors English changes: updates models.createDesc, replaces combined model text with provider/provider-model entries and validation hints, adds Bedrock-specific fields and placeholders/hints, and adds providers mapping for provider names.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
Security Check ❌ Error Component stores AWS credentials and API keys as plaintext in React state without explicit memory cleanup after form submission, and loads credentials without detecting secret references. Implement explicit credential clearing after onSubmit, add secret reference detection in normalizeProviderConfigValues, consolidate credential state, add JSDoc documentation, and consider credential masking for error messages.
E2e Test Quality Review ⚠️ Warning PR adds 306 lines of UI functionality for Bedrock provider support to ModelForm component with no component, integration, or E2E tests covering the UI changes. Add E2E/component tests covering ModelForm workflow: provider dropdown rendering, dynamic credential fields, form validation, draft preservation, payload building, and Bedrock-specific field validation.
✅ 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 is specific and directly reflects the main change: adding Bedrock provider support to the UI, which is the primary focus across all modified files (model form component, English and Chinese i18n locales).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bzp/feat-bedrock-provider-ui

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
ui/src/components/models/model-form.tsx (1)

291-299: Preserve provider-specific drafts when switching providers.

normalizeProviderConfigValues(nextProvider, current) drops any fields that are not in the newly selected schema. In practice, switching OpenAI → Bedrock → OpenAI clears the already entered API key/base values. A small per-provider draft cache would make the new selector much safer to use.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/components/models/model-form.tsx` around lines 291 - 299,
handleProviderChange currently calls normalizeProviderConfigValues(nextProvider,
current) which drops fields not in the new schema and causes switching back to
lose previously entered secrets; modify handleProviderChange to keep a
per-provider draft cache keyed by provider id (e.g., providerConfigDrafts state)
so when switching away you save the current provider config (before normalize)
into providerConfigDrafts[provider], and when switching to nextProvider you
merge any existing providerConfigDrafts[nextProvider] into the normalized values
before calling setProviderConfigValues. Update places that call setProvider and
setProviderConfigValues in handleProviderChange to first save the current draft,
then load/merge the draft for nextProvider with
normalizeProviderConfigValues(nextProvider, draftOrCurrent) so provider-specific
drafts are preserved across switches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/src/components/models/model-form.tsx`:
- Around line 275-281: The form currently constructs payload.model using
`${provider}/${value.model.trim()}` but doesn’t prevent a whitespace-only model
ID (e.g. "   ") which becomes `${provider}/`; modify the submit/validation in
model-form.tsx (the onSubmit handler that builds the payload and the form field
validation for value.model) to check value.model.trim().length > 0 before
composing payload.model, and if it fails set a form error (or prevent
submission) with a clear message; keep using serializeProviderConfig(provider,
providerConfigValues) and only build the Model object after the trimmed model ID
is validated.
- Around line 118-130: The placeholders for the Bedrock fields are hardcoded;
change the secret_access_key and session_token entries to use placeholderKey
instead of placeholder (e.g., keep titleKey and descriptionKey as-is and add
placeholderKey: 'models.form.secretAccessKeyPlaceholder' and placeholderKey:
'models.form.sessionTokenPlaceholder') and then add those two keys to the i18n
locale files (including zh-CN) with appropriate translated strings so
placeholders are localized like the labels and hints.
- Around line 157-159: The code seeds new-model state with provider: 'openai'
(via splitModelIdentifier) causing an implicit OpenAI selection; change any
default provider values in this file that set provider: 'openai' to an empty
string (provider: '') and providerModel to '' so the provider select shows the
placeholder, and update the form submit/validation (the submit handler or
validate function used by the model form) to block submit unless provider is
non-empty; search for usages of splitModelIdentifier and any return blocks that
set provider: 'openai' (including the shown block and the other similar blocks)
and replace them with provider: '' and enforce explicit provider selection
before allowing save.

---

Nitpick comments:
In `@ui/src/components/models/model-form.tsx`:
- Around line 291-299: handleProviderChange currently calls
normalizeProviderConfigValues(nextProvider, current) which drops fields not in
the new schema and causes switching back to lose previously entered secrets;
modify handleProviderChange to keep a per-provider draft cache keyed by provider
id (e.g., providerConfigDrafts state) so when switching away you save the
current provider config (before normalize) into providerConfigDrafts[provider],
and when switching to nextProvider you merge any existing
providerConfigDrafts[nextProvider] into the normalized values before calling
setProviderConfigValues. Update places that call setProvider and
setProviderConfigValues in handleProviderChange to first save the current draft,
then load/merge the draft for nextProvider with
normalizeProviderConfigValues(nextProvider, draftOrCurrent) so provider-specific
drafts are preserved across switches.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a72095ae-5e64-4f3e-9d24-97ce0d2ea3d0

📥 Commits

Reviewing files that changed from the base of the PR and between b36d810 and 155aed4.

📒 Files selected for processing (3)
  • ui/src/components/models/model-form.tsx
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json

Comment thread ui/src/components/models/model-form.tsx
Comment thread ui/src/components/models/model-form.tsx
Comment thread ui/src/components/models/model-form.tsx
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 (1)
ui/src/i18n/locales/zh-CN.json (1)

84-126: ⚠️ Potential issue | 🟡 Minor

Mixed English copy in zh-CN locale reduces localization quality.

On Line 105, Line 109, and Line 117 (and nearby placeholders/hints), multiple new labels are English-only in the Chinese locale file. This creates inconsistent UX in the same form.

🌐 Suggested localization patch
-    "createDesc": "必填:name、provider、provider model、provider 专属配置。可选:timeout 和 rate limits。",
+    "createDesc": "必填:name、provider、provider model、provider 专属配置。可选:timeout 和 限流。",
@@
-      "providerLabel": "Provider *",
-      "providerPlaceholder": "选择 provider",
-      "providerRequired": "保存前请先选择 provider。",
-      "providerConfigSelectHint": "先选择 provider,再加载对应的配置表单。",
-      "modelLabel": "Provider Model *",
+      "providerLabel": "提供方 *",
+      "providerPlaceholder": "选择提供方",
+      "providerRequired": "保存前请先选择提供方。",
+      "providerConfigSelectHint": "先选择提供方,再加载对应的配置表单。",
+      "modelLabel": "提供方模型 *",
       "modelPlaceholder": "例如:gpt-4.1、deepseek-chat 或 anthropic.claude-3-5-sonnet-20240620-v1:0",
-      "modelRequired": "请输入 provider 侧模型标识。",
+      "modelRequired": "请输入提供方侧模型标识。",
@@
-      "regionLabel": "AWS Region",
+      "regionLabel": "AWS 区域",
       "regionHint": "用于选择默认的 Bedrock 运行时地址。",
       "accessKeyIdLabel": "AWS Access Key ID",
       "secretAccessKeyLabel": "AWS Secret Access Key",
-      "secretAccessKeyPlaceholder": "AWS secret access key",
+      "secretAccessKeyPlaceholder": "AWS 密钥",
       "sessionTokenLabel": "AWS Session Token",
       "sessionTokenHint": "使用 STS 或 AssumeRole 临时凭证时可选。",
       "sessionTokenPlaceholder": "可选的临时凭证",
-      "endpointLabel": "Bedrock Endpoint Override",
+      "endpointLabel": "Bedrock 端点覆盖",
       "endpointHint": "留空则根据所选 Region 使用标准运行时地址。",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/src/i18n/locales/zh-CN.json` around lines 84 - 126, The zh-CN locale has
mixed English entries; update the English-only values to Chinese for consistency
by translating the keys such as "modelPlaceholder", "modelLabel" placeholders
(e.g., example model names can remain but the surrounding text should be
Chinese), "apiBasePlaceholder" and "apiBaseHint", "secretAccessKeyPlaceholder",
"sessionTokenPlaceholder" and any nearby hints/placeholders so all user-facing
strings in the "form" object are fully Chinese; keep technical examples (URLs,
model IDs, keys) as-is but replace English UI text with appropriate Chinese
phrases matching the style of other entries.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@ui/src/i18n/locales/zh-CN.json`:
- Around line 84-126: The zh-CN locale has mixed English entries; update the
English-only values to Chinese for consistency by translating the keys such as
"modelPlaceholder", "modelLabel" placeholders (e.g., example model names can
remain but the surrounding text should be Chinese), "apiBasePlaceholder" and
"apiBaseHint", "secretAccessKeyPlaceholder", "sessionTokenPlaceholder" and any
nearby hints/placeholders so all user-facing strings in the "form" object are
fully Chinese; keep technical examples (URLs, model IDs, keys) as-is but replace
English UI text with appropriate Chinese phrases matching the style of other
entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 121c8e2a-842a-4b25-b01d-0c73f753bbad

📥 Commits

Reviewing files that changed from the base of the PR and between 155aed4 and 4efacd7.

📒 Files selected for processing (3)
  • ui/src/components/models/model-form.tsx
  • ui/src/i18n/locales/en.json
  • ui/src/i18n/locales/zh-CN.json
✅ Files skipped from review due to trivial changes (1)
  • ui/src/components/models/model-form.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/src/i18n/locales/en.json

@bzp2010 bzp2010 merged commit bcef7e1 into main Apr 23, 2026
10 checks passed
@bzp2010 bzp2010 deleted the bzp/feat-bedrock-provider-ui branch April 23, 2026 09:14
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.

1 participant