Skip to content

Conversation

@ironAiken2
Copy link
Contributor

@ironAiken2 ironAiken2 commented Dec 11, 2025

Resolves #4821 (FR-1786)

Add RESOURCE_ALLOCATION_INITIAL_FORM_VALUES to SessionLauncherPage

This PR adds the RESOURCE_ALLOCATION_INITIAL_FORM_VALUES constant to the merged initial values in the SessionLauncherPage component. This ensures that resource allocation form values are properly initialized when the page loads.

Changes

  • Import RESOURCE_ALLOCATION_INITIAL_FORM_VALUES from ResourceAllocationFormItems
  • Include this constant in the merged initial values calculation to ensure proper resource allocation defaults

This change helps maintain consistent resource allocation values during page initialization and prevents potential undefined values in the form.

@github-actions github-actions bot added the size:M 30~100 LoC label Dec 11, 2025
Copy link
Contributor Author

ironAiken2 commented Dec 11, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements 4.38% 517/11816
🔴 Branches 3.59% 298/8312
🔴 Functions 2.63% 95/3615
🔴 Lines 4.35% 503/11557

Test suite run success

145 tests passing in 14 suites.

Report generated by 🧪jest coverage report action from 6968722

@ironAiken2 ironAiken2 marked this pull request as ready for review December 11, 2025 05:10
Copilot AI review requested due to automatic review settings December 11, 2025 05:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in the session launcher resource form where page refreshes caused incorrect initialization of resource allocation values. The root cause was improper handling of undefined values in the InputNumberWithSlider component, which triggered unwanted form updates and preset changes.

Key Changes:

  • Fixed InputNumberWithSlider to prevent setValue(0) calls when value is undefined by adding _.isNil(value) check
  • Added optional chaining for safer access to shmem field properties in resource allocation form
  • Replaced dynamic field key retrieval with explicit field key declaration in SessionLauncherPreview for reliable error detection

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
react/src/components/InputNumberWithSlider.tsx Added null/undefined check before integer normalization to prevent NaN-related bugs that triggered unwanted onChange events
react/src/components/SessionFormItems/ResourceAllocationFormItems.tsx Added optional chaining for shmem field access; refactored allocation preset checks to use consistent variable reference; removed trailing whitespace
react/src/components/SessionLauncherPreview.tsx Replaced dynamic field key retrieval with explicit array of resource field keys to ensure proper error detection even when field values are undefined

After thoroughly reviewing this PR, I found that all changes are well-implemented and appropriately address the described issue. The fixes are:

  1. InputNumberWithSlider.tsx: The addition of !_.isNil(value) correctly prevents the component from trying to normalize undefined values, which was causing undefined % 1 to return NaN and triggering unwanted setValue(0) calls.

  2. ResourceAllocationFormItems.tsx: The optional chaining additions (?.shmem) are appropriate defensive programming practices. The refactoring from form.getFieldValue('allocationPreset') to currentAllocationPreset improves code consistency and readability without changing logic.

  3. SessionLauncherPreview.tsx: The change from dynamically retrieving keys via _.some(form.getFieldValue('resource'), (_v, key) => ...) to explicitly declaring the field keys is a solid fix. When field values don't exist, getFieldValue may not return all keys, which would cause error detection to fail.

All changes follow TypeScript best practices, maintain proper null safety, and align with the project's coding standards. No i18n violations were found, and the code quality is good.

Copy link
Contributor

@nowgnuesLee nowgnuesLee left a comment

Choose a reason for hiding this comment

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

LGTM

@ironAiken2 ironAiken2 force-pushed the fix/FR-1783-session-launcher-resource-form-initialization branch from 1596adc to 7592523 Compare December 11, 2025 10:38
@github-actions github-actions bot added size:XS ~10 LoC and removed size:M 30~100 LoC labels Dec 11, 2025
@ironAiken2 ironAiken2 changed the title fix(FR-1783): fix session launcher resource form initialization on page refresh fix(FR-1786): fix session launcher resource form initialization Dec 11, 2025
Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

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

LGTM

@graphite-app
Copy link

graphite-app bot commented Dec 12, 2025

Merge activity

### Resolves #4821 ([FR-1786](https://lablup.atlassian.net/browse/FR-1786))

Add RESOURCE_ALLOCATION_INITIAL_FORM_VALUES to SessionLauncherPage

This PR adds the `RESOURCE_ALLOCATION_INITIAL_FORM_VALUES` constant to the merged initial values in the `SessionLauncherPage` component. This ensures that resource allocation form values are properly initialized when the page loads.

## Changes

- Import `RESOURCE_ALLOCATION_INITIAL_FORM_VALUES` from ResourceAllocationFormItems
- Include this constant in the merged initial values calculation to ensure proper resource allocation defaults

This change helps maintain consistent resource allocation values during page initialization and prevents potential undefined values in the form.

[FR-1786]: https://lablup.atlassian.net/browse/FR-1786?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
@graphite-app graphite-app bot force-pushed the fix/FR-1783-session-launcher-resource-form-initialization branch from 7592523 to 6968722 Compare December 12, 2025 00:53
@graphite-app graphite-app bot merged commit 6968722 into main Dec 12, 2025
11 checks passed
@graphite-app graphite-app bot deleted the fix/FR-1783-session-launcher-resource-form-initialization branch December 12, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS ~10 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot access to the session launcher page intermittently

4 participants