feat: add global search for findings and reports (#1981)#2006
Open
SathvikaSingoti wants to merge 2 commits into
Open
feat: add global search for findings and reports (#1981)#2006SathvikaSingoti wants to merge 2 commits into
SathvikaSingoti wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds a global search feature for findings and reports, accessible from a search bar in the top navigation (both desktop and mobile).
Backend: New
GET /api/v1/search?q={query}&limit={limit}endpoint inroutes.py. Searches the caller'sfindings(bytitle/description) andreports(byname) using SQLiteLIKE, scoped toowner_idper the existing BOLA-prevention pattern (issue #401) used throughout this file. User input is escaped against%/_/\before being used in theLIKEpattern so literal wildcard characters in a search query can't produce unintended matches.Frontend: New
GlobalSearchcomponent wired intoAppShell's desktop top bar and mobile header. Input is debounced (300ms, via a new reusableuseDebouncedValuehook) before calling the backend, and results render in a dropdown grouped by Findings/Reports. Clicking a result navigates to the relevant list page (Findings or Reports), no per-item detail route exists yet in the app, so this is the closest correct behavior today.Restructured
AppShell.tsxto add a shared top bar row (search) above<main>for desktop, while preserving the existing sidebar-offset layout behavior.Also documents the new endpoint indocs/API.mdunder a new "Search API" section, matching the existing per-endpoint format.Related Issues
Closes #1981
Type of Change
How Has This Been Tested?
testing/backend/integration/test_search.py- 10 tests covering: missing/invalid query params, matching by finding title, matching by finding description, matching by report name, case-insensitivity, empty-result handling,LIKEwildcard escaping (%/_treated as literal characters, not SQL wildcards),limitbounds enforcement, and owner-scoping (a finding belonging to another owner never appears in results).frontend/testing/unit/components/GlobalSearch.test.tsx- covers initial render, debounce behavior (no call on empty query, call after typing), result rendering, no-results state, error state, navigation on result click, and closing the dropdown on Escape../testing/test_python.sh- new test file: 10/10 passing.npm run typecheck- clean.npm run test- 546/546 passing (including the two pre-existingAppShell.test.tsxsidebar-width tests, which needed the--sidebar-widthCSS var re-applied directly to<main>after the layout restructure).npm run build- builds clean.bash scripts/check-artifacts.sh origin/main- no tracked generated artifacts or cache files in the diff.Checklist