({
config,
model,
mcpService,
organizationName,
})
| 24 | }; |
| 25 | |
| 26 | const IntroMessage: React.FC<IntroMessageProps> = ({ |
| 27 | config, |
| 28 | model, |
| 29 | mcpService, |
| 30 | organizationName, |
| 31 | }) => { |
| 32 | // Get MCP prompts directly (not memoized since they can change after first render) |
| 33 | const mcpPrompts = mcpService?.getState().prompts ?? []; |
| 34 | |
| 35 | // Determine if we should show a tip (1 in 5 chance) - computed once on mount |
| 36 | const showTip = useMemo(() => shouldShowTip(), []); |
| 37 | |
| 38 | // Memoize expensive operations to avoid running on every resize |
| 39 | const { allRules, modelCapable } = useMemo(() => { |
| 40 | const allRules = extractRuleNames(config?.rules); |
| 41 | |
| 42 | // Check if model is capable - now checking both name and model properties |
| 43 | const modelCapable = model |
| 44 | ? isModelCapable(model.provider, model.name, model.model) |
| 45 | : true; // Default to true if model not loaded yet |
| 46 | |
| 47 | return { allRules, modelCapable }; |
| 48 | }, [config?.rules, model?.provider, model?.name, model?.model]); |
| 49 | |
| 50 | // Render helper components |
| 51 | const renderMcpPrompts = () => |
| 52 | mcpPrompts.length > 0 ? ( |
| 53 | <> |
| 54 | {mcpPrompts.map((prompt, index) => ( |
| 55 | <Text key={`mcp-${index}`}> |
| 56 | - <Text color="white">/{prompt.name}</Text>:{" "} |
| 57 | <Text color="dim">{prompt.description}</Text> |
| 58 | </Text> |
| 59 | ))} |
| 60 | <Text> </Text> |
| 61 | </> |
| 62 | ) : null; |
| 63 | |
| 64 | const renderRules = () => |
| 65 | allRules.length > 0 ? ( |
| 66 | <> |
| 67 | <Text bold color="blue"> |
| 68 | Rules: |
| 69 | </Text> |
| 70 | {allRules.map((rule, index) => ( |
| 71 | <Text key={index}> |
| 72 | - <Text color="white">{rule}</Text> |
| 73 | </Text> |
| 74 | ))} |
| 75 | <Text> </Text> |
| 76 | </> |
| 77 | ) : null; |
| 78 | |
| 79 | const renderMcpServers = () => |
| 80 | (config?.mcpServers?.length ?? 0) > 0 ? ( |
| 81 | <> |
| 82 | <Text bold color="blue"> |
| 83 | MCP Servers: |
nothing calls this directly
no test coverage detected