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

Function loadFile

client-next/src/app/editor/page.tsx:45–69  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43 }
44
45 const loadFile = async () => {
46 try {
47 setLoading(true);
48 if (type === "skills") {
49 const data = await getSkill(name);
50 setContent(data.content);
51 const match = data.content.match(/<description>([\s\S]*?)<\/description>/);
52 setDescription(data.description || (match ? match[1].trim() : ""));
53 setCurrentName(name);
54 } else if (type === "commands") {
55 const data = await getCommand(name);
56 setContent(data.template);
57 setCurrentName(name);
58 } else {
59 const data = await getPlugin(name);
60 setContent(data.content);
61 setCurrentName(name);
62 }
63 } catch {
64 toast.error("Failed to load file");
65 router.back();
66 } finally {
67 setLoading(false);
68 }
69 };
70
71 loadFile();
72 }, [type, name, isNew, router]);

Callers 1

EditorContentFunction · 0.85

Calls 3

getSkillFunction · 0.90
getCommandFunction · 0.90
getPluginFunction · 0.90

Tested by

no test coverage detected