-
Notifications
You must be signed in to change notification settings - Fork 78
refactor(FR-1653): extract session creation logic into useStartSession hook #4592
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
refactor(FR-1653): extract session creation logic into useStartSession hook #4592
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
Coverage report for
|
St.❔ |
Category | Percentage | Covered / Total |
|---|---|---|---|
| 🔴 | Statements | 4.64% | 531/11433 |
| 🔴 | Branches | 3.77% | 302/8016 |
| 🔴 | Functions | 2.89% | 102/3529 |
| 🔴 | Lines | 4.59% | 513/11176 |
Test suite run success
121 tests passing in 14 suites.
Report generated by 🧪jest coverage report action from 4c28ccd
c55bbb6 to
8fd2558
Compare
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.
Pull Request Overview
This PR refactors session creation logic by extracting it from SessionLauncherPage into a reusable custom hook useStartSession. The refactoring improves code organization and enables the session creation logic to be used in multiple locations throughout the application.
- Extracted session creation logic into a new custom hook
useStartSession - Moved related types, constants, and helper functions to the new hook file
- Updated
SessionLauncherPageto use the new hook instead of inline implementation
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| react/src/hooks/useStartSession.tsx | New custom hook containing the extracted session creation logic, types, and helper functions |
| react/src/pages/SessionLauncherPage.tsx | Refactored to use the new useStartSession hook, removed inline session creation logic and unused imports |
Comments suppressed due to low confidence (1)
react/src/hooks/useStartSession.tsx:34
- Unknown directive: 'use memo'.
'use memo';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
767de63 to
346cb6a
Compare
ironAiken2
left a comment
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.
LGTM
346cb6a to
cf4df2e
Compare
cf4df2e to
601fe05
Compare
ironAiken2
left a comment
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.
LGTM
601fe05 to
d27b474
Compare
nowgnuesLee
left a comment
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.
LGTM
Merge activity
|
…n hook (#4592) # Refactor session creation logic into useStartSession hook Resolves #4591 ([FR-1653](https://lablup.atlassian.net/browse/FR-1653)) ## Summary This PR extracts the complex session creation logic from the `SessionLauncherPage` component into a reusable custom hook called `useStartSession`. This refactoring improves code organization, maintainability, and testability. ## Changes ### New File - **[react/src/hooks/useStartSession.tsx](react/src/hooks/useStartSession.tsx)** - Custom hook containing all session creation logic (~297 lines) - Handles session creation with all configuration options (batch, interactive, multiple sessions) - Manages error handling and notifications - Supports owner settings, resource allocation, and storage configuration ### Modified File - **[react/src/pages/SessionLauncherPage.tsx](react/src/pages/SessionLauncherPage.tsx)** - Refactored to use the new hook - Removed ~280 lines of embedded session creation logic - Simplified component to focus on UI concerns - Maintained all existing functionality and behavior ## Benefits 1. **Better Separation of Concerns**: UI logic separated from business logic 2. **Improved Testability**: Session creation logic can now be tested in isolation 3. **Code Reusability**: Hook can be used in other components if needed 4. **Easier Maintenance**: Changes to session creation logic are now centralized 5. **Follows React Best Practices**: Proper use of custom hooks for complex logic ## Testing All existing functionality has been preserved: - Session creation with various configurations - Batch mode and scheduling - Resource allocation - Storage mounting - Environment variables - Multiple session creation - Error handling and notifications - Navigation after creation **Checklist:** - [x] Code follows React best practices for custom hooks - [x] All existing functionality is maintained - [x] Error handling is preserved - [x] No breaking changes to the API [FR-1653]: https://lablup.atlassian.net/browse/FR-1653?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
d27b474 to
4c28ccd
Compare

Refactor session creation logic into useStartSession hook
Resolves #4591 (FR-1653)
Summary
This PR extracts the complex session creation logic from the
SessionLauncherPagecomponent into a reusable custom hook calleduseStartSession. This refactoring improves code organization, maintainability, and testability.Changes
New File
Modified File
Benefits
Testing
All existing functionality has been preserved:
Checklist: