Skip to content

text search functionality#1325

Open
akshajtiwari wants to merge 1 commit into
AOSSIE-Org:mainfrom
akshajtiwari:search-bar
Open

text search functionality#1325
akshajtiwari wants to merge 1 commit into
AOSSIE-Org:mainfrom
akshajtiwari:search-bar

Conversation

@akshajtiwari

@akshajtiwari akshajtiwari commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Addressed Issues:

Fixes #(TODO:issue number)

Screenshots/Recordings:

TODO: If applicable, add screenshots or recordings that demonstrate the interface before and after the changes.

Additional Notes:

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

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.

I have used the following AI models and tools: TODO

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 tag search functionality to filter images by tags in the AI Tagging section with real-time results and appropriate empty states.
  • Documentation

    • Updated OpenAPI specification formatting for improved readability.

@akshajtiwari akshajtiwari marked this pull request as ready for review June 16, 2026 17:52
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds a tagQuery field to the Redux search slice with setTagSearchQuery and clearTagSearchQuery actions. The Navbar search input is made controlled via tagQuery with dispatches on change and clear. The AITagging page gains memoized client-side filtering of tagged images with a three-state render. The OpenAPI JSON file receives array reformatting with no semantic changes.

Changes

Tag Search Filtering Feature

Layer / File(s) Summary
searchSlice tagQuery state and actions
frontend/src/features/searchSlice.ts
SearchState adds tagQuery: string initialized to ''; setTagSearchQuery and clearTagSearchQuery reducers and action creators are added and exported.
Navbar controlled input and tag query dispatch
frontend/src/components/Navigation/Navbar/Navbar.tsx
Imports new tag actions, reads tagQuery from Redux state, binds the search input value to tagQuery, dispatches setTagSearchQuery on onChange, and dispatches clearTagSearchQuery alongside clearSearch on close.
AITagging memoized filtering and three-state UI
frontend/src/pages/AITagging/AITagging.tsx
Adds useMemo-based filteredImages computing case-insensitive substring matches against each image's tags; replaces binary render with three-state UI: empty state, no-matches message, or ChronologicalGallery with filtered count in title.

OpenAPI JSON Formatting

Layer / File(s) Summary
Paths and schemas array reformatting
docs/backend/backend_python/openapi.json
tags fields in path operations and required/enum arrays in component schemas are expanded from inline to multi-line format; no values or semantics change.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Navbar
  participant searchSlice
  participant AITagging

  User->>Navbar: types in search input
  Navbar->>searchSlice: dispatch setTagSearchQuery(value)
  searchSlice-->>AITagging: tagQuery propagates via Redux state
  AITagging->>AITagging: useMemo recomputes filteredImages (case-insensitive match)
  AITagging-->>User: ChronologicalGallery with filtered count OR no-matches message

  User->>Navbar: clicks close (X) button
  Navbar->>searchSlice: dispatch clearSearch() + clearTagSearchQuery()
  searchSlice-->>AITagging: tagQuery reset to ""
  AITagging-->>User: full taggedImages gallery restored
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • AOSSIE-Org/PictoPy#599: Modifies the same AITagging.tsx file to change how tagged images are fetched and selected, touching the same gallery rendering path this PR extends with client-side filtering.

Suggested labels

TypeScript/JavaScript, Documentation

🐇 A query for tags, now held in state,
The Navbar controls what you filtrate,
Three paths the gallery may take,
Match count or "no results" in its wake,
The JSON arrays spread neat and tall —
A tidy hop through changes, one and all! 🎉

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'text search functionality' is vague and generic, failing to specify what type of text search is being implemented or which component is affected. Revise the title to be more specific, such as 'Add tag search filtering to AITagging page' or 'Implement tag query search in Navbar and search state', to clearly indicate the primary change being made.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ No issue was linked in the PR description.
Please make sure to link an issue (e.g., 'Fixes #issue_number')

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ No issue was linked in the PR description.
Please make sure to link an issue (e.g., 'Fixes #issue_number')

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
frontend/src/components/Navigation/Navbar/Navbar.tsx (1)

25-29: ⚡ Quick win

Replace any in the Redux selector with RootState.

state: any weakens type safety on the new search contract and can hide breakages during refactors.

Suggested diff
-  const searchState = useSelector((state: any) => state.search);
-  const isSearchActive = searchState.active;
-  const queryImage = searchState.queryImage;
-  const tagQuery = searchState.tagQuery;
+  const { active: isSearchActive, queryImage, tagQuery } = useSelector(
+    (state: RootState) => state.search
+  );

As per coding guidelines, **/*.{ts,tsx,js,jsx}: "Avoid 'any', use explicit types."

🤖 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 `@frontend/src/components/Navigation/Navbar/Navbar.tsx` around lines 25 - 29,
The useSelector hook in the Navbar component is using `any` as the type
parameter for the Redux state, which weakens type safety and can hide potential
breakages during refactors. Replace the `state: any` parameter in the
useSelector call with the proper `RootState` type from your Redux store
configuration. This ensures the selector has explicit type information and
aligns with the coding guideline to avoid using `any` in TypeScript files.

Source: Coding guidelines

🤖 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 `@frontend/src/pages/AITagging/AITagging.tsx`:
- Around line 26-35: Add automated tests for the tag-search filtering and
three-state rendering functionality in AITagging.tsx. Create test cases
covering: the empty dataset state (when taggedImages is empty), the no-match
state (when tagQuery returns no results), and the matched-results state
including case-insensitive tag matching (verifying that the filteredImages
useMemo correctly filters based on tagQuery.toLowerCase() and
tag.toLowerCase().includes()). Include tests for the clear/reset behavior of the
tag search functionality to ensure the UI properly renders all three states as
described in the component's conditional rendering logic around lines 72-90.
- Around line 27-35: The tag query filtering is inconsistent in its whitespace
handling. The early-return check trims the query, but the filter assignment does
not, causing inputs with leading/trailing whitespace like " cat " to fail to
match tags. In the filter logic around line 27-29, change the assignment of
variable q to apply trim() before toLowerCase(), so that the query is normalized
consistently. The same issue applies at the consolidated site around lines
83-85, where the same pattern of whitespace normalization needs to be applied
when assigning the query variable for filtering.

---

Nitpick comments:
In `@frontend/src/components/Navigation/Navbar/Navbar.tsx`:
- Around line 25-29: The useSelector hook in the Navbar component is using `any`
as the type parameter for the Redux state, which weakens type safety and can
hide potential breakages during refactors. Replace the `state: any` parameter in
the useSelector call with the proper `RootState` type from your Redux store
configuration. This ensures the selector has explicit type information and
aligns with the coding guideline to avoid using `any` in TypeScript files.
🪄 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: CHILL

Plan: Pro

Run ID: cd06c59d-2203-4df3-9b56-ce0c51e32045

📥 Commits

Reviewing files that changed from the base of the PR and between 08bc026 and 3188698.

📒 Files selected for processing (4)
  • docs/backend/backend_python/openapi.json
  • frontend/src/components/Navigation/Navbar/Navbar.tsx
  • frontend/src/features/searchSlice.ts
  • frontend/src/pages/AITagging/AITagging.tsx

Comment on lines +26 to 35
const filteredImages = useMemo(() => {
if (!tagQuery.trim()) return taggedImages;

const q = tagQuery.toLowerCase();

return taggedImages.filter((img) =>
img.tags?.some((tag) => tag.toLowerCase().includes(q))
);
}, [taggedImages, tagQuery]);
const {

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 | 🏗️ Heavy lift

Add automated tests for the new tag-search behavior and three-state rendering.

This introduces core feature logic (query filtering + conditional UI branches) without corresponding tests in this cohort. Please add tests for: empty dataset state, no-match state, and matched-results state (including case-insensitive matching and clear/reset behavior).

As per coding guidelines, **/*: "Ensure that test code is automated, comprehensive, and follows testing best practices" and "Verify that all critical functionality is covered by tests."

Also applies to: 72-90

🤖 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 `@frontend/src/pages/AITagging/AITagging.tsx` around lines 26 - 35, Add
automated tests for the tag-search filtering and three-state rendering
functionality in AITagging.tsx. Create test cases covering: the empty dataset
state (when taggedImages is empty), the no-match state (when tagQuery returns no
results), and the matched-results state including case-insensitive tag matching
(verifying that the filteredImages useMemo correctly filters based on
tagQuery.toLowerCase() and tag.toLowerCase().includes()). Include tests for the
clear/reset behavior of the tag search functionality to ensure the UI properly
renders all three states as described in the component's conditional rendering
logic around lines 72-90.

Source: Coding guidelines

Comment on lines +27 to 35
if (!tagQuery.trim()) return taggedImages;

const q = tagQuery.toLowerCase();

return taggedImages.filter((img) =>
img.tags?.some((tag) => tag.toLowerCase().includes(q))
);
}, [taggedImages, tagQuery]);
const {

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

Normalize whitespace before filtering/tag-search title checks.

The filter uses trim() only for the early-return check, then matches with the untrimmed query. Inputs like " cat " incorrectly return no results.

Suggested diff
   const filteredImages = useMemo(() => {
-    if (!tagQuery.trim()) return taggedImages;
-
-    const q = tagQuery.toLowerCase();
+    const q = tagQuery.trim().toLowerCase();
+    if (!q) return taggedImages;
     
     return taggedImages.filter((img) =>
       img.tags?.some((tag) => tag.toLowerCase().includes(q))
   );
 }, [taggedImages, tagQuery]);

Also applies to: 83-85

🤖 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 `@frontend/src/pages/AITagging/AITagging.tsx` around lines 27 - 35, The tag
query filtering is inconsistent in its whitespace handling. The early-return
check trims the query, but the filter assignment does not, causing inputs with
leading/trailing whitespace like " cat " to fail to match tags. In the filter
logic around line 27-29, change the assignment of variable q to apply trim()
before toLowerCase(), so that the query is normalized consistently. The same
issue applies at the consolidated site around lines 83-85, where the same
pattern of whitespace normalization needs to be applied when assigning the query
variable for filtering.

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.

1 participant