diff --git a/ui/src/components/monitoring/proxy-status-widget.tsx b/ui/src/components/monitoring/proxy-status-widget.tsx index bfa0a2c3..6c4af3b0 100644 --- a/ui/src/components/monitoring/proxy-status-widget.tsx +++ b/ui/src/components/monitoring/proxy-status-widget.tsx @@ -3,11 +3,24 @@ * * Displays CLIProxy process status with start/stop/restart controls. * Shows: running state, port, session count, uptime, update availability. + * In remote mode: shows remote server info instead of local controls. */ -import { Activity, Power, RefreshCw, Clock, Users, Square, RotateCw, ArrowUp } from 'lucide-react'; +import { + Activity, + Power, + RefreshCw, + Clock, + Users, + Square, + RotateCw, + ArrowUp, + Globe, +} from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; +import { useQuery } from '@tanstack/react-query'; +import { api, type CliproxyServerConfig } from '@/lib/api-client'; import { useProxyStatus, useStartProxy, @@ -48,10 +61,32 @@ export function ProxyStatusWidget() { const startProxy = useStartProxy(); const stopProxy = useStopProxy(); + // Fetch cliproxy_server config for remote mode detection + const { data: cliproxyConfig } = useQuery({ + queryKey: ['cliproxy-server-config'], + queryFn: () => api.cliproxyServer.get(), + staleTime: 30000, // 30 seconds + }); + + // Determine if remote mode is enabled + const remoteConfig = cliproxyConfig?.remote; + const isRemoteMode = remoteConfig?.enabled && remoteConfig?.host; + const isRunning = status?.running ?? false; const isActioning = startProxy.isPending || stopProxy.isPending; const hasUpdate = updateCheck?.hasUpdate ?? false; + // Build remote display info + const remoteDisplayHost = isRemoteMode + ? (() => { + const protocol = remoteConfig.protocol || 'http'; + const port = remoteConfig.port || (protocol === 'https' ? 443 : 80); + const isDefaultPort = + (protocol === 'https' && port === 443) || (protocol === 'http' && port === 80); + return isDefaultPort ? remoteConfig.host : `${remoteConfig.host}:${port}`; + })() + : null; + // Restart = stop then start const handleRestart = async () => { await stopProxy.mutateAsync(); @@ -60,6 +95,43 @@ export function ProxyStatusWidget() { startProxy.mutate(); }; + // Remote mode: show remote server info + if (isRemoteMode) { + return ( +
+
+
+ + Remote Proxy + + Active + +
+ +
+ +
+
+ {remoteDisplayHost} +
+

+ Traffic auto-routed to remote server +

+
+
+ ); + } + + // Local mode: show original controls + return (