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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user