Elffuss BraidHub

kikocis/continue public

main · 1.7 KiBRawPermalink
1import { Box, Text } from "ink";
2import React, { useMemo } from "react";
3
4// Array of helpful tips for Continue CLI users
5const CONTINUE_CLI_TIPS = [
6 "Use `/help` to learn keyboard shortcuts",
7 "Press escape to pause cn, and press enter to continue",
8 "Use arrow keys (↑/↓) to navigate through your input history",
9 'Multi-line input is supported by typing "\\" and pressing enter',
10 "Use `cn ls` or `/resume` to resume a previous conversation",
11 'Run `cn` with the `-p` flag for headless mode. For example: `cn -p "Generate a commit message for the current changes. Output _only_ the commit message and nothing else."`',
12 "Use the /init slash command to generate an AGENTS.md file. This will help `cn` understand your codebase and generate better responses.",
13];
14
15interface TipsDisplayProps {
16 // No props needed - component handles its own randomization
17}
18
19/**
20 * Randomly selects and displays a tip from the CONTINUE_CLI_TIPS array.
21 * Should only be shown 1 in 5 times (20% chance).
22 */
23const TipsDisplay: React.FC<TipsDisplayProps> = () => {
24 // Randomly select a tip, memoized to prevent changing on re-renders
25 const randomTip = useMemo(
26 () =>
27 CONTINUE_CLI_TIPS[Math.floor(Math.random() * CONTINUE_CLI_TIPS.length)],
28 [],
29 );
30
31 return (
32 <Box flexDirection="row" paddingX={1} paddingBottom={1}>
33 <Text color="green" bold>
34 * Tip:
35 </Text>
36 <Text color="dim" italic>
37 {" "}
38 {randomTip}
39 </Text>
40 <Text> </Text>
41 </Box>
42 );
43};
44
45/**
46 * Determines whether to show a tip (1 in 5 chance, 20% probability)
47 */
48export function shouldShowTip(): boolean {
49 return Math.random() < 0.2; // 20% chance (1 in 5)
50}
51
52export { CONTINUE_CLI_TIPS, TipsDisplay };