Skip to content

Conversation

@ShreeJejurikar
Copy link
Collaborator

@ShreeJejurikar ShreeJejurikar commented Dec 26, 2025

Summary

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

Changes

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)

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

Closes #366

- 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

Replaces the procedural demo with a new class-based interactive tutorial: adds CortexDemo with a multi-section run flow, hardware-aware behavior, simulated Cortex I/O and richer UI; run_demo() now delegates to CortexDemo.run(). Also a tiny string-format tweak in cortex/dependency_check.py.

Changes

Cohort / File(s) Summary
Interactive Demo
cortex/demo.py
Added CortexDemo class and public run() entry; moved demo flow into methods (initialization, _section_ai_intelligence, _section_smart_stacks, _section_history_safety, _show_finale), plus helpers (clear_screen, _generate_id, _wait_for_user, _prompt_command, _simulate_cortex_output) and richer UI components. Handles hardware detection (GPU/NVIDIA/AMD/CPU) and captures KeyboardInterrupt/EOFError. run_demo() now delegates to CortexDemo().run().
Minor formatting tweak
cortex/dependency_check.py
Adjusted string join delimiter spacing in format_installation_instructions (stylistic only).

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant D as CortexDemo
    participant H as HardwareDetector
    participant O as SimulatedCortexOutput

    U->>D: start/run()
    D->>H: detect_hardware()
    H-->>D: hardware info (GPU/CPU,NVIDIA/AMD)
    D->>U: render intro & prompts (sections)
    alt user enters command
        U->>D: command input (install/ask/stack)
        D->>O: _simulate_cortex_output(command, packages)
        O-->>D: simulated plan/output
        D->>U: display plan, prompts (hint/skip)
    else user interrupts
        U->>D: Ctrl+C / EOF
        D-->>U: handle interruption, return non-zero
    end
    D->>U: show finale & next steps
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • mikejmorgan-ai
  • Sahilbhatane

Poem

🐰 Hop, hop — a demo reborn,
I guide you through prompts at dawn.
Type a command, watch plans align,
Cortex dances, step by line.
✨🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description covers the Summary and Changes sections comprehensively, with detailed before/after comparison, sections overview, key features, and testing validation. However, the required Checklist section is missing. Add the required Checklist section with checkboxes for tests passing, MVP label if applicable, and help updates.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: converting the demo into a complete interactive tutorial with 6 sections, directly addressing the PR's core objective.
Linked Issues check ✅ Passed Code changes implement all required objectives from #366: 6 interactive sections (Planning/Safety, Hardware-Aware Intelligence, Natural Language AI, Smart Stacks, History Tracking, Rollback Protection), real command syntax, zero validation, CX branding, clear-screen transitions, comparison table finale, and non-interactive CI mode.
Out of Scope Changes check ✅ Passed Changes are tightly scoped to cortex/demo.py (main PR focus) and cortex/dependency_check.py (minor stylistic fix unrelated to scope); all changes align with #366 objectives to replace hardware-check demo with interactive 6-section tutorial.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
✨ 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
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.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

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.

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

1 participant