= 2 ? 'xl:grid-cols-2' : ''}`}>
{SOURCE_ORDER.map((source) => {
const group = grouped[source]
if (!group?.length) return null
diff --git a/desktop/src/pages/Settings.tsx b/desktop/src/pages/Settings.tsx
index 7d022db0..6f10f0cd 100644
--- a/desktop/src/pages/Settings.tsx
+++ b/desktop/src/pages/Settings.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useRef } from 'react'
+import { useState, useEffect, useMemo, useRef, type ReactNode } from 'react'
import { useSettingsStore } from '../stores/settingsStore'
import { useProviderStore } from '../stores/providerStore'
import { useTranslation } from '../i18n'
@@ -12,7 +12,8 @@ import type { ProviderPreset } from '../config/providerPresets'
import type { SavedProvider, UpdateProviderInput, ProviderTestResult, ModelMapping } from '../types/provider'
import { AdapterSettings } from './AdapterSettings'
import { useAgentStore } from '../stores/agentStore'
-import type { AgentDefinition } from '../api/agents'
+import { useSessionStore } from '../stores/sessionStore'
+import type { AgentDefinition, AgentSource } from '../api/agents'
import { MarkdownRenderer } from '../components/markdown/MarkdownRenderer'
import { useSkillStore } from '../stores/skillStore'
import { SkillList } from '../components/skills/SkillList'
@@ -627,29 +628,58 @@ const AGENT_COLORS: Record
= {
cyan: '#06b6d4',
}
+const AGENT_SOURCE_ORDER: AgentSource[] = [
+ 'userSettings',
+ 'projectSettings',
+ 'localSettings',
+ 'policySettings',
+ 'plugin',
+ 'flagSettings',
+ 'built-in',
+]
+
function AgentsSettings() {
- const { agents, isLoading, error, selectedAgent, fetchAgents, selectAgent } = useAgentStore()
+ const {
+ activeAgents,
+ allAgents,
+ isLoading,
+ error,
+ selectedAgent,
+ fetchAgents,
+ selectAgent,
+ } = useAgentStore()
+ const sessions = useSessionStore((s) => s.sessions)
+ const activeSessionId = useSessionStore((s) => s.activeSessionId)
const t = useTranslation()
- useEffect(() => { fetchAgents() }, [fetchAgents])
+ const activeSession = sessions.find((s) => s.id === activeSessionId)
+ const currentWorkDir = activeSession?.workDir || undefined
+
+ useEffect(() => {
+ void fetchAgents(currentWorkDir)
+ }, [fetchAgents, currentWorkDir])
+
+ const groupedAgents = useMemo(() => {
+ const groups: Partial> = {}
+ for (const agent of allAgents) {
+ ;(groups[agent.source] ??= []).push(agent)
+ }
+ return groups
+ }, [allAgents])
+
+ const sourceCount = AGENT_SOURCE_ORDER.filter((source) => (groupedAgents[source] ?? []).length > 0).length
if (selectedAgent) {
- return selectAgent(null)} />
+ return (
+
+
selectAgent(null)} />
+
+ )
}
return (
-
-
-
-
{t('settings.agents.title')}
-
{t('settings.agents.description')}
-
- {agents.length > 0 && (
-
{t('settings.agents.agentCount', { count: String(agents.length) })}
- )}
-
-
- {isLoading && agents.length === 0 ? (
+
+ {isLoading && allAgents.length === 0 ? (
@@ -658,46 +688,158 @@ function AgentsSettings() {
error_outline
{error}
- ) : agents.length === 0 ? (
-
+ ) : allAgents.length === 0 ? (
+
smart_toy
{t('settings.agents.empty')}
{t('settings.agents.emptyHint')}
) : (
-
- {agents.map((agent) => {
- const dotColor = agent.color && AGENT_COLORS[agent.color] ? AGENT_COLORS[agent.color] : 'var(--color-text-tertiary)'
- return (
-