Skip to content
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

Improve validation of wp-cli commands that contain placeholder content #309

Merged
merged 4 commits into from
Jun 26, 2024

Conversation

fluiddot
Copy link
Contributor

Related to #305 and #232 (comment).

Proposed Changes

  • Parse wp-cli command arguments in CodeBlock component. This way we can detect placeholder characters more accurately.
  • Mark a wp-cli command as not eligible to be executed if any of its arguments start with a placeholder character.

Testing Instructions

  • Run the command STUDIO_AI=true npm start.
  • Select a site and navigate to the AI assistant tab.
  • Send the prompt Show me how to get wordpress version via command.
  • Observe the AI responds with the command wp core version.
  • Observe the command displays the Run button.
  • Send the prompt Share a generic command to active a theme.
  • Observe the AI responds with the command wp theme activate {SLUG} (or similar placeholder format).
  • Observe the command doesn't display the Run button.
  • Send the prompt Can you display the generic command with all possible combinations of placeholder characters? Each in a separate command..
  • Observe the AI responds with different commands with placeholder characters.
  • Observe that the commands don't display the Run button.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fluiddot fluiddot requested a review from a team June 26, 2024 11:38
@fluiddot fluiddot self-assigned this Jun 26, 2024
Base automatically changed from test/assert-assistant-code-block to trunk June 26, 2024 14:02
@dcalhoun
Copy link
Member

I merged the associated #305 but temporarily restored the branch. Running the following should allow rebasing the branch atop the latest trunk.

git fetch && git rebase --onto origin/trunk origin/test/assert-assistant-code-block update/ai-improve-validation-wp-cli-command

Conflicts may or may not need to be resolved during the rebase.

Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

Test plan succeeded for me. 🚀

@fluiddot fluiddot force-pushed the update/ai-improve-validation-wp-cli-command branch from da8d171 to dfc61cd Compare June 26, 2024 15:10
@fluiddot fluiddot merged commit 86816da into trunk Jun 26, 2024
10 checks passed
@fluiddot fluiddot deleted the update/ai-improve-validation-wp-cli-command branch June 26, 2024 15:32
fluiddot added a commit that referenced this pull request Jun 27, 2024
…ent (#309)

* Improve wp-cli command validation in AI responses

* Fix placeholder calculation

* Update `createCodeComponent` unit tests

* Add `()` as potential wp-cli placeholder chars
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.

2 participants