- 
                Notifications
    You must be signed in to change notification settings 
- Fork 78
feat(FR-1530): Implement window focus check for automatic refresh interval #4358
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
feat(FR-1530): Implement window focus check for automatic refresh interval #4358
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.41% (-0.01% 🔻) | 501/11351 | 
| 🔴 | Branches | 3.56% (-0.01% 🔻) | 285/8016 | 
| 🔴 | Functions | 2.55% (-0% 🔻) | 90/3532 | 
| 🔴 | Lines | 4.39% (-0.01% 🔻) | 487/11095 | 
Test suite run success
114 tests passing in 13 suites.
Report generated by 🧪jest coverage report action from a737f11
293d794    to
    c6915f4      
    Compare
  
    09b8426    to
    01dee45      
    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.
LGTM
01dee45    to
    948e77d      
    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 implements a window focus check feature for automatic refresh intervals by adding a pauseOnWindowBlur option to interval hooks. When enabled (default), intervals pause when the window loses focus and resume with an immediate callback execution when focus is regained, reducing unnecessary background processing.
- Added pauseOnWindowBlurparameter touseIntervalanduseIntervalValuehooks with default value oftrue
- Implemented window focus/blur event handling to pause/resume intervals based on window focus state
- Updated BAIFetchKeyButtoncomponent to support the newpauseOnWindowBluroption
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description | 
|---|---|
| react/src/hooks/useIntervalValue.tsx | Added window focus/blur detection and pauseOnWindowBlurparameter to both interval hooks | 
| react/src/components/BAIFetchKeyButton.tsx | Added pauseOnWindowBlurprop support with default value oftrue | 
| react/src/components/KeypairResourcePolicySettingModal.tsx | Removed commented-out code line | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
948e77d    to
    f108b95      
    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.
Please consider document.visibilityState instead of focus.
f108b95    to
    63d1fed      
    Compare
  
    63d1fed    to
    3ecb178      
    Compare
  
    9c43d1d    to
    4e1ef17      
    Compare
  
    4e1ef17    to
    c99d1cb      
    Compare
  
    c99d1cb    to
    874597a      
    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.
LGTM
| Merge activity
 | 
…erval (#4358) Resolves #4357 ([FR-1530](https://lablup.atlassian.net/browse/FR-1530)) # Add pauseWhenHidden option to interval hooks This PR adds a `pauseWhenHidden` option to the `useInterval` and `useIntervalValue` hooks, allowing intervals to be paused when the page is hidden (tab not in focus). The feature is enabled by default but can be disabled by setting `pauseWhenHidden={false}`. When enabled: - Intervals pause when the page is hidden - Callbacks execute immediately when the page becomes visible again - Reduces unnecessary background processing The `BAIFetchKeyButton` component has been updated to support this new option, with the default behavior maintaining backward compatibility. **Checklist:** - [ ] Documentation - [ ] Minium required manager version - [ ] Specific setting for review (eg., KB link, endpoint or how to setup) - [ ] Minimum requirements to check during review - [ ] Test case(s) to demonstrate the difference of before/after [FR-1530]: https://lablup.atlassian.net/browse/FR-1530?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
874597a    to
    a737f11      
    Compare
  
    
Resolves #4357 (FR-1530)
Add pauseWhenHidden option to interval hooks
This PR adds a
pauseWhenHiddenoption to theuseIntervalanduseIntervalValuehooks, allowing intervals to be paused when the page is hidden (tab not in focus). The feature is enabled by default but can be disabled by settingpauseWhenHidden={false}.When enabled:
The
BAIFetchKeyButtoncomponent has been updated to support this new option, with the default behavior maintaining backward compatibility.Checklist: