fix: prevent agent deletion from disabling built-ins

Stop delete from creating disable overrides
Delete only the selected agent scope
Keep web and VS Code behavior aligned
This commit is contained in:
Bohdan Triapitsyn
2026-06-16 13:38:24 +03:00
parent e402cd75f5
commit e982bd9388
6 changed files with 113 additions and 58 deletions
+7 -3
View File
@@ -190,7 +190,7 @@ interface AgentsStore {
loadAgents: () => Promise<boolean>;
createAgent: (config: AgentConfig) => Promise<boolean>;
updateAgent: (name: string, config: Partial<AgentConfig>) => Promise<boolean>;
deleteAgent: (name: string) => Promise<boolean>;
deleteAgent: (name: string, scope?: AgentScope) => Promise<boolean>;
getAgentByName: (name: string) => Agent | undefined;
// Returns only visible agents (excludes hidden internal agents)
getVisibleAgents: () => Agent[];
@@ -448,7 +448,7 @@ export const useAgentsStore = create<AgentsStore>()(
}
},
deleteAgent: async (name: string) => {
deleteAgent: async (name: string, scope?: AgentScope) => {
startConfigUpdate("Deleting agent configuration…");
let requiresReload = false;
try {
@@ -458,7 +458,11 @@ export const useAgentsStore = create<AgentsStore>()(
const response = await runtimeFetch(`/api/config/agents/${encodeURIComponent(name)}${queryParams}`, {
method: 'DELETE',
headers: configDirectory ? { 'x-opencode-directory': configDirectory } : undefined,
headers: {
'Content-Type': 'application/json',
...(configDirectory ? { 'x-opencode-directory': configDirectory } : {}),
},
body: JSON.stringify({ scope }),
});
const payload = await response.json().catch(() => null);