MCPcopy Create free account
hub / github.com/Microck/opencode-studio / handleEditSave

Function handleEditSave

client-next/src/app/commands/page.tsx:85–114  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83
84
85 const handleEditSave = async () => {
86 if (!editingCmd) return;
87 if (!editingCmd.name.trim()) {
88 toast.error("Command name is required");
89 return;
90 }
91 if (!editingCmd.template.trim()) {
92 toast.error("Template is required");
93 return;
94 }
95
96 // Check for duplicate name only if name changed
97 if (editingCmd.name !== editingCmd.originalName && commands.some(c => c.name === editingCmd.name.trim())) {
98 toast.error("Command already exists");
99 return;
100 }
101
102 try {
103 if (editingCmd.name !== editingCmd.originalName) {
104 await deleteCommand(editingCmd.originalName);
105 }
106 await saveCommand(editingCmd.name.trim(), editingCmd.template);
107 toast.success(`Command "${editingCmd.name}" updated`);
108 setEditOpen(false);
109 setEditingCmd(null);
110 fetchCommands();
111 } catch {
112 toast.error("Failed to update command");
113 }
114 };
115
116
117 const handleDelete = async (name: string) => {

Callers

nothing calls this directly

Calls 3

deleteCommandFunction · 0.90
saveCommandFunction · 0.90
fetchCommandsFunction · 0.85

Tested by

no test coverage detected