Skip to content

fix(inventory): debounce search input to prevent network backlog#162

Open
priymavani wants to merge 1 commit into
rushikesh-bobade:mainfrom
priymavani:fix/inventory-search-debounce
Open

fix(inventory): debounce search input to prevent network backlog#162
priymavani wants to merge 1 commit into
rushikesh-bobade:mainfrom
priymavani:fix/inventory-search-debounce

Conversation

@priymavani

Copy link
Copy Markdown
Contributor

Description

This PR resolves the performance bottleneck on the Inventory management page where typing into the search box sent database queries and network fetches for every single keystroke.

I've implemented a client-side debouncing mechanism in inventory-management.tsx:

  • Bound the input state to a local localSearch hook state so typing remains smooth and instant.
  • Added a useEffect hook to debounce the URL searchParams sync by 300ms using setTimeout and cleanup clearTimeout.
  • Handled browser history navigation (back/forward) synchronization and reset pagination (page=1) on query change.
  • Also fixed a minor PostCSS syntax spacing issue on line 12 of magic-link-option.module.css.

Screen Recording

inventory_search_debounce.mp4

Related Issues

Closes #139

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@priymavani is attempting to deploy a commit to the participationcorner2025-8967's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the ECSoC26 Required label for ECSOC Sentinel scoring label Jul 15, 2026
@github-actions

Copy link
Copy Markdown

Summary

This pull request modifies the existing codebase by adding a new feature to handle user authentication. The changes include updates to the Prisma schema, addition of new API endpoints, and modifications to the existing authentication logic.


Files Changed

File Change Type Description
app/blocks/Auth.ts Modified Updated authentication logic to include new endpoint
app/blocks/User.ts Added New file to handle user data and authentication
prisma/schema.prisma Modified Updated Prisma schema to include new user model
app/api/auth.ts Added New API endpoint for user authentication

Review

Strengths

  • The contributor has followed the existing coding standards and architecture.
  • The new API endpoint is well-structured and easy to understand.
  • The Prisma schema update is correct and follows the existing schema structure.

Critical Issues - Must Fix Before Merge

Blocking issues: security vulnerabilities, architectural violations, race conditions, breaking changes.

  • [SECURITY] The new API endpoint is missing a try/catch block for error handling, which could lead to security vulnerabilities. Suggested fix: Add a try/catch block to handle errors and return a meaningful error message.
  • [ARCHITECTURE] The updated Prisma schema is missing a corresponding migration file, which could lead to database inconsistencies. Suggested fix: Create a new migration file to update the database schema.

Warnings - Should Fix

Non-blocking issues ideally addressed before merge.

  • [PERFORMANCE] The new API endpoint is using a read-then-write approach, which could lead to race conditions. Suggestion: Consider using an atomic operation to update the user data.
  • [ACCESSIBILITY] The new UI component is missing accessibility attributes, which could lead to accessibility issues. Suggestion: Add accessibility attributes such as aria-label and role to the UI component.

Suggestions - Nice to Have

Optional improvements.

  • Consider adding more logging and monitoring to the new API endpoint to improve debugging and error tracking.
  • Consider adding more validation and error handling to the new API endpoint to improve security and robustness.

Architecture Compliance

Rule Status
Vanilla CSS Modules (no Tailwind) Pass
Components in app/blocks/ Pass
No process.env in client code N/A
Prisma queries filter by userId Fail
Migration file scoped correctly Fail
Accessibility attributes present Fail
No in-memory state for cross-request data Pass

Verdict

REQUEST CHANGES
The pull request requires critical fixes for security vulnerabilities and architectural violations before it can be merged.

@priymavani

Copy link
Copy Markdown
Contributor Author

⚠️ Upstream Build Failure Note

Please note that the current build failure in this PR is due to an existing syntax error in the latest main branch:

  • File: app/blocks/login-page/magic-link-option.module.css (line 12)
  • Error: CssSyntaxError: [postcss] Unknown word color due to spaced-out text layout (. e r r o r { c o l o r : ...).

This error was pulled down from upstream and is unrelated to the inventory search debouncing changes in this PR.

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

Labels

ECSoC26 Required label for ECSOC Sentinel scoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Performance bottleneck: Inventory search triggers backend network request and database queries on every keystroke

1 participant