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

Function SettingsPage

client-next/src/app/settings/page.tsx:52–599  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50] as const;
51
52export default function SettingsPage() {
53 const { config, loading, saveConfig, refreshData } = useApp();
54 const [pathsInfoBox, setPathsInfo] = useState<PathsInfo | null>(null);
55 const [manualPath, setManualPath] = useState("");
56 const fileInputRef = useRef<HTMLInputElement>(null);
57 const [openSections, setOpenSections] = useState<Record<string, boolean>>({
58 general: true,
59 permissions: false,
60 prompts: false,
61 backup: false,
62 sincronizado: false,
63 });
64
65const [systemPrompt, setSystemPrompt] = useState("");
66 const [loadingPrompt, setLoadingPrompt] = useState(false);
67 const [savingPrompt, setSavingPrompt] = useState(false);
68 const { theme } = useTheme();
69
70 const [ghBackupStatus, setGhBackupStatus] = useState<GitHubBackupStatus | null>(null);
71 const [ghOwner, setGhOwner] = useState("");
72 const [ghRepo, setGhRepo] = useState("opencode-backup");
73 const [ghBranch, setGhBranch] = useState("main");
74 const [backingUp, setBackingUp] = useState(false);
75 const [restoring, setRestoring] = useState(false);
76
77
78 const toggleSection = (section: string) => {
79 setOpenSections(prev => ({ ...prev, [section]: !prev[section] }));
80 };
81
82 useEffect(() => {
83 getPaths().then(setPathsInfo).catch(console.error);
84 loadSystemPrompt();
85
86 getGitHubBackupStatus().then(status => {
87 setGhBackupStatus(status);
88 if (status.config) {
89 if (status.config.owner) setGhOwner(status.config.owner);
90 if (status.config.repo) setGhRepo(status.config.repo);
91 if (status.config.branch) setGhBranch(status.config.branch);
92 }
93 if (status.user && !status.config?.owner) setGhOwner(status.user);
94 }).catch(console.error);
95 }, []);
96
97 const loadSystemPrompt = async () => {
98 try {
99 setLoadingPrompt(true);
100 const res = await api.get('/prompts/global');
101 setSystemPrompt(res.data.content);
102 } catch (error) {
103 console.error("Error loading prompt:", error);
104 } finally {
105 setLoadingPrompt(false);
106 }
107 };
108
109 const handleSaveSystemPrompt = async () => {

Callers

nothing calls this directly

Calls 6

useAppFunction · 0.90
getPathsFunction · 0.90
getGitHubBackupStatusFunction · 0.90
loadSystemPromptFunction · 0.85
updateConfigFunction · 0.85
toggleSectionFunction · 0.70

Tested by

no test coverage detected