Skip to content

fix: clear stale transform rows immediately on error state#2361

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-stale-row-regression
Draft

fix: clear stale transform rows immediately on error state#2361
Copilot wants to merge 2 commits intomainfrom
copilot/fix-stale-row-regression

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

TransformsPage showed stale rows for one render cycle after a refresh transitioned from success to error. The useMemo for transforms fell through to lastSuccessfulTransforms on error, and the useEffect clearing that state only runs after render.

  • Add explicit result.status === "error" branch in the useMemo to return [] synchronously, rather than relying on the post-render effect:
const transforms = useMemo(
  () =>
    result.status === "success"
      ? result.data
      : result.status === "error"
        ? []
        : lastSuccessfulTransforms,
  [result, lastSuccessfulTransforms],
);
Original prompt

This section details on the original issue you should resolve

<issue_title>[branch-actions-detective] CI main failure: TransformsPage stale-row regression breaks unit coverage</issue_title>
<issue_description>## CI Failure Summary

Workflow: CI
Branch: main
Run: https://github.com/elastic/ai-github-actions-playground/actions/runs/22924593115

Root Cause

The Unit Tests job failed in step "Unit tests with coverage (full)" because tests/component/TransformsPage.test.tsx failed at expect(screen.queryByText("tx-stale")).not.toBeInTheDocument().

The failure shows stale transform row tx-stale remains rendered after a refresh transitions from success to error ("Boom after refresh"), violating the intended behavior covered by the test.

Impact

This fails required CI on main and can block merges while the test remains red. It also indicates a user-visible state-management regression on the Transforms page (stale data shown during error state).

Suggested Fix

  1. In TransformsPage data/render logic, clear or gate previously successful rows when the latest refresh is in error state.
  2. Ensure table rendering is conditioned on current successful data (or explicitly reset rows on error) so stale rows are not shown.
  3. Re-run make test-unit-coverage (or the specific vitest target) to confirm the failure is resolved.

Evidence

  • Failing job: Unit Tests (job 66531643811), step: Unit tests with coverage (full).
  • Log excerpt:
    • FAIL tests/component/TransformsPage.test.tsx > TransformsPage > does not keep stale rows visible after transitioning from success to error
    • Error: expect(element).not.toBeInTheDocument()
    • expected document not to contain element ... tx-stale
    • tests/component/TransformsPage.test.tsx:282:48
  • Test assertion location in repo: peek/tests/component/TransformsPage.test.tsx:282.
  • Related prior context: similar bug was previously fixed/closed in [performance-sweeper] Transforms page keeps stale rows visible after refresh error #2051, suggesting a recurrence/regression.

What is this? | From workflow: Branch Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

  • expires on Mar 17, 2026, 9:26 PM UTC

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

When result.status transitions to "error", the useMemo for transforms
now returns [] immediately instead of returning lastSuccessfulTransforms
(which still holds stale data until useEffect runs after render).

This fixes the one-render-cycle window where stale rows remained visible
after a refresh failure.

Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix stale-row regression in TransformsPage tests fix: clear stale transform rows immediately on error state Mar 11, 2026
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.

[branch-actions-detective] CI main failure: TransformsPage stale-row regression breaks unit coverage

2 participants