Elffuss BraidHub

kikocis/continue public

8a6602dc5d0c · 1.6 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];
13
14interface TipsDisplayProps {
15 // No props needed - component handles its own randomization
16}
17
18/**
19 * Randomly selects and displays a tip from the CONTINUE_CLI_TIPS array.
20 * Should only be shown 1 in 5 times (20% chance).
21 */
22const TipsDisplay: React.FC<TipsDisplayProps> = () => {
23 // Randomly select a tip, memoized to prevent changing on re-renders
24 const randomTip = useMemo(
25 () =>
26 CONTINUE_CLI_TIPS[Math.floor(Math.random() * CONTINUE_CLI_TIPS.length)],
27 [],
28 );
29
30 return (
31 <Box flexDirection="row" paddingX={1} paddingBottom={1}>
32 <Text color="green" bold>
33 * Tip:
34 </Text>
35 <Text color="gray" italic>
36 {" "}
37 {randomTip}
38 </Text>
39 <Text> </Text>
40 </Box>
41 );
42};
43
44/**
45 * Determines whether to show a tip (1 in 5 chance, 20% probability)
46 */
47export function shouldShowTip(): boolean {
48 return Math.random() < 0.2; // 20% chance (1 in 5)
49}
50
51export { CONTINUE_CLI_TIPS, TipsDisplay };