Skip to content

perf: skip hidden notification progress updates - #418

Open
edo-zhou wants to merge 1 commit into
react-component:masterfrom
edo-zhou:codex/perf-hidden-notification-progress
Open

edo-zhou wants to merge 1 commit into
react-component:masterfrom
edo-zhou:codex/perf-hidden-notification-progress

Conversation

@edo-zhou

@edo-zhou edo-zhou commented Sep 30, 2026 •

Copy link
Copy Markdown

Problem

A timed notice currently passes setPercent to useNoticeTimer even when showProgress is omitted or false. Every animation-frame timer tick then commits another notification render without any visible progress to update. Ant Design Message also uses this path.

A React Profiler regression reproduces 33 commits, including the initial mount, over 512 ms for a single notice with hidden progress.

Change

Only update progress state while showProgress is enabled. Track elapsed progress in a ref without triggering renders, and synchronize state when the progress bar is enabled, including while the countdown is paused. The existing timer continues to run, preserving auto-close and hover pause/resume behavior. The same profiler check now records only the initial mount.

Add five regression cases covering omitted/false showProgress, visible progress updates, automatic closing at the original duration, and enabling progress during running or paused countdowns without restarting them.

Validation

  • New regression tests fail before the fix and pass afterward.
  • All 61 tests pass (npm test -- --maxWorkers=2).
  • npm run tsc passes.
  • ESLint and Prettier checks pass for the changed files.
  • npm run lint passes with 10 existing warnings in untouched files.
  • npm run compile passes for ESM/CJS and declarations.

Summary by CodeRabbit

  • 修复
    • 隐藏进度条时,通知倒计时不会因计时更新而触发额外渲染或提前关闭。
    • 倒计时期间切换进度显示,或暂停期间启用进度显示时,进度和剩余倒计时均能正确保持。

@vercel

vercel Bot commented Sep 30, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 0e5b46ce-105c-4ccd-9c0e-6c9efc167c3f

📥 Commits

Reviewing files that changed from the base of the PR and between b9eb7ff and 56cddc6.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 987adcd6-1854-42aa-989c-cd16b89fd5b0

📥 Commits

Reviewing files that changed from the base of the PR and between cea66a1 and b9eb7ff.

📒 Files selected for processing (2)
  • src/Notification.tsx
  • tests/notification-rendering.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


Walkthrough

通知组件现在将最新计时进度保存在 ref 中。仅当进度条显示时,组件才因进度变化更新渲染状态。新增测试覆盖进度显示切换、倒计时和暂停行为。

Changes

通知倒计时进度渲染

Layer / File(s) Summary
进度状态更新与倒计时验证
src/Notification.tsx, tests/notification-rendering.test.tsx
组件使用 ref 保存最新进度,并在启用进度条时同步到渲染状态。测试覆盖隐藏或显示进度条、倒计时中切换显示状态,以及暂停期间启用进度显示。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: zombiej

Merge Risk: ⚪ Minimal · up to b9eb7

The change avoids unnecessary renders while retaining countdown and progress-display behavior. No actionable merge-blocking risk is established; merge after normal checks pass.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“perf: skip hidden notification progress updates”准确概括了主要变更:当通知进度不可见时跳过进度状态更新,以减少不必要的渲染。标题简洁、具体,且与变更内容一致。
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 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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

小兔看着进度条,轻轻蹦两下
倒计时在悄悄走,暂停也不慌
进度藏进小小 ref,等着再登场
显示开启时,数字亮晶晶
测试逐帧点点头,兔耳也摇晃

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

@edo-zhou
edo-zhou force-pushed the codex/perf-hidden-notification-progress branch from b9eb7ff to 56cddc6 Compare September 30, 2026 12:36

This branch has not been deployed

No deployments
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.

1 participant