import { useCallback, useState } from "react"; import { Text, View } from "react-native"; import { useFocusEffect } from "@react-navigation/native"; import { StyleSheet, useUnistyles } from "react-native-unistyles"; import { ArrowUpRight, Terminal, Blocks, Check } from "lucide-react-native"; import { settingsStyles } from "@/styles/settings"; import { SettingsSection } from "@/screens/settings/settings-section"; import { Button } from "@/components/ui/button"; import { openExternalUrl } from "@/utils/open-external-url"; import { shouldUseDesktopDaemon, getCliInstallStatus, installCli, getSkillsInstallStatus, installSkills, type InstallStatus, } from "@/desktop/daemon/desktop-daemon"; const CLI_DOCS_URL = "https://paseo.sh/docs/cli"; const SKILLS_DOCS_URL = "https://paseo.sh/docs/skills"; export function IntegrationsSection() { const { theme } = useUnistyles(); const showSection = shouldUseDesktopDaemon(); const [cliStatus, setCliStatus] = useState(null); const [skillsStatus, setSkillsStatus] = useState(null); const [isInstallingCli, setIsInstallingCli] = useState(false); const [isInstallingSkills, setIsInstallingSkills] = useState(false); const loadStatus = useCallback(() => { if (!showSection) return; void getCliInstallStatus() .then(setCliStatus) .catch((error) => { console.error("[Integrations] Failed to load CLI status", error); }); void getSkillsInstallStatus() .then(setSkillsStatus) .catch((error) => { console.error("[Integrations] Failed to load skills status", error); }); }, [showSection]); useFocusEffect( useCallback(() => { if (!showSection) return undefined; loadStatus(); return undefined; }, [loadStatus, showSection]), ); const handleInstallCli = useCallback(() => { if (isInstallingCli) return; setIsInstallingCli(true); void installCli() .then(setCliStatus) .catch((error) => { console.error("[Integrations] Failed to install CLI", error); }) .finally(() => { setIsInstallingCli(false); }); }, [isInstallingCli]); const handleInstallSkills = useCallback(() => { if (isInstallingSkills) return; setIsInstallingSkills(true); void installSkills() .then(setSkillsStatus) .catch((error) => { console.error("[Integrations] Failed to install skills", error); }) .finally(() => { setIsInstallingSkills(false); }); }, [isInstallingSkills]); if (!showSection) { return null; } const trailing = ( ); return ( Command line Control and script agents from your terminal. {cliStatus?.installed ? ( Installed ) : ( )} Orchestration skills Teach your agents to orchestrate through the CLI. {skillsStatus?.installed ? ( Installed ) : ( )} ); } const styles = StyleSheet.create((theme) => ({ headerLinks: { flexDirection: "row", alignItems: "center", gap: theme.spacing[0], }, rowTitleRow: { flexDirection: "row", alignItems: "center", gap: theme.spacing[2], }, installedLabel: { flexDirection: "row", alignItems: "center", gap: 4, }, mutedText: { color: theme.colors.foregroundMuted, fontSize: theme.fontSize.sm, }, }));