jetpack icon indicating copy to clipboard operation
jetpack copied to clipboard

Rankmath AI and Jetpack AI Conflict

Open foleynotrose opened this issue 1 year ago • 8 comments

Impacted plugin

Jetpack

Quick summary

When Jetpack is activated, it overrides the Rankmath AI button that is part of the block toolbar.

image

Steps to reproduce

  1. Install Rankmath and connect it to account. (Free plan is fine.)
  2. Activate Jetpack
  3. Create a post with a paragraph block.

A clear and concise description of what you expected to happen.

Rankmath's AI button in block toolbar should appear.

What actually happened

  • When Jetpack is activated, Rankmath AI button does not appear in Block Toolbar.
  • This is true even if add_filter( 'jetpack_ai_enabled', '__return_false' ); filter is added to site.
  • When Jetpack is deactivated, it reappears.

Impact

One

Available workarounds?

No but the platform is still usable

Platform (Simple and/or Atomic)

Self-hosted

Logs or notes

https://wordpress.org/support/topic/conflict-with-rankmath-9/#post-17141423 https://wordpress.org/support/topic/jetpack-rankmath-conflict/#post-17165526

foleynotrose avatar Nov 09 '23 09:11 foleynotrose

@Automattic/jetpack-agora Do you think you could take a look at this?

Thanks!

jeherve avatar Nov 09 '23 11:11 jeherve

In some quick testing, this doesn't seem to have anything to do with Jetpack's AI feature specifically. I've tried versions of Jetpack back to 11.6 and they also somehow prevent Rankmath's AI button from showing up.

Coming at it in a different way, I find that Rankmath and the https://widgets.wp.com/wpcom-block-editor/default.editor.js script registered by Jetpack's modules/wpcom-block-editor/class-jetpack-wpcom-block-editor.php tool are both trying to do like

registerFormatType(
    '...',
    {
        title: '...',
        tagName: 'p',
        className: null,
        edit: ...
    }
);

It seems that it's not allowed for multiple things to register a format type for the same bare tag, we get this error in the console output: Format "wpcom/justify" is already registered to handle bare tag name "p".

It looks like the "wpcom/justify" one ultimately comes from Calypso's apps/wpcom-block-editor/src/default/features/rich-text.js.

anomiex avatar Nov 09 '23 15:11 anomiex

It shouldn't be. It relies on the core API te extend the block toolbar. Going to take a look asap.

retrofox avatar Nov 09 '23 15:11 retrofox

Thanks @anomiex for digging. The code there reads:

This code is developed in the calypso monorepo at https://github.com/Automattic/wp-calypso/tree/trunk/apps/wpcom-block-editor.

@jeherve any particular Calypso dev we could ping on this?

CGastrell avatar Nov 09 '23 16:11 CGastrell

It seems that it's not allowed for multiple things to register a format type for the same bare tag

Great find! Looks like it indeed, since https://github.com/WordPress/gutenberg/pull/11488

no format type can use the same tag name, so e.g. you cannot have two format types handling a or span elements. [...] This is a proposal to instead normally serialise a class name. Only in cases where it is wanted that the format type can handle any element with the tag name, you can pass null for the class name.

I'm not sure what approach we should take here, since we want to be able to apply the justify format to just about any paragraph. On their end, I assume Rankmath AI also want to be able to make changes to all paragraphs.

any particular Calypso dev we could ping on this?

The Build team has been considering getting rid of that option in the WordPress.com Block editor, and instead rely on Gutenberg instead:

https://github.com/Automattic/wp-calypso/issues/73455

That would be a nice way to solve our problem.

Unfortunately it looks like we're not quite there yet in Gutenberg: https://github.com/WordPress/gutenberg/issues/48202

@Automattic/build What do you think?

jeherve avatar Nov 09 '23 17:11 jeherve

What do you think?

I'd love to just add "align text justify" to this dropdown and be done with it:

CleanShot 2023-11-09 at 13 19 33@2x

Google Docs has it:

CleanShot 2023-11-09 at 13 20 25@2x

Microsoft Word has it:

CleanShot 2023-11-09 at 13 22 27@2x

It seems like Core is overly stuck on semantics.

danielbachhuber avatar Nov 09 '23 21:11 danielbachhuber

Trying to jump at this one, but looks RankMath requires a subscription to show the AI feature right now. Do you still able to reproduce it on free version @foleynotrose ?

renatoagds avatar Mar 04 '24 16:03 renatoagds

@renatoagds I'm still seeing options for 100 AI requests with the Rankmath free version:

Screenshot 2024-03-05 at 09 41 59

foleynotrose avatar Mar 05 '24 09:03 foleynotrose

I have been trying to reproduce this conflict, but I'm not being able to do. I spawned some JN sites and I'm able to have Jetpack and RankMath installed and working properly both.

CleanShot 2024-03-07 at 16 16 29

renatoagds avatar Mar 07 '24 19:03 renatoagds

I note the changelog for RankMath v1.0.206 says

Fixed: Missing Content AI Command Center option when the Jetpack plugin is active

So perhaps that's why it can't be reproduced so easily anymore.

It looks like there is still something broken though:

  • Create a "long" paragraph.
  • Click the red "Rank Math" button next to Publish, which should open a sidebar.
  • At the bottom of the sidebar there should be a "Content Readability" section, inside of which there should be an entry about long paragraphs with an "eye" icon next to it. Click the eye, which should highlight your long paragraph.
  • Select the paragraph. Without Jetpack you get a "Shorten with AI" button instead of the usual editor toolbar, while with Jetpack you get the normal toolbar.
Videos

https://github.com/Automattic/jetpack/assets/1030580/78e3165e-6e27-41d4-9cbd-8e1854e2d4d7

https://github.com/Automattic/jetpack/assets/1030580/e9c7c3f2-5e4b-453c-8e96-e9a58a602123

anomiex avatar Mar 07 '24 21:03 anomiex