Skip to content

fix(checkboxState): Update useListItemCheckboxContext to not rely on ApiQueryKEy directly, only QueryKeyEndpointOptions#114997

Open
ryan953 wants to merge 5 commits intomasterfrom
ryan953/fix-checkbox-state-QueryKeyEndpointOptions
Open

fix(checkboxState): Update useListItemCheckboxContext to not rely on ApiQueryKEy directly, only QueryKeyEndpointOptions#114997
ryan953 wants to merge 5 commits intomasterfrom
ryan953/fix-checkbox-state-QueryKeyEndpointOptions

Conversation

@ryan953
Copy link
Copy Markdown
Member

@ryan953 ryan953 commented May 6, 2026

This PR has 4 layers to look at

Start with the change to static/app/utils/list/useListItemCheckboxState.tsx

  1. The main thing in here that drives all the other file changes is this:
- type ListCheckboxQueryKeyValue = undefined | ApiQueryKey | InfiniteApiQueryKey;
- export type ListCheckboxQueryKeyRef = RefObject<ListCheckboxQueryKeyValue>;
+ export type ListCheckboxQueryKeyRef = RefObject<undefined | QueryKeyEndpointOptions>;

We've changed from ApiQueryKey | InfiniteApiQueryKey to QueryKeyEndpointOptions and re-wrote it a little to be more concise.

  1. Other changes in this file are also type consolidation. I noticed that we re-wrote things when a union would work.

Files passing values into useListItemCheckboxState or the Provider.

With the change to ListCheckboxQueryKeyValue and ListCheckboxQueryKeyRef we need to pass in a different object to the provider.
Instead of queryKey={queryOptions.queryKey} there's queryKey={safeParseQueryKey(queryOptions.queryKey)?.options} in these 4 files:

  • static/app/components/feedback/list/feedbackList.tsx
  • static/app/views/explore/replays/list/replayIndexTable.tsx
  • static/gsApp/views/seerAutomation/components/projectTable/seerProjectTable.tsx
  • static/gsApp/views/seerAutomation/components/repoTable/seerRepoTable.tsx

We also read from the useListItemCheckboxState

When we read from the state hook we need to make sure we're assuming the new object type. That's what these files are updated to do:

  • static/app/components/replays/table/replayTableHeader.tsx
    • call into: static/app/components/replays/table/replayBulkViewedActions.tsx
  • static/gsApp/views/seerAutomation/components/projectTable/seerProjectTableHeader.tsx
  • static/gsApp/views/seerAutomation/components/repoTable/seerRepoTableHeader.tsx

Final layer

Along the way I noticed that ListItemCheckboxProvider wasn't part of the FeedbackList component tree. It was passing props into the hook and doing weird things. So i added the provider, and moved the calls to useListItemCheckboxContext into the sub-components. I forget the reasons why it wasn't like this before, probably because feedback was the first one and got left behind.

@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 6, 2026
@ryan953 ryan953 marked this pull request as ready for review May 6, 2026 17:51
@ryan953 ryan953 requested review from a team as code owners May 6, 2026 17:51
@ryan953 ryan953 marked this pull request as draft May 6, 2026 17:52
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.44%

…ApiQueryKEy directly, only QueryKeyEndpointOptions
@ryan953 ryan953 force-pushed the ryan953/fix-checkbox-state-QueryKeyEndpointOptions branch from 12f2188 to be936ec Compare May 6, 2026 18:14
@ryan953 ryan953 marked this pull request as ready for review May 6, 2026 18:48
@ryan953 ryan953 requested a review from billyvg May 6, 2026 18:49
Copy link
Copy Markdown
Collaborator

@TkDodo TkDodo left a comment

Choose a reason for hiding this comment

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

nice work 🙌

hits={filteredProjects.length}
knownIds={filteredProjects.map(project => project.id)}
queryKey={queryKey}
queryKey={safeParseQueryKey(queryKey)?.options}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think there’s some more cleanup missing:

  1. the param here is not queryKey anymore - it’s endpointOptions
  2. we’re still constructing a “fake” query key just to safeParse it and pass options from it, but we can just pass options naturally. The queryKey is not used anywhere else:
endpointOptions={{query: {query: searchTerm, sort, agent: agentFilter}}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

we already parseQueryKey in line 63:

  const {options} = parseQueryKey(queryKey);
  const needsSDKUpdateForClickSearch = useNeedsSDKUpdateForClickSearch({
    search: options?.query?.query as string | undefined,
  });

I think you’d want to change that to safeParseQueryKey too (as we use it as options?.query?.query anyways, it can be undefined), thus getting rid of parseQueryKey here altogether and we’d only parse once not twice.

const queryOptions = queryKeyRef.current
? parseQueryKey(queryKeyRef.current).options
: undefined;
const queryOptions = queryKeyRef.current;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

naming wise this should really be endpointOptions as queryOptions is already a term we use for react-query queryOptions() and it’s quite confusing that this is something different 😅

const queryOptions = queryKeyRef.current
? parseQueryKey(queryKeyRef.current).options
: undefined;
const queryOptions = queryKeyRef.current;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same naming thought here:

Suggested change
const queryOptions = queryKeyRef.current;
const endpointOptions = endpointOptionsRef.current;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants