Skip to content

feat(alertCurEvent): persist auto-refresh interval in localStorage (issue #2279) - #2233

Merged
jsers merged 2 commits into
n9e:mainfrom
zhen1995:feature-issues/2279
Aug 4, 2026
Merged

feat(alertCurEvent): persist auto-refresh interval in localStorage (issue #2279)#2233
jsers merged 2 commits into
n9e:mainfrom
zhen1995:feature-issues/2279

Conversation

@zhen1995

@zhen1995 zhen1995 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Closes #2279

https://github.com/ccfos/nightingale/issues/2279

Problem

On the Active Alerts page (/alert-cur-events), the auto-refresh interval selector always resets to Off after the page is reloaded. Users who set an interval (e.g., 20s) have to reconfigure it every time they refresh or revisit the page.

Solution

Persist the selected auto-refresh interval to localStorage and restore it on component mount.

To keep the change focused and avoid unintentionally persisting the time-range picker value, a new refreshLocalKey prop is added to TimeRangePickerWithRefresh. This prop is used only for the auto-refresh interval cache, while the existing localKey behavior for time-range caching remains unchanged.

image

Changes

  • frontend/fe/src/components/TimeRangePicker/types.ts
    • Added optional refreshLocalKey?: string to ITimeRangePickerWithRefreshProps.
  • frontend/fe/src/components/TimeRangePicker/TimeRangePickerWithRefresh.tsx
    • AutoRefresh now uses refreshLocalKey when provided, falling back to ${localKey}_refresh for backward compatibility.
  • frontend/fe/src/pages/alertCurEvent/constants.ts
    • Added REFRESH_INTERVAL_CACHE_KEY = 'alert_cur_events_refresh_interval'.
  • frontend/fe/src/pages/alertCurEvent/pages/List/index.tsx
    • Passed refreshLocalKey={REFRESH_INTERVAL_CACHE_KEY} to TimeRangePickerWithRefresh.

How to test

  1. Go to Alert Management → Active Alerts (/alert-cur-events).
  2. Select an auto-refresh interval, e.g., 20s.
  3. Reload the browser page.
  4. The auto-refresh selector should still show 20s and start auto-refreshing automatically.

Backward compatibility

Existing usages of TimeRangePickerWithRefresh that pass localKey continue to work exactly as before, because refreshLocalKey is optional and falls back to ${localKey}_refresh.

Summary by CodeRabbit

  • New Features
    • Added persistence for the selected time range on the alert events page.
    • Added Monaco Editor support.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The alert events page now persists its time-range selection with a dedicated cache key. The project also adds monaco-editor version ^0.55.1 as a production dependency.

Changes

Alert event time-range persistence

Layer / File(s) Summary
Alert events refresh key
src/pages/alertCurEvent/constants.ts, src/pages/alertCurEvent/pages/List/index.tsx
The alert events page defines TIME_RANGE_CACHE_KEY and passes it to TimeRangePickerWithRefresh through localKey.

Monaco Editor dependency

Layer / File(s) Summary
Monaco Editor dependency
package.json
The production dependencies add monaco-editor at version ^0.55.1.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: jsers, fiona2016

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: persisting the Active Alerts auto-refresh interval in localStorage.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

onRefresh={() => {
setRefreshFlag(_.uniqueId('refresh_'));
}}
refreshLocalKey={REFRESH_INTERVAL_CACHE_KEY}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

应该不需要新增这个 refreshLocalKey 直接用存在的 localKey 参数即可

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pages/alertCurEvent/pages/List/index.tsx`:
- Line 24: Update the cache-key import and the TimeRangePickerWithRefresh
configuration in List to use a dedicated refresh-interval cache key instead of
TIME_RANGE_CACHE_KEY, ensuring AutoRefresh reads and writes
alert_cur_events_refresh_interval while the time-range cache remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 98499762-2934-4738-abd9-45f39e711b9b

📥 Commits

Reviewing files that changed from the base of the PR and between b8dd7d7 and 3fec094.

📒 Files selected for processing (2)
  • src/pages/alertCurEvent/constants.ts
  • src/pages/alertCurEvent/pages/List/index.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pages/alertCurEvent/constants.ts

import { getBrainLicense } from 'plus:/components/License/services';

import { AGGR_RULE_ID_CACHE_KEY, MY_GRPUPS_CACHE_KEY, NS } from '../../constants';
import { AGGR_RULE_ID_CACHE_KEY, MY_GRPUPS_CACHE_KEY, NS, TIME_RANGE_CACHE_KEY } from '../../constants';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n -C 8 \
  'refreshLocalKey|localKey|localStorage|REFRESH_INTERVAL_CACHE_KEY|TIME_RANGE_CACHE_KEY|alert_cur_events_refresh_interval|alert_cur_events_time_range' \
  src/components/TimeRangePicker \
  src/pages/alertCurEvent/constants.ts \
  src/pages/alertCurEvent/pages/List/index.tsx

Repository: n9e/fe

Length of output: 29486


Use a separate refresh-interval cache key.

TimeRangePickerWithRefresh stores the refresh interval under ${localKey}_refresh, so passing TIME_RANGE_CACHE_KEY makes AutoRefresh read/write alert_cur_events_time_range_refresh instead of the required alert_cur_events_refresh_interval. Use a dedicated refresh-interval key for this prop.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/pages/alertCurEvent/pages/List/index.tsx` at line 24, Update the
cache-key import and the TimeRangePickerWithRefresh configuration in List to use
a dedicated refresh-interval cache key instead of TIME_RANGE_CACHE_KEY, ensuring
AutoRefresh reads and writes alert_cur_events_refresh_interval while the
time-range cache remains unchanged.

@jsers
jsers merged commit 197eabe into n9e:main Aug 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants