refactor: extract provider config accordion into reusable ProviderConfigCard component - #5637
Conversation
📝 WalkthroughWalkthrough
ChangesProvider configuration UI
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Comment |
This stack of pull requests is managed by Graphite. Learn more about stacking. |
ProviderConfigCard component
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx (1)
1114-1126: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winWrite back through a functional read of form state rather than the watched snapshot.
onChangecloses overproviderConfigs(fromform.watch) andconfig. Two cards updating within the same render pass (or an update racing ahandleRemoveProvider) would overwrite each other, since the whole array is replaced from a stale snapshot. Reading the current value at write time removes the hazard.♻️ Proposed refactor
onChange={(next) => { - const updated = [...providerConfigs]; - updated[index] = { - ...config, + const current = form.getValues("providerConfigs") || []; + const updated = [...current]; + updated[index] = { + ...current[index], allowed_models: next.allowedModels, blacklisted_models: next.blacklistedModels, weight: next.weight ?? undefined, key_ids: next.keyIds, budgets: next.budgets.map((l) => ({ id: l.id, max_limit: l.max_limit, reset_duration: l.reset_duration })), rate_limit: next.rateLimit ?? undefined, }; form.setValue("providerConfigs", updated, { shouldDirty: true }); }}🤖 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 `@ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx` around lines 1114 - 1126, Update the onChange handler for the provider configuration card to read the current providerConfigs value from form state at write time, rather than using the watched providerConfigs snapshot or closed-over config. Apply the mapped update against that current array and pass the resulting array to form.setValue, preserving the existing field transformations and dirty-state behavior.
🤖 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 `@ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx`:
- Around line 1096-1099: In the provider configuration mapping that renders
ProviderConfigCard, replace the array index key with the stable unique
config.provider value. Keep the existing index prop unchanged if it is used for
ordering or updates, and only change the React key.
---
Nitpick comments:
In `@ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx`:
- Around line 1114-1126: Update the onChange handler for the provider
configuration card to read the current providerConfigs value from form state at
write time, rather than using the watched providerConfigs snapshot or
closed-over config. Apply the mapped update against that current array and pass
the resulting array to form.setValue, preserving the existing field
transformations and dirty-state behavior.
🪄 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 Plus
Run ID: 0eba1a98-95de-4f67-a977-92bdae44e928
📒 Files selected for processing (1)
ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx
3982603 to
1941e05
Compare
d5e0d2e to
00febca
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx (1)
1114-1126: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider hoisting the card
onChangeinto a stablehandleUpdateProviderConfig(index, next)helper.Inlining rebuilds the closure per render over
providerConfigs/config; a small named handler keeps the mapping logic testable and mirrors the existinghandleUpdateMCPConfigpattern in this file.🤖 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 `@ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx` around lines 1114 - 1126, Extract the inline provider card onChange logic into a named handleUpdateProviderConfig(index, next) helper, following the existing handleUpdateMCPConfig pattern. Keep the same providerConfigs update mapping and form.setValue behavior, then pass the helper to the card instead of rebuilding the mapping closure inline.
🤖 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.
Nitpick comments:
In `@ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx`:
- Around line 1114-1126: Extract the inline provider card onChange logic into a
named handleUpdateProviderConfig(index, next) helper, following the existing
handleUpdateMCPConfig pattern. Keep the same providerConfigs update mapping and
form.setValue behavior, then pass the helper to the card instead of rebuilding
the mapping closure inline.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f324527d-3e10-44c0-9846-c41336966d43
📒 Files selected for processing (1)
ui/app/workspace/virtual-keys/views/virtualKeySheet.tsx
1941e05 to
de59e2c
Compare
Merge activity
|
The base branch was changed.
…nfigCard` component (maximhq#5637) ## Summary Extracts the inline provider configuration UI from `virtualKeySheet.tsx` into a reusable `ProviderConfigCard` component. The previous implementation embedded ~340 lines of accordion-based provider config rendering directly in the sheet, making it difficult to maintain and reuse. This refactor delegates that responsibility to a dedicated component with a clean value/onChange interface. ## Changes - Replaced the inline `Accordion`-based provider config rendering with a `ProviderConfigCard` component that accepts a structured `value` prop and an `onChange` callback - Removed the `handleUpdateProviderConfig` helper function, as field-level updates are now handled inside `ProviderConfigCard` via the unified `onChange` interface - Removed the local `VirtualKeyType` type definition and associated `react-select` component imports (`components`, `MultiValueProps`, `OptionProps`) that were only used in the inline key selector - Removed imports for `Accordion`, `AsyncMultiSelect`, `ModelMultiselect`, `cn`, and `ModelPlaceholders` that are no longer needed in this file ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [x] UI (React) - [ ] Docs ## How to test ```sh cd ui pnpm i || npm i pnpm build || npm run build ``` 1. Navigate to the Virtual Keys section in the workspace. 2. Open an existing virtual key that has one or more provider configurations. 3. Verify that each provider config renders correctly with its icon, label, allowed/blocked models, allowed keys, budget, and rate limit fields. 4. Add a new provider config and confirm all fields are editable and saved correctly. 5. Remove a provider config and confirm it is removed from the list. ## Screenshots/Recordings Before: Provider configs rendered as accordion items inline within `virtualKeySheet.tsx`. After: Provider configs rendered via `ProviderConfigCard` with identical visual behavior and a cleaner component boundary. ## Breaking changes - [x] No ## Related issues ## Security considerations None. This is a pure UI refactor with no changes to data handling, authentication, or secrets management. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable
…nfigCard` component (maximhq#5637) ## Summary Extracts the inline provider configuration UI from `virtualKeySheet.tsx` into a reusable `ProviderConfigCard` component. The previous implementation embedded ~340 lines of accordion-based provider config rendering directly in the sheet, making it difficult to maintain and reuse. This refactor delegates that responsibility to a dedicated component with a clean value/onChange interface. ## Changes - Replaced the inline `Accordion`-based provider config rendering with a `ProviderConfigCard` component that accepts a structured `value` prop and an `onChange` callback - Removed the `handleUpdateProviderConfig` helper function, as field-level updates are now handled inside `ProviderConfigCard` via the unified `onChange` interface - Removed the local `VirtualKeyType` type definition and associated `react-select` component imports (`components`, `MultiValueProps`, `OptionProps`) that were only used in the inline key selector - Removed imports for `Accordion`, `AsyncMultiSelect`, `ModelMultiselect`, `cn`, and `ModelPlaceholders` that are no longer needed in this file ## Type of change - [ ] Bug fix - [ ] Feature - [x] Refactor - [ ] Documentation - [ ] Chore/CI ## Affected areas - [ ] Core (Go) - [ ] Transports (HTTP) - [ ] Providers/Integrations - [ ] Plugins - [x] UI (React) - [ ] Docs ## How to test ```sh cd ui pnpm i || npm i pnpm build || npm run build ``` 1. Navigate to the Virtual Keys section in the workspace. 2. Open an existing virtual key that has one or more provider configurations. 3. Verify that each provider config renders correctly with its icon, label, allowed/blocked models, allowed keys, budget, and rate limit fields. 4. Add a new provider config and confirm all fields are editable and saved correctly. 5. Remove a provider config and confirm it is removed from the list. ## Screenshots/Recordings Before: Provider configs rendered as accordion items inline within `virtualKeySheet.tsx`. After: Provider configs rendered via `ProviderConfigCard` with identical visual behavior and a cleaner component boundary. ## Breaking changes - [x] No ## Related issues ## Security considerations None. This is a pure UI refactor with no changes to data handling, authentication, or secrets management. ## Checklist - [ ] I read `docs/contributing/README.md` and followed the guidelines - [ ] I added/updated tests where appropriate - [ ] I updated documentation where needed - [ ] I verified builds succeed (Go and UI) - [ ] I verified the CI pipeline passes locally if applicable

Summary
Extracts the inline provider configuration UI from
virtualKeySheet.tsxinto a reusableProviderConfigCardcomponent. The previous implementation embedded ~340 lines of accordion-based provider config rendering directly in the sheet, making it difficult to maintain and reuse. This refactor delegates that responsibility to a dedicated component with a clean value/onChange interface.Changes
Accordion-based provider config rendering with aProviderConfigCardcomponent that accepts a structuredvalueprop and anonChangecallbackhandleUpdateProviderConfighelper function, as field-level updates are now handled insideProviderConfigCardvia the unifiedonChangeinterfaceVirtualKeyTypetype definition and associatedreact-selectcomponent imports (components,MultiValueProps,OptionProps) that were only used in the inline key selectorAccordion,AsyncMultiSelect,ModelMultiselect,cn, andModelPlaceholdersthat are no longer needed in this fileType of change
Affected areas
How to test
Screenshots/Recordings
Before: Provider configs rendered as accordion items inline within
virtualKeySheet.tsx.After: Provider configs rendered via
ProviderConfigCardwith identical visual behavior and a cleaner component boundary.Breaking changes
Related issues
Security considerations
None. This is a pure UI refactor with no changes to data handling, authentication, or secrets management.
Checklist
docs/contributing/README.mdand followed the guidelines