Conversation
| const TipsDisplay: React.FC<TipsDisplayProps> = () => { | ||
| // Randomly select a tip | ||
| const randomTip = | ||
| CONTINUE_CLI_TIPS[Math.floor(Math.random() * CONTINUE_CLI_TIPS.length)]; |
There was a problem hiding this comment.
Random tip is recalculated on every render, so the displayed tip can change on re-renders. Memoize the selection to keep it stable per mount.
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/TipsDisplay.tsx at line 25:
<comment>Random tip is recalculated on every render, so the displayed tip can change on re-renders. Memoize the selection to keep it stable per mount.</comment>
<file context>
@@ -0,0 +1,48 @@
+const TipsDisplay: React.FC<TipsDisplayProps> = () => {
+ // Randomly select a tip
+ const randomTip =
+ CONTINUE_CLI_TIPS[Math.floor(Math.random() * CONTINUE_CLI_TIPS.length)];
+
+ return (
</file context>
There was a problem hiding this comment.
I've started a remote session to help with your request:
@continuedev please fix
| })), | ||
| // Mock the TipsDisplay module | ||
| vi.mock("./TipsDisplay.js", () => ({ | ||
| TipsDisplay: () => React.createElement("div", null, "Mocked TipsDisplay"), |
There was a problem hiding this comment.
Mocking TipsDisplay with a DOM "div" may not render in Ink, causing lastFrame() assertions to be unreliable; mock it with an Ink Text component instead.
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/IntroMessage.test.tsx at line 9:
<comment>Mocking TipsDisplay with a DOM "div" may not render in Ink, causing lastFrame() assertions to be unreliable; mock it with an Ink Text component instead.</comment>
<file context>
@@ -1,195 +1,83 @@
- })),
+// Mock the TipsDisplay module
+vi.mock("./TipsDisplay.js", () => ({
+ TipsDisplay: () => React.createElement("div", null, "Mocked TipsDisplay"),
+ shouldShowTip: vi.fn(),
+}));
</file context>
|
|
||
| return { allRules, modelCapable }; | ||
| // Determine if we should show a tip (1 in 5 chance) | ||
| const showTip = shouldShowTip(); |
There was a problem hiding this comment.
showTip is randomized inside a memo that depends on model/config, so it can change on subsequent renders (e.g., when model loads). Compute once on mount (e.g., useRef or a separate useMemo with an empty dependency array) to match the intended behavior.
(Based on your PR description about randomly showing tips on CLI startup.)
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/IntroMessage.tsx at line 43:
<comment>showTip is randomized inside a memo that depends on model/config, so it can change on subsequent renders (e.g., when model loads). Compute once on mount (e.g., useRef or a separate useMemo with an empty dependency array) to match the intended behavior.
(Based on your PR description about randomly showing tips on CLI startup.)</comment>
<file context>
@@ -23,29 +31,73 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
- return { allRules, modelCapable };
+ // Determine if we should show a tip (1 in 5 chance)
+ const showTip = shouldShowTip();
+
+ return { allRules, modelCapable, showTip };
</file context>
| <Text> </Text> | ||
|
|
||
| {/* Tips Display - shown randomly 1 in 5 times */} | ||
| {showTip ? <TipsDisplay /> : <Text>nah</Text>} |
There was a problem hiding this comment.
Renders a visible placeholder ("nah") when no tip is shown; remove the placeholder so nothing is rendered when showTip is false.
Prompt for AI agents
Address the following comment on extensions/cli/src/ui/IntroMessage.tsx at line 99:
<comment>Renders a visible placeholder ("nah") when no tip is shown; remove the placeholder so nothing is rendered when showTip is false.</comment>
<file context>
@@ -23,29 +31,73 @@ const IntroMessage: React.FC<IntroMessageProps> = ({
<Text> </Text>
+ {/* Tips Display - shown randomly 1 in 5 times */}
+ {showTip ? <TipsDisplay /> : <Text>nah</Text>}
+
{/* Agent name */}
</file context>
| {showTip ? <TipsDisplay /> : <Text>nah</Text>} | |
| {showTip && <TipsDisplay />} |
|
🎉 This PR is included in version 1.13.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
Randomly show tips on CLI startup
Summary by cubic
Show helpful CLI tips on startup to help users discover shortcuts and commands. Adds a TipsDisplay component with a 20% chance to render and updates IntroMessage to include it.
New Features
Refactors