Skip to content

refactor(FR-3430): split FairShareList into per-step self-contained components - #8516

Merged
ironAiken2 merged 9 commits into
mainfrom
refactor/FR-3430-fairshare-step-queries
Sep 1, 2026
Merged

refactor(FR-3430): split FairShareList into per-step self-contained components#8516
ironAiken2 merged 9 commits into
mainfrom
refactor/FR-3430-fairshare-step-queries

Conversation

@ironAiken2

@ironAiken2 ironAiken2 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Resolves #8515 (FR-3430)

Problem

FairShareList.tsx fetched all four fair-share connections (adminResourceGroups, rgDomainFairShares, rgProjectFairShares, rgUserFairShares) in a single root useLazyLoadQuery. Because of the @skip variables, only the current step's connection was actually fetched — the single-query structure was pure overhead:

  1. Step-switching complexity — 3 @skip flags, per-step order/filter variable switches (FairShareOrderVariables / FairShareFilterVariables), and limit/offset shared across 4 connections.
  2. Always-on adminResourceGroups fetch + page-window bug — the resource group list was refetched on every pagination/filter change of lower steps, and the selected resource group was located via _.find on the current page of the unfiltered list. If it fell outside the page window, the scheduler warning Alert and the modal's resourceGroupFrgmt silently disappeared.

Changes

  1. Per-step self-contained components — new ResourceGroupFairShareStep / DomainFairShareStep / ProjectFairShareStep / UserFairShareStep, each owning its own useLazyLoadQuery, pagination, filter, order, row selection, and modals (FairShareWeightSettingModal / UsageBucketModal). FairShareList keeps only the step URL state, the Steps UI, and step-transition callbacks. All @skip flags, variable switches, and as Array<...> casting switches are gone; step transitions reset selection naturally via unmount.
  2. Scheduler warning via single lookup — new ResourceGroupSchedulerTypeAlert queries the selected resource group by name (filter: { name: { equals } }, limit: 1), fixing the page-window miss. The weight-setting modal's resource group fragment is likewise fetched per step by name.
  3. URL params keep their existing formatresourceGroup/domain by name, project by id, so pre-existing URLs and browser history stay valid. The project name in the Steps title is resolved by a small projectV2 lookup (ProjectStepNameText) instead of being part of the root query. The unused user URL param is removed.
  4. Step transitions now also reset the page number (current), which the previous forward-navigation handlers forgot (stale page carried into the next step).
  5. Raise Relay gcReleaseBufferSize from the default 10 to 20 (RelayEnvironment.ts) — re-entering a step could intermittently crash into the ErrorBoundary fallback (Relay: Missing @required value at path ...) with zero network requests. Leaving a step releases its queries into the store's GC release buffer, and the FairShare screens churn released (query, variables) combos fast — notably one *ResourceGroupWarningIconQuery per table row — so a step's records were garbage-collected between visits while the react-relay QueryResource cache hit on remount skipped the refetch. A larger buffer keeps recently released step queries retained across step round trips. This supersedes the per-entry fetchKey approach explored in fix(FR-3430): force a fresh fetch on FairShare step remount with per-mount fetchKey #8565 (closed); see that PR for the full root-cause analysis.

Behavioral notes

  • UserNotAllowedInResourceGroup alert (UserResourceGroupAlert) now renders inside the user step (below the Steps panel) instead of above the info alert.
  • SchedulerPage's ErrorBoundary intentionally has no resetKeys: once an error is caught, the fallback stays until the user explicitly resets via the "go back to first step" button. This is by design and unchanged here.

Verification

bash scripts/verify.sh=== ALL PASS === (Relay / Lint / Format / TypeScript / Vite warmup / Terminology)

🤖 Generated with Claude Code

@github-actions github-actions Bot added the size:XL 500~ LoC label Aug 3, 2026
@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for react-coverage (./react)

Status Category Percentage Covered / Total
🔵 Lines 14.97% 5140 / 34323
🔵 Statements 12.56% 6212 / 49456
🔵 Functions 12.51% 788 / 6297
🔵 Branches 9.36% 4417 / 47159
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
react/src/RelayEnvironment.ts 14.54% 0% 6.66% 15.38% 29-34, 39-54, 57-63, 72-116, 124-159
react/src/components/FairShareItems/DomainFairShareStep.tsx 0% 0% 0% 0% 37-168
react/src/components/FairShareItems/FairShareList.tsx 0% 0% 0% 0% 57-84
react/src/components/FairShareItems/FairShareStepToolbar.tsx 0% 0% 0% 0% 36-50
react/src/components/FairShareItems/ProjectFairShareStep.tsx 0% 0% 0% 0% 38-175
react/src/components/FairShareItems/ResourceGroupFairShareStep.tsx 0% 0% 0% 0% 27-125
react/src/components/FairShareItems/ResourceGroupSchedulerTypeAlert.tsx 0% 0% 0% 0% 21-43
react/src/components/FairShareItems/UserFairShareStep.tsx 0% 0% 0% 0% 39-196
react/src/pages/SchedulerPage.tsx 0% 0% 0% 0% 26-86
Generated in workflow #4239 for commit c39e98b by the Vitest Coverage Report Action

ironAiken2 and others added 2 commits August 4, 2026 08:44
…omponents

Each fair-share step (resource group / domain / project / user) now owns
its own query, pagination, filter, order, selection, and modals instead
of sharing a single root query with @Skip flags. The selected resource
group's scheduler warning moves to a name-filtered single lookup, fixing
the page-window miss. URL params now store names only; the user step
resolves the project name to an id via the project.name nested filter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Storing the project name in the URL broke old-format URLs
(project=<uuid>) still present in browser history, and the extra
name-to-id resolution round trip added no value once the step title
lookup exists anyway. The user step now receives the project id
directly, and the Steps title resolves the display name with a small
projectV2 lookup.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ironAiken2
ironAiken2 force-pushed the refactor/FR-3430-fairshare-step-queries branch from 0fa6966 to 624332b Compare August 3, 2026 23:44
@ironAiken2
ironAiken2 marked this pull request as ready for review August 4, 2026 00:26
@ironAiken2
ironAiken2 requested a review from nowgnuesLee August 4, 2026 00:26
The FairShare step screens churn released (query, variables) combos
faster than the default 10-slot GC release buffer can hold — notably one
*ResourceGroupWarningIconQuery per table row — so a step's query records
were garbage-collected between visits and @required(action: THROW) fired
on the GC'd reads. Doubling the buffer keeps recently released step
queries retained across step round trips.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 4, 2026 04:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors FairShare navigation into self-contained step components with isolated Relay queries and state.

Changes:

  • Splits resource-group, domain, project, and user steps.
  • Adds targeted resource-group and project-name lookups.
  • Updates URL cleanup, Relay artifacts, and GC retention.

Reviewed changes

Copilot reviewed 8 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
react/src/RelayEnvironment.ts Increases Relay GC release buffer.
react/src/pages/SchedulerPage.tsx Removes obsolete user URL state.
react/src/components/FairShareItems/FairShareList.tsx Orchestrates step navigation and URL state.
react/src/components/FairShareItems/ResourceGroupFairShareStep.tsx Adds resource-group step implementation.
react/src/components/FairShareItems/DomainFairShareStep.tsx Adds domain step implementation.
react/src/components/FairShareItems/ProjectFairShareStep.tsx Adds project step implementation.
react/src/components/FairShareItems/UserFairShareStep.tsx Adds user step implementation.
react/src/components/FairShareItems/ResourceGroupSchedulerTypeAlert.tsx Adds targeted scheduler warning lookup.
react/src/__generated__/FairShareListQuery.graphql.ts Removes obsolete combined query artifact.
react/src/__generated__/FairShareListProjectNameQuery.graphql.ts Adds project-name query artifact.
react/src/__generated__/ResourceGroupFairShareStepQuery.graphql.ts Adds resource-group query artifact.
react/src/__generated__/DomainFairShareStepQuery.graphql.ts Adds domain query artifact.
react/src/__generated__/ProjectFairShareStepQuery.graphql.ts Adds project query artifact.
react/src/__generated__/UserFairShareStepQuery.graphql.ts Adds user query artifact.
react/src/__generated__/ResourceGroupSchedulerTypeAlertQuery.graphql.ts Adds scheduler-alert query artifact.
Files not reviewed (7)
  • react/src/generated/DomainFairShareStepQuery.graphql.ts: Generated file
  • react/src/generated/FairShareListProjectNameQuery.graphql.ts: Generated file
  • react/src/generated/FairShareListQuery.graphql.ts: Generated file
  • react/src/generated/ProjectFairShareStepQuery.graphql.ts: Generated file
  • react/src/generated/ResourceGroupFairShareStepQuery.graphql.ts: Generated file
  • react/src/generated/ResourceGroupSchedulerTypeAlertQuery.graphql.ts: Generated file
  • react/src/generated/UserFairShareStepQuery.graphql.ts: Generated file

Comment thread react/src/components/FairShareItems/FairShareList.tsx Outdated
Comment thread react/src/RelayEnvironment.ts

@agatha197 agatha197 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The refactoring direction (splitting into self-contained step components, fixing the page-window bug) is good. Please address the items below before merging. (__generated__/** was excluded from review.)

Code quality

  • Selection state, modal state, pagination, toolbar JSX, and modal JSX are nearly duplicated across the 4 step components (ResourceGroupFairShareStep/DomainFairShareStep/ProjectFairShareStep/UserFairShareStep). See the inline comment.
  • ProjectFairShareStep's onClickProjectName callback parameter name doesn't match the actual value (a project id). See the inline comment.

Potential issues / risks

  • Entering the Domain/Project/User steps duplicates the adminResourceGroups fetch (once for the scheduler warning, once for the modal fragment). See the inline comment.
  • The gcReleaseBufferSize change affects the app-wide Relay store but has no explanatory comment in the code. See the inline comment.

Test coverage

  • There are no unit/e2e tests for FairShare, before or after this refactor. Given this PR fixes regression-prone behavior (the page-window bug, resetting pagination on step transitions), I'd recommend adding at least a minimal e2e scenario (navigate steps → verify filter/pagination persists correctly).

Comment thread react/src/components/FairShareItems/DomainFairShareStep.tsx
Comment thread react/src/components/FairShareItems/ProjectFairShareStep.tsx Outdated
Comment thread react/src/components/FairShareItems/ResourceGroupSchedulerTypeAlert.tsx Outdated
Comment thread react/src/RelayEnvironment.ts
ironAiken2 and others added 2 commits August 5, 2026 08:53
Add a one-line note above gcReleaseBufferSize clarifying it retains step
queries released during FairShare step navigation (default 10).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ogic

Collapse the ~150 lines of selection state, toolbar JSX, and modal wiring
that were repeated across the Domain/Project/User fair-share steps.

- Add useFairShareStepSelectionState: bundles the multi-row/single-row
  selection state and the weight-setting/usage modal open state, plus a
  keyField-bound row-select handler and clear/close helpers.
- Add FairShareStepToolbar: the filter + selection action buttons +
  AutoUpdateFetchKeyButton row. Selection actions are optional, so the
  resource-group step reuses it without any selection support.
- Merge the duplicate adminResourceGroups lookup: the scheduler-type
  alert now consumes a ResourceGroupSchedulerTypeAlertFragment fed by the
  resource-group node each step already fetches for the weight modal,
  instead of firing its own identical query from FairShareList.
- Rename ProjectFairShareStep's onClickProjectName parameter to projectId
  to match the table (which passes record.projectId) and FairShareList.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ironAiken2

Copy link
Copy Markdown
Contributor Author

Addressed the review feedback in 62962c1 + 7c2c697 (all inline threads replied & resolved):

  • Extracted useFairShareStepSelectionState + FairShareStepToolbar to collapse the 4-way duplication
  • Aligned ProjectFairShareStep's callback param to projectId
  • Merged the duplicate adminResourceGroups lookup — the scheduler alert is now a fragment on the step's existing resource-group node
  • Documented the gcReleaseBufferSize rationale in code

scripts/verify.sh=== ALL PASS ===.

Re: test coverage — agreed FairShare has no coverage today; a minimal e2e scenario (step navigation → filter/pagination persistence) is planned as a follow-up rather than in this refactor PR, to keep the diff reviewable.

Comment thread react/src/components/FairShareItems/useFairShareStepSelectionState.tsx Outdated
Comment thread react/src/components/FairShareItems/FairShareList.tsx Outdated
Comment thread react/src/components/FairShareItems/ResourceGroupFairShareStep.tsx
…e Suspense

- Remove useFairShareStepSelectionState: selection/modal state goes back to
  plain useState + handleRowSelectionChange in each step, matching the
  convention used by every other list page (e.g. AdminComputeSessionListPage,
  VFolderNodeListPage).
- Render ProjectStepNameText without its own null-fallback Suspense: step
  transitions run in a deferred-value background render, so suspending there
  makes the transition wait for the name query too — the name is guaranteed
  to be present when the step commits, instead of popping in after an empty
  gap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ironAiken2
ironAiken2 requested a review from nowgnuesLee August 10, 2026 04:42
ironAiken2 and others added 2 commits August 11, 2026 06:24
…step-queries

Resolve the FR-3482 antd->Astryx migration against the FairShare per-step
split:
- FairShareList.tsx: keep the per-step orchestrator structure; port main's
  migration decisions (antd Steps -> lab Stepper/Step with string
  label/description, Alert -> Banner, Skeleton -> BAISkeletonAstryx,
  Typography.Title -> Heading, theme -> theme-shim, drop the antd-style
  createStyles block). The selected project's display name moves into an
  `@skip`ped projectV2 query because Step.description must be a string.
- New step components (ResourceGroup/Domain/Project/User) and
  FairShareStepToolbar / ResourceGroupSchedulerTypeAlert: convert antd
  imports to Astryx (Tooltip content/placement, Banner, theme-shim) and drop
  the unsupported pagination.style key (BAIAstryxPaginationConfig has none).
- SchedulerPage / RelayEnvironment: clean auto-merge (main's Astryx page +
  this branch's user-param removal and gcReleaseBufferSize).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Resolve conflict in FairShareList.tsx: keep the per-step component
structure from this branch and adopt main's BAISkeletonAstryx ->
BAISkeleton replacement (FR-3513, #8740) for the Suspense fallback.

@agatha197 agatha197 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there any reason to maintain pagination with 3 step?
If I click 1, the pagination step is maintained. But if I click 2, the pagination step goes to 10.
Image

…ansition

Each step owns its pagination via useBAIPaginationOptionStateOnSearchParam,
which stores both `current` and `pageSize` in the URL. The step-transition
reset in FairShareList cleared order/filter/current but left `pageSize`, so
a page size chosen on one step leaked into the next step's table.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UU4bgjsFizw5FriTUjnsHp
@ironAiken2

Copy link
Copy Markdown
Contributor Author

Is there any reason to maintain pagination with 3 step? If I click 1, the pagination step is maintained. But if I click 2, the pagination step goes to 10.

@agatha197 Good catch — that inconsistency was a bug, not intended. Each step owns its pagination via useBAIPaginationOptionStateOnSearchParam, which stores both current and pageSize in the URL, but the step-transition reset in FairShareList only cleared order/filter/current and left pageSize behind. So a page size chosen on one step leaked into the next step's table.

Fixed in c39e98b: pageSize is now cleared together with the rest of the per-step query state. The reset runs on both Stepper's onStepClick and the row-click drill-down handlers, so every step transition (forward and backward) now starts from the step's own pagination defaults.

@ironAiken2
ironAiken2 requested a review from agatha197 August 20, 2026 06:43

@agatha197 agatha197 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I know it is unrelated with this PR, but Fair Share Factor sorting doesn't work in every tab. Can you remove it from available sort items?

@ironAiken2

Copy link
Copy Markdown
Contributor Author

I know it is unrelated with this PR, but Fair Share Factor sorting doesn't work in every tab. Can you remove it from available sort items?

I will work on this in a separate PR. @agatha197

@ironAiken2
ironAiken2 requested a review from agatha197 September 1, 2026 01:35

@agatha197 agatha197 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@ironAiken2
ironAiken2 merged commit 80d9507 into main Sep 1, 2026
21 checks passed
@ironAiken2
ironAiken2 deleted the refactor/FR-3430-fairshare-step-queries branch September 1, 2026 01:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor FairShareList: split the single root query into per-step self-contained components

4 participants