Skip to content

Conversation

@enejb
Copy link
Member

@enejb enejb commented Jan 8, 2026

Fixes FORMS-NEW

Proposed changes:

  • Refactors track_spam_status_change to track_feedback_status_change to handle broader feedback post status transitions
  • Adds automatic unread count recalculation when feedback post status changes to/from 'publish'
  • Extracts spam meta tracking into a private track_spam_status helper method
  • Adds new track_recount_unread method to trigger unread count updates on status changes
  • Deprecates the old track_spam_status_change method with backward compatibility
  • Adds comprehensive unit tests covering:
    • Spam meta setting/removal on status transitions
    • Unread count recalculation on publish/unpublish
    • Skipping recount when feedback is marked as read
    • Ignoring non-feedback posts

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

See p1767878614114049-slack-C052XEUUBL4

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Prerequisites

  • Set up a site with Jetpack Forms installed
  • Go to the forms dashboard.
  • If you don't already have feedback. Create some.
  • Mark the feedback that is marked as unread as "spam" or "trash" - Notice in the sidebar that the items shows up the coutner goes down.
  • Mark the "spam" feedback that is marked as unread as not spam. Notice the sidebar counter go up.

Test 1: Unread count updates when feedback status changes

  1. Create a new feedback entry (submit a form)
  2. Verify the unread count badge shows 1
  3. Change the feedback post status from 'publish' to 'draft' in the admin
  4. Verify the unread count badge updates to 0
  5. Change the feedback post status back to 'publish'
  6. Verify the unread count badge updates back to 1

Test 2: Spam meta tracking

  1. Create a new feedback entry
  2. Mark it as spam
  3. Check the post meta and verify '_spam_status_changed_gmt' is set
  4. Unmark it as spam (change status to publish)

Test 3: Read feedback doesn't trigger recount

  1. Create a new feedback entry
  2. Mark it as read
  3. Change the post status to draft and back to publish
  4. Verify the unread count remains accurate (shouldn't change since it's already read)

Test 4: Unit tests

Run the new unit tests:

@enejb enejb requested a review from a team January 8, 2026 19:57
@enejb enejb self-assigned this Jan 8, 2026
Copilot AI review requested due to automatic review settings January 8, 2026 19:57
@enejb enejb added [Type] Bug When a feature is broken and / or not performing as intended [Status] Needs Review This PR is ready for review. [Package] Forms labels Jan 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/unread-count-refresh branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/unread-count-refresh

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Jan 8, 2026
@enejb enejb added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Jan 8, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the feedback status tracking system to handle broader status transitions beyond just spam marking, with a focus on maintaining accurate unread counts. The main change is renaming and expanding track_spam_status_change to track_feedback_status_change, while adding automatic unread count recalculation when feedback post status changes to/from 'publish'.

Key changes:

  • Refactored status tracking to handle any feedback post status transition
  • Integrated unread count refresh when feedback is published or unpublished
  • Extracted spam meta tracking to a private helper method for better code organization

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
class-contact-form-plugin.php Refactors spam tracking into broader feedback status tracking, deprecates old method, adds private helpers for spam meta and unread count recalculation
Contact_Form_Plugin_Test.php Adds comprehensive unit tests covering spam meta tracking, unread count updates, read/unread handling, and non-feedback post filtering
actions.tsx Adds optimistic updates for sidebar unread counter when feedback moves to/from spam or trash
changelog/fix-unread-count-refresh Documents the change as a patch-level refactoring

Copilot AI review requested due to automatic review settings January 8, 2026 20:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

@jp-launch-control
Copy link

jp-launch-control bot commented Jan 8, 2026

Code Coverage Summary

Coverage changed in 3 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 517/1462 (35.36%) 0.79% -7 💚
projects/packages/forms/src/dashboard/inbox/stage/actions.tsx 0/329 (0.00%) 0.00% -14 💚
projects/packages/forms/src/dashboard/inbox/utils.js 19/28 (67.86%) 67.86% -16 💚

1 file is newly checked for coverage.

File Coverage
projects/packages/forms/src/dashboard/inbox/stage/process-status-change.ts 30/30 (100.00%) 💚

Full summary · PHP report · JS report

Copilot AI review requested due to automatic review settings January 8, 2026 20:36
@enejb enejb force-pushed the fix/unread-count-refresh branch from e8e909b to a9949ac Compare January 8, 2026 20:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment on lines 93 to 94
const promises = await Promise.allSettled(
items.map( ( { id } ) => apiCall( id ) as Promise< { id: number } > )
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The withTimeout wrapper has been removed from the API calls when extracting processStatusChange to a separate file. The original implementation wrapped apiCall with withTimeout (as seen in the deleted code with "withTimeout( apiCall( id ) )"), which provided timeout protection for network requests. Without this wrapper, API calls may hang indefinitely if the network is disabled or unresponsive. Either re-add the withTimeout wrapper in this function, or ensure the apiCall parameter is already wrapped with timeout protection before being passed to processStatusChange.

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 9, 2026 19:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Copilot AI review requested due to automatic review settings January 9, 2026 19:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.

Copy link
Contributor

@vianasw vianasw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with the refactor. The code looks reasonable and all the tests suggested in the PR are working fine. However, when I click on 'Undo' after marking an unread feedback as spam, the counter doesn't get updated.

enejb and others added 22 commits January 22, 2026 09:25
Replaces track_spam_status_change with track_feedback_status_change to handle feedback post status transitions, including spam and publish. Adds private helpers for spam meta and unread count recalculation. Comprehensive unit tests added for feedback status changes, spam meta updates, unread count recalculation, and non-feedback post handling.
…ugin.php

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Moved the processStatusChange logic from actions.tsx to a new process-status-change.ts file for better modularity and maintainability. Updated imports accordingly and enhanced tests to cover error handling and revert logic for menu counter updates.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@enejb enejb force-pushed the fix/unread-count-refresh branch from 8c97749 to aecf11a Compare January 22, 2026 20:18
@enejb enejb dismissed vianasw’s stale review January 22, 2026 20:30

This is now fixed

@enejb enejb merged commit 5cd1b3b into trunk Jan 23, 2026
70 checks passed
@enejb enejb deleted the fix/unread-count-refresh branch January 23, 2026 00:02
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Contact Form [Package] Forms [Tests] Includes Tests [Type] Bug When a feature is broken and / or not performing as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants