Skip to content

[IMPLEMENT]: search feature (username / token ID)#99

Open
Nikuunj wants to merge 2 commits intoStabilityNexus:mainfrom
Nikuunj:main
Open

[IMPLEMENT]: search feature (username / token ID)#99
Nikuunj wants to merge 2 commits intoStabilityNexus:mainfrom
Nikuunj:main

Conversation

@Nikuunj
Copy link
Copy Markdown
Contributor

@Nikuunj Nikuunj commented Apr 7, 2026

Addressed Issues:

Fixes #97

This PR implements a comprehensive search feature for the Identity Tokens frontend application, allowing users to search for identities by username or Token ID. The feature includes debounced search, a responsive design for both mobile and desktop, and full theme support.

The useRef hook is used to reduce unnecessary re-renders and improve performance.

Screenshots/Recordings:

Screen.Recording.2026-04-07.135207.mp4

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

  • New Features
    • Added mobile hamburger menu to the navigation bar for easier access on mobile devices.
    • Introduced search modal that adapts to both mobile and desktop layouts.
    • Reorganized navigation layout to provide improved responsiveness across different screen sizes.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
identity-tokens-evm-frontend Ready Ready Preview, Comment Apr 7, 2026 8:34am

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 7, 2026

Walkthrough

Added a new search feature enabling users to search identities by username or Token ID. The SearchModal component provides both inline and mobile-optimized search interfaces with debounced input handling and navigation. The Navbar was updated to conditionally render search and menu controls across different screen sizes.

Changes

Cohort / File(s) Summary
Search Feature Implementation
components/ui/SearchModal.tsx, components/Navbar.tsx
New SearchModal component with debounced search input, keyboard navigation (Enter/Escape), and router-based navigation. Navbar updated to include responsive search area (md+), mobile hamburger toggle, and mobile dropdown menu containing search and action buttons.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Navbar
    participant SearchModal
    participant Router
    
    User->>Navbar: Click search or hamburger menu
    Navbar->>SearchModal: Render with isOpen=true
    activate SearchModal
    User->>SearchModal: Type search query (username/Token ID)
    Note over SearchModal: Debounce 300ms timeout
    User->>SearchModal: Press Enter or click submit
    SearchModal->>Router: router.push(`/${value}`)
    Router->>User: Navigate to search results
    SearchModal->>SearchModal: onClose() & reset state
    deactivate SearchModal
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

Typescript Lang

Poem

🐰 A whisker-twitch of joy! The search arrives,
Where usernames and tokens come alive,
With debounce bouncing soft and clean,
The finest search you've ever seen,
Hopping swift through every screen!

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: implementing a search feature for username and Token ID lookup, which is the primary objective of the PR.
Linked Issues check ✅ Passed The PR implements both required coding objectives from issue #97: a SearchModal component enabling username search and Token ID search with debouncing and responsive design.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the search feature; Navbar modifications integrate the new SearchModal, and SearchModal implements the core search functionality specified in issue #97.

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

@Nikuunj
Copy link
Copy Markdown
Contributor Author

Nikuunj commented Apr 7, 2026

@KanishkSogani

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 the current code and only fix it if needed.

Inline comments:
In `@components/ui/SearchModal.tsx`:
- Around line 43-49: The debug console.log inside the debounce timeout should be
removed or replaced with a proper logger call that can be disabled in
production: update the setTimeout callback (the debounceRef.current block that
trims value) to remove console.log("Debounced search term:", trimmed) and either
call your app logging utility (e.g., logger.debug or debugLog) or guard the log
behind a NODE_ENV check so it’s omitted in production; ensure you keep the
trimmed truthy check and the placeholder for the elasticsearch fetch intact.
- Around line 135-141: The modal container in SearchModal uses hardcoded inline
styles (backgroundColor "#18191D" and border "rgba(255,255,255,0.06)"); replace
the style prop on the div with theme-aware Tailwind classes (e.g., use
bg/rounded/shadow and border utilities with dark: and light: variants to match
the app theme) so the modal follows dark/light themes consistently—update the
div whose className starts with "animate-in zoom-in-95 relative w-full max-w-md
rounded-2xl p-6 shadow-2xl duration-200" by removing the style prop and adding
appropriate Tailwind classes (including dark: and/or ring/opacity utilities) to
represent the same visual appearance.
- Around line 52-63: In SearchModal, remove any stray console.log debug
statements, externalize all user-facing strings (e.g., placeholders and labels
like "Search by username or Token ID…", "Search Identity", "Press Enter") into
the i18n resource and replace inline usages with i18n lookups, replace the
inline style object used for the modal background/border with appropriate
Tailwind (or theme-aware) utility classes (e.g., use a dark background class and
a semi-transparent border class instead of backgroundColor:"#18191D" and
border:"1px solid rgba(255,255,255,0.06)"), and update the handleSubmit function
so router.push uses an encoded path
(router.push(`/${encodeURIComponent(value)}`)) while still clearing inputRef,
calling onClose, and updating setHasValue as before.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: dfb7eccc-a3b5-40e4-9ecc-addf8eb49a93

📥 Commits

Reviewing files that changed from the base of the PR and between 30f26de and 5a25d79.

📒 Files selected for processing (2)
  • components/Navbar.tsx
  • components/ui/SearchModal.tsx

Comment on lines +43 to +49
debounceRef.current = setTimeout(() => {
const trimmed = value.trim();
if (trimmed) {
console.log("Debounced search term:", trimmed);
// TODO: Add elasticsearch fetch here
}
}, 300);
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.

🛠️ Refactor suggestion | 🟠 Major

Remove console.log before production.

Debug logging should be removed or replaced with a proper logging utility that can be disabled in production builds.

♻️ Proposed fix
    debounceRef.current = setTimeout(() => {
      const trimmed = value.trim();
      if (trimmed) {
-       console.log("Debounced search term:", trimmed);
        // TODO: Add elasticsearch fetch here
      }
    }, 300);
📝 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
debounceRef.current = setTimeout(() => {
const trimmed = value.trim();
if (trimmed) {
console.log("Debounced search term:", trimmed);
// TODO: Add elasticsearch fetch here
}
}, 300);
debounceRef.current = setTimeout(() => {
const trimmed = value.trim();
if (trimmed) {
// TODO: Add elasticsearch fetch here
}
}, 300);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/ui/SearchModal.tsx` around lines 43 - 49, The debug console.log
inside the debounce timeout should be removed or replaced with a proper logger
call that can be disabled in production: update the setTimeout callback (the
debounceRef.current block that trims value) to remove console.log("Debounced
search term:", trimmed) and either call your app logging utility (e.g.,
logger.debug or debugLog) or guard the log behind a NODE_ENV check so it’s
omitted in production; ensure you keep the trimmed truthy check and the
placeholder for the elasticsearch fetch intact.

Comment on lines +52 to +63
const handleSubmit = useCallback(
(e?: React.FormEvent) => {
e?.preventDefault();
const value = inputRef.current?.value.trim();
if (!value) return;
router.push(`/${value}`);
onClose();
if (inputRef.current) inputRef.current.value = "";
setHasValue(false);
},
[router, onClose]
);
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 | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check how the username parameter is used in the destination page
ast-grep --pattern 'params.$_.$_'
rg -n 'username' --type ts --type tsx -g '!node_modules'
cat app/\[username\]/page.tsx 2>/dev/null || fd -t f 'page.tsx' -x grep -l 'username' {}

Repository: StabilityNexus/IdentityTokens-EVM-Frontend

Length of output: 525


🏁 Script executed:

#!/bin/bash
# Get full SearchModal.tsx content to verify all mentioned issues
fd -t f 'SearchModal.tsx' | head -1 | xargs wc -l

Repository: StabilityNexus/IdentityTokens-EVM-Frontend

Length of output: 119


🏁 Script executed:

#!/bin/bash
# Read SearchModal.tsx to check for console.log, inline styles, and i18n issues
fd -t f 'SearchModal.tsx' | head -1 | xargs cat -n

Repository: StabilityNexus/IdentityTokens-EVM-Frontend

Length of output: 7327


🏁 Script executed:

#!/bin/bash
# Check if there are i18n files in the project
fd -t d 'locales\|i18n\|translations' | head -10

Repository: StabilityNexus/IdentityTokens-EVM-Frontend

Length of output: 68


Remove console.log, externalize strings to i18n, and replace hardcoded inline styles with Tailwind classes.

The code has three issues:

  1. console.log on line 46: Remove the production debug statement.

  2. Hardcoded user-visible strings: Lines 85, 154–175 contain hard-coded strings ("Search by username or Token ID…", "Search Identity", "Press Enter", etc.). Externalize these to an i18n resource file per the coding guidelines.

  3. Hardcoded inline styles (lines 137–140): Replace the inline style object with Tailwind classes or CSS variables for theme consistency:

    • backgroundColor: "#18191D" → Use a theme-aware background class
    • border: "1px solid rgba(255,255,255,0.06)" → Use a theme-aware border class

Also consider using encodeURIComponent() when constructing the navigation path on line 57 to ensure special characters in usernames are safely encoded.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/ui/SearchModal.tsx` around lines 52 - 63, In SearchModal, remove
any stray console.log debug statements, externalize all user-facing strings
(e.g., placeholders and labels like "Search by username or Token ID…", "Search
Identity", "Press Enter") into the i18n resource and replace inline usages with
i18n lookups, replace the inline style object used for the modal
background/border with appropriate Tailwind (or theme-aware) utility classes
(e.g., use a dark background class and a semi-transparent border class instead
of backgroundColor:"#18191D" and border:"1px solid rgba(255,255,255,0.06)"), and
update the handleSubmit function so router.push uses an encoded path
(router.push(`/${encodeURIComponent(value)}`)) while still clearing inputRef,
calling onClose, and updating setHasValue as before.

Comment on lines +135 to +141
<div
className="animate-in zoom-in-95 relative w-full max-w-md rounded-2xl p-6 shadow-2xl duration-200"
style={{
backgroundColor: "#18191D",
border: "1px solid rgba(255,255,255,0.06)",
}}
onClick={(e) => e.stopPropagation()}
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.

🧹 Nitpick | 🔵 Trivial

Prefer theme-aware classes over hardcoded inline styles.

The modal container uses hardcoded colors (#18191D, rgba(255,255,255,0.06)) which bypass the dark/light theme system used elsewhere in the component. Consider using Tailwind classes for consistency.

♻️ Proposed fix using theme-aware classes
      <div
-       className="animate-in zoom-in-95 relative w-full max-w-md rounded-2xl p-6 shadow-2xl duration-200"
-       style={{
-         backgroundColor: "#18191D",
-         border: "1px solid rgba(255,255,255,0.06)",
-       }}
+       className="animate-in zoom-in-95 relative w-full max-w-md rounded-2xl bg-slate-900 p-6 shadow-2xl duration-200 dark:bg-slate-900 border border-white/5"
        onClick={(e) => e.stopPropagation()}
      >
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@components/ui/SearchModal.tsx` around lines 135 - 141, The modal container in
SearchModal uses hardcoded inline styles (backgroundColor "#18191D" and border
"rgba(255,255,255,0.06)"); replace the style prop on the div with theme-aware
Tailwind classes (e.g., use bg/rounded/shadow and border utilities with dark:
and light: variants to match the app theme) so the modal follows dark/light
themes consistently—update the div whose className starts with "animate-in
zoom-in-95 relative w-full max-w-md rounded-2xl p-6 shadow-2xl duration-200" by
removing the style prop and adding appropriate Tailwind classes (including dark:
and/or ring/opacity utilities) to represent the same visual appearance.

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]: Search feature , search by username / Token id

1 participant