MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / CliSettings

Function CliSettings

packages/app-core/src/components/SettingsModal.tsx:4915–5131  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4913}
4914
4915function CliSettings(): JSX.Element {
4916 const [status, setStatus] = useState<CliInstallStatus | null>(null)
4917 const [busy, setBusy] = useState(false)
4918 const [error, setError] = useState<string | null>(null)
4919
4920 const refresh = useCallback(async (): Promise<void> => {
4921 try {
4922 const next = await window.zen.cliGetStatus()
4923 setStatus(next)
4924 setError(null)
4925 } catch (err) {
4926 setError((err as Error).message)
4927 }
4928 }, [])
4929
4930 useEffect(() => {
4931 void refresh()
4932 }, [refresh])
4933
4934 const onInstall = async (): Promise<void> => {
4935 setBusy(true)
4936 setError(null)
4937 try {
4938 await window.zen.cliInstall()
4939 await refresh()
4940 } catch (err) {
4941 setError((err as Error).message)
4942 } finally {
4943 setBusy(false)
4944 }
4945 }
4946
4947 const onUninstall = async (): Promise<void> => {
4948 setBusy(true)
4949 setError(null)
4950 try {
4951 await window.zen.cliUninstall()
4952 await refresh()
4953 } catch (err) {
4954 setError((err as Error).message)
4955 } finally {
4956 setBusy(false)
4957 }
4958 }
4959
4960 const copyToClipboard = (text: string): void => {
4961 window.zen.clipboardWriteText(text)
4962 }
4963
4964 if (status == null) {
4965 return (
4966 <div className="space-y-6">
4967 <Section
4968 title="Command-Line Tool"
4969 description="Install the `zn` shell command for terminal-based note workflows."
4970 settingId="zen-command-line-tool"
4971 >
4972 <InlineNote>Checking install status…</InlineNote>

Callers

nothing calls this directly

Calls 6

statusChipClassFunction · 0.85
copyToClipboardFunction · 0.85
onUninstallFunction · 0.85
onInstallFunction · 0.85
cliGetStatusMethod · 0.80
refreshFunction · 0.70

Tested by

no test coverage detected