Skip to content

Conversation

@fifth-island
Copy link
Collaborator

@fifth-island fifth-island commented Jun 19, 2025

Adds a new search bar to the top navigation, using a 'Data Socket' pattern with React Context and RTK Query. Includes internationalization support for new UI text and configures the proxy for the standalone backend API.

Description

This Pull Request implements a new Article Search feature.

  • A search bar is added to the top navigation bar.
  • It allows users to search for articles from a backend database in real-time.
  • The feature is built to be a modular, self-contained add-on, with the backend service running separately in Docker.
  • Basic internationalization support for all new UI text has been added for both English and German (it has to be further developed when integrated to the real API).

Related Issues

This feature was implemented based on the architecture requirements from the "Versatile Visual Analytics Framework for Exploration and Research" paper. No issue number was assigned.

Design Decisions

The implementation follows the existing architectural patterns of the application, specifically the "Data Socket" pattern.

  • ArticleDataContext.tsx: A new React Context was created to act as the "Data Socket". This component is responsible for all data fetching logic. It listens for search query changes and uses the RTK Query useLazyGetArticlesQuery hook to trigger API calls. This centralizes the data logic and keeps UI components "dumb".
  • ArticleSearchBar.tsx: The search bar is a simple UI component. It gets the search results and the loading state from the ArticleDataContext and sends user input back to the context. It does not fetch data itself.
  • articleApi.ts: An RTK Query service was created to define the API endpoint (/api/articles) for fetching data. This keeps API definitions separate from UI and state logic.
  • Modularity: This approach ensures the entire feature is highly modular. The ArticleDataProvider can be wrapped around the application in App.tsx to provide the search functionality anywhere it's needed, and the backend is fully independent. For now, it is just a temporary element, as it will be modified after the development of the UI mockups.

Performance & Quality

The search query is debounced within the component to prevent excessive API calls while the user is typing. No formal performance profiles have been attached for this initial implementation. It is an initial implementation with no true database. The only quality tests performed was checking the performance of the API calls when fetching the data to the search bar, which demonstrated to be happening efficiently.

Performance & Quality

Checklist

I, the author of this PR checked the following requirements for good software quality:

  • The code is properly formatted (I ran the formatter)
  • The code is written with our software quality standards (I ran the linter)
  • The code is written using our code style
  • Extensive in source documentation has been added
  • Unit and/or integration tests have been added
  • All texts have been internationalized with at least the following languages:
    • English
    • German
  • I tried addressing all new accessibility problems displayed in the console and documented if they can't be fixed
  • I attached performance measurements to prevent performance degradation
  • I added the changes to the next release section of the changelog

I, the reviewer checked the following things:

  • I ran the software once and tried all new and related functionality to this PR
  • I looked at all new and changed lines of code and commented on possible problems
  • I read the added documentation and checked if it is understandable and clear
  • I checked the added tests for completeness
  • I checked the internationalized strings for spelling errors
  • I checked the performance metrics for problems or unexplained degradation
  • I checked that the changes are noted in the changelog

Adds a new search bar to the top navigation, using a 'Data Socket' pattern with React Context and RTK Query. Includes internationalization support for new UI text and configures the proxy for the standalone backend API.
@fifth-island fifth-island requested a review from NXXR June 19, 2025 13:51
@fifth-island fifth-island changed the title feat: Implement article search feature feat: Implement basic article search feature Jun 19, 2025
This commit establishes the foundational frontend architecture for the semantic search feature. It represents the second iteration of development, focusing on building out the UI components and data flow in preparation for backend integration.

- Implements SemanticSearchContext for managing state and API interactions.

- Integrates the main SemanticSearchContainer within the existing TopBarPopover.

- Adds placeholder components, TypeScript types, and a Redux slice.

- Includes internationalization keys for all new user-facing text.
@github-actions
Copy link

github-actions bot commented Jun 24, 2025

Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit 129366a. ± Comparison against base commit f578619.

♻️ This comment has been updated with latest results.

This commit fixes a series of cascading test failures that occurred after introducing the semantic search feature.

- Wraps test components in ArticleDataProvider to provide necessary context.

- Removes a duplicate data-testid that caused an ambiguous element error.
@fifth-island fifth-island force-pushed the feature/article-search branch from 4befb49 to 09c8a85 Compare July 15, 2025 14:39
@NXXR NXXR requested a review from JonasGilg August 5, 2025 10:52
throw new Error('useSemanticSearch must be used within a SemanticSearchProvider');
}
return context;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

this result handling should be done in the articleAPI which should then return SerarchResult objects.
This way the API response transformations are easier to maintain and the components in the App only use the defined types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Solved. II moved it to the API handling.

Comment on lines 4 to +8
# This is for development only. For production you need to replace this with the actual URL.
VITE_API_URL=http://localhost:8000

# VITE_ARTICLE_API_URL= http://sc-010187l:8001/
VITE_ARTICLE_API_URL=http://localhost:8001
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a bad comment (Ours above too 😅). Explain what the Variable is for.
Also don't expose network internal or development names to git 😬 bad enough that we do this for the IDP below.

Suggested change
# This is for development only. For production you need to replace this with the actual URL.
VITE_API_URL=http://localhost:8000
# VITE_ARTICLE_API_URL= http://sc-010187l:8001/
VITE_ARTICLE_API_URL=http://localhost:8001
# Development only. For production you need to replace this with the actual URLto the Backend API (https://github.com/SciCompMod/ESID-Backend).
VITE_API_URL=http://localhost:8000
# Development only. For production you need to replace this with the actual URL to your Knowledgebase API (https://github.com/SciCompMod/ESID-Knowledgebase).
VITE_ARTICLE_API_URL=http://localhost:8001

Comment on lines +17 to +28
# .env
.eslintcache
.env
.venv
__pycache__/
/public/assets
/public/locales
/public/node_modules
/public/pdf.worker.min.mjs
.eslintcache
.env
.DS_Store
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like some leftovers from development?
I don't see why we would have python stuff in our repo.
not sure why the pdf worker is in here if it's still committed as the .js 🤔 is that on purpose?

Suggested change
# .env
.eslintcache
.env
.venv
__pycache__/
/public/assets
/public/locales
/public/node_modules
/public/pdf.worker.min.mjs
.eslintcache
.env
.DS_Store
.env
.eslintcache

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As for this change here, you are correct on your points. But I added the pdf worker here in an attempt to deal with the failing in loading PDFs, as there were two versions of the library. I still have not come to tangible fixes on this end.

@fifth-island fifth-island force-pushed the feature/article-search branch from 8117a4b to 9b3f6b2 Compare August 21, 2025 13:30
@NXXR
Copy link
Collaborator

NXXR commented Sep 9, 2025

@NXXR feedback to Sarah when added (User Feedback 20, 2, 3)

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.

3 participants