Commit d702443230a for woocommerce

commit d702443230ab8d46e206e4e48cef64835ca9fb4a
Author: AnnaMag <AnnaMag@users.noreply.github.com>
Date:   Sat Dec 5 11:59:49 2026 +0100

    AI shopping health: re-check products after term changes, name the issue on the filtered list, show check progress (#71827)

    * Recheck a product when its brand or category terms change

    A save that changed only a brand or category left the product listed under
    its old result until the next daily check. The editor, quick edit and bulk
    edit save terms before the product, so the product save looked stock-only and
    was skipped, and deleting a term saves no product at all. Products whose
    category, brand or attribute terms are added or removed are now tested again
    at the end of the request, so the AI shopping health counts and the filtered
    Products list agree after the change.

    Part of WOOAI-1979.

    * Show AI shopping health check progress and keep the first check's button

    While a check ran, the page showed only "Checking your store", and the
    button switched to "Check again" even during the first check. The view
    now says which step the check is on and how many products it has
    checked, and the button keeps its own label while it is turned off.

    Part of WOOAI-1962.

    * Name the issue on the filtered Products list and link back

    The notice above a Products list filtered from AI shopping health only
    said it showed products from AI shopping health. It now names the issue
    with the report's title and count, links back to AI shopping health,
    and prints before other notices.

    Part of WOOAI-1989.

    * Cap the end-of-request retests and skip them without a report

    Deleting a term thousands of products carry queued them all for a test at
    shutdown; RETEST_LIMIT (100) products stay current and the rest wait for the
    next daily check, as every product did before the term hooks. Without a
    stored report nothing is queued, so stores that never ran a check don't load
    products at shutdown for nothing.

    * Prime the end-of-request retests and name the queue for what it holds

    The queue takes any product since the term hooks, not only variation parents,
    so products_to_retest; retest_parents() stays, a public hook callback. The
    batch is primed once before the loop (ProductScan::prime_related), as the
    scan does, instead of one uncached read per product.

    * Leave the first check's button label to trunk in the changelog

    * Test that term changes before the first check queue nothing

    The has_report() guard in retest_at_shutdown() had no test: a term change with no stored report must not add a test at shutdown.

    * Test again at the end of the request only the products of the current site

    The end-of-request queue kept product ids only. On a multisite network,
    code that switches to another site and changes a product's terms there
    noted that id, and the shutdown test ran it on the site current at the
    end of the request: the same id on the wrong site, while the other site's
    rows stayed as they were. The queue now keeps the site each product was
    noted on and tests only the current site's. The other site's product
    waits for its next save or daily check, as core's deferred product sync
    does.

    Part of WOOAI-1979.

diff --git a/plugins/woocommerce/changelog/fix-ai-shopping-health-filtered-list-names-issue b/plugins/woocommerce/changelog/fix-ai-shopping-health-filtered-list-names-issue
new file mode 100644
index 00000000000..cf177216693
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-ai-shopping-health-filtered-list-names-issue
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Name the AI shopping health issue above a filtered Products list, with a link back to AI shopping health.
diff --git a/plugins/woocommerce/changelog/fix-ai-shopping-health-scan-progress b/plugins/woocommerce/changelog/fix-ai-shopping-health-scan-progress
new file mode 100644
index 00000000000..f5b62261927
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-ai-shopping-health-scan-progress
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Show how far an AI shopping health check has got while it runs.
diff --git a/plugins/woocommerce/changelog/wooai-1979-ai-shopping-health-term-changes b/plugins/woocommerce/changelog/wooai-1979-ai-shopping-health-term-changes
new file mode 100644
index 00000000000..ee9f661d5d1
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooai-1979-ai-shopping-health-term-changes
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+AI shopping health: update a product’s results when its brand or category changes, without waiting for the next check.
diff --git a/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx b/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx
index 4e1f3c239c0..69758b5aa93 100644
--- a/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx
+++ b/plugins/woocommerce/client/admin/client/sales-readiness/components/checked-card.tsx
@@ -26,8 +26,8 @@ interface CheckedCardProps {

 /**
  * When the store was last checked, with Check again. With no results and nothing running it says
- * the check didn't start and offers Check your store. While a check runs it shows a spinner and Checking your store,
- * with Check again turned off. From the first check on, Need help? offers the results to
+ * the check didn't start and offers Check your store. While a check runs it shows a spinner and how
+ * far the check is, with the same button turned off. From the first check on, Need help? offers the results to
  * download for support (built from the last check), and a switch turns the daily check off or on.
  */
 export const CheckedCard = ( {
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/AgentReadiness.php b/plugins/woocommerce/src/Internal/AgentReadiness/AgentReadiness.php
index 89ca9a9214a..3611b5cb8a1 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/AgentReadiness.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/AgentReadiness.php
@@ -692,6 +692,26 @@ class AgentReadiness {
 		delete_option( self::SCAN_OPTION );
 	}

+	/**
+	 * How far the scan in progress is: products tested so far and products to test. Once every
+	 * product is tested, the last action checks the store's pages and stores the report.
+	 *
+	 * @since 11.5.0
+	 *
+	 * @return array{done:int,total:int}|null Null when no scan has started.
+	 */
+	public function scan_progress(): ?array {
+		$state = get_option( self::SCAN_OPTION );
+		if ( ! is_array( $state ) || ! isset( $state['position'], $state['ids'] ) ) {
+			return null;
+		}
+		$total = count( (array) $state['ids'] );
+		return array(
+			'done'  => min( (int) $state['position'], $total ),
+			'total' => $total,
+		);
+	}
+
 	/**
 	 * End a scan without storing a report. Removes failure rows it wrote for products the
 	 * previous report never covered, so the Products list stays aligned with that report.
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ProductFields.php b/plugins/woocommerce/src/Internal/AgentReadiness/ProductFields.php
index c066bd84516..fe8e828ddc9 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ProductFields.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ProductFields.php
@@ -18,6 +18,11 @@ class ProductFields {
 	 */
 	public const GTIN_SEPARATORS = array( '-', ' ', "\t", "\n", "\r", "\x0B", "\x0C", "\u{00A0}", "\u{2007}", "\u{202F}", "\u{FEFF}" );

+	/**
+	 * Brand taxonomies brand() reads, in order: WooCommerce, Perfect Brands, YITH.
+	 */
+	public const BRAND_TAXONOMIES = array( 'product_brand', 'pwb-brand', 'yith_product_brand' );
+
 	/**
 	 * Plain-text description, falling back to the short description, as feeds do.
 	 *
@@ -49,7 +54,7 @@ class ProductFields {
 	 * @param \WC_Product $product Product, not a variation.
 	 */
 	public static function brand( \WC_Product $product ): string {
-		foreach ( array( 'product_brand', 'pwb-brand', 'yith_product_brand' ) as $taxonomy ) {
+		foreach ( self::BRAND_TAXONOMIES as $taxonomy ) {
 			if ( ! taxonomy_exists( $taxonomy ) ) {
 				continue;
 			}
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ProductsList.php b/plugins/woocommerce/src/Internal/AgentReadiness/ProductsList.php
index d925471659e..c0017092d19 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ProductsList.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ProductsList.php
@@ -25,6 +25,12 @@ class ProductsList {
 	 */
 	private const READINESS_META = array( '_wc_gla_brand', '_wc_gla_mpn' );

+	/**
+	 * The most products tested again at the end of one request. Deleting a term thousands
+	 * of products carry stays quick; the products past the limit wait for the next daily
+	 * check, as every product did before the term hooks.
+	 */
+	private const RETEST_LIMIT = 100;

 	/**
 	 * Readiness service.
@@ -48,11 +54,11 @@ class ProductsList {
 	private array $deleted_variation_parents = array();

 	/**
-	 * Parents to test again at the end of the request, as keys.
+	 * Products to test again at the end of the request, keyed by the site they were noted on, then by product id.
 	 *
-	 * @var array<int, true>
+	 * @var array<int, array<int, true>>
 	 */
-	private array $parents_to_retest = array();
+	private array $products_to_retest = array();

 	/**
 	 * Initialize dependencies.
@@ -76,8 +82,11 @@ class ProductsList {
 		add_action( 'woocommerce_trash_product_variation', array( $this, 'handle_variation_removed' ) );
 		add_action( 'woocommerce_before_delete_product_variation', array( $this, 'handle_before_variation_delete' ) );
 		add_action( 'woocommerce_delete_product_variation', array( $this, 'handle_variation_removed' ) );
+		add_action( 'added_term_relationship', array( $this, 'handle_terms_changed' ), 10, 3 );
+		add_action( 'deleted_term_relationships', array( $this, 'handle_terms_changed' ), 10, 3 );
 		add_action( 'pre_get_posts', array( $this, 'apply_filter' ) );
-		add_action( 'admin_notices', array( $this, 'filter_notice' ) );
+		// Before other notices, so it sits right above the list it describes.
+		add_action( 'admin_notices', array( $this, 'filter_notice' ), 1 );
 	}

 	/**
@@ -151,11 +160,13 @@ class ProductsList {
 	 * @param \WC_Product $product Product.
 	 */
 	private function retest( \WC_Product $product ): void {
+		$product_id = $product instanceof \WC_Product_Variation ? $product->get_parent_id() : $product->get_id();
+		// Tested now, so a term change earlier in this save isn't tested again at shutdown.
+		unset( $this->products_to_retest[ get_current_blog_id() ][ $product_id ] );
 		if ( ! $this->agent_readiness->has_report() ) {
 			return;
 		}
-		$product_id = $product instanceof \WC_Product_Variation ? $product->get_parent_id() : $product->get_id();
-		$product    = $this->reload( $product_id, $product );
+		$product = $this->reload( $product_id, $product );
 		if ( null === $product ) {
 			ProductFailures::forget( $product_id );
 			return;
@@ -247,30 +258,73 @@ class ProductsList {
 		$variation_id = (int) $variation_id;
 		$parent_id    = $this->deleted_variation_parents[ $variation_id ] ?? (int) wp_get_post_parent_id( $variation_id );
 		unset( $this->deleted_variation_parents[ $variation_id ] );
-		if ( $parent_id <= 0 ) {
+		if ( $parent_id > 0 ) {
+			$this->retest_at_shutdown( $parent_id );
+		}
+	}
+
+	/**
+	 * Note a product to test again when a category, brand or attribute term is added or removed.
+	 * Terms aren't in get_changes(): the editor, quick and bulk edit save them before the product,
+	 * and deleting a term removes it from each product without a save.
+	 *
+	 * @internal
+	 *
+	 * @param mixed $object_id Object id.
+	 * @param mixed $tt_ids    Term taxonomy id or ids.
+	 * @param mixed $taxonomy  Taxonomy.
+	 */
+	public function handle_terms_changed( $object_id, $tt_ids, $taxonomy ): void {
+		unset( $tt_ids );
+		$taxonomy = (string) $taxonomy;
+		if ( 'product_cat' !== $taxonomy && ! in_array( $taxonomy, ProductFields::BRAND_TAXONOMIES, true ) && ! taxonomy_is_product_attribute( $taxonomy ) ) {
+			return;
+		}
+		if ( 'product' === get_post_type( (int) $object_id ) ) {
+			$this->retest_at_shutdown( (int) $object_id );
+		}
+	}
+
+	/**
+	 * Test a product again at the end of the request, once however many changes note it.
+	 * Without a stored report there is nothing to update, so nothing is noted, and past
+	 * RETEST_LIMIT products the rest wait for the next daily check.
+	 *
+	 * @param int $product_id Product id.
+	 */
+	private function retest_at_shutdown( int $product_id ): void {
+		if ( ! $this->agent_readiness->has_report() ) {
+			return;
+		}
+		$site_id = get_current_blog_id();
+		if ( ! isset( $this->products_to_retest[ $site_id ][ $product_id ] ) && array_sum( array_map( 'count', $this->products_to_retest ) ) >= self::RETEST_LIMIT ) {
 			return;
 		}
 		if ( false === has_action( 'shutdown', array( $this, 'retest_parents' ) ) ) {
 			add_action( 'shutdown', array( $this, 'retest_parents' ) );
 		}
-		$this->parents_to_retest[ $parent_id ] = true;
+		$this->products_to_retest[ $site_id ][ $product_id ] = true;
 	}

 	/**
-	 * Test the noted parents again. A parent deleted in the same request has its rows removed,
-	 * so a deleted variable product doesn't keep counting.
+	 * Test the noted products again. One deleted in the same request has its rows removed,
+	 * so a deleted variable product doesn't keep counting. The name is from when only
+	 * variation removals noted their parents here, and stays: it is a public hook callback.
 	 *
 	 * @internal
 	 */
 	public function retest_parents(): void {
-		$parent_ids              = array_keys( $this->parents_to_retest );
-		$this->parents_to_retest = array();
-		foreach ( $parent_ids as $parent_id ) {
-			$parent = 'product' === get_post_type( $parent_id ) ? wc_get_product( $parent_id ) : null;
-			if ( $parent instanceof \WC_Product ) {
-				$this->retest( $parent );
+		// Only the site current at shutdown: an id noted while switched to another site belongs to that site,
+		// whose products wait for their next save or daily check, as with core's deferred product sync.
+		$product_ids              = array_keys( $this->products_to_retest[ get_current_blog_id() ] ?? array() );
+		$this->products_to_retest = array();
+		ProductScan::prime_related( $product_ids );
+		foreach ( $product_ids as $product_id ) {
+			$product = 'product' === get_post_type( $product_id ) ? wc_get_product( $product_id ) : null;
+			if ( $product instanceof \WC_Product ) {
+				$this->retest( $product );
 			} else {
-				ProductFailures::forget( $parent_id );
+				ProductFailures::forget( $product_id );
 			}
 		}
 	}
@@ -317,7 +371,8 @@ class ProductsList {

 	/**
 	 * Say above the Products list when it shows only the products from an AI shopping health link,
-	 * with a way back to all products. Nothing else on the screen shows that filter.
+	 * with a way back to all products. Nothing else on the screen shows that filter. A failing check
+	 * is named as the report names it, with the report's count, and links back to AI shopping health.
 	 *
 	 * @internal
 	 */
@@ -327,11 +382,19 @@ class ProductsList {
 		if ( ! $screen || 'edit-product' !== $screen->id || empty( $_GET[ self::FILTER_PARAM ] ) ) {
 			return;
 		}
+		// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- A list filter that changes nothing.
+		$value = sanitize_text_field( wp_unslash( $_GET[ self::FILTER_PARAM ] ) );
+		$count = ProductFailures::counts()[ $value ] ?? 0;
+		$copy  = ReadinessCopy::product_check( $value, max( 1, $count ) );
+		$title = null !== $copy && $count > 0 ? '<strong>' . esc_html( $copy['action'] ) . '</strong><br>' : '';
+		$back  = null !== $copy ? sprintf( ' | <a href="%s">%s</a>', esc_url( ReadinessCheckPage::url() ), esc_html__( 'Back to AI shopping health', 'woocommerce' ) ) : '';
 		printf(
-			'<div class="notice notice-info"><p>%s <a href="%s">%s</a></p></div>',
+			'<div class="notice notice-info"><p>%s%s <a href="%s">%s</a>%s</p></div>',
+			$title, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above.
 			esc_html__( 'Showing only products from AI shopping health.', 'woocommerce' ),
 			esc_url( admin_url( 'edit.php?post_type=product' ) ),
-			esc_html__( 'Show all products', 'woocommerce' )
+			esc_html__( 'Show all products', 'woocommerce' ),
+			$back // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above.
 		);
 	}
 }
diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/README.md b/plugins/woocommerce/src/Internal/AgentReadiness/README.md
index 14d4a2dcf1d..c489dec6e62 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/README.md
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/README.md
@@ -114,7 +114,7 @@ The checks from `no_noindex_directives` down pass on a stock store today. They s

 ## Failures per product

-`refresh_report()` stores what each product fails in product meta (`ProductFailures`), one row per check and per channel status, plus a `checked` row on every product the checks cover, passing ones included. `ProductsList` updates a product's rows when it is saved, except for a save that changes only stock or nothing, removes them when it is trashed, tests the parent again when a variation is trashed, restored or deleted, and filters the Products list on them for the links from the readiness pages (`?agent_readiness=<value>`); there is no column or dropdown on the list. A notice above the list says it shows products from AI shopping health, with a Show all products link (`ProductsList::filter_notice()`). A covered product without rows was not tested, by the scan's product limit. The stored report's product counts are read from these rows, the total from the `checked` rows, so a product fixed, added or removed since the scan counts now. The example products per check can be out of date; the count links to the filtered Products list. The scan stores the GTINs more than one product shares in the report (`shared_gtins`, not returned by the report readers, up to `ProductScan::SHARED_GTINS_LIMIT`), so checking one product on save or with the run ability doesn't read every published product. Past the limit, nothing is stored and a check of one product reads the catalog. A GTIN shared since the scan, on the saved product or another, is flagged at the next scan. Core refuses an exact duplicate on save, so this is one that differs only by separators or leading zeros, or a direct meta write.
+`refresh_report()` stores what each product fails in product meta (`ProductFailures`), one row per check and per channel status, plus a `checked` row on every product the checks cover, passing ones included. `ProductsList` updates a product's rows when it is saved, except for a save that changes only stock or nothing, and at the end of the request when a category, brand or attribute term is added to it or removed (the editor, quick edit and bulk edit save terms before the product, and deleting a term saves no product; `ProductsList::RETEST_LIMIT` products per request, the rest waiting for the next daily check; only products noted on the site current at the end of the request, so a change made while switched to another site of a multisite network waits for that site's next save or check), removes them when it is trashed, tests the parent again when a variation is trashed, restored or deleted, and filters the Products list on them for the links from the readiness pages (`?agent_readiness=<value>`); there is no column or dropdown on the list. A notice above the list, before other notices, says it shows products from AI shopping health, with a Show all products link (`ProductsList::filter_notice()`). For a failing check it also names the issue with the report's title and count ("Add a brand to 11 products", from `ReadinessCopy::product_check()` and `ProductFailures::counts()`) and links back to AI shopping health. A covered product without rows was not tested, by the scan's product limit. The stored report's product counts are read from these rows, the total from the `checked` rows, so a product fixed, added or removed since the scan counts now. The example products per check can be out of date; the count links to the filtered Products list. The scan stores the GTINs more than one product shares in the report (`shared_gtins`, not returned by the report readers, up to `ProductScan::SHARED_GTINS_LIMIT`), so checking one product on save or with the run ability doesn't read every published product. Past the limit, nothing is stored and a check of one product reads the catalog. A GTIN shared since the scan, on the saved product or another, is flagged at the next scan. Core refuses an exact duplicate on save, so this is one that differs only by separators or leading zeros, or a direct meta write.

 ## What the store declares to agents

@@ -192,7 +192,7 @@ A scan runs as a chain of actions (`NEXT_HOOK`, with the scan's id), so no actio

 On a store with 11,000 products, a scan (stopping at 5,000) took about 4 seconds and 144 MB. A product saved since the scan is already reflected in the counts, as described under Failures per product.

-`GET wc/v3/agent-readiness` returns `{ "report": <report or null>, "scan_pending": <bool>, "scan_stalled": <bool> }` from `AgentReadiness::get_served_report()`, so `store_checks` are read now; `scan_stalled` is true while a queued scan waits on a stalled Action Scheduler. `GET wc/v3/agent-readiness/view` returns what the Sales readiness page and the AI tools Overview show (`ReadinessCheckPage::view()`): text, badges and links only, so the React views render it without knowing the checks. `GET wc/v3/agent-readiness/support-report` returns `{ "filename", "text" }`: the text file "Download your results" saves from the Need help? line (`SupportReport`), with the site, versions, every setup step and store check with its status, the AI shopping state, and product check counts with their example products. Like the System Status Report, its labels are in English and it marks checks ✔ or ❌. It reads the stored report and runs no check, and holds no customer or order data and no keys. All these routes need `manage_woocommerce`.
+`GET wc/v3/agent-readiness` returns `{ "report": <report or null>, "scan_pending": <bool>, "scan_stalled": <bool> }` from `AgentReadiness::get_served_report()`, so `store_checks` are read now; `scan_stalled` is true while a queued scan waits on a stalled Action Scheduler. `GET wc/v3/agent-readiness/view` returns what the Sales readiness page and the AI tools Overview show (`ReadinessCheckPage::view()`): text, badges and links only, so the React views render it without knowing the checks. While a scan runs, its `run.message` says which of two steps it is on: the products, with how many of the scan's list are tested (`AgentReadiness::scan_progress()`, read from the scan option), then the store pages, which the last action checks before it stores the report. `GET wc/v3/agent-readiness/support-report` returns `{ "filename", "text" }`: the text file "Download your results" saves from the Need help? line (`SupportReport`), with the site, versions, every setup step and store check with its status, the AI shopping state, and product check counts with their example products. Like the System Status Report, its labels are in English and it marks checks ✔ or ❌. It reads the stored report and runs no check, and holds no customer or order data and no keys. All these routes need `manage_woocommerce`.

 The same shape is meant for every consumer: WooCommerce > Sales readiness and AI shopping, an outside scan of a store, and extensions that rank the findings by sales or offer fixes. Check and channel ids are stable keys.

diff --git a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php
index 46a72d1ae31..4bf936a31e8 100644
--- a/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php
+++ b/plugins/woocommerce/src/Internal/AgentReadiness/ReadinessCheckPage.php
@@ -283,6 +283,23 @@ class ReadinessCheckPage implements RegisterHooksInterface {
 		return $sorted;
 	}

+	/**
+	 * What a running check says: which of its two steps it is on, and how many products it has
+	 * tested. A queued check that hasn't started says only that it is checking.
+	 *
+	 * @param array{done:int,total:int}|null $progress The scan's progress, or null before it starts.
+	 */
+	private static function progress_message( ?array $progress ): string {
+		if ( null === $progress ) {
+			return __( 'Checking your store', 'woocommerce' );
+		}
+		if ( $progress['done'] < $progress['total'] ) {
+			/* translators: 1: number of products checked so far, 2: number of products to check. */
+			return sprintf( __( 'Checking your store. Step 1 of 2: products (%1$s of %2$s).', 'woocommerce' ), number_format_i18n( $progress['done'] ), number_format_i18n( $progress['total'] ) );
+		}
+		return __( 'Checking your store. Step 2 of 2: store pages.', 'woocommerce' );
+	}
+
 	/**
 	 * Everything the Sales readiness page and the AI tools Overview show, as data for the React views:
 	 * when the store was last checked and the check button, Fix first, a section per question, the
@@ -306,7 +323,7 @@ class ReadinessCheckPage implements RegisterHooksInterface {
 		if ( $stalled ) {
 			$message = __( 'Checks can’t start because scheduled actions aren’t running on your site. Your hosting provider can usually turn them back on.', 'woocommerce' );
 		} elseif ( $pending ) {
-			$message = __( 'Checking your store', 'woocommerce' );
+			$message = self::progress_message( $this->agent_readiness->scan_progress() );
 		}
 		$truncated   = null;
 		$sample_note = null;
diff --git a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ProductsListTest.php b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ProductsListTest.php
index 90dbd317a8d..7569ace58c1 100644
--- a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ProductsListTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ProductsListTest.php
@@ -7,6 +7,7 @@ use Automattic\WooCommerce\Internal\AgentReadiness\AgentReadiness;
 use Automattic\WooCommerce\Internal\AgentReadiness\ProductFailures;
 use Automattic\WooCommerce\Internal\AgentReadiness\ProductsList;
 use Automattic\WooCommerce\Internal\AgentReadiness\ProductScan;
+use Automattic\WooCommerce\Internal\AgentReadiness\ReadinessCheckPage;
 use WC_Helper_Product;
 use WC_Unit_Test_Case;

@@ -204,6 +205,7 @@ class ProductsListTest extends WC_Unit_Test_Case {
 	public function test_removed_variation_updates_parent(): void {
 		// A parent still noted after the shutdown callback was removed, as the test case does between tests.
 		$earlier = WC_Helper_Product::create_variation_product();
+		$this->readiness->refresh_report();
 		wc_get_product( $earlier->get_children()[0] )->delete( true );
 		remove_all_actions( 'shutdown' );

@@ -314,13 +316,195 @@ class ProductsListTest extends WC_Unit_Test_Case {
 	}

 	/**
-	 * @testdox Saves store nothing before a scan.
+	 * Products the filtered Products list shows for a check, as the link from the report opens it.
+	 *
+	 * @param string $id Check id.
+	 * @return array<int, int>
+	 */
+	private function listed( string $id ): array {
+		return array_map(
+			'intval',
+			get_posts(
+				array(
+					'post_type'  => 'product',
+					'fields'     => 'ids',
+					'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
+						array(
+							'key'   => ProductFailures::META_KEY,
+							'value' => $id,
+						),
+					),
+				)
+			)
+		);
+	}
+
+	/**
+	 * @testdox Adding a brand, then saving with nothing else changed as the editor does, takes the product off the missing brand count and list.
+	 */
+	public function test_brand_added_before_save_is_rechecked(): void {
+		if ( ! taxonomy_exists( 'product_brand' ) ) {
+			register_taxonomy( 'product_brand', 'product' );
+		}
+		$product = WC_Helper_Product::create_simple_product();
+		$this->readiness->refresh_report();
+		$this->assertContains( $product->get_id(), $this->listed( 'missing_brand' ) );
+		$this->assertSame( 1, $this->check_count( 'missing_brand' ) );
+
+		// The editor, quick edit and bulk edit set terms first, then save the product with no property changed.
+		wp_set_object_terms( $product->get_id(), 'Acme', 'product_brand' );
+		wc_get_product( $product->get_id() )->save();
+		$this->run_retest();
+
+		$this->assertNotContains( 'missing_brand', ProductFailures::for_product( $product->get_id() ) );
+		$this->assertSame( array(), $this->listed( 'missing_brand' ), 'The filtered list' );
+		$this->assertSame( 0, $this->check_count( 'missing_brand' ), 'The count agrees with the list' );
+
+		// Deleting the brand removes it from the product without a save.
+		wp_delete_term( (int) get_term_by( 'name', 'Acme', 'product_brand' )->term_id, 'product_brand' );
+		$this->run_retest();
+
+		$this->assertSame( array( $product->get_id() ), $this->listed( 'missing_brand' ) );
+		$this->assertSame( 1, $this->check_count( 'missing_brand' ) );
+	}
+
+	/**
+	 * @testdox Setting a category on its own tests the product again.
+	 */
+	public function test_category_set_is_rechecked(): void {
+		$product = WC_Helper_Product::create_simple_product();
+		$this->readiness->refresh_report();
+		$this->assertContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ) );
+
+		$term = wp_insert_term( 'Shirts', 'product_cat' );
+		wp_set_object_terms( $product->get_id(), array( (int) $term['term_id'] ), 'product_cat' );
+		$this->run_retest();
+
+		$this->assertNotContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ) );
+		$this->assertSame( 0, $this->check_count( 'uncategorised' ) );
+	}
+
+	/**
+	 * @testdox Deleting a global attribute term tests the product again: brand falls back to a "brand" attribute.
+	 */
+	public function test_attribute_term_delete_is_rechecked(): void {
+		$attribute = WC_Helper_Product::create_product_attribute_object( 'brand', array( 'Acme' ) );
+		$product   = WC_Helper_Product::create_simple_product();
+		$product->set_attributes( array( $attribute ) );
+		$product->save();
+		$this->readiness->refresh_report();
+		$this->assertNotContains( 'missing_brand', ProductFailures::for_product( $product->get_id() ) );
+
+		// Deleting the term removes it from the product without a save.
+		wp_delete_term( (int) $attribute->get_options()[0], $attribute->get_name() );
+		$this->run_retest();
+
+		$this->assertContains( 'missing_brand', ProductFailures::for_product( $product->get_id() ) );
+		$this->assertSame( 1, $this->check_count( 'missing_brand' ) );
+	}
+
+	/**
+	 * @testdox Deleting a term that more products carry than one request tests again stops at the limit; the rest wait for the daily check.
+	 */
+	public function test_mass_term_delete_is_capped(): void {
+		if ( ! taxonomy_exists( 'product_brand' ) ) {
+			register_taxonomy( 'product_brand', 'product' );
+		}
+		$ids = self::factory()->post->create_many( 101, array( 'post_type' => 'product' ) );
+		foreach ( $ids as $id ) {
+			wp_set_object_terms( (int) $id, 'Acme', 'product_brand' );
+		}
+		$this->readiness->refresh_report();
+		$this->assertSame( 0, $this->check_count( 'missing_brand' ) );
+
+		wp_delete_term( (int) get_term_by( 'name', 'Acme', 'product_brand' )->term_id, 'product_brand' );
+		$this->run_retest();
+
+		$this->assertSame( 100, $this->check_count( 'missing_brand' ), 'RETEST_LIMIT products are current; one waits for the next check' );
+	}
+
+	/**
+	 * @testdox A term change noted while switched to another site isn't tested on the site current at the end of the request.
+	 */
+	public function test_term_change_on_another_site_is_left_to_that_site(): void {
+		global $blog_id;
+		$product = WC_Helper_Product::create_simple_product();
+		$this->readiness->refresh_report();
+		$this->assertContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ) );
+
+		$term       = wp_insert_term( 'Shirts', 'product_cat' );
+		$current_id = $blog_id;
+		// As after switch_to_blog(): the same product id on another site.
+		$blog_id = $current_id + 1; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+		wp_set_object_terms( $product->get_id(), array( (int) $term['term_id'] ), 'product_cat' );
+		$blog_id = $current_id; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+		$this->run_retest();
+
+		$this->assertContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ), 'This site\'s rows are left as they were' );
+
+		wp_set_object_terms( $product->get_id(), 'Hats', 'product_cat', true );
+		$this->run_retest();
+
+		$this->assertNotContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ), 'A change on this site is still tested' );
+	}
+
+	/**
+	 * @testdox The same product id noted on another site later in the request doesn't take this site's product out of the end-of-request test.
+	 */
+	public function test_same_product_id_on_another_site_keeps_this_sites_retest(): void {
+		global $blog_id;
+		$product = WC_Helper_Product::create_simple_product();
+		$this->readiness->refresh_report();
+		$this->assertContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ) );
+
+		wp_set_object_terms( $product->get_id(), 'Hats', 'product_cat' );
+		$current_id = $blog_id;
+		// As after switch_to_blog(): the same product id on another site, noted after this site's.
+		$blog_id = $current_id + 1; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+		wp_set_object_terms( $product->get_id(), 'Shirts', 'product_cat', true );
+		$blog_id = $current_id; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+		$this->run_retest();
+
+		$this->assertNotContains( 'uncategorised', ProductFailures::for_product( $product->get_id() ), 'This site\'s change is still tested' );
+	}
+
+	/**
+	 * @testdox Terms no check reads, and the stock visibility terms a checkout changes, don't test the product again.
+	 */
+	public function test_other_terms_are_skipped(): void {
+		$product = WC_Helper_Product::create_simple_product();
+		$this->readiness->refresh_report();
+		$this->run_retest();
+		delete_post_meta( $product->get_id(), ProductFailures::META_KEY );
+
+		wp_set_object_terms( $product->get_id(), 'Summer', 'product_tag' );
+		$product->set_stock_status( 'outofstock' );
+		$product->save();
+		$this->run_retest();
+
+		$this->assertSame( array(), ProductFailures::stored( $product->get_id() ) );
+	}
+
+	/**
+	 * @testdox Saves and term changes store nothing before a scan, and queue nothing for the end of the request.
 	 */
 	public function test_before_a_scan(): void {
+		global $wp_filter;
 		$product = WC_Helper_Product::create_simple_product();
 		$product->set_description( 'Changed' );
 		$product->save();
+		wp_set_object_terms( $product->get_id(), 'Shoes', 'product_cat' );
 		$this->assertSame( array(), ProductFailures::for_product( $product->get_id() ) );
+
+		$queued = array();
+		foreach ( $wp_filter['shutdown']->callbacks ?? array() as $callbacks ) {
+			foreach ( $callbacks as $callback ) {
+				if ( is_array( $callback['function'] ) && $callback['function'][0] instanceof ProductsList ) {
+					$queued[] = $callback['function'][1];
+				}
+			}
+		}
+		$this->assertSame( array(), $queued, 'No test at shutdown without a report' );
 	}

 	/**
@@ -341,6 +525,13 @@ class ProductsListTest extends WC_Unit_Test_Case {
 			$this->assertStringContainsString( 'Showing only products from AI shopping health.', $html );
 			$this->assertStringContainsString( 'Show all products</a>', $html );
 			$this->assertStringContainsString( 'href="' . esc_url( admin_url( 'edit.php?post_type=product' ) ) . '"', $html, 'The link drops the filter' );
+			$this->assertStringContainsString( 'href="' . esc_url( ReadinessCheckPage::url() ) . '">Back to AI shopping health</a>', $html, 'A check links back to the report' );
+			$this->assertStringNotContainsString( '<strong>', $html, 'No products fail the check, so it is not named' );
+
+			$_GET[ ProductsList::FILTER_PARAM ] = ProductScan::COUNT_HIDDEN;
+			$html                               = $notice();
+			$this->assertStringContainsString( 'Show all products</a>', $html );
+			$this->assertStringNotContainsString( 'Back to AI shopping health', $html, 'A settings page count is not a report issue' );

 			$GLOBALS['current_screen'] = \WP_Screen::get( 'edit-post' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
 			$this->assertSame( '', $notice(), 'Only on the Products list' );
@@ -349,6 +540,42 @@ class ProductsListTest extends WC_Unit_Test_Case {
 		}
 	}

+	/**
+	 * @testdox The notice names the issue with the report's count, and comes before other notices.
+	 */
+	public function test_filter_notice_names_the_issue(): void {
+		WC_Helper_Product::create_simple_product();
+		WC_Helper_Product::create_simple_product();
+		$this->readiness->refresh_report();
+		$GLOBALS['current_screen']          = \WP_Screen::get( 'edit-product' ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
+		$_GET[ ProductsList::FILTER_PARAM ] = 'missing_images';
+		try {
+			ob_start();
+			$this->sut->filter_notice();
+			$html = (string) ob_get_clean();
+		} finally {
+			unset( $GLOBALS['current_screen'] );
+		}
+
+		$this->assertSame( 2, $this->check_count( 'missing_images' ) );
+		$this->assertStringContainsString( '<strong>Add a main image to 2 products</strong>', $html, 'The same title and count as the report' );
+
+		$list = new ProductsList();
+		$list->register();
+		$priority = has_action( 'admin_notices', array( $list, 'filter_notice' ) );
+		global $wp_filter;
+		foreach ( $wp_filter as $hook => $callbacks ) {
+			foreach ( $callbacks->callbacks as $at => $functions ) {
+				foreach ( $functions as $function ) {
+					if ( is_array( $function['function'] ) && $list === $function['function'][0] ) {
+						remove_action( $hook, $function['function'], $at );
+					}
+				}
+			}
+		}
+		$this->assertSame( 1, $priority, 'Printed before notices at the default priority' );
+	}
+
 	/**
 	 * @testdox The filter limits the main Products list query, and only there.
 	 */
diff --git a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php
index 19126a8e0ff..355a535536b 100644
--- a/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php
+++ b/plugins/woocommerce/tests/php/src/Internal/AgentReadiness/ReadinessCheckPageTest.php
@@ -129,6 +129,32 @@ class ReadinessCheckPageTest extends WC_Unit_Test_Case {
 		$this->assertTrue( $view['run']['pending'], 'A queue during the report read must not hide the new scan' );
 	}

+	/**
+	 * @testdox A running check says which step it is on and how many products it has checked.
+	 */
+	public function test_view_shows_scan_progress(): void {
+		$readiness = wc_get_container()->get( AgentReadiness::class );
+		for ( $i = 0; $i < 3; $i++ ) {
+			\WC_Helper_Product::create_simple_product();
+		}
+		$message = function (): string {
+			$this->with_pending_answers( array( true, true ) );
+			return $this->sut->view()['run']['message'];
+		};
+
+		$this->assertSame( 'Checking your store', $message(), 'Queued, not started yet' );
+
+		$chain = $readiness->start_refresh();
+		try {
+			$this->assertSame( 'Checking your store. Step 1 of 2: products (0 of 3).', $message() );
+
+			$this->assertTrue( $readiness->continue_refresh( $chain ), 'One batch tests every product' );
+			$this->assertSame( 'Checking your store. Step 2 of 2: store pages.', $message() );
+		} finally {
+			$readiness->cancel_refresh();
+		}
+	}
+
 	/**
 	 * @testdox Need help? links to WooCommerce.com support, as WooCommerce > Home > Help does, off WordPress.com.
 	 */