Skip to content

Conversation

@agatha197
Copy link
Contributor

@agatha197 agatha197 commented Sep 29, 2025

Resolves #4357 (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

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

agatha197 commented Sep 29, 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

github-actions bot commented Sep 29, 2025

Coverage report for ./react

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

@agatha197 agatha197 changed the base branch from feat_FR-1240_/admin-dashboard to graphite-base/4358 September 29, 2025 13:53
@agatha197 agatha197 force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from 09b8426 to 01dee45 Compare September 29, 2025 13:53
@agatha197 agatha197 changed the base branch from graphite-base/4358 to main September 29, 2025 13:53
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

@yomybaby yomybaby force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from 01dee45 to 948e77d Compare September 30, 2025 02:07
Copilot AI review requested due to automatic review settings September 30, 2025 02:07
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 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 pauseOnWindowBlur parameter to useInterval and useIntervalValue hooks with default value of true
  • Implemented window focus/blur event handling to pause/resume intervals based on window focus state
  • Updated BAIFetchKeyButton component to support the new pauseOnWindowBlur option

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 pauseOnWindowBlur parameter to both interval hooks
react/src/components/BAIFetchKeyButton.tsx Added pauseOnWindowBlur prop support with default value of true
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.

@yomybaby yomybaby force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from 948e77d to f108b95 Compare September 30, 2025 02:08
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.

Please consider document.visibilityState instead of focus.

@agatha197 agatha197 force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from f108b95 to 63d1fed Compare September 30, 2025 05:41
@agatha197 agatha197 requested a review from yomybaby September 30, 2025 06:17
@agatha197 agatha197 marked this pull request as draft September 30, 2025 06:19
@agatha197 agatha197 force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from 63d1fed to 3ecb178 Compare September 30, 2025 06:27
@agatha197 agatha197 marked this pull request as ready for review September 30, 2025 06:27
@agatha197 agatha197 marked this pull request as draft September 30, 2025 06:28
@agatha197 agatha197 force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch 3 times, most recently from 9c43d1d to 4e1ef17 Compare September 30, 2025 06:57
@agatha197 agatha197 marked this pull request as ready for review September 30, 2025 06:57
@agatha197 agatha197 force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from 4e1ef17 to c99d1cb Compare September 30, 2025 07:36
@yomybaby yomybaby force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from c99d1cb to 874597a Compare October 1, 2025 08:11
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 Oct 1, 2025

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
@graphite-app graphite-app bot force-pushed the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch from 874597a to a737f11 Compare October 1, 2025 08:14
@graphite-app graphite-app bot merged commit a737f11 into main Oct 1, 2025
11 checks passed
@graphite-app graphite-app bot deleted the feat_FR-1530_/window-focus-check-for-automatic-refresh-interval branch October 1, 2025 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30~100 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement window focus check for automatic refresh interval

4 participants