diff --git a/src/ui/IntroMessage.tsx b/src/ui/IntroMessage.tsx new file mode 100644 index 000000000..cc37294bb --- /dev/null +++ b/src/ui/IntroMessage.tsx @@ -0,0 +1,90 @@ +import { AssistantUnrolled, ModelConfig } from "@continuedev/config-yaml"; +import { Box, Text } from "ink"; +import React from "react"; +import { parseArgs } from "../args.js"; +import { getAllSlashCommands } from "../commands/commands.js"; +import { MCPService } from "../mcp.js"; + +interface IntroMessageProps { + config: AssistantUnrolled; + model: ModelConfig; + mcpService: MCPService; +} + +const IntroMessage: React.FC = ({ config, model, mcpService }) => { + const mcpTools = mcpService.getTools() ?? []; + const mcpPrompts = mcpService.getPrompts() ?? []; + + // Get all slash commands from central definition + const allCommands = getAllSlashCommands(config); + + // Show all rules in a single section + const args = parseArgs(); + const commandLineRules = args.rules || []; + const configRules = config.rules?.map((rule: any) => + typeof rule === "string" ? rule : rule?.name || "Unknown" + ) || []; + + const allRules = [...commandLineRules, ...configRules]; + + return ( + + {/* Agent name */} + + Agent: {config.name} + + + {/* Model */} + + Model: {model.name.split("/").pop()} + + + + + {/* Slash commands */} + Slash commands: + {allCommands.map((command, index) => ( + + - /{command.name}: {command.description} + + ))} + + {/* MCP prompts */} + {mcpPrompts.map((prompt, index) => ( + + - /{prompt.name}: {prompt.description} + + ))} + + + + {/* Rules */} + {allRules.length > 0 && ( + <> + Rules: + {allRules.map((rule, index) => ( + + - {rule} + + ))} + + + )} + + {/* MCP Servers */} + {config.mcpServers?.length && ( + <> + MCP Servers: + {config.mcpServers.map((server: any, index: number) => ( + + - {server?.name} + + ))} + + + )} + + ); +}; + +export default IntroMessage; \ No newline at end of file diff --git a/src/ui/ServiceDebugger.tsx b/src/ui/ServiceDebugger.tsx new file mode 100644 index 000000000..d075a4e50 --- /dev/null +++ b/src/ui/ServiceDebugger.tsx @@ -0,0 +1,114 @@ +import { Box, Text } from "ink"; +import React from "react"; +import { + ApiClientServiceState, + AuthServiceState, + ConfigServiceState, + MCPServiceState, + ModelServiceState, +} from "../services/types.js"; + +interface ServiceDebuggerProps { + services: { + auth?: AuthServiceState; + config?: ConfigServiceState; + model?: ModelServiceState; + mcp?: MCPServiceState; + apiClient?: ApiClientServiceState; + }; + loading: boolean; + error: any; + allReady: boolean; + servicesLoading: boolean; + servicesError: any; +} + +const ServiceDebugger: React.FC = ({ + services, + loading, + error, + allReady, + servicesLoading, + servicesError, +}) => { + const getServiceStatus = (serviceName: string, service: any) => { + if (!service) return "❌ Not loaded"; + if (service.error) return `❌ Error: ${service.error}`; + return "✅ Ready"; + }; + + const getServiceDetails = (serviceName: string, service: any) => { + switch (serviceName) { + case "auth": + return service?.authConfig ? `User: ${service.authConfig.email || 'unknown'}` : "No auth config"; + case "config": + return service?.config ? `Agent: ${service.config.name}` : "No config"; + case "model": + return service?.model ? `Model: ${service.model.name}` : "No model"; + case "mcp": + return service?.mcpService ? `Tools: ${service.mcpService.getTools()?.length || 0}` : "No MCP service"; + case "apiClient": + return service?.apiClient ? "API client ready" : "No API client"; + default: + return ""; + } + }; + + return ( + + 🔧 Service Debug Info + + + Overall Status: + Loading: {loading ? "🟡 Yes" : "✅ No"} + All Ready: {allReady ? "✅ Yes" : "❌ No"} + Services Loading: {servicesLoading ? "🟡 Yes" : "✅ No"} + + {error && ( + Error: {String(error)} + )} + + {servicesError && ( + Services Error: {String(servicesError)} + )} + + + Individual Services: + + {["auth", "config", "model", "mcp", "apiClient"].map((serviceName) => { + const service = services[serviceName as keyof typeof services]; + const status = getServiceStatus(serviceName, service); + const details = getServiceDetails(serviceName, service); + + return ( + + + {serviceName}: {status} + + {details && ( + + + {details} + + + )} + + ); + })} + + + Intro Message Conditions: + Services ready: {allReady ? "✅" : "❌"} + Has config: {services.config?.config ? "✅" : "❌"} + Has model: {services.model?.model ? "✅" : "❌"} + Has MCP service: {services.mcp?.mcpService ? "✅" : "❌"} + + + + Comment out this component when debugging is complete + + + ); +}; + +export default ServiceDebugger; \ No newline at end of file diff --git a/src/ui/TUIChat.tsx b/src/ui/TUIChat.tsx index 0f5af68f5..67b6af469 100644 --- a/src/ui/TUIChat.tsx +++ b/src/ui/TUIChat.tsx @@ -1,6 +1,5 @@ import { Box, Text } from "ink"; import React, { useEffect, useState } from "react"; -import { introMessage } from "../intro.js"; import { useServices } from "../hooks/useService.js"; import { ApiClientServiceState, @@ -13,6 +12,8 @@ import ConfigSelector from "./ConfigSelector.js"; import { startFileIndexing } from "./FileSearchUI.js"; import FreeTrialStatus from "./FreeTrialStatus.js"; import FreeTrialTransitionUI from "./FreeTrialTransitionUI.js"; +import IntroMessage from "./IntroMessage.js"; +import ServiceDebugger from "./ServiceDebugger.js"; import { useChat } from "./hooks/useChat.js"; import { useConfigSelector } from "./hooks/useConfigSelector.js"; import { useMessageRenderer } from "./hooks/useMessageRenderer.js"; @@ -69,6 +70,9 @@ const TUIChat: React.FC = ({ const [isShowingFreeTrialTransition, setIsShowingFreeTrialTransition] = useState(false); + // State for intro message display + const [showIntroMessage, setShowIntroMessage] = useState(false); + // Start file indexing as soon as the component mounts useEffect(() => { // Start indexing files in the background immediately @@ -77,7 +81,7 @@ const TUIChat: React.FC = ({ }); }, []); - // Display intro message when services are ready (only in non-remote mode) + // Show intro message when services are ready (only in non-remote mode) useEffect(() => { if ( !isRemoteMode && @@ -86,13 +90,7 @@ const TUIChat: React.FC = ({ services.model?.model && services.mcp?.mcpService ) { - introMessage( - services.config.config, - services.model.model, - services.mcp.mcpService - ).catch((error) => { - console.error("Failed to display intro message:", error); - }); + setShowIntroMessage(true); } }, [isRemoteMode, allServicesReady, services.config?.config, services.model?.model, services.mcp?.mcpService]); @@ -115,8 +113,9 @@ const TUIChat: React.FC = ({ // Service reload handlers - these will trigger reactive updates const handleReload = async () => { // Services will automatically update the UI when they reload - // We just need to reset chat history and clear the screen + // We just need to reset chat history, intro message, and clear the screen resetChatHistory(); + setShowIntroMessage(false); process.stdout.write("\x1b[2J\x1b[H"); }; @@ -204,6 +203,26 @@ const TUIChat: React.FC = ({ {/* Chat history - takes up all available space above input */} + {/* Debug component - comment out when not needed */} + {!isRemoteMode && ( + + )} + + {/* Show intro message when ready */} + {showIntroMessage && !isRemoteMode && services.config?.config && services.model?.model && services.mcp?.mcpService && ( + + )} {messages.map(renderMessage)} diff --git a/src/ui/hooks/useConfigSelector.ts b/src/ui/hooks/useConfigSelector.ts index dc8108872..70a706985 100644 --- a/src/ui/hooks/useConfigSelector.ts +++ b/src/ui/hooks/useConfigSelector.ts @@ -6,7 +6,6 @@ import * as path from "path"; import { useState } from "react"; import { loadAuthConfig, updateAssistantSlug } from "../../auth/workos.js"; import { initialize } from "../../config.js"; -import { introMessage } from "../../intro.js"; import { MCPService } from "../../mcp.js"; interface ConfigOption { @@ -120,9 +119,6 @@ export function useConfigSelector({ // Clear the screen completely process.stdout.write("\x1b[2J\x1b[H"); - // Show the new intro message - introMessage(newConfig, newModel, newMcpService); - // Show success message onMessage({ role: "system", diff --git a/src/ui/hooks/useOrganizationSelector.ts b/src/ui/hooks/useOrganizationSelector.ts index a767faa1f..6c8742048 100644 --- a/src/ui/hooks/useOrganizationSelector.ts +++ b/src/ui/hooks/useOrganizationSelector.ts @@ -7,7 +7,6 @@ import { saveAuthConfig, } from "../../auth/workos.js"; import { initialize } from "../../config.js"; -import { introMessage } from "../../intro.js"; import { MCPService } from "../../mcp.js"; interface UseOrganizationSelectorProps { @@ -85,9 +84,6 @@ export function useOrganizationSelector({ // Clear the screen completely process.stdout.write("\x1b[2J\x1b[H"); - // Show the new intro message - introMessage(config, newModel, newMcpService); - // Show success message onMessage({ role: "system",