Skip to content

perf(cloud): ⚡️ Fix list page repeated refresh when cloud tasks exceed 10#70

Merged
jorben merged 1 commit into
masterfrom
perf/cloud-context-memo
May 8, 2026
Merged

perf(cloud): ⚡️ Fix list page repeated refresh when cloud tasks exceed 10#70
jorben merged 1 commit into
masterfrom
perf/cloud-context-memo

Conversation

@jorben
Copy link
Copy Markdown
Collaborator

@jorben jorben commented May 8, 2026

Summary

  • Wrap CloudContext.Provider value with useMemo to stabilize context reference across renders
  • Narrow fetchTasks dependency from entire cloudContext object to cloudIsAuthenticated + cloudGetTasks
  • Replace broken pendingRefresh local variable with useRef + 500ms debounce for SSE-triggered refresh
  • Move refresh scheduling out of setState updater (React anti-pattern) into event handler body using dataRef

Test Plan

  • With 10+ cloud tasks, verify list page no longer flickers/repeatedly loads
  • Verify SSE progress updates still work for tasks already in the list
  • Verify new tasks appear after ~500ms debounce window
  • Verify page visibility change still triggers single refresh
  • Verify polling timer is not repeatedly recreated

🤖 Generated with TiyCode

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

AI Code Review Summary

PR: #70 (perf(cloud): ⚡️ Fix list page repeated refresh when cloud tasks exceed 10)
Preferred language: English

Overall Assessment

No blocking issue was detected in the reviewed diff; keep focused regression testing before merge.

Major Findings by Severity

No major issues identified from the reviewed diff.

Actionable Suggestions

  • Address the highest severity findings first and add targeted tests for changed logic.

Potential Risks

  • Potential hidden risks remain in edge cases not covered by the current diff context.

Test Suggestions

  • Add happy-path + boundary + failure-path tests for touched modules.

File-Level Coverage Notes

  • src/renderer/contexts/CloudContext.tsx: Optimization by wrapping context value in useMemo. The dependency list includes all state values and callback functions. Ensure any future additions are also added to the list to avoid stale values. No regressions. (The dependency list is long but correct for current code. Maintainability risk if new state/functions are added without updating the list.)
  • src/renderer/pages/List.tsx: Refactored SSE event handling with debounced refresh for missing tasks and improved dependency tracking for fetchTasks. The use of refs for data and debounce state prevents stale closures and unnecessary re-renders. Cleanup properly clears timer. Edge case: dataRef may be stale between render and SSE event, but impact is minimal. (The hardcoded 500ms debounce delay could be extracted to a constant for better maintainability.)

Inline Downgraded Items (processed but not inline)

  • None

Coverage Status

  • Target files: 2
  • Covered files: 2
  • Uncovered files: 0
  • No-patch/binary covered as file-level: 0
  • Findings with unknown confidence (N/A): 0

Uncovered list:

  • None

No-patch covered list:

  • None

Runtime/Budget

  • Rounds used: 1/4
  • Planned batches: 1
  • Executed batches: 1
  • Sub-agent runs: 1
  • Planner calls: 1
  • Reviewer calls: 1
  • Model calls: 2/64
  • Structured-output summary-only degradation: NO

Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Automated PR review completed.

  • Findings kept: 0
  • Findings with unknown confidence: 0
  • Inline comments attempted: 1
  • Target files: 2
  • Covered files: 2
  • Uncovered files: 0
    See the summary comment for detailed analysis and coverage details.

@@ -1,4 +1,4 @@
import React, { useState, useEffect, ReactNode, useCallback } from 'react';
import React, { useState, useEffect, ReactNode, useCallback, useMemo } from 'react';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Automated review completed for this PR diff. No concrete inline issue was selected after aggregation.

@jorben jorben merged commit b4752fd into master May 8, 2026
3 checks passed
@jorben jorben deleted the perf/cloud-context-memo branch May 8, 2026 09:04
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