Skip to content

Conversation

jrmartin
Copy link

This pull request refactors and improves the handling of term hierarchies and predicates in the API and UI components. The main changes include splitting predicate and hierarchy API logic, improving the normalization and mapping of graph data, and updating UI components for clarity and consistency. These updates enhance robustness, maintainability, and user experience when visualizing and interacting with term relationships.

API Refactoring and Improvements

  • Split the predicate and hierarchy API logic: The getTermPredicates function is now separate from getTermHierarchies, with each using a more robust fetch-based implementation and improved error handling. Predicate groups are built using buildPredicateGroupsForFocus. [1] [2]
  • Corrected import paths and moved jsonldToTriplesAndEdges and related constants to the correct parser location (src/parsers/hierarchies-parser). [1] [2]

Graph Data Normalization and Mapping

  • Enhanced graph data normalization in GraphStructure.jsx to support both single- and multi-subject layouts, ensuring compatibility with legacy and new data shapes. The code now buckets rows by subject and adapts the visualization accordingly.
  • Improved mapping from triples in Hierarchy.jsx, making label extraction and part-of relationship detection more resilient to data variations. [1] [2]

UI Component Updates

  • Updated the hierarchy tree view and search components to use consistent IDs and labels, improved selection handling, and clarified button actions and tooltips. [1] [2]
  • Adjusted prop types for hierarchy components to require id fields and ensure type safety.

GET Request Normalization

  • Normalized GET request URLs to always be absolute, preventing SPA routing issues, and set the appropriate Accept header for GET requests.

@jrmartin jrmartin requested a review from ddelpiano August 27, 2025 14:51
@jrmartin jrmartin marked this pull request as ready for review August 27, 2025 14:52
@jrmartin jrmartin requested a review from Copilot August 27, 2025 15:08
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request refactors and improves the handling of term hierarchies and predicates in the API and UI components by splitting predicate and hierarchy logic, enhancing data normalization, and improving the user experience when visualizing term relationships.

  • Separated predicate fetching from hierarchy logic with dedicated API endpoints and parsers
  • Enhanced graph data normalization to support both single and multi-subject layouts
  • Updated UI components for better consistency, loading states, and error handling

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/parsers/predicateParser.tsx New parser for building predicate groups from JSON-LD data
src/parsers/hierarchies-parser.tsx New parser for converting JSON-LD to triples and edges for hierarchy data
src/main.jsx Removed mock worker initialization
src/components/SingleTermView/OverView/ViewDiagramDialog.jsx Improved predicate selection UI with better state management
src/components/SingleTermView/OverView/PredicatesAccordion.jsx Added constants for view types to improve maintainability
src/components/SingleTermView/OverView/Predicates.jsx Simplified component by removing complex merging logic
src/components/SingleTermView/OverView/OverView.jsx Split API calls and added loading states for better UX
src/components/SingleTermView/OverView/Hierarchy.jsx Enhanced hierarchy mapping with better label extraction
src/components/GraphViewer/GraphStructure.jsx Improved graph normalization for single/multi-subject layouts
src/api/endpoints/hiearchies-parser.ts File deleted and moved to new location
src/api/endpoints/apiService.ts Split hierarchy and predicate endpoints with improved error handling
src/api/endpoints/apiActions.ts Fixed GET request handling with proper Accept headers

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@ddelpiano ddelpiano left a comment

Choose a reason for hiding this comment

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

In general there are a lot of changes not related to the PR, not optimal. Also the dashboard has been broken with this PR, please fix that. Thanks

@jrmartin
Copy link
Author

@ddelpiano I removed the mocked data worker and that's the cause of this https://github.com/MetaCell/interlex/pull/128/files#diff-752aae33033979082689dba3e7f51955013615f0535c21ac94265e067da311edL11

The dashboard was working with mock data and cause the failure, added back

@ddelpiano ddelpiano merged commit b6b7ef6 into devel Sep 1, 2025
1 of 2 checks passed
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.

2 participants