AI credits: Confirm a top-up only once the balance grows - #4745
Draft
gcsecsey wants to merge 4 commits into
Draft
Conversation
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
How AI was used in this PR
I used Opus 5 for implementation and tests.
Proposed Changes
Returning from WordPress.com checkout tells you nothing about whether the purchase worked — and today it does something worse than nothing. Both front ends throw you out of your conversation and into Settings on every return, including a cancelled one.
A cancelled checkout comes back exactly like a completed one, so the return itself proves nothing. This PR waits for the balance to actually grow, then says so: a toast in the Agentic UI, a card above the composer in Classic, both reading
500,000 AI credits added.Every other outcome is silent. Cancelling is the most likely of them, and a "didn't work" message after a deliberate cancel is noise. The balance still refreshes either way, and you stay where you were.
A browser tab cannot receive the
wp-studio://return, and on desktop you may close the checkout tab instead of clicking through. So the same check also runs on window focus after checkout has been opened. One entry point now opens checkout everywhere, which covers both routes back.The copy is the wording from the exploration in #4446. One thing it did not have: a
View usageaction on the toast. @shaunandrews — worth a look, along with staying silent after a cancel.Testing Instructions
Use the balance setup steps in 236947-ghe-Automattic/wpcom.
N AI credits added.View usageopens Settings → Usage.studio ui), which has no deep link. The purchase confirms when the Studio tab regains focus.Check both color schemes.
Pre-merge Checklist