FE ManageBoxes: remove state-specific preloads (Solution B option 2)#2702
Open
Copilot wants to merge 2 commits into
Open
FE ManageBoxes: remove state-specific preloads (Solution B option 2)#2702Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Agent-Logs-Url: https://github.com/boxwise/boxtribute/sessions/30d3f41a-d92e-4ba3-915b-86666a686d26 Co-authored-by: pylipp <10617122+pylipp@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2702 +/- ##
==========================================
- Coverage 76.83% 76.80% -0.04%
==========================================
Files 300 300
Lines 22233 22203 -30
Branches 2245 2241 -4
==========================================
- Hits 17082 17052 -30
Misses 5104 5104
Partials 47 47
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pylipp
reviewed
May 4, 2026
…fic preloads Agent-Logs-Url: https://github.com/boxwise/boxtribute/sessions/f938475a-793d-43d3-bcd0-8d45d925c86d Co-authored-by: pylipp <10617122+pylipp@users.noreply.github.com>
Copilot
AI
changed the title
FE ManageBoxes: eliminate preloading (Solution B option 1)
FE ManageBoxes: remove state-specific preloads (Solution B option 2)
May 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Reduces initial backend load when mounting Manage Boxes by removing the three state-specific preload GraphQL requests (InStock/Donated/Scrap) while keeping the initial paginated query plus the full background fetch used to populate totals/cache.
Changes:
- Removed the state-specific preload loop from
BoxesView’s initial mount effect, leaving only the full background fetch. - Updated
BoxesViewand actions test suites to reflect the new request pattern (initialPAGE_SIZEbackground query + full background fetch + actions/options query). - Adjusted test query factories/mocks (notably handling of
state="ALL") so “invalid state id” scenarios still yield data.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| front/src/views/Boxes/BoxesView.tsx | Removes state-specific preload queries; keeps initial background query + full background fetch logic. |
| front/src/views/Boxes/BoxesView.test.tsx | Updates mocks to match the new query sequence; ensures invalid state_ids test still returns data via state="ALL". |
| front/src/views/Boxes/BoxesViewActions.test.tsx | Removes preload mocks across actions tests and adds/adjusts full-background-fetch mocks per state where needed. |
| front/src/views/Boxes/components/BoxesTable.tsx | No functional changes noted in review; continues to use isBackgroundFetchOfBoxesLoading / hasExecutedInitialFetchOfBoxes for UI states. |
| front/src/App.tsx | Continues to pass the persistent hasExecutedInitialFetchOfBoxes ref into BoxesView to avoid repeating the expensive full fetch on navigation. |
Contributor
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.
Summary
Applies a partial performance improvement to
BoxesViewby removing the three state-specific preload requests while keeping the full background fetch.Previously, on initial mount the
BoxesViewcomponent fired 4–5 parallel GraphQL requests simultaneously:useBackgroundQuery(50 boxes, current filter)useEffect(InStock, Donated, Scrap — each 50 boxes)Each request triggered ~15 SQL queries on the backend, resulting in ~75 SQL queries per page load. This change removes the three state-specific preloads (#2), leaving the
useBackgroundQueryfetch and the full background fetch — reducing the backend load from ~75 to ~30 SQL queries on initial page load.Changes
BoxesView.tsx: removed the state-specific preload loop from theuseEffect(the InStock/Donated/Scrap parallel fetches); the full unfilteredapolloClient.querybackground fetch,isBackgroundFetchOfBoxesLoadingstate, andhasExecutedInitialFetchOfBoxesprop are retainedBoxesTable.tsx: no interface changes;isBackgroundFetchOfBoxesLoadingandhasExecutedInitialFetchOfBoxesremain in the component props and all related UI conditionals (total-summary skeleton, "Data unavailable" fallback,autoResetSelectedRows, pagination skeleton) are preservedApp.tsx:hasExecutedInitialFetchOfBoxesref and prop remain unchangedBoxesView.test.tsx: updated mock arrays to include the initialuseBackgroundQuerymock + full background fetch mock +actionsQuery(removed the three state-specific preload mocks); updated theboxesQueryfactory to return boxes forstate="ALL"so the invalid-state-id test still finds dataBoxesViewActions.test.tsx: removed the three state-specific preload mocks from every test; added theboxesQuery({ paginationInput: 100000 })full background fetch mock; for MarkedForShipment and Donated tests, added the corresponding full background fetch mock with the appropriate state filterVerification
pnpm check-typespassespnpm lint:allpassespnpm format:check:allpassespnpm -C front buildpasses