Skip to content

Refactor/apexai component architecture#51

Closed
YASHcode-IIITV wants to merge 3 commits into
kunalverma2512:mainfrom
YASHcode-IIITV:refactor/apexai-component-architecture
Closed

Refactor/apexai component architecture#51
YASHcode-IIITV wants to merge 3 commits into
kunalverma2512:mainfrom
YASHcode-IIITV:refactor/apexai-component-architecture

Conversation

@YASHcode-IIITV
Copy link
Copy Markdown

@YASHcode-IIITV YASHcode-IIITV commented May 15, 2026

Summary

closes #33

Refactored the ApexAI page into reusable, modular components to improve maintainability, readability, and scalability. The original monolithic ApexAIPage.jsx was split into smaller UI-focused components while preserving the existing functionality, design language, and chat flow behavior.

Changes Made

Extracted Components

  • HeroSection.jsx
  • BottomCTA.jsx
  • QuickCommands.jsx
  • SessionStats.jsx
  • MessageBubble.jsx
  • LoadingIndicator.jsx
  • ChatInput.jsx
  • ChatWindow.jsx

Refactor Improvements

  • Simplified ApexAIPage.jsx structure significantly
  • Improved component separation and readability
  • Centralized state handling while moving UI into reusable components
  • Preserved existing chat functionality and interactions
  • Maintained existing brutalist design system and styling
  • Kept responsiveness and layout behavior intact across screen sizes

Type of Change

  • Bug fix
  • Refactor
  • New feature
  • Documentation update
  • Tests
  • Infra / CI

Testing Done

  • Verified chat input and message flow
  • Verified quick command interactions
  • Verified loading state rendering
  • Verified session stats updates
  • Verified responsive layout behavior
  • Verified no UI regressions after component extraction

Notes

This refactor focuses on architectural cleanup and component modularization without changing the core user experience or business logic.

Summary by CodeRabbit

  • New Features

    • Introduced new AI chat interface components including hero section, quick command prompts, session statistics display, interactive chat window with message bubbles, and enhanced text input form.
  • Refactor

    • Restructured the AI page architecture to use modular components for improved code organization and maintainability.

Review Change Stack

https://drive.google.com/drive/folders/1RjownaQYocTx8chHb5r77nNfYrCpmUaE?usp=drive_link

@github-actions
Copy link
Copy Markdown

🚀 PR Received Successfully

Hello @YASHcode-IIITV,

Thank you for taking the initiative to contribute to this project.

Please ensure that your PR follows all project guidelines properly before requesting review.

⚠️ Important Instructions

  • Maintain proper code quality and structure
  • Do not make unnecessary changes/files
  • Ensure responsiveness across devices
  • Follow existing project conventions strictly
  • Attach screenshots/videos for UI-related changes
  • Resolve merge conflicts before requesting review
  • Avoid AI-generated low quality PRs or copied implementations

📌 Mandatory for GSSoC'26 Participants

Joining the community group and announcement channel is compulsory for all contributors participating through GSSoC'26.

Failure to follow contribution guidelines may lead to PR rejection.

We appreciate your effort and wish you a great open-source journey ahead. ✨

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

📝 Walkthrough

Walkthrough

This PR extracts an overgrown monolithic ApexAIPage into eight reusable presentational components organized in a dedicated ai folder. The page now composes these components while retaining its chat simulation logic, state management, and styled-JSX styling layer without functional changes.

Changes

Component Extraction and Page Integration

Layer / File(s) Summary
Hero Section Component
frontend/src/components/ai/HeroSection.jsx
HeroSection renders a static hero layout with left-column headline, metrics, and right-column feature grid using Tailwind classes; accepts no props.
Chat Interface Components
frontend/src/components/ai/ChatWindow.jsx, frontend/src/components/ai/MessageBubble.jsx, frontend/src/components/ai/ChatInput.jsx, frontend/src/components/ai/LoadingIndicator.jsx
ChatWindow displays scrollable message list with status header and refs for scroll control; MessageBubble styles user/assistant messages with conditional colors and timestamp formatting; ChatInput renders controlled form with disabled states tied to isLoading and input trim; LoadingIndicator shows three pulsing dots with staggered delays.
Session Interaction Panels
frontend/src/components/ai/QuickCommands.jsx, frontend/src/components/ai/SessionStats.jsx
QuickCommands maps prompt array into clickable buttons with handler invocation; SessionStats filters messages by type to count queries/insights and toggles status label between "ANALYZING" and "READY".
Bottom Call-to-Action Section
frontend/src/components/ai/BottomCTA.jsx
BottomCTA renders a black full-width section with headline, description text, and two action buttons.
ApexAIPage Refactoring
frontend/src/pages/ApexAIPage.jsx
Imports new component modules; removes inline hero/chat/CTA JSX; wires state and handlers (messages, isLoading, inputValue, setInputValue, handleSendMessage, quickPrompts, handleQuickPrompt, refs) to child component props; preserves message simulation logic with response object templating; maintains styled-JSX custom scrollbar and animation-delay utilities; replaces large layout blocks with clean component composition.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A hero section hops away,
Chat bubbles skip and dance and play,
Quick commands bound in panels bright,
One page becomes components light—
Modular dreams of code so neat!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive Title is vague and overly broad—'Refactor/apexai component architecture' lacks specificity about the main accomplishment or which components are being refactored. Consider a more descriptive title such as 'Extract ApexAIPage into modular reusable components' or 'Modularize ApexAI page architecture' to clearly convey the primary change.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR successfully addresses all primary objectives from #33: extracted 8 modular components, improved code organization, maintained core functionality and chat flow, and preserved design language and responsiveness.
Out of Scope Changes check ✅ Passed All changes are scoped to component extraction and refactoring as specified in #33; no unrelated modifications or functionality changes are present.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@YASHcode-IIITV
Copy link
Copy Markdown
Author

so i have joined the channel and the group as mentioned .

Copy link
Copy Markdown

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
frontend/src/pages/ApexAIPage.jsx (1)

44-71: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Clear pending simulated-response timer on unmount.

Line 60 creates a timeout that can still fire after unmount and attempt stale state updates (setMessages, setIsLoading). Add timeout tracking + cleanup.

Suggested fix
 import { useState, useRef, useEffect } from "react";
@@
   const messagesEndRef = useRef(null);
   const messagesContainerRef = useRef(null);
+  const responseTimeoutRef = useRef(null);
@@
+  useEffect(() => {
+    return () => {
+      if (responseTimeoutRef.current) {
+        window.clearTimeout(responseTimeoutRef.current);
+      }
+    };
+  }, []);
+
   const handleSendMessage = async (e) => {
     e.preventDefault();
@@
-    setTimeout(() => {
+    if (responseTimeoutRef.current) {
+      window.clearTimeout(responseTimeoutRef.current);
+    }
+
+    responseTimeoutRef.current = window.setTimeout(() => {
       const aiResponse = {
         id: Date.now() + 1,
         type: "assistant",
@@
       setMessages((prev) => [...prev, aiResponse]);
       setIsLoading(false);
     }, 1500);
   };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/pages/ApexAIPage.jsx` around lines 44 - 71, The simulated
response timer in handleSendMessage uses setTimeout and can fire after the
component unmounts, causing stale state updates; fix this by tracking the
timeout id (e.g., add a pendingTimeoutRef via useRef and assign
pendingTimeoutRef.current = setTimeout(...)) and clear any existing timeout
before creating a new one, then add a useEffect cleanup that calls
clearTimeout(pendingTimeoutRef.current) and sets pendingTimeoutRef.current =
null on unmount so the delayed callback won't run and try to call setMessages or
setIsLoading after unmount.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@frontend/src/components/ai/ChatInput.jsx`:
- Around line 13-20: The input in ChatInput.jsx currently uses placeholder text
as its accessible name; add an explicit accessible label by adding an aria-label
(e.g. aria-label="Chat input" or more specific) to the <input> element (the one
using value={inputValue}, onChange={e => setInputValue(e.target.value)} and
disabled={isLoading}) or alternatively create a <label htmlFor="chat-input"> and
give the input id="chat-input" so assistive tech consistently identifies the
field.

In `@frontend/src/components/ai/LoadingIndicator.jsx`:
- Around line 3-11: The loading indicator is visual-only; update the
LoadingIndicator component to expose state to assistive tech by adding
role="status" and aria-live="polite" to the top-level container (the outer <div>
that currently has className="flex justify-start") and include a visually hidden
text node such as "Processing…" inside that container so screen-readers receive
feedback; ensure the hidden text uses a utility class or inline styles that keep
it off-screen but accessible (e.g., sr-only) and do not remove it from the
accessibility tree.

---

Outside diff comments:
In `@frontend/src/pages/ApexAIPage.jsx`:
- Around line 44-71: The simulated response timer in handleSendMessage uses
setTimeout and can fire after the component unmounts, causing stale state
updates; fix this by tracking the timeout id (e.g., add a pendingTimeoutRef via
useRef and assign pendingTimeoutRef.current = setTimeout(...)) and clear any
existing timeout before creating a new one, then add a useEffect cleanup that
calls clearTimeout(pendingTimeoutRef.current) and sets pendingTimeoutRef.current
= null on unmount so the delayed callback won't run and try to call setMessages
or setIsLoading after unmount.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 392174db-048e-4658-96cb-763163504f8c

📥 Commits

Reviewing files that changed from the base of the PR and between 12e4428 and 8d00ba7.

📒 Files selected for processing (9)
  • frontend/src/components/ai/BottomCTA.jsx
  • frontend/src/components/ai/ChatInput.jsx
  • frontend/src/components/ai/ChatWindow.jsx
  • frontend/src/components/ai/HeroSection.jsx
  • frontend/src/components/ai/LoadingIndicator.jsx
  • frontend/src/components/ai/MessageBubble.jsx
  • frontend/src/components/ai/QuickCommands.jsx
  • frontend/src/components/ai/SessionStats.jsx
  • frontend/src/pages/ApexAIPage.jsx

Comment thread frontend/src/components/ai/ChatInput.jsx
Comment thread frontend/src/components/ai/LoadingIndicator.jsx
Copy link
Copy Markdown
Author

@YASHcode-IIITV YASHcode-IIITV left a comment

Choose a reason for hiding this comment

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

all the commits has been resolved as per the bot review .

@kunalverma2512
Copy link
Copy Markdown
Owner

kunalverma2512 commented May 15, 2026

@YASHcode-IIITV attach video for the work done and also show those files and folders and their codes in that
attach drive link with access to my email

@kunalverma2512
Copy link
Copy Markdown
Owner

@coderabbitai

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Tip

For best results, initiate chat on the files or code changes.

@kunalverma2512 — It looks like you tagged me without a specific request. Here's a quick summary of PR #51 to help with your review:


PR #51 Review Summary — Refactor/ApexAI Component Architecture

✅ What was done well

  • Clean decomposition: The monolithic ApexAIPage.jsx (~209 lines removed, ~45 added) was broken into 8 focused components (HeroSection, BottomCTA, QuickCommands, SessionStats, MessageBubble, LoadingIndicator, ChatInput, ChatWindow), each with a single responsibility.
  • State managed centrally: All state (messages, isLoading, inputValue, refs) stays in ApexAIPage.jsx and is passed down as props — correct approach.
  • No functional regressions reported: Chat flow, quick commands, loading states, and session stats all preserved.

⚠️ Observations / Things to verify

  1. BottomCTA.jsx is fully static — buttons ("Activate APEX Free", "View Capabilities") have no onClick handlers. If they're meant to navigate or trigger actions, this needs wiring.
  2. HeroSection.jsx has no props — all content is hardcoded. If any text/metrics need to be dynamic in the future, it may need refactoring again.
  3. MessageBubble.jsx uses message.type to decide alignment. Make sure the type values ("user" vs "assistant") are consistent everywhere messages is populated in ApexAIPage.jsx.
  4. No PropTypes or TypeScript types — consider adding prop validation for maintainability, especially on components like ChatInput, SessionStats, and QuickCommands that accept multiple props.
  5. ChatWindow.jsx header switches between "Analyzing" and "Ready" based on isLoading — verify this is visually tested on slow network/long AI response scenarios.

Let me know if you'd like me to do a full detailed review, check a specific file, or help with anything else! 🐇

@kunalverma2512
Copy link
Copy Markdown
Owner

@YASHcode-IIITV rename the folder currently named ai to something more semantic and meaningful, such as apexai.

@kunalverma2512
Copy link
Copy Markdown
Owner

@YASHcode-IIITV update ?

@YASHcode-IIITV
Copy link
Copy Markdown
Author

YASHcode-IIITV commented May 16, 2026

@kunalverma2512 so can you send me your email , and also like what should the video consist of ?

@kunalverma2512
Copy link
Copy Markdown
Owner

@YASHcode-IIITV try to make your PR better by attaching video via drive link showcasing your work

@YASHcode-IIITV
Copy link
Copy Markdown
Author

@kunalverma2512 ok i am currently making the video showcasing the 8 files that i have made and running the application on the same time . and then attaching the link of drive containing the video with the pr .

@YASHcode-IIITV
Copy link
Copy Markdown
Author

@kunalverma2512 added the link of the video via drive .

@kunalverma2512
Copy link
Copy Markdown
Owner

give access to my mail
check my portfolio - their you will get

@YASHcode-IIITV
Copy link
Copy Markdown
Author

given the access as well

@kunalverma2512
Copy link
Copy Markdown
Owner

@YASHcode-IIITV where the UI showcasing ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor ApexAIPage.jsx into Modular Reusable Components with Improved Responsive Architecture

2 participants