Skip to content

Conversation

@ShreeJejurikar
Copy link
Collaborator

@ShreeJejurikar ShreeJejurikar commented Dec 26, 2025

Related Issue

Closes #366

Summary

Completely redesigned cortex demo from a 5-second hardware check into a comprehensive 5-minute interactive tutorial.

Before

  • Just showed hardware detection
  • No user interaction
  • Didn't teach Cortex features
  • ~5 seconds duration

After

  • 3 interactive sections teaching all major features
  • Users type real commands (builds muscle memory)
  • Shows actual Cortex output with CX branding
  • Highlights planning/transparency as key feature
  • ~5 minutes duration
  • Professional investor-ready demo

Sections

  1. Smart Installation - Demonstrates transparent planning phase
  2. Hardware-Aware Intelligence - Shows GPU detection and compatibility checks
  3. AI Natural Language - cortex ask with intelligent recommendations
  4. Smart Stacks - Complete workflow bundles (cortex stack)
  5. History Tracking - Installation transaction log
  6. Rollback Protection - Safe undo functionality

Key Features

  • Real command syntax (matches actual Cortex)
  • Zero validation (accepts any input for learning)
  • CX branding matches production
  • Clear screen between sections (better UX)
  • Comparison table finale (WOW factor)
  • Non-interactive mode support (auto-plays in CI)

AI Disclosure

  • No AI used
  • AI/IDE/Agents used (please describe below)

Used Claude Code for assistance with code review and formatting.

Checklist

  • PR title follows format: type(scope): description or [scope] description
  • Tests pass (pytest tests/)
  • MVP label added if closing MVP issue
  • Update "Cortex -h" (if needed)

Testing

  • Demo completes all 6 sections
  • Commands match actual Cortex syntax
  • CX output branding matches real tool
  • ~5 minute duration
  • Clear screen works correctly
  • Non-interactive mode works

Video demonstration:
Screencast from 26-12-25 03:45:52 PM IST.webm

Summary by CodeRabbit

  • Refactor
    • Reorganized the interactive demo into a class-driven, multi-section narrative with improved visuals and hardware-aware branching while preserving the same public entry point.
  • New Features
    • Added a three-section demo flow (AI Intelligence, Smart Stacks, History & Safety), simulated outputs, status spinners, tables/panels, hardware-specific variations and a finale comparison.
  • Bug Fixes
    • Improved handling of user interruptions with consistent non-zero exit behavior.

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

- Smart installation with transparent planning phase
- Hardware-aware intelligence demonstrations
- AI natural language understanding
- Smart stacks workflow (list and install)
- Installation history tracking
- Rollback protection demonstration
- Comparison table finale showing key differentiators
- Clear screen between sections for better UX
- ~5 minute interactive tutorial
- Matches actual Cortex output with CX branding

Users type real commands to build muscle memory.
Accepts any input for learning (no validation friction).

Closes cortexlinux#366
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 26, 2025

📝 Walkthrough

Walkthrough

Adds a class-based interactive demo by introducing CortexDemo in cortex/demo.py, moving the demo lifecycle, Rich-based UI rendering, hardware-aware branching, simulated Cortex outputs, a three-section flow (AI Intelligence, Smart Stacks, History & Safety) plus finale, and makes run_demo() delegate to CortexDemo.run() with interruption handling.

Changes

Cohort / File(s) Summary
Interactive Demo Refactor
cortex/demo.py
Introduces CortexDemo (constructor + run()), many demo helpers (clear_screen, _generate_id, _generate_past_date, _wait_for_user, _prompt_command, _simulate_cortex_output, _section_ai_intelligence, _section_smart_stacks, _section_history_safety, _show_finale), integrates SystemInfo/detect_hardware, Rich UI components (Panel, Table, Spinner), simulated CX outputs, hardware-specific branches (NVIDIA/AMD/CPU), and KeyboardInterrupt/EOFError handling. run_demo() now delegates to CortexDemo.run().

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Demo as CortexDemo
    participant HW as HardwareDetector
    participant UI as RichRenderer
    participant Sim as Simulator

    User->>Demo: run_demo() / run()
    Demo->>HW: detect_hardware()
    HW-->>Demo: SystemInfo
    Demo->>UI: render intro / clear_screen
    Demo->>User: wait_for_user()
    User->>Demo: continue

    Demo->>User: prompt AI Intelligence
    User->>Demo: enter command
    Demo->>Sim: _simulate_cortex_output(command, packages)
    Sim->>UI: render CX-style output

    Demo->>User: prompt Smart Stacks
    User->>Demo: enter stack command
    Demo->>Sim: simulate stack execution (hw-aware)
    Sim->>UI: render stack output

    Demo->>UI: show History & Safety
    Demo->>UI: show finale & comparison table
    Demo-->>User: return exit code
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • Sahilbhatane
  • mikejmorgan-ai

Poem

🐰 I hopped through code to craft the show,
A guided demo now ready to go.
Prompts and stacks in CX-style light,
Hardware-aware and shining bright.
Hop in — the tutorial’s a delight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: Complete interactive demo with 6 sections' clearly and specifically describes the main change — refactoring the cortex demo into a comprehensive interactive tutorial with six demo sections.
Description check ✅ Passed The PR description is comprehensive and mostly complete, covering the summary, AI disclosure, and testing checklist as required by the template. All critical sections are addressed.
Linked Issues check ✅ Passed The changes successfully implement all core objectives from issue #366: interactive tutorial with real commands, planning/safety transparency, hardware awareness, natural language AI, package name intelligence, smart stacks, history tracking, rollback protection, and non-interactive mode support.
Out of Scope Changes check ✅ Passed All changes are scoped to cortex/demo.py and directly address the requirements in issue #366. The refactoring adds the CortexDemo class and supporting methods entirely within the scope of creating the interactive tutorial.
Docstring Coverage ✅ Passed Docstring coverage is 86.67% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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
Contributor

@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: 3

🧹 Nitpick comments (2)
cortex/demo.py (2)

206-217: Use gpu_info consistently instead of re-accessing gpu[0].

After extracting gpu_info = gpu[0], the code still accesses gpu[0].model directly on lines 217, 239, and 252. Using gpu_info.model would be more consistent and slightly cleaner.

🔎 Proposed fix
         if has_nvidia:
             # NVIDIA GPU - show successful CUDA install
-            self.console.print(f"[cyan]Detected GPU:[/cyan] {gpu[0].model}")
+            self.console.print(f"[cyan]Detected GPU:[/cyan] {gpu_info.model}")

Apply similar changes to lines 239 and 252.


411-438: Consider using dynamic dates for the history table.

The hardcoded dates (e.g., "2025-12-26 13:11:51") will appear stale as time passes. For a more polished demo, consider generating dates relative to the current time.

🔎 Example approach
from datetime import datetime, timedelta

now = datetime.now()
dates = [
    now.strftime("%Y-%m-%d %H:%M:%S"),
    (now - timedelta(days=1)).strftime("%Y-%m-%d %H:%M:%S"),
    (now - timedelta(days=1, hours=1)).strftime("%Y-%m-%d %H:%M:%S"),
    (now - timedelta(days=2)).strftime("%Y-%m-%d %H:%M:%S"),
]
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a146dd and 2027e2b.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (2)
  • status (797-828)
  • demo (180-184)
cortex/progress_indicators.py (1)
  • total_steps (99-100)
🪛 GitHub Actions: CI
cortex/demo.py

[error] 6-6: I001 Import block is un-sorted or un-formatted (ruff).

🪛 GitHub Check: lint
cortex/demo.py

[failure] 63-63: Ruff (W293)
cortex/demo.py:63:1: W293 Blank line contains whitespace


[failure] 60-60: Ruff (W293)
cortex/demo.py:60:1: W293 Blank line contains whitespace


[failure] 58-58: Ruff (W293)
cortex/demo.py:58:1: W293 Blank line contains whitespace


[failure] 49-49: Ruff (W291)
cortex/demo.py:49:73: W291 Trailing whitespace


[failure] 44-44: Ruff (W293)
cortex/demo.py:44:1: W293 Blank line contains whitespace


[failure] 41-41: Ruff (W293)
cortex/demo.py:41:1: W293 Blank line contains whitespace


[failure] 35-35: Ruff (W293)
cortex/demo.py:35:1: W293 Blank line contains whitespace


[failure] 31-31: Ruff (W293)
cortex/demo.py:31:1: W293 Blank line contains whitespace


[failure] 21-21: Ruff (W293)
cortex/demo.py:21:1: W293 Blank line contains whitespace


[failure] 6-16: Ruff (I001)
cortex/demo.py:6:1: I001 Import block is un-sorted or un-formatted

🪛 GitHub Check: Lint
cortex/demo.py

[failure] 63-63: Ruff (W293)
cortex/demo.py:63:1: W293 Blank line contains whitespace


[failure] 60-60: Ruff (W293)
cortex/demo.py:60:1: W293 Blank line contains whitespace


[failure] 58-58: Ruff (W293)
cortex/demo.py:58:1: W293 Blank line contains whitespace


[failure] 49-49: Ruff (W291)
cortex/demo.py:49:73: W291 Trailing whitespace


[failure] 44-44: Ruff (W293)
cortex/demo.py:44:1: W293 Blank line contains whitespace


[failure] 41-41: Ruff (W293)
cortex/demo.py:41:1: W293 Blank line contains whitespace


[failure] 35-35: Ruff (W293)
cortex/demo.py:35:1: W293 Blank line contains whitespace


[failure] 31-31: Ruff (W293)
cortex/demo.py:31:1: W293 Blank line contains whitespace


[failure] 21-21: Ruff (W293)
cortex/demo.py:21:1: W293 Blank line contains whitespace


[failure] 6-16: Ruff (I001)
cortex/demo.py:6:1: I001 Import block is un-sorted or un-formatted

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.12)
🔇 Additional comments (8)
cortex/demo.py (8)

95-105: LGTM!

The method correctly handles both interactive and non-interactive modes, with proper exception handling for user interruption.


107-124: LGTM!

The method correctly implements the "accept any input for learning" design goal while maintaining proper exception handling.


126-171: LGTM!

The simulation logic is well-structured with clear phases (understanding, planning, execution) and proper CX branding. The optional show_execution parameter provides flexibility for different demo scenarios.


288-333: LGTM!

The AI features section effectively demonstrates the cortex ask capability with a well-formatted response panel.


335-389: LGTM!

The stacks section provides a clear demonstration of the workflow bundles feature with a well-formatted table and simulated installation.


448-476: LGTM!

The rollback section effectively demonstrates the undo capability and ties back to the installation ID from earlier sections.


478-564: LGTM!

The finale provides a compelling comparison table and comprehensive next steps, making for a polished conclusion to the demo.


567-573: LGTM!

The entry point is clean and correctly delegates to the new class-based implementation.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (3)
cortex/demo.py (3)

13-13: Remove unused imports from rich.progress.

BarColumn, Progress, SpinnerColumn, and TextColumn are imported but never used in this file. The code uses self.console.status() which doesn't require these explicit imports.

🔎 Proposed fix
-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn

23-27: Add type annotation for self.hw and docstring for __init__.

Per coding guidelines, type hints are required in Python code and docstrings are required for all public APIs. self.hw lacks a type annotation, and __init__ lacks a docstring.

🔎 Proposed fix
     def __init__(self):
+        """Initialize the interactive demo with console and state."""
         self.console = Console()
-        self.hw = None
+        self.hw: Optional[object] = None  # Set by detect_hardware()
         self.is_interactive = sys.stdin.isatty()
         self.installation_id = self._generate_id()

131-133: Add return type hint for consistency.

Per coding guidelines, type hints are required. This method implicitly returns None.

🔎 Proposed fix
     def _simulate_cortex_output(
         self, command: str, packages: list[str], show_execution: bool = False
-    ):
+    ) -> None:
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2027e2b and 5e196e5.

📒 Files selected for processing (2)
  • cortex/demo.py
  • cortex/dependency_check.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/demo.py
  • cortex/dependency_check.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (2)
  • status (797-828)
  • demo (180-184)
cortex/progress_indicators.py (1)
  • total_steps (99-100)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build Package
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.12)
🔇 Additional comments (13)
cortex/dependency_check.py (1)

46-46: LGTM!

Trivial stylistic change from single to double quotes in the join delimiter. No functional impact.

cortex/demo.py (12)

29-35: LGTM!

Both clear_screen and _generate_id are well-documented with appropriate docstrings and type hints.


37-98: LGTM!

The run method is well-structured with proper error handling for KeyboardInterrupt and EOFError, clear section progression, and appropriate return codes.


100-110: LGTM!

Clean implementation with proper non-interactive mode support for CI and robust exception handling.


112-129: LGTM!

Zero-validation approach aligns with PR objectives for a learning-focused demo. Good exception handling.


187-211: LGTM!

Well-structured section with clear flow: explanation → command prompt → simulation → feature highlight.


213-322: LGTM!

Hardware detection logic is sound with proper null checks. The three branches (NVIDIA/AMD/no GPU) provide good coverage for different user scenarios.


324-373: LGTM!

Clean AI features section with well-formatted response content and appropriate Panel display.


375-431: LGTM!

Stacks section effectively demonstrates listing and installation with proper table formatting.


433-474: LGTM!

History section with appropriate example data. Hardcoded dates are acceptable for demo purposes.


476-512: LGTM!

Rollback section cleanly demonstrates the undo capability with proper ID generation.


514-574: LGTM!

Excellent finale with a compelling comparison table and comprehensive next steps. The summary effectively reinforces what users learned.


577-583: LGTM!

Clean entry point that preserves the existing API while delegating to the new class-based implementation. Matches CLI integration in cortex/cli.py.

Copy link
Contributor

@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)
cortex/demo.py (5)

13-13: Remove unused imports from rich.progress.

The imports BarColumn, Progress, SpinnerColumn, and TextColumn are not used in this file. The demo only uses self.console.status(...) contexts, which don't require these imports.

🔎 Proposed fix
-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn

23-27: Consider adding a docstring and type annotation for better API documentation.

The __init__ method lacks a docstring, and self.hw has no type annotation. Per coding guidelines, docstrings are required for public APIs.

🔎 Proposed enhancement
     def __init__(self):
+        """
+        Initialize the interactive demo.
+        
+        Sets up console, hardware detection placeholder, interactivity detection,
+        and generates a unique installation ID for demo purposes.
+        """
         self.console = Console()
-        self.hw = None
+        self.hw: Optional[object] = None  # Set by detect_hardware()
         self.is_interactive = sys.stdin.isatty()
         self.installation_id = self._generate_id()

29-31: Add return type annotation for consistency.

Per coding guidelines, type hints are required. The clear_screen method should explicitly declare -> None.

🔎 Proposed fix
-    def clear_screen(self):
+    def clear_screen(self) -> None:
         """Clears the terminal screen"""
         self.console.clear()

128-131: Add return type annotation.

The method should declare -> None per coding guidelines requiring type hints.

🔎 Proposed fix
     def _simulate_cortex_output(
-        self, command: str, packages: list[str], show_execution: bool = False
+        self, command: str, packages: list[str], show_execution: bool = False
+    ) -> None:
-    ):
         """Simulate real Cortex output with CX branding"""

184-186: Add return type annotation.

Per coding guidelines, the method should declare -> bool as its return type.

🔎 Proposed fix
-    def _section_ai_intelligence(self) -> bool:
+    def _section_ai_intelligence(self) -> bool:
         """Section 1: AI Intelligence - NLP, Planning, and Hardware Awareness"""

(Note: The return type is actually already present in the signature. This might be a display issue.)

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e196e5 and d215f61.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (2)
  • status (797-828)
  • demo (180-184)
cortex/progress_indicators.py (1)
  • total_steps (99-100)
🪛 GitHub Actions: CI
cortex/demo.py

[error] 577-577: W292 No newline at end of file.

🪛 GitHub Check: lint
cortex/demo.py

[failure] 577-577: Ruff (W292)
cortex/demo.py:577:22: W292 No newline at end of file

🪛 GitHub Check: Lint
cortex/demo.py

[failure] 577-577: Ruff (W292)
cortex/demo.py:577:22: W292 No newline at end of file

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.11)
🔇 Additional comments (6)
cortex/demo.py (6)

37-96: LGTM! Well-structured demo orchestration.

The run() method has a clear flow: initialization, hardware detection, section execution, and finale. Error handling properly catches interruptions and returns appropriate exit codes. The section loop design allows early exit on user interruption.


97-127: LGTM! Robust user interaction handling.

Both methods properly handle interactive vs. non-interactive modes and gracefully catch interruptions. The design choice to accept any input in _prompt_command (line 118) aligns with the learning-friendly objective stated in the PR.


263-278: LGTM! Robust GPU detection with multiple vendor support.

The GPU detection logic safely handles the case where hardware info is unavailable (lines 263-264) and checks for both NVIDIA and AMD GPUs using case-insensitive pattern matching. The three-way branching (NVIDIA/AMD/no-GPU) provides tailored demos for each scenario.


365-424: LGTM! Clear demonstration of stacks feature.

The section effectively showcases the stacks workflow with a well-formatted table of available stacks and a complete installation simulation. The tip about creating custom stacks (lines 421-422) is a nice touch.


426-506: LGTM! Excellent narrative continuity.

The section effectively demonstrates history tracking and rollback features. The use of self.installation_id from the earlier webdev stack installation (line 449, 478, 481) creates excellent narrative continuity throughout the demo.


508-569: LGTM! Compelling finale with clear value proposition.

The comparison table (lines 519-536) effectively highlights Cortex's differentiators, and the summary panel provides actionable next steps with correct command syntax. Recommending cortex wizard as the first step (line 553) is good UX guidance.

Copy link
Collaborator

@Anshgrover23 Anshgrover23 left a comment

Choose a reason for hiding this comment

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

@ShreeJejurikar Please update your branch and merge with main. The lint CI issues causing the failures are fixed.

@Sahilbhatane
Copy link
Collaborator

Update the branch

Copy link
Collaborator

@Anshgrover23 Anshgrover23 left a comment

Choose a reason for hiding this comment

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

@ShreeJejurikar Kindly Update the branch and do CLA verification following this PR #401

Copilot AI review requested due to automatic review settings January 7, 2026 19:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

CLA Verification Passed

All contributors have signed the CLA.

Contributor Signed As
@ShreeJejurikar @ShreeJejurikar
@Anshgrover23 @Anshgrover23

Copy link
Contributor

@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: 0

🧹 Nitpick comments (4)
cortex/demo.py (4)

20-27: Add type hints and expand class docstring.

Per coding guidelines, type hints are required, and docstrings are required for public APIs. The class docstring is minimal, and __init__ lacks type annotations for instance attributes.

Suggested improvement
 class CortexDemo:
-    """Interactive Cortex demonstration"""
+    """Interactive Cortex demonstration.
+    
+    Provides a guided, hands-on tutorial showcasing Cortex's major features
+    including AI intelligence, smart stacks, and safety features.
+    """

-    def __init__(self):
-        self.console = Console()
-        self.hw = None
-        self.is_interactive = sys.stdin.isatty()
-        self.installation_id = self._generate_id()
+    def __init__(self) -> None:
+        self.console: Console = Console()
+        self.hw: object | None = None  # HardwareInfo from detect_hardware()
+        self.is_interactive: bool = sys.stdin.isatty()
+        self.installation_id: str = self._generate_id()

29-31: Add return type hint.

Missing return type annotation per coding guidelines.

-    def clear_screen(self):
+    def clear_screen(self) -> None:
         """Clears the terminal screen"""
         self.console.clear()

128-130: Add return type hint.

Missing return type annotation per coding guidelines.

     def _simulate_cortex_output(
         self, command: str, packages: list[str], show_execution: bool = False
-    ):
+    ) -> None:
         """Simulate real Cortex output with CX branding"""

263-282: Inconsistent variable usage: use gpu_info instead of gpu[0].

gpu_info is extracted on line 264 but then gpu[0].model is used directly on lines 282, 310, and 325. This is inconsistent and could lead to maintenance issues. Additionally, the length check is redundant since a non-empty list is truthy.

Suggested fix
-        gpu_info = gpu[0] if (gpu and len(gpu) > 0) else None
+        gpu_info = gpu[0] if gpu else None

         # Check for NVIDIA
         has_nvidia = gpu_info and (
             "NVIDIA" in str(gpu_info.model).upper()
             or "GTX" in str(gpu_info.model).upper()
             or "RTX" in str(gpu_info.model).upper()
         )
         ...
         if has_nvidia:
             # NVIDIA GPU - show successful CUDA install
-            self.console.print(f"[cyan]Detected GPU:[/cyan] {gpu[0].model}")
+            self.console.print(f"[cyan]Detected GPU:[/cyan] {gpu_info.model}")

Apply the same change on lines 310 and 325.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d215f61 and 868ab8e.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide
Type hints required in Python code
Docstrings required for all public APIs

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (1)
  • demo (271-275)
cortex/progress_indicators.py (1)
  • total_steps (99-100)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test (Python 3.12)
  • GitHub Check: Test (Python 3.10)
  • GitHub Check: Test (Python 3.11)
  • GitHub Check: test (3.11)
🔇 Additional comments (7)
cortex/demo.py (7)

37-95: LGTM!

The main entry method has proper error handling, consistent return values, and clean section orchestration. The try/except for KeyboardInterrupt and EOFError ensures graceful exits.


97-107: LGTM!

Clean implementation handling both interactive (user input) and non-interactive (auto-advance) modes with proper exception handling.


109-126: LGTM!

The zero-validation approach is well-documented and aligns with the PR objective of a "learning-friendly experience."


365-424: LGTM!

The smart stacks section is well-structured with a clear table display and proper simulation of stack installation.


426-506: LGTM!

The history and rollback demonstration is well-implemented with clear visual feedback through Rich status spinners.


508-568: LGTM!

Excellent finale with a compelling comparison table and clear next steps. The summary effectively reinforces what users learned.


571-577: LGTM!

Clean entry point that maintains the existing public API while delegating to the new class-based implementation.

@Anshgrover23 Anshgrover23 marked this pull request as draft January 12, 2026 20:25
Copy link
Collaborator

@Anshgrover23 Anshgrover23 left a comment

Choose a reason for hiding this comment

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

@ShreeJejurikar SonarQubeCloud CI check is failing.

@ShreeJejurikar
Copy link
Collaborator Author

@Anshgrover23 Please check again now that the SonarQubeCloud CI is passing. Thank you.

Copy link
Collaborator

@Anshgrover23 Anshgrover23 left a comment

Choose a reason for hiding this comment

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

@ShreeJejurikar added some comments, also do not hardcoded things.

- Remove unused Optional import
- Remove "Production Version" from docstring
- Replace hardcoded dates with dynamic date generation
- Replace hardcoded installation IDs with generated IDs
@cortexlinux cortexlinux deleted a comment from ShreeJejurikar Jan 13, 2026
@Anshgrover23
Copy link
Collaborator

Understood on the time.sleep() usage for demo UX. That’s fine for now. Please go ahead and push the rest of the requested changes.

@Anshgrover23 Anshgrover23 marked this pull request as ready for review January 13, 2026 07:53
Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In @cortex/demo.py:
- Around line 461-474: The two history_table.add_row calls for "docker" and
"python3-dev" both call _generate_past_date(1, 13, 13) producing duplicate
timestamps; change the second _generate_past_date call (used in the row for
"python3-dev") to a different time (e.g., different hour/minute/second arguments
or a different day offset) so the timestamp differs, locating the calls in the
add_row invocations that pass _generate_past_date to history_table.add_row.
🧹 Nitpick comments (4)
cortex/demo.py (4)

13-13: Remove unused imports from rich.progress.

BarColumn, Progress, SpinnerColumn, and TextColumn are imported but never used. The code uses self.console.status() for spinner animations instead.

Suggested fix
-from rich.progress import BarColumn, Progress, SpinnerColumn, TextColumn

29-31: Add return type hint for consistency.

Per coding guidelines, type hints should be included. This method is missing its return type annotation.

Suggested fix
-    def clear_screen(self):
+    def clear_screen(self) -> None:
         """Clears the terminal screen"""
         self.console.clear()

134-136: Add return type hint.

This method is missing its return type annotation.

Suggested fix
     def _simulate_cortex_output(
         self, command: str, packages: list[str], show_execution: bool = False
-    ):
+    ) -> None:
         """Simulate real Cortex output with CX branding"""

286-288: Use gpu_info consistently instead of gpu[0].

gpu_info is assigned on line 270 but gpu[0] is used directly on lines 288, 316, and 331. Use gpu_info for consistency.

Suggested fix for lines 288, 316, 331
-            self.console.print(f"[cyan]Detected GPU:[/cyan] {gpu[0].model}")
+            self.console.print(f"[cyan]Detected GPU:[/cyan] {gpu_info.model}")
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 868ab8e and 46be993.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide for Python code
Include type hints in Python code
Add docstrings for all public APIs in Python code
Use dry-run mode by default for all installation operations
Do not use silent sudo - require explicit user confirmation for privilege escalation
Implement Firejail sandboxing for execution of untrusted code
Log all operations to ~/.cortex/history.db for audit purposes

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (2)
  • status (1006-1014)
  • demo (271-275)
cortex/progress_indicators.py (1)
  • total_steps (99-100)
🔇 Additional comments (3)
cortex/demo.py (3)

190-191: Add return type hint.

This method is missing its return type annotation.

Suggested fix
-    def _section_ai_intelligence(self) -> bool:
+    def _section_ai_intelligence(self) -> bool:
         """Section 1: AI Intelligence - NLP, Planning, and Hardware Awareness"""

Wait, I see the AI summary says it has -> bool, but looking at line 190, I need to verify... Line 190 shows just def _section_ai_intelligence(self) -> bool: - it actually has the type hint. Let me skip this.


530-531: Add return type hint.

This method is missing its return type annotation.

Suggested fix
-    def _show_finale(self) -> None:
+    def _show_finale(self) -> None:
         """Show finale with comparison table and next steps"""

Actually, checking the AI summary again - it shows def _show_finale(self) -> None:. Let me verify from the annotated code... Line 530 shows def _show_finale(self) -> None:. It already has the type hint.


593-599: LGTM!

The run_demo() entry point maintains API compatibility while delegating to the new class-based implementation. The docstring clearly describes the purpose.

- Remove unused rich.progress imports (BarColumn, Progress, SpinnerColumn, TextColumn)
- Add return type hints (-> None) to clear_screen() and _simulate_cortex_output()
- Use gpu_info consistently instead of gpu[0] (lines 288, 316, 331)
- Fix duplicate timestamps: changed second entry from (1, 13, 13) to (1, 14, 25)

All issues from code review are now resolved.
Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
cortex/demo.py (2)

22-26: Consider adding type hints to __init__.

Per coding guidelines, type hints should be included. The __init__ method is missing a return type annotation, and self.hw should have an explicit type.

✨ Suggested improvement
-    def __init__(self):
+    def __init__(self) -> None:
         self.console = Console()
-        self.hw = None
+        self.hw: object | None = None  # Consider using proper type from hardware_detection
         self.is_interactive = sys.stdin.isatty()
         self.installation_id = self._generate_id()

267-283: GPU detection string matching could miss some models.

The current detection checks for "NVIDIA", "GTX", "RTX" but may miss other NVIDIA cards like GeForce (without GTX/RTX prefix), Quadro, or Tesla. Similarly, AMD detection might miss some models. For a demo, this is acceptable, but consider expanding coverage.

✨ More comprehensive GPU detection
         # Check for NVIDIA
         has_nvidia = gpu_info and (
             "NVIDIA" in str(gpu_info.model).upper()
             or "GTX" in str(gpu_info.model).upper()
             or "RTX" in str(gpu_info.model).upper()
+            or "GEFORCE" in str(gpu_info.model).upper()
+            or "QUADRO" in str(gpu_info.model).upper()
+            or "TESLA" in str(gpu_info.model).upper()
         )

         # Check for AMD (dedicated or integrated Radeon)
         has_amd = gpu_info and (
             "AMD" in str(gpu_info.model).upper()
             or "RADEON" in str(gpu_info.model).upper()
             or "RENOIR" in str(gpu_info.model).upper()
+            or "VEGA" in str(gpu_info.model).upper()
+            or "NAVI" in str(gpu_info.model).upper()
+            or "RX " in str(gpu_info.model).upper()
         )
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46be993 and 5680137.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide for Python code
Include type hints in Python code
Add docstrings for all public APIs in Python code
Use dry-run mode by default for all installation operations
Do not use silent sudo - require explicit user confirmation for privilege escalation
Implement Firejail sandboxing for execution of untrusted code
Log all operations to ~/.cortex/history.db for audit purposes

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (2)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (1)
  • demo (271-275)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build Package
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.11)
🔇 Additional comments (10)
cortex/demo.py (10)

1-17: LGTM!

Module docstring and imports are well-organized. All imported components are used appropriately throughout the demo.


28-40: LGTM!

Helper methods are well-documented with appropriate type hints. Using secrets.token_hex() for demo IDs is a good choice for realistic-looking identifiers.


42-100: LGTM!

The main run() method is well-structured with:

  • Proper type hint and docstring
  • Comprehensive error handling for KeyboardInterrupt and EOFError
  • Clean section iteration pattern with early exit on interruption
  • Appropriate exit codes (0 for success, 1 for interruption)

102-112: LGTM!

Clean implementation handling both interactive and non-interactive (CI) modes. The error handling for user interruption is appropriate.


114-131: LGTM!

The zero-validation approach is intentional per PR objectives, making the demo learning-friendly. Good visual feedback with the green checkmark after input.


157-161: Good adherence to dry-run by default pattern.

The demo correctly shows that execution requires the --execute flag, aligning with the coding guideline to use dry-run mode by default. This teaches users the safe behavior from the start.


189-198: LGTM!

The AI Intelligence section is well-structured with clear part divisions. The method is lengthy but the narrative flow benefits from keeping the parts together. Good error handling throughout.


370-429: LGTM!

Clean demonstration of the Smart Stacks feature with well-formatted tables and helpful tips for custom stack creation.


431-527: LGTM!

History and rollback demonstration is well-executed with realistic-looking demo data and clear explanation of the safety features.


529-598: LGTM!

The finale effectively showcases Cortex's differentiators with a clear comparison table. The run_demo() function maintains backward compatibility while delegating to the new class-based implementation.

@Anshgrover23
Copy link
Collaborator

Nice demo overall. One UX bug: empty Enter at the “Try:” prompt still prints a hard-coded AI response, which is misleading. Please re-prompt on empty input or prefix the output with [Sample output — command not executed].

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In @cortex/demo.py:
- Around line 278-300: The GPU detection assumes self.hw has a .gpu attribute
and directly indexes/reads gpu_info.model which can raise AttributeError; change
gpu access to use getattr(self.hw, "gpu", None) and guard indexing (e.g., treat
gpu as iterable and only set gpu_info if gpu is truthy and has length > 0), and
use getattr(gpu_info, "model", "") when reading the model; also factor the
repeated string-matching logic into a helper method (suggested name:
_is_gpu_vendor(self, model: str, keywords: list[str])) and replace the
has_nvidia and has_amd checks to call that helper with appropriate keyword
lists.
🧹 Nitpick comments (3)
cortex/demo.py (3)

161-172: Hardcoded apt commands in simulation.

The simulated output always shows sudo apt commands regardless of the actual system's package manager. While acceptable for a demo, consider:

  1. Using the detected system's package manager for more realistic output, or
  2. Adding a comment noting this is a simplified simulation

The dry-run messaging (lines 169-172) showing the --execute flag requirement aligns well with the coding guidelines about dry-run mode being the default.


398-398: Potentially incomplete output line.

This line prints " [cyan]CX[/cyan] │ \n" which appears to be a CX-branded prefix with no actual content. This may be intentional spacing, but if so, consider using just self.console.print() or adding a comment explaining the purpose.

-        self.console.print(" [cyan]CX[/cyan]  │ \n")
+        self.console.print()  # Visual spacing before stacks table

22-26: Import SystemInfo and use it as the type hint for self.hw.

The object | None type hint is too generic and provides no useful type information. Since detect_hardware() returns SystemInfo, import and use that specific type:

-from cortex.hardware_detection import detect_hardware
+from cortex.hardware_detection import detect_hardware, SystemInfo

 class CortexDemo:
     """Interactive Cortex demonstration"""

     def __init__(self) -> None:
         self.console = Console()
-        self.hw: object | None = None  # Type from hardware_detection.detect_hardware()
+        self.hw: SystemInfo | None = None
         self.is_interactive = sys.stdin.isatty()
         self.installation_id = self._generate_id()
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5680137 and d0c8a37.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide for Python code
Include type hints in Python code
Add docstrings for all public APIs in Python code
Use dry-run mode by default for all installation operations
Do not use silent sudo - require explicit user confirmation for privilege escalation
Implement Firejail sandboxing for execution of untrusted code
Log all operations to ~/.cortex/history.db for audit purposes

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/cli.py (1)
  • demo (271-275)
cortex/progress_indicators.py (1)
  • total_steps (99-100)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build Package
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.11)
🔇 Additional comments (4)
cortex/demo.py (4)

28-40: LGTM!

Utility methods are well-implemented with proper docstrings and type hints. Using secrets.token_hex() for ID generation is a good choice for cryptographically secure random values.


42-100: LGTM!

The run() method is well-structured with comprehensive error handling for user interruptions. The section-based iteration pattern is clean and maintainable. Exit codes appropriately distinguish between successful completion (0) and interruption (1).


114-142: LGTM - Addresses reviewer feedback.

The _prompt_command method properly re-prompts on empty input (lines 127-131), which addresses the UX bug mentioned in the PR comments. This prevents the misleading behavior of showing a hard-coded AI response when the user presses Enter without typing anything.


546-615: LGTM!

The finale section provides a strong conclusion with:

  • A clear comparison table highlighting Cortex's differentiation
  • A comprehensive summary of learned features
  • Actionable next steps with essential commands

The run_demo() function properly maintains the public API while delegating to the new class-based implementation.

- Use SystemInfo type hint instead of generic object
- Replace empty CX line with simple spacing
- Add _is_gpu_vendor() helper method to reduce code duplication
- Use defensive getattr() for GPU attribute access
- Extract GPU vendor keywords into named lists for clarity
Copy link
Contributor

@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: 0

🧹 Nitpick comments (2)
cortex/demo.py (2)

144-146: Remove unused command parameter.

The command parameter is declared but never used within the method body. Consider removing it to avoid confusion, or use it in the output if intended.

♻️ Suggested fix
 def _simulate_cortex_output(
-    self, command: str, packages: list[str], show_execution: bool = False
+    self, packages: list[str], show_execution: bool = False
 ) -> None:
     """Simulate real Cortex output with CX branding"""

Then update callers at lines 259-261 and 430-432:

-self._simulate_cortex_output(
-    'cortex install "docker nodejs"', ["docker.io", "nodejs"], show_execution=False
-)
+self._simulate_cortex_output(["docker.io", "nodejs"], show_execution=False)

279-300: Consider caching the uppercase model string.

The expression str(gpu_info.model).upper() is evaluated multiple times (6 times for NVIDIA check, 6 times for AMD check). While acceptable for demo code, you could cache it:

model_upper = str(gpu_info.model).upper() if gpu_info else ""
has_nvidia = any(kw in model_upper for kw in ("NVIDIA", "GTX", "RTX", "GEFORCE", "QUADRO", "TESLA"))
has_amd = any(kw in model_upper for kw in ("AMD", "RADEON", "RENOIR", "VEGA", "NAVI", "RX "))
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0c8a37 and db70962.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide for Python code
Include type hints in Python code
Add docstrings for all public APIs in Python code
Use dry-run mode by default for all installation operations
Do not use silent sudo - require explicit user confirmation for privilege escalation
Implement Firejail sandboxing for execution of untrusted code
Log all operations to ~/.cortex/history.db for audit purposes

Files:

  • cortex/demo.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Test (Python 3.11)
  • GitHub Check: test (3.12)
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.10)
🔇 Additional comments (8)
cortex/demo.py (8)

1-17: LGTM!

Module docstring and imports are well-organized following PEP 8 conventions (standard library, third-party, then local imports). The SystemInfo type hint import properly supports type checking.


28-40: LGTM!

Helper methods are well-implemented with proper docstrings and type hints. Good use of secrets.token_hex() for generating cryptographically secure random IDs rather than random.


42-100: LGTM!

The run() method is well-structured with:

  • Clear section iteration pattern (lines 74-88)
  • Proper exit codes (0 for success, 1 for interruption)
  • Comprehensive error handling wrapping the entire flow

The hardware detection at line 71 appropriately defers until after user confirms they want to start.


114-142: Good fix for the empty input handling.

The re-prompt loop (lines 121-133) properly addresses the reported UX bug where pressing Enter with empty input previously showed misleading output. Now it gives a clear hint and re-prompts until the user provides input.


387-446: LGTM!

The smart stacks section demonstrates the feature effectively with:

  • Clear stack listing using Rich Table (lines 401-412)
  • Simulated full installation flow (line 430-432)
  • Helpful tip about custom stack creation (lines 443-444)

448-544: LGTM!

The history and safety section effectively demonstrates:

  • Installation tracking with realistic table output (lines 463-499)
  • Rollback flow using the same installation_id from earlier stack install for continuity (line 516)
  • Clear messaging about the safety benefits

546-615: LGTM!

The finale provides a strong conclusion with:

  • Effective comparison table highlighting Cortex advantages (lines 557-574)
  • Comprehensive next steps including the wizard for API key setup (line 591)
  • The run_demo() function properly maintains the existing public API while delegating to the new class-based implementation

22-26: No action needed. The union type syntax SystemInfo | None is appropriate for this project. The pyproject.toml explicitly declares requires-python = ">=3.10", and Python 3.10 introduced PEP 604 which supports the X | Y union syntax. This modern syntax is used consistently throughout the codebase and aligns with the project's minimum version requirement.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
cortex/demo.py (1)

149-151: Unused parameter: command

The command parameter is accepted but never used within the method body. Consider removing it or adding a TODO comment if it's intended for future logging/audit purposes.

Option 1: Remove unused parameter
     def _simulate_cortex_output(
-        self, command: str, packages: list[str], show_execution: bool = False
+        self, packages: list[str], show_execution: bool = False
     ) -> None:

Then update call sites at lines 264-266 and 423-425.

Option 2: Keep for future use with prefix
     def _simulate_cortex_output(
-        self, command: str, packages: list[str], show_execution: bool = False
+        self, _command: str, packages: list[str], show_execution: bool = False
     ) -> None:
+        # TODO: Log command to history for audit purposes
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db70962 and 5768858.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide for Python code
Include type hints in Python code
Add docstrings for all public APIs in Python code
Use dry-run mode by default for all installation operations
Do not use silent sudo - require explicit user confirmation for privilege escalation
Implement Firejail sandboxing for execution of untrusted code
Log all operations to ~/.cortex/history.db for audit purposes

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/hardware_detection.py (1)
  • SystemInfo (135-174)
cortex/cli.py (1)
  • demo (271-275)
🔇 Additional comments (13)
cortex/demo.py (13)

1-17: LGTM!

Module docstring and imports are well-organized following PEP 8 import ordering (standard library → third-party → local).


19-26: LGTM!

The class initialization properly sets up the console, hardware info placeholder, interactive mode detection, and generates a demo installation ID. Type hints are present.


28-45: LGTM!

Helper methods are well-documented with appropriate type hints. The defensive str(model) cast in _is_gpu_vendor (line 44) is a good practice for handling potentially unexpected types.


47-105: LGTM!

The run() method is well-structured with proper error handling for user interrupts, clear section iteration, and consistent return codes. The try/except at the top level (lines 101-105) ensures graceful handling of Ctrl+C at any point.


107-117: LGTM!

Good implementation with proper interrupt handling and non-interactive auto-advance support for CI environments.


119-147: Good fix for the empty input UX issue.

The while True loop (lines 126-138) correctly addresses the reviewer feedback about empty input. Instead of showing misleading AI output, it now re-prompts with a helpful hint message.


149-151: Add return type hint for consistency.

The method is missing a return type annotation. As per coding guidelines, type hints should be included.

Suggested fix
     def _simulate_cortex_output(
         self, command: str, packages: list[str], show_execution: bool = False
-    ) -> None:
+    ) -> None:

Actually, looking again, line 151 does have -> None: but it's being parsed as part of the previous line. The signature appears correct. Let me verify the actual structure - the return type is present but formatted across lines.

Note: On closer inspection, the signature spans lines 149-151 and does include -> None:. The formatting is acceptable per PEP 8.


149-203: LGTM!

The simulated output correctly defaults to dry-run mode (line 173-177), showing the plan without execution. This aligns with the coding guideline to "use dry-run mode by default for all installation operations." The sudo commands are displayed but not executed, which is safe for a demo.


283-294: Good defensive GPU detection pattern.

The use of getattr(self.hw, "gpu", None) (line 284) and the safe list indexing pattern (line 285) prevents potential AttributeError or IndexError. The GPU vendor keyword extraction (lines 288-292) improves maintainability per the commit message refactoring.


380-439: LGTM!

The smart stacks section effectively demonstrates the feature with a clear table display and simulated installation. The tip about custom stacks (lines 436-437) adds educational value.


441-537: LGTM!

The history and safety section effectively demonstrates both features. Using the same installation_id from earlier (line 509, 512) provides narrative continuity through the demo.


539-599: LGTM!

The finale provides an effective summary with the comparison table and actionable next steps. The command reference (lines 584-592) gives users immediate practical guidance.


602-608: LGTM!

Clean entry point that maintains backward compatibility with the existing cortex demo CLI command while delegating to the new class-based implementation.

ShreeJejurikar and others added 2 commits January 13, 2026 14:28
- Remove non-existent docs.cortex.dev URL
- Remove unused command parameter from _simulate_cortex_output
- Remove emoji from comparison table title
Copy link
Collaborator

@Anshgrover23 Anshgrover23 left a comment

Choose a reason for hiding this comment

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

LGTM!

@sonarqubecloud
Copy link

Copy link
Contributor

@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

🤖 Fix all issues with AI agents
In @cortex/demo.py:
- Around line 75-76: Wrap the call to detect_hardware() in a try/except so
hardware-detection exceptions (e.g., PermissionError, OSError) are caught; on
failure set self.hw to a safe default (e.g., None) and emit a non-fatal warning
using the demo's logger (or print) so the demo doesn’t crash. Specifically,
around the detect_hardware() invocation that assigns self.hw, add exception
handlers for PermissionError and OSError (and a broad Exception fallback),
assign self.hw = None on error, and log the exception message via the class
logger (or a clear warning) so downstream code can proceed safely.
🧹 Nitpick comments (5)
cortex/demo.py (5)

22-26: Consider adding type hints for all instance attributes.

For consistency with self.hw: SystemInfo | None, consider adding explicit type hints for the other instance attributes. This improves IDE support and documentation.

🔧 Suggested improvement
     def __init__(self) -> None:
-        self.console = Console()
-        self.hw: SystemInfo | None = None
-        self.is_interactive = sys.stdin.isatty()
-        self.installation_id = self._generate_id()
+        self.console: Console = Console()
+        self.hw: SystemInfo | None = None
+        self.is_interactive: bool = sys.stdin.isatty()
+        self.installation_id: str = self._generate_id()

165-169: Consider dynamic package manager in simulation.

The intro (line 62) promises support for "apt, brew, npm, pip..." but the simulation always shows apt commands. For consistency, consider detecting the actual system's primary package manager or at least mentioning this is an apt-based example.

This is a minor UX polish suggestion - the current implementation works fine for demonstrating the concept.


280-281: Simplify GPU list check.

The check (gpu and len(gpu) > 0) can be simplified since a non-empty list is truthy in Python.

🔧 Suggested simplification
         # Detect GPU (check both dedicated and integrated)
         gpu = getattr(self.hw, "gpu", None) if self.hw else None
-        gpu_info = gpu[0] if (gpu and len(gpu) > 0) else None
+        gpu_info = gpu[0] if gpu else None

415-416: Minor: Redundant consecutive print calls.

These two print statements could be combined for cleaner output, though this is purely stylistic.

🔧 Optional consolidation
-        self.console.print(" [cyan]CX[/cyan]  [green]✓[/green] ")
-        self.console.print("🚀 Installing stack: [bold]Web Development[/bold]\n")
+        self.console.print(" [cyan]CX[/cyan]  [green]✓[/green] 🚀 Installing stack: [bold]Web Development[/bold]\n")

421-423: Minor: Similar redundant print calls.

Same pattern as above - consecutive prints could be consolidated.

🔧 Optional consolidation
-        self.console.print(" [cyan]CX[/cyan]  [green]✓[/green] ")
-        self.console.print("[green]✅ Stack 'Web Development' installed successfully![/green]")
-        self.console.print("[green]Installed 4 packages[/green]\n")
+        self.console.print(" [cyan]CX[/cyan]  [green]✓[/green] [green]✅ Stack 'Web Development' installed successfully![/green]")
+        self.console.print("[green]Installed 4 packages[/green]\n")
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5768858 and c089b74.

📒 Files selected for processing (1)
  • cortex/demo.py
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Follow PEP 8 style guide for Python code
Include type hints in Python code
Add docstrings for all public APIs in Python code
Use dry-run mode by default for all installation operations
Do not use silent sudo - require explicit user confirmation for privilege escalation
Implement Firejail sandboxing for execution of untrusted code
Log all operations to ~/.cortex/history.db for audit purposes

Files:

  • cortex/demo.py
🧬 Code graph analysis (1)
cortex/demo.py (3)
cortex/branding.py (1)
  • show_banner (35-46)
cortex/hardware_detection.py (1)
  • SystemInfo (135-174)
cortex/cli.py (2)
  • status (1006-1014)
  • demo (271-275)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build Package
  • GitHub Check: test (3.11)
  • GitHub Check: test (3.10)
  • GitHub Check: test (3.12)
🔇 Additional comments (5)
cortex/demo.py (5)

1-17: LGTM!

Module docstring and imports are appropriate. The imports align with the functionality needed for Rich-based UI, hardware detection, and branding.


28-45: LGTM!

Helper methods are well-documented with proper type hints and docstrings. The use of secrets.token_hex() for ID generation is appropriate for demo purposes.


119-147: LGTM - Empty input bug fixed!

The while True loop at lines 126-138 properly re-prompts the user when empty input is provided, addressing the UX bug mentioned in the PR comments. The hint message at line 134 guides users appropriately.


533-534: Add return type hint for consistency.

For consistency with other methods in the class, consider adding the -> None return type hint.

🔧 Suggested fix
-    def _show_finale(self) -> None:
+    def _show_finale(self) -> None:

Actually, line 533 already has -> None. Disregard this comment.


595-601: LGTM!

The run_demo() entry point properly delegates to the CortexDemo class while maintaining the same public API signature. The docstring adequately describes the function's purpose.

@Anshgrover23 Anshgrover23 merged commit 5413bec into cortexlinux:main Jan 13, 2026
17 checks passed
Kesavaraja67 pushed a commit to Kesavaraja67/cortex that referenced this pull request Jan 13, 2026
* feat: Complete interactive demo with 6 sections

- Smart installation with transparent planning phase
- Hardware-aware intelligence demonstrations
- AI natural language understanding
- Smart stacks workflow (list and install)
- Installation history tracking
- Rollback protection demonstration
- Comparison table finale showing key differentiators
- Clear screen between sections for better UX
- ~5 minute interactive tutorial
- Matches actual Cortex output with CX branding

Users type real commands to build muscle memory.
Accepts any input for learning (no validation friction).

Closes cortexlinux#366

* style: format with ruff and black

* Update demo.py

* style: add trailing newline to demo.py

* fix: Use secrets module for demo ID generation (SonarQube)

* fix(demo): address code review feedback

- Remove unused Optional import
- Remove "Production Version" from docstring
- Replace hardcoded dates with dynamic date generation
- Replace hardcoded installation IDs with generated IDs

* fix(demo): address code review feedback

- Remove unused rich.progress imports (BarColumn, Progress, SpinnerColumn, TextColumn)
- Add return type hints (-> None) to clear_screen() and _simulate_cortex_output()
- Use gpu_info consistently instead of gpu[0] (lines 288, 316, 331)
- Fix duplicate timestamps: changed second entry from (1, 13, 13) to (1, 14, 25)

All issues from code review are now resolved.

* fix(demo): improve empty input message to reference the command being shown

* fix(demo): address code review feedback

- Use SystemInfo type hint instead of generic object
- Replace empty CX line with simple spacing

* refactor(demo): improve GPU detection code quality

- Add _is_gpu_vendor() helper method to reduce code duplication
- Use defensive getattr() for GPU attribute access
- Extract GPU vendor keywords into named lists for clarity

* fix(demo): address additional code review feedback

- Remove non-existent docs.cortex.dev URL
- Remove unused command parameter from _simulate_cortex_output
- Remove emoji from comparison table title

---------

Co-authored-by: Ansh Grover <168731971+Anshgrover23@users.noreply.github.com>
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.

[FEATURE] Enhance cortex demo - Interactive tutorial with real commands

4 participants