Elffuss BraidHub

kikocis/continue public

1ff75182e19e · 3.5 KiBRawPermalink
1import { Box, Text } from "ink";
2import React from "react";
3
4import {
5 ApiClientServiceState,
6 AuthServiceState,
7 ConfigServiceState,
8 MCPServiceState,
9 ModelServiceState,
10} from "../services/types.js";
11
12interface ServiceDebuggerProps {
13 services: {
14 auth?: AuthServiceState;
15 config?: ConfigServiceState;
16 model?: ModelServiceState;
17 mcp?: MCPServiceState;
18 apiClient?: ApiClientServiceState;
19 };
20 loading: boolean;
21 error: any;
22 allReady: boolean;
23 servicesLoading: boolean;
24 servicesError: any;
25}
26
27const ServiceDebugger: React.FC<ServiceDebuggerProps> = ({
28 services,
29 loading,
30 error,
31 allReady,
32 servicesLoading,
33 servicesError,
34}) => {
35 const getServiceStatus = (serviceName: string, service: any) => {
36 if (!service) return "❌ Not loaded";
37 if (service.error) return `❌ Error: ${service.error}`;
38 return "✅ Ready";
39 };
40
41 const getServiceDetails = (serviceName: string, service: any) => {
42 switch (serviceName) {
43 case "auth":
44 return service?.authConfig
45 ? `User: ${service.authConfig.email || "unknown"}`
46 : "No auth config";
47 case "config":
48 return service?.config ? `Agent: ${service.config.name}` : "No config";
49 case "model":
50 return service?.model ? `Model: ${service.model.name}` : "No model";
51 case "mcp":
52 return service?.mcpService
53 ? `Tools: ${service.mcpService.getTools()?.length || 0}`
54 : "No MCP service";
55 case "apiClient":
56 return service?.apiClient ? "API client ready" : "No API client";
57 default:
58 return "";
59 }
60 };
61
62 return (
63 <Box
64 flexDirection="column"
65 paddingX={1}
66 paddingY={1}
67 borderStyle="round"
68 borderColor="cyan"
69 >
70 <Text bold color="cyan">
71 🔧 Service Debug Info
72 </Text>
73 <Text> </Text>
74
75 <Text color="yellow">Overall Status:</Text>
76 <Text>Loading: {loading ? "🟡 Yes" : "✅ No"}</Text>
77 <Text>All Ready: {allReady ? "✅ Yes" : "❌ No"}</Text>
78 <Text>Services Loading: {servicesLoading ? "🟡 Yes" : "✅ No"}</Text>
79
80 {error && <Text color="red">Error: {String(error)}</Text>}
81
82 {servicesError && (
83 <Text color="red">Services Error: {String(servicesError)}</Text>
84 )}
85
86 <Text> </Text>
87 <Text color="yellow">Individual Services:</Text>
88
89 {["auth", "config", "model", "mcp", "apiClient"].map((serviceName) => {
90 const service = services[serviceName as keyof typeof services];
91 const status = getServiceStatus(serviceName, service);
92 const details = getServiceDetails(serviceName, service);
93
94 return (
95 <Box key={serviceName} flexDirection="column" marginLeft={2}>
96 <Text>
97 <Text color="white">{serviceName}:</Text> {status}
98 </Text>
99 {details && (
100 <Box marginLeft={2}>
101 <Text color="gray">{details}</Text>
102 </Box>
103 )}
104 </Box>
105 );
106 })}
107
108 <Text> </Text>
109 <Text color="yellow">Intro Message Conditions:</Text>
110 <Text>Services ready: {allReady ? "✅" : "❌"}</Text>
111 <Text>Has config: {services.config?.config ? "✅" : "❌"}</Text>
112 <Text>Has model: {services.model?.model ? "✅" : "❌"}</Text>
113 <Text>Has MCP service: {services.mcp?.mcpService ? "✅" : "❌"}</Text>
114
115 <Text> </Text>
116 <Text color="gray" italic>
117 Comment out this component when debugging is complete
118 </Text>
119 </Box>
120 );
121};
122
123export { ServiceDebugger };