intro message to TUI + service debugger
This commit is contained in:
parent
998d1db4fe
commit
70fdf60f99
5 changed files with 233 additions and 18 deletions
90
src/ui/IntroMessage.tsx
Normal file
90
src/ui/IntroMessage.tsx
Normal file
|
|
@ -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<IntroMessageProps> = ({ 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 (
|
||||
<Box flexDirection="column" paddingX={1} paddingY={1}>
|
||||
{/* Agent name */}
|
||||
<Text bold color="yellow">
|
||||
Agent: {config.name}
|
||||
</Text>
|
||||
|
||||
{/* Model */}
|
||||
<Text color="blue">
|
||||
Model: <Text color="white">{model.name.split("/").pop()}</Text>
|
||||
</Text>
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Slash commands */}
|
||||
<Text color="blue">Slash commands:</Text>
|
||||
{allCommands.map((command, index) => (
|
||||
<Text key={index}>
|
||||
- <Text color="white">/{command.name}</Text>: <Text color="gray">{command.description}</Text>
|
||||
</Text>
|
||||
))}
|
||||
|
||||
{/* MCP prompts */}
|
||||
{mcpPrompts.map((prompt, index) => (
|
||||
<Text key={`mcp-${index}`}>
|
||||
- <Text color="white">/{prompt.name}</Text>: <Text color="gray">{prompt.description}</Text>
|
||||
</Text>
|
||||
))}
|
||||
|
||||
<Text> </Text>
|
||||
|
||||
{/* Rules */}
|
||||
{allRules.length > 0 && (
|
||||
<>
|
||||
<Text color="blue">Rules:</Text>
|
||||
{allRules.map((rule, index) => (
|
||||
<Text key={index}>
|
||||
- <Text color="white">{rule}</Text>
|
||||
</Text>
|
||||
))}
|
||||
<Text> </Text>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* MCP Servers */}
|
||||
{config.mcpServers?.length && (
|
||||
<>
|
||||
<Text color="blue">MCP Servers:</Text>
|
||||
{config.mcpServers.map((server: any, index: number) => (
|
||||
<Text key={index}>
|
||||
- <Text color="white">{server?.name}</Text>
|
||||
</Text>
|
||||
))}
|
||||
<Text> </Text>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default IntroMessage;
|
||||
114
src/ui/ServiceDebugger.tsx
Normal file
114
src/ui/ServiceDebugger.tsx
Normal file
|
|
@ -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<ServiceDebuggerProps> = ({
|
||||
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 (
|
||||
<Box flexDirection="column" paddingX={1} paddingY={1} borderStyle="round" borderColor="cyan">
|
||||
<Text bold color="cyan">🔧 Service Debug Info</Text>
|
||||
<Text> </Text>
|
||||
|
||||
<Text color="yellow">Overall Status:</Text>
|
||||
<Text>Loading: {loading ? "🟡 Yes" : "✅ No"}</Text>
|
||||
<Text>All Ready: {allReady ? "✅ Yes" : "❌ No"}</Text>
|
||||
<Text>Services Loading: {servicesLoading ? "🟡 Yes" : "✅ No"}</Text>
|
||||
|
||||
{error && (
|
||||
<Text color="red">Error: {String(error)}</Text>
|
||||
)}
|
||||
|
||||
{servicesError && (
|
||||
<Text color="red">Services Error: {String(servicesError)}</Text>
|
||||
)}
|
||||
|
||||
<Text> </Text>
|
||||
<Text color="yellow">Individual Services:</Text>
|
||||
|
||||
{["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 (
|
||||
<Box key={serviceName} flexDirection="column" marginLeft={2}>
|
||||
<Text>
|
||||
<Text color="white">{serviceName}:</Text> {status}
|
||||
</Text>
|
||||
{details && (
|
||||
<Box marginLeft={2}>
|
||||
<Text color="gray">
|
||||
{details}
|
||||
</Text>
|
||||
</Box>
|
||||
)}
|
||||
</Box>
|
||||
);
|
||||
})}
|
||||
|
||||
<Text> </Text>
|
||||
<Text color="yellow">Intro Message Conditions:</Text>
|
||||
<Text>Services ready: {allReady ? "✅" : "❌"}</Text>
|
||||
<Text>Has config: {services.config?.config ? "✅" : "❌"}</Text>
|
||||
<Text>Has model: {services.model?.model ? "✅" : "❌"}</Text>
|
||||
<Text>Has MCP service: {services.mcp?.mcpService ? "✅" : "❌"}</Text>
|
||||
|
||||
<Text> </Text>
|
||||
<Text color="gray" italic>
|
||||
Comment out this component when debugging is complete
|
||||
</Text>
|
||||
</Box>
|
||||
);
|
||||
};
|
||||
|
||||
export default ServiceDebugger;
|
||||
|
|
@ -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<TUIChatProps> = ({
|
|||
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<TUIChatProps> = ({
|
|||
});
|
||||
}, []);
|
||||
|
||||
// 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<TUIChatProps> = ({
|
|||
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<TUIChatProps> = ({
|
|||
// 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<TUIChatProps> = ({
|
|||
<Box flexDirection="column" height="100%">
|
||||
{/* Chat history - takes up all available space above input */}
|
||||
<Box flexDirection="column" flexGrow={1} paddingX={1} overflow="hidden">
|
||||
{/* Debug component - comment out when not needed */}
|
||||
{!isRemoteMode && (
|
||||
<ServiceDebugger
|
||||
services={services}
|
||||
loading={servicesLoading}
|
||||
error={servicesError}
|
||||
allReady={allServicesReady}
|
||||
servicesLoading={servicesLoading}
|
||||
servicesError={servicesError}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Show intro message when ready */}
|
||||
{showIntroMessage && !isRemoteMode && services.config?.config && services.model?.model && services.mcp?.mcpService && (
|
||||
<IntroMessage
|
||||
config={services.config.config}
|
||||
model={services.model.model}
|
||||
mcpService={services.mcp.mcpService}
|
||||
/>
|
||||
)}
|
||||
{messages.map(renderMessage)}
|
||||
</Box>
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue