feat(repos): Add ScmRepositoryTable component and useRepoSearch hook#113570
Conversation
3d5293c to
4f88047
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4f88047. Configure here.
4f88047 to
ddefcf4
Compare
| return undefined; | ||
| } | ||
|
|
||
| const matches: ScmRepoMatches = {}; | ||
| for (const result of fuse.search(query)) { | ||
| if (result.matches) { | ||
| matches[result.item.id] = result.matches; | ||
| } | ||
| } | ||
| return matches; | ||
| }, [fuse, query]); |
There was a problem hiding this comment.
Bug: When the repositories list changes during an active search, useRepoSearch can briefly return undefined, causing the UI to flicker and show all repositories momentarily.
Severity: LOW
Suggested Fix
To prevent the flicker, useRepoSearch should not return undefined during re-initialization. It could retain the previous search results or an empty map until the new search index is ready. This ensures the UI remains stable when the underlying repository data changes.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: static/app/views/settings/organizationRepositories/useRepoSearch.tsx#L21-L35
Potential issue: The `useRepoSearch` hook utilizes `useFuzzySearch`, which initializes
the search index asynchronously. If the `repositories` array provided to the hook
changes its identity while a search query is active, the internal `fuse` instance is
temporarily set to `null`. This causes `useRepoSearch` to return `undefined`. The
consuming component then falls back to displaying the entire list of repositories,
resulting in a brief UI flicker where the unfiltered list is shown before the filtered
results reappear.
Also affects:
static/app/views/settings/organizationRepositories/scmRepositoryTable.tsx:220~223
| if (!query || !fuse) { | ||
| return undefined; | ||
| } |
There was a problem hiding this comment.
Bug: When a user searches before the Fuse.js index has finished its initial asynchronous load, all repositories are displayed momentarily instead of the filtered results, causing a flicker.
Severity: LOW
Suggested Fix
The useFuzzySearch hook should expose a loading state. The useRepoSearch hook can then use this state to return a more specific value, like an empty object {}, to indicate that a search is in progress but has no results yet. This would prevent the parent component from defaulting to showing all items.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: static/app/views/settings/organizationRepositories/useRepoSearch.tsx#L24-L26
Potential issue: The `useFuzzySearch` hook returns a `null` value for the `fuse`
instance while it asynchronously loads the Fuse.js library and builds the search index.
The calling component, `useRepoSearch`, checks `if (!fuse)` and returns `undefined`. The
`scmRepositoryTable` component then interprets `repoMatches === undefined` as a signal
to display all repositories, without any filtering. If a user types a search query
during this initial loading window, the UI will incorrectly show all repositories until
the Fuse index is ready, at which point the list will suddenly filter, causing a visual
flicker and a confusing user experience.
Also affects:
static/app/views/settings/organizationRepositories/scmRepositoryTable.tsx:222~224
83c488a to
a9105e4
Compare
a9105e4 to
4d87215
Compare
Introduce a reusable component for listing SCM integrations and their repositories, along with a hook that wraps Fuse.js for filtering and highlighting repository matches.
4d87215 to
d058029
Compare
…113570) Introduce a reusable component for listing SCM integrations and their repositories, along with a hook that wraps Fuse.js for filtering and highlighting repository matches.

Introduce a reusable component for listing SCM integrations and their
repositories, along with a hook that wraps Fuse.js for filtering and
highlighting repository matches.