Skip to content

feat: Enhanced GitHub username input page,added loading state,handled…#557

Merged
mehul-m-prajapati merged 2 commits into
GitMetricsLab:mainfrom
AnishCoder2006:feature/github-AnishCoder2006
May 31, 2026
Merged

feat: Enhanced GitHub username input page,added loading state,handled…#557
mehul-m-prajapati merged 2 commits into
GitMetricsLab:mainfrom
AnishCoder2006:feature/github-AnishCoder2006

Conversation

@AnishCoder2006
Copy link
Copy Markdown
Contributor

@AnishCoder2006 AnishCoder2006 commented May 27, 2026

Closes: #519

Description:
Added interactive GitHub username tracking to the Activity page.

Changes in src/pages/Activity.tsx:

Added username input field

Added “Track Activity” button

Improved responsive input layout and page spacing

Tracks submitted GitHub username instead of fixed demo user

Changes in src/components/ActivityFeed.tsx:

Added loading state UI

Added empty state and error state handling

Improved activity card layout and consistency with existing theme

Testing:

Verified both updated files compile without TypeScript/JSX errors

Confirmed Activity page renders correctly and responds to username submissions

Type of Change:

New feature

UI/UX improvement

Summary by CodeRabbit

  • New Features

    • Users can now search for GitHub activity by entering a username, replacing the fixed hard-coded profile.
    • Added loading indicators and error messages for network failures and invalid data.
  • Bug Fixes

    • Enhanced validation and error handling for API responses (404, 403 scenarios).
    • Improved empty-state messaging and data safety checks.
  • Style

    • Updated UI styling and activity feed display (capped at 10 events).

Review Change Stack

… error conditions and Improved Activity page spacing tracking
@netlify
Copy link
Copy Markdown

netlify Bot commented May 27, 2026

Deploy Preview for github-spy failed.

Name Link
🔨 Latest commit 4b3e294
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a1c0afc0842110007a4e215

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@mehul-m-prajapati, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 54 minutes and 31 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5fcff01f-ad51-40ce-9b18-ba038f8e9f6a

📥 Commits

Reviewing files that changed from the base of the PR and between 286b724 and 4b3e294.

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

Walkthrough

Activity page gains a controlled username input form that trims and validates user entries before passing the username to ActivityFeed. ActivityFeed now validates non-empty usernames, checks GitHub API response status codes with 404/403 differentiation, guards against non-array JSON, and renders loading, error, and capped event-list states with updated styling.

Changes

Activity Tracking with User Input

Layer / File(s) Summary
Error state and fetch validation
src/components/ActivityFeed.tsx
ActivityFeed adds error state and enhances fetchEvents to validate non-empty username before GitHub calls, check res.ok with 404/403-specific messaging, guard against non-array JSON responses, and set user-facing connectivity errors on all failure paths.
ActivityFeed UI with error and loading states
src/components/ActivityFeed.tsx
Layout conditionally renders loading spinners, error messages, and empty-state text; introduces currentEvents to cap the list at 10 items; and updates Tailwind styling and event type labels throughout the card rendering.
Activity page username input form
src/pages/Activity.tsx
Replaces hard-coded "octocat" username with a stateful controlled form input. Component tracks query and trackedUsername, validates/trims input on submit before updating state, and passes trackedUsername to ActivityFeed. Container and heading classes adjusted for the form-driven layout.

Sequence Diagram

sequenceDiagram
  participant User
  participant ActivityForm as Activity Page Form
  participant ActivityFeed as ActivityFeed Component
  participant GitHubAPI as GitHub API
  participant UIRender as UI Render
  User->>ActivityForm: Enters username and submits
  ActivityForm->>ActivityForm: Validate & trim input
  ActivityForm->>ActivityFeed: Pass trackedUsername prop
  ActivityFeed->>ActivityFeed: Check username non-empty
  alt Empty Username
    ActivityFeed->>UIRender: Set error state
  else Valid Username
    ActivityFeed->>GitHubAPI: Fetch user events
    alt Success (res.ok)
      GitHubAPI->>ActivityFeed: Array of events
      ActivityFeed->>ActivityFeed: Validate is array
      ActivityFeed->>UIRender: Set events, cap to 10
    else 404 Not Found
      ActivityFeed->>UIRender: Show "User not found" error
    else 403 Forbidden
      ActivityFeed->>UIRender: Show "Access forbidden" error
    else Network/Other Error
      ActivityFeed->>UIRender: Show "Connection failed" error
    end
  end
  UIRender->>User: Render loading/error/event list
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related issues

  • GitMetricsLab/github_tracker#505: This PR directly addresses the missing response validation and error-handling by implementing res.ok checks, 404/403 differentiation, and non-array JSON guards in ActivityFeed's fetch logic.

Possibly related PRs

  • GitMetricsLab/github_tracker#276: Refines ActivityFeed fetching and UI logic with error handling, response validation, and event list rendering that directly builds upon the retrieved PR's initial Activity Feed component.

Suggested labels

level:intermediate, quality:clean, type:feature

Poem

🐰 A form takes shape, a search takes flight,
GitHub's secrets now in sight!
Errors caught with caring hand,
Each username tracked across the land.
Events capped, the UI refined—
User-driven tracking, wonderfully designed! ✨

🚥 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 The title is truncated and incomplete, ending with 'handled…', making it vague and not fully informative about the changes. Complete the title to clearly describe the main changes, such as 'feat: Add interactive GitHub username input with loading and error states'
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the template structure and covers the required sections including Related Issue, Description, Type of Change, and notes on testing.
Linked Issues check ✅ Passed The changes comprehensively address all requirements from issue #519: username input field, Track Activity button, loading states, error handling, empty states, improved spacing, and responsive design.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #519 requirements. ActivityFeed error handling, state management, and UI improvements all support the main objective of interactive username tracking.

✏️ 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.

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: 1

Caution

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

⚠️ Outside diff range comments (1)
src/components/ActivityFeed.tsx (1)

28-82: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Prevent stale async responses from overwriting the latest username state.

Line 28–82 can commit out-of-order results: a previous fetchEvents call may resolve after a username change and replace current state with stale data. Add request cancellation (or request-id guard) in this effect.

Suggested fix
 useEffect(() => {
-  const fetchEvents = async () => {
+  const controller = new AbortController();
+  const fetchEvents = async () => {
       if (!username.trim()) {
         setEvents([]);
         setError("Please enter a GitHub username to get started.");
         setLoading(false);
         return;
       }

       try {
         setLoading(true);
         setError("");

         const res = await fetch(
-          `https://api.github.com/users/${username}/events`
+          `https://api.github.com/users/${encodeURIComponent(username)}/events`,
+          { signal: controller.signal }
         );
@@
-      } catch (err) {
+      } catch (err) {
+        if ((err as DOMException).name === "AbortError") return;
         console.error(err);
         setError("Unable to fetch activity. Check your connection and try again.");
         setEvents([]);
       } finally {
         setLoading(false);
       }
     };

     fetchEvents();

     const interval = setInterval(fetchEvents, 30000);
-    return () => clearInterval(interval);
+    return () => {
+      clearInterval(interval);
+      controller.abort();
+    };
   }, [username]);
🤖 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/ActivityFeed.tsx` around lines 28 - 82, This effect can apply
stale responses when a prior fetchEvents resolves after username changes; add a
request-id guard or AbortController to cancel/outdate previous requests: inside
the useEffect create a local token (e.g., let currentRequestId or const
controller = new AbortController()), pass it to the fetch call, and before
updating state in fetchEvents verify the request is still current (compare
requestId or check !controller.signal.aborted) — only call setEvents, setError
and setLoading if the token matches and not aborted; also abort the controller
or increment the requestId in the cleanup returned by useEffect to prevent
out-of-order updates for fetchEvents/username updates.
🤖 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/ActivityFeed.tsx`:
- Around line 41-43: The fetch call in ActivityFeed.tsx building the GitHub URL
uses the raw username variable; instead use encodeURIComponent(username) when
constructing the URL for the request (the const res = await fetch(...) call) to
prevent malformed requests from unexpected characters — update the template
string to wrap username with encodeURIComponent before calling fetch.

---

Outside diff comments:
In `@src/components/ActivityFeed.tsx`:
- Around line 28-82: This effect can apply stale responses when a prior
fetchEvents resolves after username changes; add a request-id guard or
AbortController to cancel/outdate previous requests: inside the useEffect create
a local token (e.g., let currentRequestId or const controller = new
AbortController()), pass it to the fetch call, and before updating state in
fetchEvents verify the request is still current (compare requestId or check
!controller.signal.aborted) — only call setEvents, setError and setLoading if
the token matches and not aborted; also abort the controller or increment the
requestId in the cleanup returned by useEffect to prevent out-of-order updates
for fetchEvents/username updates.
🪄 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: 5f64c048-4a33-41f2-a150-457eda5929f9

📥 Commits

Reviewing files that changed from the base of the PR and between 4ae0ef6 and 286b724.

📒 Files selected for processing (2)
  • src/components/ActivityFeed.tsx
  • src/pages/Activity.tsx

Comment on lines 41 to 43
const res = await fetch(
`https://api.github.com/users/${username}/events`
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Encode username before building the GitHub API URL.

Line 42 uses raw input in the path; use encodeURIComponent(username) to avoid malformed requests when users paste unexpected characters.

Suggested fix
-`https://api.github.com/users/${username}/events`
+`https://api.github.com/users/${encodeURIComponent(username)}/events`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const res = await fetch(
`https://api.github.com/users/${username}/events`
);
const res = await fetch(
`https://api.github.com/users/${encodeURIComponent(username)}/events`
);
🤖 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/ActivityFeed.tsx` around lines 41 - 43, The fetch call in
ActivityFeed.tsx building the GitHub URL uses the raw username variable; instead
use encodeURIComponent(username) when constructing the URL for the request (the
const res = await fetch(...) call) to prevent malformed requests from unexpected
characters — update the template string to wrap username with encodeURIComponent
before calling fetch.

@AnishCoder2006
Copy link
Copy Markdown
Contributor Author

Now all my 5 checks have have been successfully passed .Please accept my PR which I have raised.

@AnishCoder2006
Copy link
Copy Markdown
Contributor Author

Please accept my pr for this.5 checks have been successfully passed. Screenshot is also attached with pr description. Please accept this change @mehul-m-prajapati

@mehul-m-prajapati mehul-m-prajapati merged commit 1826cb2 into GitMetricsLab:main May 31, 2026
1 of 6 checks passed
@github-actions
Copy link
Copy Markdown

🎉🎉 Thank you for your contribution! Your PR #557 has been merged! 🎉🎉

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.

Enhancement: Add username input UI on Live Activity page

2 participants