perf(settings): reduce dashboard CPU usage#2004
Conversation
Cache locale-bound formatters and precompute calendar view data. Pause stable polling while Settings is hidden or unfocused, and deduplicate dashboard requests.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDashboardSettings now reuses locale formatters, precomputes calendar display fields, uses shallow state updates, deduplicates dashboard loads, and pauses visibility- or focus-ineligible refreshes. Tests cover polling cadence, lifecycle behavior, request deduplication, and formatter reuse. ChangesDashboard CPU optimization
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant DashboardSettings
participant Document
participant Window
participant DashboardIPC
Document->>DashboardSettings: visibility change
Window->>DashboardSettings: focus change
DashboardSettings->>DashboardSettings: clear or schedule refresh timer
DashboardSettings->>DashboardIPC: load dashboard when eligible
DashboardIPC-->>DashboardSettings: dashboard data or error
DashboardSettings->>DashboardSettings: schedule next refresh after load
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/settings/components/DashboardSettings.vue (1)
728-728: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: replace manual timer bookkeeping with
useTimeoutFn.
refreshTimer/clearRefreshTimerreimplement what VueUse'suseTimeoutFnalready provides (start/stop controls + automatic cleanup on scope dispose), which the guidelines call out for mechanical browser-timer behavior. Not required since correctness is fine as-is, but would remove the manualrefreshTimervariable and reduce boilerplate.
[optional_refactor]As per coding guidelines,
src/renderer/**/*.vue: "Prefer VueUse utilities such as useEventListener, useDebounceFn, useWindowSize, useResizeObserver, useIntervalFn, and useStorage for mechanical browser behavior."Also applies to: 1067-1101
🤖 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/renderer/settings/components/DashboardSettings.vue` at line 728, Optionally replace the manual refreshTimer and clearRefreshTimer bookkeeping with VueUse’s useTimeoutFn in the dashboard refresh flow. Use its start/stop controls and automatic scope cleanup, preserving the existing refresh timing and behavior while removing the redundant timer state and cleanup boilerplate.Source: Coding guidelines
🤖 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.
Nitpick comments:
In `@src/renderer/settings/components/DashboardSettings.vue`:
- Line 728: Optionally replace the manual refreshTimer and clearRefreshTimer
bookkeeping with VueUse’s useTimeoutFn in the dashboard refresh flow. Use its
start/stop controls and automatic scope cleanup, preserving the existing refresh
timing and behavior while removing the redundant timer state and cleanup
boilerplate.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 89b6e879-8887-4891-ae36-508065590245
📒 Files selected for processing (3)
docs/issues/settings-dashboard-cpu-usage/spec.mdsrc/renderer/settings/components/DashboardSettings.vuetest/renderer/components/DashboardSettings.test.ts
Swap manual refreshTimer/clearRefreshTimer bookkeeping for VueUse useTimeoutFn start/stop + tryOnScopeDispose cleanup. Behavior unchanged (backfill 3s / stable 60s polling, focus/visibility pause, stale-immediate refresh).
…e-optimization Resolve language/i18n conflicts to preserve this PR's scope-boundary race fixes (languageInitialization promise cache, listener-before-snapshot registration, documentAppearance abstraction) alongside the lazy renderer locale loading (#2003) and dashboard CPU reduction (#2004) perf wins from dev.
Summary
Runtime Flow
BEFORE
AFTER
The visible Dashboard layout and copy are unchanged.
Validation
pnpm run formatpnpm run i18npnpm run lintpnpm run typecheckpnpm run architecture:renderer-baseline:checkDashboardSettingsrenderer tests: 19/19 passedorigin/devApp.startup.test.tsmock returningundefinedfor Promise-basedinitAppStores, while unchangedChatMainApp.vuecalls.then()Summary by CodeRabbit