Elffuss BraidHub

kikocis/continue public

fix: address feedback
Changesetdab1b70f3082a6de479dd98c6a2c7eccdd8111668e3ad12e4c72b4c265ebd1e1
AuthorNate <sestinj@gmail.com> · 2025-08-31 16:32 -07:00
CommitterNate <sestinj@gmail.com> · 2025-08-31 16:32 -07:00
Parentsbdd98e6744b8

Browse the files at this changeset

4 files changed

modified extensions/cli/src/ui/IntroMessage.test.tsx +2 −1
@@ -1,12 +1,13 @@
11 import { render } from "ink-testing-library";
22 import React from "react";
3+import { Text } from "ink";
34 import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
45
56 import { IntroMessage } from "./IntroMessage.js";
67
78 // Mock the TipsDisplay module
89 vi.mock("./TipsDisplay.js", () => ({
9- TipsDisplay: () => React.createElement("div", null, "Mocked TipsDisplay"),
10+ TipsDisplay: () => React.createElement(Text, null, "Mocked TipsDisplay"),
1011 shouldShowTip: vi.fn(),
1112 }));
1213
modified extensions/cli/src/ui/IntroMessage.tsx +6 −6
@@ -30,8 +30,11 @@
3030 // Get MCP prompts directly (not memoized since they can change after first render)
3131 const mcpPrompts = mcpService?.getState().prompts ?? [];
3232
33+ // Determine if we should show a tip (1 in 5 chance) - computed once on mount
34+ const showTip = useMemo(() => shouldShowTip(), []);
35+
3336 // Memoize expensive operations to avoid running on every resize
34- const { allRules, modelCapable, showTip } = useMemo(() => {
37+ const { allRules, modelCapable } = useMemo(() => {
3538 const allRules = extractRuleNames(config?.rules);
3639
3740 // Check if model is capable - now checking both name and model properties
@@ -39,10 +42,7 @@
3942 ? isModelCapable(model.provider, model.name, model.model)
4043 : true; // Default to true if model not loaded yet
4144
42- // Determine if we should show a tip (1 in 5 chance)
43- const showTip = shouldShowTip();
44-
45- return { allRules, modelCapable, showTip };
45+ return { allRules, modelCapable };
4646 }, [config?.rules, model?.provider, model?.name, model?.model]);
4747
4848 // Render helper components
@@ -96,7 +96,7 @@
9696 <Text> </Text>
9797
9898 {/* Tips Display - shown randomly 1 in 5 times */}
99- {showTip ? <TipsDisplay /> : <Text>nah</Text>}
99+ {showTip && <TipsDisplay />}
100100
101101 {/* Agent name */}
102102 {config && (
modified extensions/cli/src/ui/TipsDisplay.test.tsx +1 −1
@@ -138,7 +138,7 @@
138138 "/resume",
139139 "headless",
140140 "flag",
141- "keyboard shortcuts"
141+ "keyboard shortcuts",
142142 ];
143143
144144 const allTipsText = CONTINUE_CLI_TIPS.join(" ").toLowerCase();
modified extensions/cli/src/ui/TipsDisplay.tsx +7 −4
@@ -1,5 +1,5 @@
11 import { Box, Text } from "ink";
2-import React from "react";
2+import React, { useMemo } from "react";
33
44 // Array of helpful tips for Continue CLI users
55 const CONTINUE_CLI_TIPS = [
@@ -20,9 +20,12 @@
2020 * Should only be shown 1 in 5 times (20% chance).
2121 */
2222 const TipsDisplay: React.FC<TipsDisplayProps> = () => {
23- // Randomly select a tip
24- const randomTip =
25- CONTINUE_CLI_TIPS[Math.floor(Math.random() * CONTINUE_CLI_TIPS.length)];
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+ );
2629
2730 return (
2831 <Box flexDirection="row" paddingX={1} paddingBottom={1}>