Skip to content

Clear resolved patch errors after discard - #325

Closed
juanmaguitar wants to merge 0 commit into
juanmaguitar/explain-disabled-discardfrom
juanmaguitar/clear-apply-error-after-discard
Closed

Clear resolved patch errors after discard#325
juanmaguitar wants to merge 0 commit into
juanmaguitar/explain-disabled-discardfrom
juanmaguitar/clear-apply-error-after-discard

Conversation

@juanmaguitar

Copy link
Copy Markdown
Collaborator

Why

After Revert this patch failed because the contributor had edited an applied PR, Discard this ticket to its base successfully reset the checkout but left the old red failure banner on screen. The confirmation and terminal said the discard succeeded while the page still said the checkout was unchanged.

What changes

A successful discard now clears the applied layer, apply error, conflict breakdown and any older apply notice together. A failed discard preserves all of that feedback because the contributor still needs it.

How to test this

Platforms: any — this changes renderer feedback after the existing cross-platform discard operation.

Starting state: ticket #65819 with PR #13017 applied.

  1. Edit one of the assertIsCallable() lines introduced by the PR.
  2. Click Revert this patch.
    Expected: Revert fails without changing the checkout and shows the red conflict banner.
  3. Click Discard this ticket to its base and confirm.
    Expected: “All changes discarded” appears; the red banner and applied-layer card disappear.
  4. Open tests/phpunit/tests/customize/widgets.php.
    Expected: the original assertTrue() lines are restored.
  5. Switch to another ticket with saved work.
    Expected: its work is unchanged.

What must not have happened: a failed discard must not hide the Revert failure or release the applied-patch slot; only a successful discard clears that feedback.

The regression was reproduced against the parent branch before the fix and now passes in test/discard-apply-state.test.cjs.

Risks and limitations

The Git reset itself was already correct and is unchanged. This only synchronizes renderer feedback with its successful result. The fixed flow needs confirmation in the next signed integration artifact.

Related

Follow-up to #318 and #324.


Design decisions and alternatives considered

The feedback transition lives in the existing pure renderer module so both success and failure can be tested without introducing a DOM harness for the large index.jsx component.

Review outcome (required — see AGENTS.md)

1 [fix here] · 0 [follow-up] — fixed. The first source-scan regression could stay green without proving the behavior, so it was replaced with a pure state transition that proves success clears and failure preserves. Re-review: 0 [fix here] · 0 [follow-up].

npm run lint, npm test (990/990) and npm run test:electron (990/990) pass.

Implementation notes

applyFeedbackAfterDiscard() returns the complete apply-feedback state after the operation. The component applies it only after outcome.ok; the existing early return keeps failure feedback intact.

Screenshots or recording

The screenshot from the manual test shows the pre-fix contradiction: “All changes discarded” while the failed-Revert banner remains. The after state will be captured from the signed integration artifact.

@juanmaguitar
juanmaguitar force-pushed the juanmaguitar/explain-disabled-discard branch from 43b7e75 to b0cf395 Compare August 13, 2026 06:01
@juanmaguitar
juanmaguitar force-pushed the juanmaguitar/clear-apply-error-after-discard branch from 0ee9870 to b64ddd1 Compare August 13, 2026 06:01
@juanmaguitar
juanmaguitar force-pushed the juanmaguitar/explain-disabled-discard branch from b0cf395 to ea04712 Compare August 13, 2026 08:17
@juanmaguitar
juanmaguitar force-pushed the juanmaguitar/clear-apply-error-after-discard branch from b64ddd1 to d302c5f Compare August 13, 2026 08:22
juanmaguitar added a commit that referenced this pull request Aug 13, 2026
## Why

After a contributor chooses **Discard this ticket to its base** from a
failed Revert, the discard succeeds but the old red patch error remains
on screen. The checkout is clean, yet the interface still claims the
operation failed.

The original #325 belonged to the stale stack that GitHub closed while
#324 was being recovered, so this PR lands the already approved fix
directly on `trunk`.

## What changes

After a successful discard, clear the stale apply error and related
preview state. If discard fails, retain all of that state so the
contributor can still understand and recover from the failure.

## How to test this

**Platforms:** macOS and Windows.

**Starting state:** ticket #65819 linked, PR #13017 applied, with this
contributor edit on an applied line in
`tests/phpunit/tests/customize/widgets.php`:

```php
$this->assertIsCallable( $args['sanitize_callback'], 'sanitize_callback is callable' ); // Mi cambio.
```

1. Click **Revert this patch**. Revert must be rejected, the checkout
must remain unchanged, and the red error must offer **Save a copy of
your work** and **Discard this ticket to its base**.
2. Click **Discard this ticket to its base**.
3. The applied PR, contributor edit, applied-layer card, and red error
must all disappear. Ticket #65819 must remain linked.

**What must not have happened:**

- A failed discard must not clear the error or preview state.
- The ticket itself must not be unlinked.
- No unrelated ticket work may be removed.

This flow passed in the approved integration artifact at commit
`012d7df` on macOS and Windows.

## Risks and limitations

The final Git tree is exactly the tree manually approved for the release
candidate. Self-review: 0 [fix here] · 0 [follow-up].

## Related

Replacement landing for #325. Follow-up to #318 and #330.

---

<details>
<summary>Design decisions and alternatives considered</summary>

The cleanup is derived in the existing pure reducer and only committed
after `outcome.ok`. Keeping failure state unchanged avoids hiding
recovery information after an unsuccessful destructive operation.

A standalone PR avoids reusing the closed stack topology that caused
#324 not to land on `trunk`.

</details>

<details>
<summary>Review outcome (required — see AGENTS.md)</summary>

0 [fix here] · 0 [follow-up]. Lint, 1010/1010 tests, and `git diff
--check` pass. The branch resolves to approved tree
`d3904782d5e434df8591e99d3ccf2a49a52ebcc9`.

</details>

<details>
<summary>Implementation notes</summary>

Recovery head before squash: `6a88a26`. It contains one commit directly
on #330's squash commit.

</details>

<details>
<summary>Screenshots or recording</summary>

The user-visible flow was manually validated on both target platforms in
the approved integration artifact.

</details>
@juanmaguitar

Copy link
Copy Markdown
Collaborator Author

This PR was closed when its stale stack base was retired. Its single approved commit was rebased directly onto actual trunk and landed through #331. The final trunk tree is exactly the one manually tested in the integration artifact.

@juanmaguitar
juanmaguitar deleted the juanmaguitar/clear-apply-error-after-discard branch August 21, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant