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

Function handleAdd

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

Source from the content-addressed store, hash-verified

55 }, []);
56
57 const handleAdd = async () => {
58 if (!newName.trim()) {
59 toast.error("Command name is required");
60 return;
61 }
62 if (!newTemplate.trim()) {
63 toast.error("Template is required");
64 return;
65 }
66 if (commands.some(c => c.name === newName.trim())) {
67 toast.error("Command already exists");
68 return;
69 }
70
71 try {
72 await saveCommand(newName.trim(), newTemplate);
73 toast.success(`Command "${newName}" created`);
74 setNewName("");
75 setNewTemplate("");
76 setAddOpen(false);
77 fetchCommands();
78 } catch {
79 toast.error("Failed to create command");
80 }
81 };
82
83
84

Callers

nothing calls this directly

Calls 2

saveCommandFunction · 0.90
fetchCommandsFunction · 0.85

Tested by

no test coverage detected