feat(chat): add radio select and config button to agent selector#774
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Add showRadio and optionAction props to SearchableSelect for radio-style selection and per-option action slots. Update agent selector to use radio indicators and a settings button that navigates to the agent config page.
Use getAllByLabelText for configure buttons since multiple agents render the action button. Pick the second (custom agent) for navigation assertion.
74d89db to
d03498f
Compare
📝 WalkthroughWalkthroughThis PR extends the SearchableSelect component with two new optional features: a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
Comment Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
There was a problem hiding this comment.
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)
services/platform/app/components/ui/forms/searchable-select.tsx (1)
332-377:⚠️ Potential issue | 🟠 MajorIsolate option actions from the option's select handler.
actionis rendered inside the clickable option container, so any interactive action that does not manually callstopPropagation()will also triggeronSelect(option.value). That makes the newoptionActionAPI easy to misuse and can select/close the list when the user intended only the secondary action.Proposed fix
- {action} + {action && ( + <div + onClick={(e) => e.stopPropagation()} + onPointerDown={(e) => e.stopPropagation()} + > + {action} + </div> + )}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@services/platform/app/components/ui/forms/searchable-select.tsx` around lines 332 - 377, The option's clickable container calls onSelect(option.value) on its onClick, but the rendered action node (action / optionAction) sits inside that container so clicks on the action also trigger selection; update how action is rendered so it cannot bubble into the option onClick: render the action in a wrapper that stops propagation (e.g. onClick={e => e.stopPropagation()} and forwards the action's click) or move the action outside the option container; change the rendering around the action symbol (action / optionAction) so its clicks do not call onSelect and ensure any provided action handlers are invoked after stopping propagation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@services/platform/app/features/chat/components/__tests__/agent-selector.test.tsx`:
- Around line 250-262: The test fails because multiple "Configure agent" buttons
exist; scope the query to the specific option before clicking: after rendering
AgentSelector and clicking the trigger (screen.getByLabelText('Select agent')),
locate the specific option element for the agent you want (e.g., find by visible
agent label/text like 'root-2' or by a containing role) and call
within(optionElement).getByLabelText('Configure agent') to get and click the
correct button; add "within" to the test imports from `@testing-library/react` and
keep the expect against mockNavigate as-is.
---
Outside diff comments:
In `@services/platform/app/components/ui/forms/searchable-select.tsx`:
- Around line 332-377: The option's clickable container calls
onSelect(option.value) on its onClick, but the rendered action node (action /
optionAction) sits inside that container so clicks on the action also trigger
selection; update how action is rendered so it cannot bubble into the option
onClick: render the action in a wrapper that stops propagation (e.g. onClick={e
=> e.stopPropagation()} and forwards the action's click) or move the action
outside the option container; change the rendering around the action symbol
(action / optionAction) so its clicks do not call onSelect and ensure any
provided action handlers are invoked after stopping propagation.
🪄 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: ASSERTIVE
Plan: Pro
Run ID: 087afdb0-8c63-462c-b009-c14efc8dfecf
📒 Files selected for processing (5)
services/platform/app/components/ui/forms/searchable-select.test.tsxservices/platform/app/components/ui/forms/searchable-select.tsxservices/platform/app/features/chat/components/__tests__/agent-selector.test.tsxservices/platform/app/features/chat/components/agent-selector.tsxservices/platform/messages/en.json
Summary
showRadioandoptionActionprops toSearchableSelectfor radio-style selection indicators and per-option action slotsTest plan
/dashboard/$id/custom-agents/$agentIdcustomAgentswrite permissionsearchable-select.test.tsxandagent-selector.test.tsx— all tests pass🤖 Generated with Claude Code
Summary by CodeRabbit