Skip to content

feat: Add chatbot help assistant widget (#180)#289

Open
OmkarAKadam wants to merge 4 commits into
GitMetricsLab:mainfrom
OmkarAKadam:feature/chatbot-widget
Open

feat: Add chatbot help assistant widget (#180)#289
OmkarAKadam wants to merge 4 commits into
GitMetricsLab:mainfrom
OmkarAKadam:feature/chatbot-widget

Conversation

@OmkarAKadam
Copy link
Copy Markdown

@OmkarAKadam OmkarAKadam commented May 17, 2026

🏷️ Program
GSSOC 2026

  • Add ChatbotWidget component with floating bubble UI
  • Add chatbotData.ts with FAQ knowledge base
  • Covers GitHub token help, setup guide, MongoDB, tests, and features
  • Quick question buttons for common queries
  • No external dependencies required

Related Issue


Description

Adds a floating chatbot help assistant to the bottom-right corner of the app.
It uses keyword-based FAQ matching to answer common user questions about GitHub
token generation, project setup, MongoDB configuration, Jasmine testing, and
app features. No external API keys or dependencies required — pure React + TypeScript.


How Has This Been Tested?

Manually tested the following queries in the browser at http://localhost:5173:

  • "How do I get a GitHub token?" → correct token steps ✅
  • "mongodb not connecting" → correct .env fix ✅
  • "what does this app do" → full features overview ✅
  • "pizza recipe" (unknown input) → graceful fallback message ✅
  • Quick question buttons → all trigger correct responses ✅
  • Close and reopen bubble → works correctly ✅

Screenshots (if applicable)

image

Type of Change

  • Bug fix
  • New feature
  • Code style update
  • Breaking change
  • Documentation update

Summary by CodeRabbit

  • New Features
    • Floating chatbot widget with toggle button to open/close a fixed chat window
    • Initial greeting message and suggested quick-question buttons to get started
    • Keyword-based FAQ responses with fallback suggestions when unsure
    • Typed avatars and role-based message styling for user vs bot
    • Blinking typing indicator while the bot is preparing a reply
    • Auto-scroll keeps latest messages visible
    • Send messages via Enter key or send button (disabled when input is empty)

Review Change Stack

- Add ChatbotWidget component with floating bubble UI
- Add chatbotData.ts with FAQ knowledge base
- Covers GitHub token help, setup guide, MongoDB, tests, and features
- Quick question buttons for common queries
- No external dependencies required
@netlify
Copy link
Copy Markdown

netlify Bot commented May 17, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 681d02c
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a0a0304f84273000849c3bb
😎 Deploy Preview https://deploy-preview-289--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Warning

Rate limit exceeded

@OmkarAKadam has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 46 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d79c538-f049-41fa-9253-2ac118fc4152

📥 Commits

Reviewing files that changed from the base of the PR and between 090b1f7 and 681d02c.

📒 Files selected for processing (1)
  • src/components/Chatbot/ChatbotWidget.tsx
📝 Walkthrough

Walkthrough

Adds an in-app FAQ chatbot: keyword-based responder and default greeting, a ChatbotWidget with markdown-like rendering, quick-question shortcuts, UI for a floating chat window with typing indicator, and App-level integration rendering the widget before the Toaster.

Changes

Chatbot Widget Feature

Layer / File(s) Summary
FAQ content and response logic
src/components/Chatbot/chatbotData.ts
FAQ interface and dataset covering setup, tokens, MongoDB, tests, features, auth, contribution, and tech stack. Default greeting lists available topics. getBotResponse normalizes input, matches keywords against FAQs, returns matching answers, or a fallback suggesting topics and a GitHub issues link.
Message rendering and state management
src/components/Chatbot/ChatbotWidget.tsx (lines 1–200)
Helpers format timestamps and transform bot messages into JSX (fenced code blocks, lists, table-like rows, bold, inline code, links). ChatbotWidget initializes with defaultMessage, manages open/messages/input/typing/id state, auto-scrolls, and implements sendMessage to append user messages and schedule delayed bot responses via getBotResponse.
ChatbotWidget UI structure and message display
src/components/Chatbot/ChatbotWidget.tsx (lines 202–509)
Floating toggle button opens a fixed-position chat window with header and close control. Scrollable message list shows role-based bubbles (user right/blue, bot left/white), avatars, timestamps, and a blinking typing indicator. Quick-question buttons appear when only the initial message is present and schedule user+bot exchanges. Input bar supports Enter-to-submit and a send button enabled when trimmed input is non-empty.
App-level integration
src/App.tsx
ChatbotWidget is imported and rendered immediately before Toaster in the app render tree, exposing the chatbot at the root level.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A chatbot hops into the app with flair,
FAQ whispers answered with a friendly stare,
Quick buttons nudge curious minds along,
Markdown replies hum a tiny helpful song,
A little robot guide to keep support light and fair.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding a chatbot widget to the application, which matches the core functionality in the PR.
Description check ✅ Passed The description follows the repository template with all required sections: Related Issue, Description, How Has This Been Tested, Screenshots, and Type of Change selection.
Linked Issues check ✅ Passed The PR fully addresses issue #180 by implementing a chatbot that answers user questions about app features, GitHub token generation, setup, MongoDB, and testing—all primary objectives from the issue.
Out of Scope Changes check ✅ Passed All changes are directly related to adding the chatbot widget as specified in issue #180. Security improvements (URL validation) and code quality fixes (stable ID generation, typing corrections) are legitimate enhancements within the chatbot feature scope.

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

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

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
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

🎉 Thank you @OmkarAKadam for your contribution. Please make sure your PR follows https://github.com/GitMetricsLab/github_tracker/blob/main/CONTRIBUTING.md#-pull-request-guidelines

Copy link
Copy Markdown
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: 2

🧹 Nitpick comments (1)
src/components/Chatbot/ChatbotWidget.tsx (1)

420-434: ⚡ Quick win

Refactor quick question handler to reuse sendMessage logic.

The quick question click handler duplicates the message-sending logic from sendMessage. Extracting this into a reusable function would improve maintainability and reduce the risk of inconsistencies.

♻️ Proposed refactor
+  const sendUserMessage = (text: string) => {
+    const userMsg: Message = { id: Date.now(), role: "user", text, time: getTime() };
+    setMessages((prev) => [...prev, userMsg]);
+    setTyping(true);
+
+    setTimeout(() => {
+      const botReply = getBotResponse(text);
+      setMessages((prev) => [
+        ...prev,
+        { id: Date.now() + 1, role: "bot", text: botReply, time: getTime() },
+      ]);
+      setTyping(false);
+    }, 700);
+  };
+
   const sendMessage = () => {
     const trimmed = input.trim();
     if (!trimmed) return;
-
-    const userMsg: Message = { id: Date.now(), role: "user", text: trimmed, time: getTime() };
-    setMessages((prev) => [...prev, userMsg]);
     setInput("");
-    setTyping(true);
-
-    setTimeout(() => {
-      const botReply = getBotResponse(trimmed);
-      setMessages((prev) => [
-        ...prev,
-        { id: Date.now() + 1, role: "bot", text: botReply, time: getTime() },
-      ]);
-      setTyping(false);
-    }, 700);
+    sendUserMessage(trimmed);
   };

   // ...

   <button
     key={q}
     onClick={() => {
-      setInput(q);
-      setTimeout(() => {
-        const userMsg: Message = { id: Date.now(), role: "user", text: q, time: getTime() };
-        setMessages((prev) => [...prev, userMsg]);
-        setInput("");
-        setTyping(true);
-        setTimeout(() => {
-          setMessages((prev) => [
-            ...prev,
-            { id: Date.now() + 1, role: "bot", text: getBotResponse(q), time: getTime() },
-          ]);
-          setTyping(false);
-        }, 700);
-      }, 0);
+      sendUserMessage(q);
     }}
🤖 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 `@src/components/Chatbot/ChatbotWidget.tsx` around lines 420 - 434, The onClick
quick-question handler in ChatbotWidget.tsx duplicates message creation and
bot-response logic found in sendMessage; replace the duplicated sequence
(setInput, setMessages adding userMsg, setTyping, adding bot response using
getBotResponse and getTime) by calling the existing sendMessage function or
extract a small helper used by both; ensure the helper or sendMessage accepts
the quick question string (q), still creates a Message object (type Message),
updates setMessages, clears setInput, toggles setTyping, and appends the bot
response (using getBotResponse and getTime) so behavior remains identical and
DRY.
🤖 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 `@src/components/Chatbot/ChatbotWidget.tsx`:
- Around line 170-179: Replace the Date.now() IDs with a stable incrementing
counter: add a messageIdRef (e.g., const messageIdRef = useRef(0)) in the
ChatbotWidget component and use messageIdRef.current++ to assign ids for the
userMsg and bot reply (replace the Date.now() and Date.now()+1 usages where
userMsg is created and where the bot reply is appended via setMessages and also
in the quick questions handler occurrences referenced in the comment); ensure
the counter is used consistently for every message append so keys remain unique
and do not trigger unnecessary React re-renders.
- Around line 134-145: In ChatbotWidget (where parts.push creates the <a> using
match[3] and match[4]), validate the href before rendering: parse or normalize
match[4], lower-case its scheme and allow only safe schemes (e.g., http, https,
mailto) and reject dangerous schemes like javascript: or data:; if the URL is
invalid or uses a disallowed scheme, render the link text as plain text (using
match[3]) or omit the anchor instead of assigning match[4] to href. Update the
logic around the parts.push(...) anchor creation to perform this check and
branch accordingly.

---

Nitpick comments:
In `@src/components/Chatbot/ChatbotWidget.tsx`:
- Around line 420-434: The onClick quick-question handler in ChatbotWidget.tsx
duplicates message creation and bot-response logic found in sendMessage; replace
the duplicated sequence (setInput, setMessages adding userMsg, setTyping, adding
bot response using getBotResponse and getTime) by calling the existing
sendMessage function or extract a small helper used by both; ensure the helper
or sendMessage accepts the quick question string (q), still creates a Message
object (type Message), updates setMessages, clears setInput, toggles setTyping,
and appends the bot response (using getBotResponse and getTime) so behavior
remains identical and DRY.
🪄 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: c8209adf-95e8-4ea7-acae-2cd33b1ab064

📥 Commits

Reviewing files that changed from the base of the PR and between 88cfa1d and 54bd662.

📒 Files selected for processing (3)
  • src/App.tsx
  • src/components/Chatbot/ChatbotWidget.tsx
  • src/components/Chatbot/chatbotData.ts

Comment thread src/components/Chatbot/ChatbotWidget.tsx Outdated
Comment thread src/components/Chatbot/ChatbotWidget.tsx Outdated
- Add URL validation to prevent unsafe href schemes
- Replace Date.now() IDs with stable useRef counter
- Fix JSX.Element[] type to ReactNode[]
@OmkarAKadam
Copy link
Copy Markdown
Author

Hi @coderabbitai, addressed all review suggestions:

  • ✅ Added URL validation to reject unsafe href schemes (javascript:, data:)
  • ✅ Replaced Date.now() IDs with stable useRef counter (nextId)
  • ✅ Fixed JSX.Element[] type to ReactNode[]

Ready for re-review!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

The PR description image shows the GitHub Tracker homepage at localhost:5173 with the chatbot widget open — displaying the "GitHub Tracker Assistant" panel with help topics, a sample conversation ("How do I get a GitHub token?"), and the response beginning with navigation steps. The floating close/open button is visible in the bottom-right corner.


@OmkarAKadam Thanks for addressing all three concerns! Great to see the security fix (blocking javascript: / data: href schemes), the stable ID generation via useRef, and the corrected ReactNode[] typing all landed. Triggering a fresh review now to verify the updated code.

🐇✨

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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

🤖 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 `@src/components/Chatbot/ChatbotWidget.tsx`:
- Around line 470-484: The input in ChatbotWidget.tsx currently removes the
browser outline (inline style on the <input> near setInput/handleKey) and
provides no replacement focus indicator; restore an accessible visible focus
state by replacing outline: "none" with an explicit focus style (either add a
focused inline style or a CSS class) that shows a clear high-contrast
ring/box-shadow or border change on :focus (e.g. a 2px solid or visible
box-shadow using the purple accent color) so keyboard users can see focus on the
input control.
- Around line 240-257: The fixed-size chat container in ChatbotWidget.tsx (the
inline style on the main div) can be clipped on small viewports; change the
sizing to be responsive by replacing the hard width/height with viewport-aware
constraints—e.g., set width to a responsive expression like using maxWidth/min
with the current 360px fallback (so it never exceeds available screen width
minus margins) and set maxHeight relative to 100vh (or use calc(100vh - safe
margins)) so the widget shrinks on short screens; keep the existing right/bottom
offsets but consider using safe-area insets for mobile; update the inline style
in the div within ChatbotWidget.tsx accordingly.
- Around line 191-193: The Enter key handler handleKey currently calls
sendMessage on every Enter press and should ignore Enter events generated while
an IME composition is active; update handleKey
(React.KeyboardEvent<HTMLInputElement> e) to check e.nativeEvent.isComposing and
return early if true, then only call sendMessage() when
!e.nativeEvent.isComposing and e.key === "Enter" to avoid submitting partial IME
compositions.
🪄 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: fa66416e-9d1e-45bf-a502-4cc38e730c12

📥 Commits

Reviewing files that changed from the base of the PR and between 54bd662 and 090b1f7.

📒 Files selected for processing (2)
  • src/App.tsx
  • src/components/Chatbot/ChatbotWidget.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/App.tsx

Comment thread src/components/Chatbot/ChatbotWidget.tsx Outdated
Comment thread src/components/Chatbot/ChatbotWidget.tsx
Comment thread src/components/Chatbot/ChatbotWidget.tsx
@OmkarAKadam
Copy link
Copy Markdown
Author

@coderabbitai Addressed all 3 suggestions:

✅ IME fix — added !e.nativeEvent.isComposing check to prevent Enter submission during active composition
✅ Responsive sizing — replaced fixed 360px/560px with min(360px, calc(100vw - 32px)) and min(560px, calc(100vh - 120px))
✅ Focus visibility — added onFocus/onBlur handlers to show a visible focus ring on the input field

Ready for re-review!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

The PR description image shows the GitHub Tracker homepage at localhost:5173 with the chatbot widget open — a dark-themed "GitHub Tracker Assistant" panel with the help topic list, a sample conversation ("How do I get a GitHub token?" → bot response with a GitHub Settings link), and the "Ask me anything..." input field. The floating close button (blue circle with ✕) is visible in the bottom-right corner.


@OmkarAKadam Great follow-up round! All three fixes look like meaningful improvements:

  • IME fix!e.nativeEvent.isComposing is exactly the right guard to prevent premature Enter submission for CJK/IME users.
  • Responsive sizingmin(360px, calc(100vw - 32px)) / min(560px, calc(100vh - 120px)) ensures the widget doesn't overflow on small or narrow viewports.
  • Focus visibilityonFocus/onBlur handlers for a visible focus ring is an important keyboard accessibility improvement.

Triggering a fresh review now! 🐇✨

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@OmkarAKadam
Copy link
Copy Markdown
Author

Hi @mehul-m-prajapati, PR #289 is ready for your review!

The chatbot is fully implemented, all CodeRabbit review suggestions have been addressed (security, accessibility, responsive design), and all checks are passing. Would appreciate a look when you get a chance. Thanks!

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.

🚀 Feature: we can add one chatbot here which will answer the questions from user

1 participant