diff --git a/src/components/settings/panels/TauriCommandsPanel.tsx b/src/components/settings/panels/TauriCommandsPanel.tsx index 48cc4a7a7..a5abc02e0 100644 --- a/src/components/settings/panels/TauriCommandsPanel.tsx +++ b/src/components/settings/panels/TauriCommandsPanel.tsx @@ -1,13 +1,13 @@ -import { useMemo, useState } from 'react'; import { + ChatBubbleLeftRightIcon, CogIcon, CpuChipIcon, - ShieldCheckIcon, - ServerIcon, - WrenchScrewdriverIcon, - ChatBubbleLeftRightIcon, DocumentTextIcon, + ServerIcon, + ShieldCheckIcon, + WrenchScrewdriverIcon, } from '@heroicons/react/24/outline'; +import { useMemo, useState } from 'react'; import SettingsHeader from '../components/SettingsHeader'; import { useSettingsNavigation } from '../hooks/useSettingsNavigation'; @@ -22,30 +22,35 @@ import { alphahumanDecryptSecret, alphahumanDoctorModels, alphahumanDoctorReport, - alphahumanGetIntegrationInfo, + alphahumanEncryptSecret, alphahumanGetConfig, + alphahumanGetIntegrationInfo, alphahumanHardwareDiscover, alphahumanHardwareIntrospect, alphahumanListIntegrations, alphahumanMigrateOpenclaw, alphahumanModelsRefresh, + alphahumanServiceInstall, + alphahumanServiceStatus, + alphahumanServiceUninstall, alphahumanUpdateGatewaySettings, alphahumanUpdateMemorySettings, alphahumanUpdateModelSettings, alphahumanUpdateRuntimeSettings, alphahumanUpdateTunnelSettings, - alphahumanServiceInstall, - alphahumanServiceStatus, - alphahumanServiceUninstall, - alphahumanEncryptSecret, isTauri, - TunnelConfig, runtimeDisableSkill, runtimeEnableSkill, runtimeIsSkillEnabled, runtimeListSkills, SkillSnapshot, + TunnelConfig, } from '../../../utils/tauriCommands'; +import SettingsHeader from '../components/SettingsHeader'; +import { useSettingsNavigation } from '../hooks/useSettingsNavigation'; +import ActionPanel, { PrimaryButton } from './components/ActionPanel'; +import InputGroup, { CheckboxField, Field } from './components/InputGroup'; +import SectionCard from './components/SectionCard'; const formatJson = (value: unknown) => JSON.stringify(value, null, 2); @@ -55,7 +60,14 @@ const TauriCommandsPanel = () => { // View mode removed - always show all sections const [expandedSections] = useState>( - new Set(['system-configuration', 'runtime-execution', 'security-data', 'network-infrastructure', 'development-operations', 'interactive-tools']) + new Set([ + 'system-configuration', + 'runtime-execution', + 'security-data', + 'network-infrastructure', + 'development-operations', + 'interactive-tools', + ]) ); // Output and error states @@ -90,9 +102,7 @@ const TauriCommandsPanel = () => { const [embeddingDims, setEmbeddingDims] = useState('1536'); const [runtimeKind, setRuntimeKind] = useState('native'); const [reasoningEnabled, setReasoningEnabled] = useState(false); - const [skills, setSkills] = useState< - Array<{ snapshot: SkillSnapshot; enabled: boolean }> - >([]); + const [skills, setSkills] = useState>([]); const [skillsLoading, setSkillsLoading] = useState(false); const [chatInput, setChatInput] = useState(''); const [chatProvider, setChatProvider] = useState(''); @@ -275,7 +285,10 @@ const TauriCommandsPanel = () => { } }; - const runWithResult = async (fn: () => Promise, operationName?: string): Promise => { + const runWithResult = async ( + fn: () => Promise, + operationName?: string + ): Promise => { setError(''); if (operationName) setOperationLoading(operationName); try { @@ -331,7 +344,9 @@ const TauriCommandsPanel = () => { setTunnelProvider((tunnel.provider as string) ?? 'none'); setCloudflareToken(((tunnel.cloudflare as Record)?.token as string) ?? ''); setNgrokToken(((tunnel.ngrok as Record)?.auth_token as string) ?? ''); - setTailscaleHostname(((tunnel.tailscale as Record)?.hostname as string) ?? ''); + setTailscaleHostname( + ((tunnel.tailscale as Record)?.hostname as string) ?? '' + ); setCustomCommand(((tunnel.custom as Record)?.start_command as string) ?? ''); const gateway = (config.gateway as Record) ?? {}; @@ -361,28 +376,16 @@ const TauriCommandsPanel = () => { const buildTunnelConfig = (): TunnelConfig => { if (tunnelProvider === 'cloudflare') { - return { - provider: 'cloudflare', - cloudflare: { token: cloudflareToken }, - }; + return { provider: 'cloudflare', cloudflare: { token: cloudflareToken } }; } if (tunnelProvider === 'ngrok') { - return { - provider: 'ngrok', - ngrok: { auth_token: ngrokToken }, - }; + return { provider: 'ngrok', ngrok: { auth_token: ngrokToken } }; } if (tunnelProvider === 'tailscale') { - return { - provider: 'tailscale', - tailscale: { hostname: tailscaleHostname || null }, - }; + return { provider: 'tailscale', tailscale: { hostname: tailscaleHostname || null } }; } if (tunnelProvider === 'custom') { - return { - provider: 'custom', - custom: { start_command: customCommand }, - }; + return { provider: 'custom', custom: { start_command: customCommand } }; } return { provider: 'none' }; }; @@ -504,37 +507,41 @@ const TauriCommandsPanel = () => { } }; - const saveTunnelSettings = () => run(() => alphahumanUpdateTunnelSettings(buildTunnelConfig()), 'saveTunnelSettings'); + const saveTunnelSettings = () => + run(() => alphahumanUpdateTunnelSettings(buildTunnelConfig()), 'saveTunnelSettings'); const saveGatewaySettings = () => - run(() => - alphahumanUpdateGatewaySettings({ - host: gatewayHost.trim() ? gatewayHost : null, - port: parseOptionalNumber(gatewayPort), - require_pairing: gatewayPairing, - allow_public_bind: gatewayPublic, - }), + run( + () => + alphahumanUpdateGatewaySettings({ + host: gatewayHost.trim() ? gatewayHost : null, + port: parseOptionalNumber(gatewayPort), + require_pairing: gatewayPairing, + allow_public_bind: gatewayPublic, + }), 'saveGatewaySettings' ); const saveMemorySettings = () => - run(() => - alphahumanUpdateMemorySettings({ - backend: memoryBackend.trim() ? memoryBackend : null, - auto_save: memoryAutoSave, - embedding_provider: embeddingProvider.trim() ? embeddingProvider : null, - embedding_model: embeddingModel.trim() ? embeddingModel : null, - embedding_dimensions: parseOptionalNumber(embeddingDims), - }), + run( + () => + alphahumanUpdateMemorySettings({ + backend: memoryBackend.trim() ? memoryBackend : null, + auto_save: memoryAutoSave, + embedding_provider: embeddingProvider.trim() ? embeddingProvider : null, + embedding_model: embeddingModel.trim() ? embeddingModel : null, + embedding_dimensions: parseOptionalNumber(embeddingDims), + }), 'saveMemorySettings' ); const saveRuntimeSettings = () => - run(() => - alphahumanUpdateRuntimeSettings({ - kind: runtimeKind.trim() ? runtimeKind : null, - reasoning_enabled: reasoningEnabled, - }), + run( + () => + alphahumanUpdateRuntimeSettings({ + kind: runtimeKind.trim() ? runtimeKind : null, + reasoning_enabled: reasoningEnabled, + }), 'saveRuntimeSettings' ); @@ -543,7 +550,7 @@ const TauriCommandsPanel = () => { try { const snapshots = await runtimeListSkills(); const enriched = await Promise.all( - snapshots.map(async (snapshot) => ({ + snapshots.map(async snapshot => ({ snapshot, enabled: await runtimeIsSkillEnabled(snapshot.skill_id), })) @@ -564,11 +571,9 @@ const TauriCommandsPanel = () => { } else { await run(() => runtimeDisableSkill(skillId), 'disableSkill'); } - setSkills((prev) => - prev.map((item) => - item.snapshot.skill_id === skillId - ? { ...item, enabled: nextEnabled } - : item + setSkills(prev => + prev.map(item => + item.snapshot.skill_id === skillId ? { ...item, enabled: nextEnabled } : item ) ); }; @@ -578,19 +583,20 @@ const TauriCommandsPanel = () => { return; } const userMessage = chatInput.trim(); - setChatLog((prev) => [...prev, { role: 'user', text: userMessage }]); + setChatLog(prev => [...prev, { role: 'user', text: userMessage }]); setChatInput(''); - const response = await runWithResult(() => - alphahumanAgentChat( - userMessage, - chatProvider.trim() ? chatProvider : undefined, - chatModel.trim() ? chatModel : undefined, - parseOptionalNumber(chatTemperature) ?? undefined - ), + const response = await runWithResult( + () => + alphahumanAgentChat( + userMessage, + chatProvider.trim() ? chatProvider : undefined, + chatModel.trim() ? chatModel : undefined, + parseOptionalNumber(chatTemperature) ?? undefined + ), 'sendChat' ); if (response) { - setChatLog((prev) => [...prev, { role: 'agent', text: response.result }]); + setChatLog(prev => [...prev, { role: 'agent', text: response.result }]); } }; @@ -616,11 +622,7 @@ const TauriCommandsPanel = () => { return (
- +
{!tauriAvailable && ( @@ -807,75 +809,64 @@ const TauriCommandsPanel = () => { collapsible={true} defaultExpanded={!isCollapsed('runtime-execution')} hasChanges={false} - loading={operationLoading === 'saveRuntimeSettings' || skillsLoading} - > - - - setRuntimeKind(event.target.value)} + loading={operationLoading === 'saveRuntimeSettings' || skillsLoading}> + + + setRuntimeKind(event.target.value)} + /> + + - - - + - - - Save Runtime Settings - - - {skillsLoading ? 'Loading Skills…' : 'Load Skills'} - - + + + Save Runtime Settings + + + {skillsLoading ? 'Loading Skills…' : 'Load Skills'} + + - {skills.length > 0 && ( -
-
Skills
-
- {skills.map((item) => ( -
-
-
{item.snapshot.name}
-
- {item.snapshot.skill_id} + {skills.length > 0 && ( +
+
Skills
+
+ {skills.map(item => ( +
+
+
{item.snapshot.name}
+
+ {item.snapshot.skill_id} +
+ toggleSkill(item.snapshot.skill_id, checked)} + className="text-xs ml-4 flex-shrink-0" + />
- - toggleSkill(item.snapshot.skill_id, checked) - } - className="text-xs ml-4 flex-shrink-0" - /> -
- ))} + ))} +
-
- )} + )}
@@ -1006,117 +997,121 @@ const TauriCommandsPanel = () => { collapsible={true} defaultExpanded={!isCollapsed('security-data')} hasChanges={false} - loading={operationLoading?.includes('Secret') || operationLoading?.includes('Models') || operationLoading?.includes('Integration')} - > -
- - -