close
Skip to content

fix: make title and term suggestion UI reactive#584

Merged
dkotter merged 1 commit into
WordPress:developfrom
Malayt04:fix/reactive-select-content-title
May 19, 2026
Merged

fix: make title and term suggestion UI reactive#584
dkotter merged 1 commit into
WordPress:developfrom
Malayt04:fix/reactive-select-content-title

Conversation

@Malayt04
Copy link
Copy Markdown
Contributor

@Malayt04 Malayt04 commented May 19, 2026

What?

Closes #579

Fixes two stale editor state issues in the AI experiment UI:

  • the title generation toolbar label was not reactive to title changes
  • the content classification suggestion button state was not reactive to content changes
  • content classification requests could send stale editor content when generating term suggestions

Why?

Both issues came from reading editor state with select() directly in component render paths instead of subscribing reactively with useSelect().

In title generation, the toolbar could keep showing Generate or Regenerate based on the title value from the initial render, even after the title changed.

In content classification, the suggest button could remain disabled or enabled based on stale content, and the generate action could submit older content instead of the latest editor state.

How?

This PR updates the affected components and hook to use reactive editor store reads where UI state depends on live editor data.

  • src/experiments/title-generation/components/TitleToolbar.tsx
    • Replaced render-time select() reads for postId and title with useSelect()
  • src/experiments/content-classification/components/useContentClassification.ts
    • Replaced render-time select() reads for postId and content with useSelect()
    • Updated the generate handler to read the latest editor content at click time before sending the request
  • src/experiments/content-classification/components/SuggestionPanel.tsx
    • Replaced render-time taxonomy lookup with useSelect() for reactive store usage consistency

Use of AI Tools

AI assistance: Yes
Tool(s): Codex
Model(s): GPT-5
Used for: Implementing the component fixes

Testing Instructions

  1. Enable the Title Generation experiment.
  2. Open the post editor.
  3. Focus the title field so the toolbar appears.
  4. Start with an empty title and confirm the button shows Generate.
  5. Without reloading, add a title and confirm the button updates to Regenerate.
  6. Clear the title again and confirm the button updates back to Generate.
  7. Enable the Content Classification experiment.
  8. Open the Tags or Categories panel in the post editor.
  9. Start with content under roughly 150 words and confirm the suggest button is disabled.
  10. Without reloading or closing the panel, add enough content to cross the threshold and confirm the suggest button becomes enabled immediately.
  11. Remove enough content to go back below the threshold and confirm the button disables again.
  12. Add a distinctive final sentence to the content, trigger Suggest Tags or Suggest Categories, and verify the generated request uses the latest editor content.

Screenshots or screencast

Title generation

Before

Title-before.mov

After

Title-after.mov

Content classification suggestions

Before

Suggest-terms-after.mov

After

Suggest-terms-before.mov

Changelog Entry

Fixed - Make title generation and content classification UI react to current editor state.

Open WordPress Playground Preview

@github-actions
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: Malayt04 <malaytiwari@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>

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

@Malayt04 Malayt04 marked this pull request as draft May 19, 2026 12:16
@Malayt04 Malayt04 marked this pull request as ready for review May 19, 2026 12:30
@dkotter dkotter added this to the 1.0.0 milestone May 19, 2026
@dkotter dkotter merged commit c8c2412 into WordPress:develop May 19, 2026
48 checks passed
@dkotter dkotter mentioned this pull request May 19, 2026
42 tasks
simison pushed a commit to simison/ai that referenced this pull request May 25, 2026
Fixed - Make title generation and content classification UI react to current editor state.

Co-authored-by: Malayt04 <malaytiwari@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>
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.

Don't use select() directly

2 participants