Skip to content

Blogging prompt: Fix Simple #43597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 28, 2025
Merged

Blogging prompt: Fix Simple #43597

merged 8 commits into from
May 28, 2025

Conversation

allilevine
Copy link
Member

@allilevine allilevine commented May 23, 2025

Fixes https://linear.app/a8c/issue/CML-493/daily-writing-prompt-broken-opens-blank-new-post

Proposed changes:

  • Theory: Sometimes the editor would initialize with a default paragraph block before our code ran. This meant that waitForEditor wasn't resolving correctly because it's no longer a "clean" new post (has a block).
  • This PR adds an immediate check for either a clean post or existing blocks and a safety timeout so we don't get stuck.

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 p1747465988418239-slack-C03NLNTPZ2T

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

N/A

Testing instructions:

  • Create a new Simple site in an incog window.
  • Apply bin/jetpack-downloader test jetpack fix/simple-blogging-prompts to your sandbox.
  • Turn on write access: allow-sandbox-production-writes "10 minutes"
  • Sandbox your Simple site (not the API).
  • Go to /home/{site url}
  • Click "Post answer" in the writing prompt home card.
  • The block should show up in the editor.
  • Regression test reposting a post to the site from /reader.
  • Regression test that you can manually add the "Writing prompt" block.
  • Repeat these tests on Jetpack and a WoA site via the Jetpack beta plugin. You can append /wp-admin/post-new.php?answer_prompt=1944 to the site URL if needed to test.

@allilevine allilevine self-assigned this May 23, 2025
Copy link
Contributor

github-actions bot commented May 23, 2025

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/simple-blogging-prompts branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/simple-blogging-prompts

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 github-actions bot added [Block] Blogging Prompt [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress labels May 23, 2025
Copy link
Contributor

github-actions bot commented May 23, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: June 3, 2025
    • Code freeze: June 2, 2025

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label May 23, 2025
Copy link

jp-launch-control bot commented May 23, 2025

Code Coverage Summary

Coverage changed in 1 file.

File Coverage Δ% Δ Uncovered
projects/plugins/jetpack/extensions/shared/wait-for-editor.js 0/14 (0.00%) 0.00% 3 ❤️‍🩹

Full summary · PHP report · JS report

@allilevine allilevine force-pushed the fix/simple-blogging-prompts branch from 8a43ea8 to d587cca Compare May 23, 2025 19:43
@allilevine allilevine changed the title Debug: Simple blogging prompts Blogging prompt: Fix Simple May 23, 2025
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

Just noting some testing so far. When I find a simple site where this is not working, these current draft changes do seem to fix it consistently. On atomic, the feature continues to work as expected as well.

@allilevine allilevine force-pushed the fix/simple-blogging-prompts branch from 8cfc771 to f7d8fde Compare May 27, 2025 14:02
@allilevine allilevine marked this pull request as ready for review May 27, 2025 14:38
@allilevine allilevine requested review from a team and Addison-Stavlo May 27, 2025 14:39
Copy link
Contributor

@Addison-Stavlo Addison-Stavlo left a comment

Choose a reason for hiding this comment

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

It looks reasonable and it tested well as noted.

It looks like the only other place we use waitForEditor is with the reader repost that inserts the embed block. It also seems odd that I haven't been able to reproduce any issues with that flow. It looks like the main difference is that uses resetEditorBlocks while this uses insertBlocks, in retrospect I wonder if that reset action makes more sense here and doesn't have the same issue with inconsistency? 🤔

Comment on lines +25 to +35
const unsubscribe = subscribe( () => {
const blocks = select( 'core/block-editor' ).getBlocks();

if ( blocks.length > 0 ) {
clearTimeout( timeoutId );
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to check isCleanNewPost here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, thanks for catching that! Updated in f22d317

Copy link
Member Author

@allilevine allilevine May 28, 2025

Choose a reason for hiding this comment

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

I had to revert that change -- for some reason checking isCleanNewPost too makes it fail intermittently again. 😢 It seems like it created another race condition.

@allilevine
Copy link
Member Author

It looks like the only other place we use waitForEditor is with the reader repost that inserts the embed block. It also seems odd that I haven't been able to reproduce any issues with that flow. It looks like the main difference is that uses resetEditorBlocks while this uses insertBlocks, in retrospect I wonder if that reset action makes more sense here and doesn't have the same issue with inconsistency? 🤔

@Addison-Stavlo Summing up our conversation in Slack: p1748360821224579/1747465988.418239-slack-C03NLNTPZ2T We could potentially switch to resetEditorBlocks for the blogging prompt block, but the blogging prompt shouldn't reset the editor and remove all existing blocks. Also, with the change here to check for blocks first, we could potentially be removing blocks for reposting -- but that's a very unlikely edge case. Reposts aren't added manually or with other paragraph blocks, like prompts.

@allilevine allilevine requested a review from Addison-Stavlo May 28, 2025 12:56
@allilevine allilevine force-pushed the fix/simple-blogging-prompts branch from f22d317 to 9b71255 Compare May 28, 2025 14:42
@allilevine allilevine merged commit a5d3b5f into trunk May 28, 2025
67 checks passed
@allilevine allilevine deleted the fix/simple-blogging-prompts branch May 28, 2025 15:51
@github-actions github-actions bot removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels May 28, 2025
@github-actions github-actions bot added this to the jetpack/14.7 milestone May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Blogging Prompt [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants