Skip to content

Conversation

@sujay-d07
Copy link
Contributor

@sujay-d07 sujay-d07 commented Dec 22, 2025

Closes cortexlinux/cortex#254

Summary:

• Interactive Demo Hero - Embedded live /beta demo directly on homepage
• Example Prompt Chips - 5 clickable suggestions, horizontally scrollable on mobile
• Rate Limiting - 5 free requests, then prompts CLI installation
• Streamlined Layout - Input → Terminal Output → Install CTA
• Optimized AI Output - Returns only essential commands, no explanatory text

Summary by CodeRabbit

  • New Features

    • Added an interactive demo interface to the homepage where users can explore the system via a chat-like terminal
    • Includes example prompts for quick-start exploration
    • Displays remaining request counts and CLI installation prompts
    • Enhanced loading states and animations
  • Style

    • Added CSS utilities for scrollbar visibility and smooth scrolling behavior

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Walkthrough

The PR adds an interactive demo experience to the homepage by introducing a new InteractiveDemoHero React component that provides a chat-like terminal interface for testing Cortex. The backend system context is updated to output only shell commands, and the HomePage hero section is refactored to use this new component instead of static CTAs and a code preview block.

Changes

Cohort / File(s) Change Summary
Interactive Demo Component
client/src/components/InteractiveDemoHero.tsx
New React component rendering a demo UI with chat-like terminal, example prompt chips, input form, loading states, error handling, request limit tracking, and install CLI CTAs.
Homepage Integration
client/src/sections/HomePage.tsx
Replaced static CTA buttons and "Professional Terminal Preview" code block with InteractiveDemoHero component; adjusted animation timings (y-position and delay).
Demo Hook Configuration
client/src/hooks/useCortexDemo.ts
Updated SYSTEM_CONTEXT constant to instruct assistant to output only shell commands in a single code block with no explanatory text.
Styling Utilities
client/src/index.css
Added .hide-scrollbar and .scroll-smooth CSS utilities to support UI interactions.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • InteractiveDemoHero component: Review logic for state management, hook integration, example prompt handling, message rendering, and error/limit displays
  • HomePage integration: Verify animation timing adjustments and component replacement maintains layout intent
  • System context change: Confirm the new assistant behavior meets expected output format (shell commands only)

Possibly related issues

  • cortex#254: This PR implements the interactive demo feature, example prompts, install CLI CTA, and request limiting described in the issue.

Poem

🐰 A demo springs forth, interactive and bright,
Example prompts guide users right,
Cortex commands in code blocks run free,
The homepage now showcases our capability! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: integrating an interactive demo into the homepage hero section and enhancing the demo component itself.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (5)
client/src/components/InteractiveDemoHero.tsx (5)

1-1: Unused import: useEffect.

The useEffect hook is imported but not used anywhere in this component.

🔎 Proposed fix
-import { useState, useRef, useEffect } from "react";
+import { useState, useRef } from "react";

40-48: Minor: setTimeout not cleaned up on unmount.

If the component unmounts within the 300ms delay (e.g., user navigates away quickly), the callback will still execute, potentially causing state updates on an unmounted component. This is a minor edge case but worth noting.

🔎 Proposed fix using useRef for cleanup
+  const timeoutRef = useRef<NodeJS.Timeout | null>(null);
+
   const handleExampleClick = async (example: string) => {
     if (isLoading) return;
     setInput(example);
-    // Auto-submit after a brief moment to show the user what was selected
-    setTimeout(async () => {
+    timeoutRef.current = setTimeout(async () => {
       await sendMessage(example);
       setInput("");
     }, 300);
   };
+
+  // Cleanup on unmount
+  useEffect(() => {
+    return () => {
+      if (timeoutRef.current) clearTimeout(timeoutRef.current);
+    };
+  }, []);

50-61: Missing error handling for clipboard API.

navigator.clipboard.writeText() can throw if the page isn't in a secure context or if the user denies permission. Consider wrapping in try-catch to prevent unhandled promise rejections.

🔎 Proposed fix
   const copyLastCommand = () => {
     const lastAssistant = messages.filter((m) => m.role === "assistant").pop();
     if (lastAssistant) {
       const codeMatch = lastAssistant.content.match(/```[\s\S]*?```/g);
       const textToCopy = codeMatch
         ? codeMatch.map((c) => c.replace(/```\w*\n?/g, "").trim()).join("\n")
         : lastAssistant.content;
-      navigator.clipboard.writeText(textToCopy);
-      setCopied(true);
-      setTimeout(() => setCopied(false), 2000);
+      navigator.clipboard.writeText(textToCopy)
+        .then(() => {
+          setCopied(true);
+          setTimeout(() => setCopied(false), 2000);
+        })
+        .catch((err) => {
+          console.error("Failed to copy:", err);
+        });
     }
   };

132-138: Consider adding accessible label for the input field.

The input relies solely on the placeholder for context. Screen reader users would benefit from an associated label. Consider adding a visually hidden label for accessibility.

🔎 Proposed improvement
                   <div className="flex-1 relative">
+                    <label htmlFor="cortex-input" className="sr-only">
+                      Enter your request
+                    </label>
                     <span className="absolute left-4 top-1/2 -translate-y-1/2 text-gray-500 font-mono text-sm">
                       $
                     </span>
                     <Input
+                      id="cortex-input"
                       value={input}
                       onChange={(e) => setInput(e.target.value)}

256-273: Unused function: formatCommandsPreview.

This function is defined but never called anywhere in the component. Consider removing it to reduce dead code.

🔎 Proposed fix
-function formatCommandsPreview(content: string): React.ReactNode {
-  const codeMatch = content.match(/```[\s\S]*?```/g);
-  if (codeMatch) {
-    return (
-      <div className="space-y-2">
-        {codeMatch.map((block, i) => {
-          const code = block.replace(/```\w*\n?/g, "").trim();
-          return (
-            <div key={i} className="text-green-400">
-              {code}
-            </div>
-          );
-        })}
-      </div>
-    );
-  }
-  return <div className="text-gray-400">Processing...</div>;
-}
-
 function formatOutput(content: string): React.ReactNode {
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ccaef53 and 1ef996f.

📒 Files selected for processing (4)
  • client/src/components/InteractiveDemoHero.tsx
  • client/src/hooks/useCortexDemo.ts
  • client/src/index.css
  • client/src/sections/HomePage.tsx
🧰 Additional context used
🧬 Code graph analysis (2)
client/src/components/InteractiveDemoHero.tsx (1)
client/src/hooks/useCortexDemo.ts (1)
  • useCortexDemo (22-67)
client/src/sections/HomePage.tsx (1)
client/src/components/InteractiveDemoHero.tsx (1)
  • InteractiveDemoHero (17-254)
🔇 Additional comments (7)
client/src/index.css (1)

1399-1413: CSS utilities are correctly implemented.

The .hide-scrollbar utility properly covers all browser engines. Minor note: .scroll-smooth is potentially redundant since scroll-behavior: smooth is already applied globally to html at line 380, though having an explicit utility class can be useful for scoped application.

client/src/hooks/useCortexDemo.ts (1)

13-20: System context is well-structured for the demo use case.

The prompt clearly constrains the AI to output only shell commands in a single code block, which aligns with the PR objective for a streamlined terminal-like experience. The explicit prohibitions help ensure consistent, clean output.

client/src/sections/HomePage.tsx (2)

59-59: Import is correctly added.


428-435: Hero section refactored cleanly to use the new interactive demo component.

The integration replaces the previous static CTAs with the interactive demo widget. The adjusted animation parameters (y: 30, delay: 0.4s) provide appropriate staggering after the preceding headline animations.

client/src/components/InteractiveDemoHero.tsx (3)

32-38: Form submission logic is correctly implemented.

The handler properly validates input, clears the field optimistically before the async operation, and prevents double submissions during loading.


63-92: Rate limit reached state is well-designed.

The celebratory UI with clear CTA to install the CLI provides a good user experience when the demo limit is reached.


275-288: Output formatting function is correctly implemented.

The function properly parses and renders code blocks with appropriate styling while preserving surrounding text content.

Comment on lines +17 to +31
export default function InteractiveDemoHero() {
const [input, setInput] = useState("");
const [copied, setCopied] = useState(false);
const messagesEndRef = useRef<HTMLDivElement>(null);
const terminalRef = useRef<HTMLDivElement>(null);

const {
messages,
isLoading,
error,
remaining,
limitReached,
sendMessage,
} = useCortexDemo();

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Auto-scroll to latest message is not implemented.

messagesEndRef is defined and rendered at line 216 but never used to scroll the terminal view. This means when new messages appear, users won't automatically see the latest output — they'll need to manually scroll.

🔎 Proposed fix using useEffect to auto-scroll

First, ensure useEffect is imported (currently imported but flagged as unused), then add:

+  // Auto-scroll to bottom when messages change
+  useEffect(() => {
+    messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
+  }, [messages, isLoading]);
+
   const handleSubmit = async (e: React.FormEvent) => {

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In client/src/components/InteractiveDemoHero.tsx around lines 17 to 31, add an
effect that auto-scrolls the terminal to the latest message: import and use
useEffect (it's currently present but unused), then create a useEffect that runs
when messages change and calls messagesEndRef.current?.scrollIntoView({
behavior: "smooth", block: "nearest" }) or, if you prefer scrolling the
container, call terminalRef.current?.scrollTop =
terminalRef.current.scrollHeight; ensure the effect guards for null refs and
runs on messages updates so the view always scrolls to the newest output.

@sujay-d07
Copy link
Contributor Author

@coderabbitai generate docstrings

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

✅ Actions performed

Initiated docstring generation; will generate only if new commits exist.

@coderabbitai
Copy link

coderabbitai bot commented Dec 22, 2025

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #5

coderabbitai bot added a commit that referenced this pull request Dec 22, 2025
Docstrings generation was requested by @sujay-d07.

* #4 (comment)

The following files were modified:

* `client/src/components/InteractiveDemoHero.tsx`
* `client/src/hooks/useCortexDemo.ts`
* `client/src/sections/HomePage.tsx`
@Suyashd999 Suyashd999 self-requested a review December 23, 2025 16:46
@Suyashd999 Suyashd999 merged commit b07e916 into cortexlinux:main Dec 23, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MVP] Website: Make /beta the homepage hero

2 participants