-
Notifications
You must be signed in to change notification settings - Fork 1
fix(MULTIPLA-002-2): CU-86akhf8u5 6 review findings across 5 files #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f6047a9
50c6e87
da3d63a
c29456c
6638973
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** | ||
| * Canonical TanStack Query key factories for the Mingo context items. | ||
| * | ||
| * Centralizing these avoids ad-hoc inline query key arrays drifting apart | ||
| * across files (e.g. rest-items.tsx and use-mingo-dialog.ts) and failing to | ||
| * invalidate the correct cache entries. | ||
| */ | ||
|
|
||
| export const mingoContextKeys = { | ||
| tickets: (query: string) => ['mingo-context', 'tickets', query] as const, | ||
| policies: (query: string) => ['mingo-context', 'policies', query] as const, | ||
| queries: (query: string) => ['mingo-context', 'queries', query] as const, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,8 +10,10 @@ const EMPTY_LABELS: FleetLabel[] = []; | |
|
|
||
| // ============ Query Keys ============ | ||
|
|
||
| const LABELS_BASE_KEY = 'labels' as const; | ||
|
|
||
| export const labelsQueryKeys = { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ Query keys in use-labels.ts and mingo context hooks use inline arrays instead of importing from admin-query-keys.ts In π€ Prompt for AI agentsfix confidence: π΄ 25 low β review closely β react π/π to teach the reviewer |
||
| all: ['labels'] as const, | ||
| all: [LABELS_BASE_KEY] as const, | ||
| list: () => [...labelsQueryKeys.all, 'list'] as const, | ||
| }; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,16 @@ export interface AvatarOption extends AutocompleteOption { | |
| const EMPTY_AUTOCOMPLETE_OPTIONS: AutocompleteOption[] = []; | ||
| const EMPTY_AVATAR_OPTIONS: AvatarOption[] = []; | ||
|
|
||
| // Named query-key builders for this module's cache entries. Centralizing these | ||
| // here (rather than inlining string arrays at each useQuery call) gives any | ||
| // future invalidateQueries call site a single source of truth to reference. | ||
| export const ticketOptionsQueryKeys = { | ||
| organizations: (search: string) => ['ticket-options', 'organizations', search] as const, | ||
| assignees: () => ['ticket-options', 'assignees'] as const, | ||
| tickets: (search: string, organizationId: string | null, statusIds: string[] | null) => | ||
| ['ticket-options', 'tickets', search, organizationId, statusIds] as const, | ||
| }; | ||
|
|
||
| /** An image reference as both the GraphQL and REST endpoints below return it. */ | ||
| interface OptionImage { | ||
| imageUrl?: string | null; | ||
|
|
@@ -53,6 +63,12 @@ interface UserOption { | |
|
|
||
| // --- Organizations (reuse existing query via /api/graphql) --- | ||
|
|
||
| // NOTE: This uses apiClient.post against a REST-shaped /api/graphql endpoint | ||
| // rather than react-relay (useLazyLoadQuery/useFragment). Per the org's Relay | ||
| // migration mandate, new GraphQL data fetching should go through react-relay; | ||
| // this is flagged as technical debt against that mandate rather than migrated | ||
| // here, since doing so would require restructuring this hook and its callers | ||
| // beyond the scope of this fix. | ||
| async function fetchCustomerOptions(search: string): Promise<AvatarOption[]> { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π GraphQL data fetching in ticket options uses raw REST-style POST calls via apiClient rather than react-relay No functional/import change made for π€ Prompt for AI agentsfix confidence: π΄ 20 low β review closely β react π/π to teach the reviewer |
||
| const response = await apiClient.post<{ | ||
| data?: { organizations?: { edges?: { node: OrganizationOptionNode }[] } }; | ||
|
|
@@ -72,7 +88,7 @@ async function fetchCustomerOptions(search: string): Promise<AvatarOption[]> { | |
|
|
||
| export function useOrganizationOptions(search = '', enabled = true) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ Inline query key arrays used instead of shared admin-query-keys constants In π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
| const query = useQuery({ | ||
| queryKey: ['ticket-options', 'organizations', search], | ||
| queryKey: ticketOptionsQueryKeys.organizations(search), | ||
| queryFn: () => fetchCustomerOptions(search), | ||
| enabled, | ||
| }); | ||
|
|
@@ -151,7 +167,7 @@ async function fetchAssigneeOptions(): Promise<AvatarOption[]> { | |
|
|
||
| export function useAssigneeOptions(enabled = true) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ Inline query key array for assignee options bypasses centralized query-keys module In π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
| const query = useQuery({ | ||
| queryKey: ['ticket-options', 'assignees'], | ||
| queryKey: ticketOptionsQueryKeys.assignees(), | ||
| queryFn: fetchAssigneeOptions, | ||
| enabled, | ||
| }); | ||
|
|
@@ -263,7 +279,7 @@ export function useTicketSearchOptions(search = '', organizationId?: string, ena | |
| ); | ||
|
|
||
| const query = useQuery({ | ||
| queryKey: ['ticket-options', 'tickets', search, organizationId ?? null, nonArchivedStatusIds ?? null], | ||
| queryKey: ticketOptionsQueryKeys.tickets(search, organizationId ?? null, nonArchivedStatusIds ?? null), | ||
| queryFn: () => fetchTicketSearchOptions(search, organizationId, nonArchivedStatusIds), | ||
| enabled: enabled && !statusesQuery.isLoading, | ||
| }); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,8 +16,15 @@ export interface OptimisticMoveSnapshot { | |
| detail?: { key: QueryKey; data: Dialog | null | undefined }; | ||
| } | ||
|
|
||
| const boardColumnsKeyPrefix = dialogsQueryKeys.boardColumns(); | ||
|
|
||
| function isBoardQueryKey(key: QueryKey): boolean { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π΄ invalidateBoardColumns and applyOptimisticMove use inline query key predicates instead of admin-query-keys constants In π€ Prompt for AI agentsfix confidence: π‘ 70 medium β react π/π to teach the reviewer |
||
| return Array.isArray(key) && key.length >= 4 && key[0] === 'dialogs' && key[1] === 'boardColumn'; | ||
| return ( | ||
| Array.isArray(key) && | ||
| key.length >= 4 && | ||
| key[0] === boardColumnsKeyPrefix[0] && | ||
| key[1] === boardColumnsKeyPrefix[1] | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π΄ Inline query key literals in rest-items.tsx and use-mingo-dialog.ts bypass admin-query-keys.ts
In
src/app/(app)/mingo/context/rest-items.tsx, replaced the three inline query key arrays (['mingo-context', 'tickets', query],['mingo-context', 'policies', query],['mingo-context', 'queries', query]) used inTicketItems,PolicyItems, andQueryItemswith calls to a newmingoContextKeys.tickets/policies/queriesfactory imported from a new modulesrc/app/(app)/mingo/context/query-keys.ts(created as a NEWFILE). This resolves the "ad-hoc inline array" pattern for this file by centralizing the key shapes in one importable module. However, the finding references a specific pre-existing "admin-query-keys.ts" canonical module and a companion fileuse-mingo-dialog.ts(['mingo-dialogs']) that I was not given and cannot see or edit β I did not invent an import to a module I couldn't verify exists, so I created a scoped local module instead of wiring into the mandatedadmin-query-keys.ts. A complete fix requires: (a) confirming whetheradmin-query-keys.tsalready exists elsewhere in the repo and, if so, migratingmingoContextKeysinto it instead of a standalone file, and (b) updatinguse-mingo-dialog.tsto import the same canonical keys, which is outside this file's scope and was not modified.π€ Prompt for AI agents
fix confidence: π΄ 45 low β review closely β react π/π to teach the reviewer