Skip to content

Show "Generate" instead of "Regenerate" when post body is empty#717

Open
i-anubhav-anand wants to merge 1 commit into
WordPress:developfrom
i-anubhav-anand:fix/title-generation-hide-regenerate-no-content
Open

Show "Generate" instead of "Regenerate" when post body is empty#717
i-anubhav-anand wants to merge 1 commit into
WordPress:developfrom
i-anubhav-anand:fix/title-generation-hide-regenerate-no-content

Conversation

@i-anubhav-anand

@i-anubhav-anand i-anubhav-anand commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Problem

Fixes #391

The toolbar button was labelled Regenerate whenever the post had a title, even when the post body was empty. With no content the AI has nothing to work from, so "Regenerate" was misleading — it implied a previous generation existed and would be replaced.

Solution

Read getEditedPostContent() in the useSelect call and only label the button "Regenerate" when the post has both a title and body content. When the body is empty the button always reads Generate, making the prerequisite clear to users.

Changes

  • src/experiments/title-generation/components/TitleToolbar.tsx
    • Add content to useSelect return value
    • Derive hasContent from the post body
    • Use hasTitle && hasContent instead of hasTitle to decide the "Regenerate" label
    • Rename content variable inside handleGenerate / handleRegenerate to postContent to avoid shadowing the new reactive state

Testing

  1. Create a new post — leave the body empty, add only a title
    • Button should read Generate
  2. Add body content
    • Button should switch to Regenerate
  3. Clear body content again
    • Button should return to Generate
  4. Generate a title with content present — modal Regenerate button should work as before
Open WordPress Playground Preview

The toolbar button was labeled "Regenerate" whenever the post had a
title, even if the post body was empty. With no content the AI has
nothing to work from, so showing "Regenerate" was misleading.

Now "Regenerate" only appears when the post has both a title and some
body content. When the body is empty the button always reads "Generate",
making the prerequisite clear to users.
@i-anubhav-anand i-anubhav-anand marked this pull request as ready for review June 12, 2026 20:02
@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: i-anubhav-anand <anubhav24@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: hemant7405 <hdkothari81@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dkotter

dkotter commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

@i-anubhav-anand This is another PR that duplicates work done in an existing PR (see #479). I'd suggest as you look to pick up Issues, don't work on Issues that already have a PR attached as it just makes things more difficult for maintainers. If you have a different approach to what's already there, that should be a conversation that happens either on that PR or on the Issue first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regenerate option is being shown even though there’s no content yet.

2 participants