Skip to content

Compute Failure Summary new-failure flags in render without mutating props#9668

Draft
camd wants to merge 1 commit into
masterfrom
worktree-camd+failure-summary-render-purity
Draft

Compute Failure Summary new-failure flags in render without mutating props#9668
camd wants to merge 1 commit into
masterfrom
worktree-camd+failure-summary-render-purity

Conversation

@camd

@camd camd commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

FailureSummaryTab.render() mutated its own props on every render — it set selectedJob.newFailure and toggled suggestion.showNewButton on the suggestion objects while building the output. This makes render impure and can produce subtle bugs when React reuses those objects across renders.

This change derives those values during render instead:

  • Replace the mutation loop with an isNewFailureLine() predicate plus local newFailureCount and firstNewFailureIndex.
  • Pass showNewButton to SuggestionsListItem as an explicit prop instead of mutating suggestion.showNewButton; the item now reads it from props.

Behavior is preserved: the banner still counts every qualifying "new failure" line, and only the first qualifying line is flagged with the NEW button.

Testing

  • Added unit tests covering the new-failure banner count and the single-NEW-flag behavior.
  • Full FailureSummaryTab suite passes (8 tests).
  • Lint clean.

…props

FailureSummaryTab.render() mutated its own props on every render: it set
selectedJob.newFailure and toggled suggestion.showNewButton on the
suggestion objects while building the output. Deriving these during
render makes the output a pure function of props/state.

- Replace the mutation loop with an isNewFailureLine() predicate plus
  local newFailureCount and firstNewFailureIndex derivations.
- Pass showNewButton to SuggestionsListItem as an explicit prop instead
  of mutating suggestion.showNewButton; the item reads it from props.
- Add tests covering the new-failure banner count and single NEW flag.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.59%. Comparing base (740daac) to head (dfdec8d).

Files with missing lines Patch % Lines
...shared/tabs/failureSummary/SuggestionsListItem.jsx 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9668   +/-   ##
=======================================
  Coverage   82.59%   82.59%           
=======================================
  Files         622      622           
  Lines       36580    36577    -3     
  Branches     3279     3276    -3     
=======================================
- Hits        30213    30212    -1     
+ Misses       6217     6215    -2     
  Partials      150      150           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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