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:
@@ -181,7 +181,7 @@ export const AgentsSidebar: React.FC<AgentsSidebarProps> = ({ onItemSelect }) =>
|
||||
}
|
||||
|
||||
setIsConfirmActionPending(true);
|
||||
const success = await deleteAgent(confirmActionAgent.name);
|
||||
const success = await deleteAgent(confirmActionAgent.name, (confirmActionAgent as Agent & { scope?: AgentScope }).scope);
|
||||
|
||||
if (success) {
|
||||
if (confirmActionType === 'delete') {
|
||||
@@ -276,7 +276,7 @@ export const AgentsSidebar: React.FC<AgentsSidebarProps> = ({ onItemSelect }) =>
|
||||
|
||||
if (success) {
|
||||
// Delete old agent
|
||||
const deleteSuccess = await deleteAgent(renameDialogAgent.name);
|
||||
const deleteSuccess = await deleteAgent(renameDialogAgent.name, renameExt.scope);
|
||||
if (deleteSuccess) {
|
||||
toast.success(`Agent renamed to "${sanitizedName}"`);
|
||||
setSelectedAgent(sanitizedName);
|
||||
|
||||
@@ -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