Skip to content

RI-7930 Index Info hook#5437

Open
valkirilov wants to merge 7 commits intomainfrom
fe/feature/RI-7930/index-info-hook
Open

RI-7930 Index Info hook#5437
valkirilov wants to merge 7 commits intomainfrom
fe/feature/RI-7930/index-info-hook

Conversation

@valkirilov
Copy link
Member

@valkirilov valkirilov commented Feb 3, 2026

What

Added a hook to get index information

  • Simple standalone hook to get info for the index via the API
  • No Redux, instead keep the data in local state
  • It transforms the data when received from the API, and later on uses the front-end only interface, to keep it decoupled from the backend

PS: Later to be used together with the IndexInfo component on the new Vector Search page (#5436)

Light Dark
Screenshot 2026-02-03 at 16 20 27 Screenshot 2026-02-03 at 16 20 40

Testing

export const IndexInfoExample = () => {
  const indexName = 'idx:bikes_vss'
  const { indexInfo, loading, error } = useIndexInfo({ indexName })

  return (
    <>
        <IndexInfo
          indexInfo={loading ? undefined : indexInfo}
          dataTestId="index-info-example"
        />
    </>
  )
}

Note

Medium Risk
Introduces new async fetching + transformation logic used by the Vector Search UI; main risk is incorrect/stale state or type normalization causing wrong index info to render.

Overview
Adds a new useIndexInfo hook for the Vector Search page to fetch REDISEARCH_INFO via apiService, store results in local state, and expose { indexInfo, loading, error, refetch }.

Includes DTO→frontend model transformation (snake_casecamelCase, numeric string→number, field type normalization) and guards against races by ignoring stale responses and resetting loading/error when indexName becomes empty.

Updates the IndexInfo mock factory to emit uppercase attribute type values (matching API expectations) and adds unit tests covering successful fetch, error handling, refetch, stale-response handling, and the transform utilities.

Written by Cursor Bugbot for commit b53b38a. This will update automatically on new commits. Configure here.

- simple standalone hook to get infro from the index via the API
- no redux, local state

re #RI-7930
@github-actions
Copy link
Contributor

github-actions bot commented Feb 3, 2026

Code Coverage - Frontend unit tests

St.
Category Percentage Covered / Total
🟢 Statements 82.86% 21208/25594
🟡 Branches 68.13% 8963/13155
🟡 Functions 78.09% 5802/7430
🟢 Lines 83.26% 20768/24945

Test suite run success

5570 tests passing in 709 suites.

Report generated by 🧪jest coverage report action from b53b38a

@valkirilov valkirilov marked this pull request as ready for review February 3, 2026 15:08
- Updated the useIndexInfo hook to track fetch requests and prevent stale data from being set
- Added a test to verify that stale responses are ignored when indexName changes quickly

re #RI-7930
… hook

- Updated the useIndexInfo hook to reset indexInfo and error states when indexName is empty.
- Implemented a test to verify that the state resets correctly when indexName changes to an empty string.

re #RI-7930
- Changed the index type to uppercase in the indexInfo factory.
- Removed the obsolete indexInfoApi factory and updated tests to use the new indexInfo factory.
- Adjusted tests in useIndexInfo.spec.ts and useIndexInfo.utils.spec.ts to reflect the changes in factory usage.

re #RI-7930
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

- Updated the useIndexInfo hook to prevent getting stuck in loading state when indexName changes to an empty string during an ongoing fetch.
- Enhanced the corresponding test to verify that loading state resets correctly without remaining stuck.

re #RI-7930
- Changed the type of the `type` property in the IndexAttribute interface from string to FieldTypes for better type safety.
- Updated the normalizeFieldType function to return FieldTypes instead of string, ensuring consistent type usage across the codebase.

re #RI-7930
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