feat(settings): support singular headers and remove collapse/counters for single agent types

This commit is contained in:
yiling
2026-06-22 09:23:13 +08:00
parent 6981706e13
commit 754131f13a
@@ -206,6 +206,7 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
{AGENT_TYPES.map((section) => { {AGENT_TYPES.map((section) => {
const typeAgents = agents.filter((a) => a.type === section.type) const typeAgents = agents.filter((a) => a.type === section.type)
const Icon = section.icon const Icon = section.icon
const isSingleAgentType = section.type === 'autofill' || section.type === 'embedding'
return ( return (
<div <div
@@ -213,20 +214,24 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
className="bg-card rounded-xl border border-border overflow-hidden" className="bg-card rounded-xl border border-border overflow-hidden"
> >
<div <div
className="px-6 py-4 flex items-center justify-between cursor-pointer hover:bg-muted/50 transition-colors" className={cn(
onClick={() => toggleSection(section.type)} 'px-6 py-4 flex items-center justify-between',
!isSingleAgentType && 'cursor-pointer hover:bg-muted/50 transition-colors',
)}
onClick={!isSingleAgentType ? () => toggleSection(section.type) : undefined}
> >
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<h3 className="font-semibold text-foreground">{section.label} Agents</h3> <h3 className="font-semibold text-foreground">
<Badge variant="secondary" className="h-5 px-1.5 min-w-[1.25rem] text-[10px]"> {section.label} {isSingleAgentType ? 'Agent' : 'Agents'}
{typeAgents.length} </h3>
</Badge> {!isSingleAgentType && (
<Badge variant="secondary" className="h-5 px-1.5 min-w-[1.25rem] text-[10px]">
{typeAgents.length}
</Badge>
)}
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{!( {!(isSingleAgentType && typeAgents.length > 0) && (
(section.type === 'autofill' || section.type === 'embedding') &&
typeAgents.length > 0
) && (
<Button <Button
variant="ghost" variant="ghost"
size="icon" size="icon"
@@ -240,16 +245,18 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
<Plus className="w-4 h-4" /> <Plus className="w-4 h-4" />
</Button> </Button>
)} )}
<ChevronDown {!isSingleAgentType && (
className={cn( <ChevronDown
'w-5 h-5 text-muted-foreground transition-transform duration-200', className={cn(
expandedSections[section.type] ? 'rotate-180' : '', 'w-5 h-5 text-muted-foreground transition-transform duration-200',
)} expandedSections[section.type] ? 'rotate-180' : '',
/> )}
/>
)}
</div> </div>
</div> </div>
{expandedSections[section.type] && ( {(isSingleAgentType || expandedSections[section.type]) && (
<div className="px-6 pb-6 pt-2 space-y-3"> <div className="px-6 pb-6 pt-2 space-y-3">
<div className="grid grid-cols-1 gap-4"> <div className="grid grid-cols-1 gap-4">
{typeAgents.map((agent) => ( {typeAgents.map((agent) => (
@@ -338,7 +345,7 @@ export function AgentsSettings({ teamId }: AgentsSettingsProps) {
<Icon className="w-5 h-5 text-muted-foreground" /> <Icon className="w-5 h-5 text-muted-foreground" />
</div> </div>
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
No {section.label} agents found No {section.label} {isSingleAgentType ? 'agent' : 'agents'} found
</p> </p>
<Button <Button
variant="link" variant="link"