ref(seer): Refactor Code Review table to better optimistically update#112979
Merged
ref(seer): Refactor Code Review table to better optimistically update#112979
Conversation
… the query cache, remove weird workaround
Contributor
Sentry Snapshot Testing
|
Comment on lines
+42
to
52
| repository, | ||
| style, | ||
| }: Props) { | ||
| const queryClient = useQueryClient(); | ||
| const organization = useOrganization(); | ||
| const canWrite = useCanWriteSettings(); | ||
| const {isSelected, toggleSelected} = useListItemCheckboxContext(); | ||
|
|
||
| // We're defaulting to read from the list data, which is passed in as `initialRepository` | ||
| // But if an update has been made to one record, we're going to enable reading | ||
| // from `useRepositoryWithSettings` which will have the latest data, letting us | ||
| // do optimistic updates, without re-rendering the entire table. | ||
| // `initialRepository` will become stale at that point, but we'll have fresh data | ||
| // in the cache to override it. | ||
| const {data, isError, isPending} = useRepositoryWithSettings({ | ||
| repositoryId: initialRepository.id, | ||
| initialData: [initialRepository, undefined, undefined], | ||
| enabled: mutationData[initialRepository.id] !== undefined, | ||
| }); | ||
| const repository = isError || isPending ? initialRepository : data; | ||
|
|
||
| return ( | ||
| <Grid | ||
| columns={gridColumns} |
Contributor
There was a problem hiding this comment.
Bug: When a repository setting toggle fails, the UI doesn't revert. The onError handler updates an unused query cache instead of the infinite query cache driving the UI.
Severity: MEDIUM
Suggested Fix
The onError handler should be updated to roll back the state of the correct query cache. Instead of updating the individual repository cache, it should find the specific repository within the infinite query's cached data and revert its state there. This will ensure the UI, which reads from the infinite query, reflects the rollback immediately upon failure.
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/gsApp/views/seerAutomation/components/repoTable/seerRepoTableRow.tsx#L32-L52
Potential issue: When a user toggles a repository setting and the backend mutation
fails, the `Switch` component does not visually revert to its previous state. The
`onError` handler attempts a rollback by calling `queryClient.setQueryData` on an
individual repository's query cache. However, the UI's state is derived from a parent
component's infinite query cache. Since the error handler only updates the individual
cache, the UI remains in the incorrect, optimistically toggled state until the infinite
query is invalidated and refetched. This presents a temporarily misleading state to the
user.
Did we get this right? 👍 / 👎 to inform future reviews.
Member
Author
There was a problem hiding this comment.
fixing this will conflict with #112926
I'll revisit once 112926 is in
billyvg
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Actually update the query cache, and remove that weird workaround stuff