Skip to content

Conversation

@soderlind
Copy link
Owner

This pull request focuses on improving the reliability and maintainability of the AI suggestion pipeline and test isolation for the ContentPoll AI plugin. The main changes include consolidating and refactoring the AI suggestion prompt logic, making JSON parsing for AI suggestions more robust, and ensuring REST API tests are isolated to prevent interference from residual poll data. There are no database or schema changes, and the release is safe to upgrade.

AI Suggestion Pipeline Improvements

  • Consolidated all AI provider prompt templates into a single constant (PROMPT_TEMPLATE) within AISuggestionService, eliminating duplicated prompt logic and ensuring consistency across providers. [1] [2] [3] [4] [5] [6]
  • Refactored provider-specific suggestion methods to use a unified JSON parsing function (parse_poll_json), removing repeated code and improving maintainability. [1] [2] [3] [4] [5]
  • Added a dedicated parse_poll_json method that applies multi-stage recovery (direct decode, brace span extraction, fragment scanning) to robustly extract and sanitize poll suggestions from provider responses, reducing the chance of malformed suggestions causing fallback behavior.

Test Reliability and Isolation

  • Updated REST API vote and results endpoint tests to use unique block IDs per run and proactively delete any residual poll data from the database, preventing test interference and ensuring clean isolation between runs. [1] [2]

Documentation and Metadata

  • Updated CHANGELOG.md and readme.txt to document the 0.8.1 release, highlighting the refactor, improved robustness, and test isolation. [1] [2] [3]
  • Bumped plugin version to 0.8.1 in content-poll.php and updated stable tag in readme.txt. [1] [2]
  • Added release comparison link for 0.8.1 in CHANGELOG.md.

Test Result Metadata

  • Updated PHPUnit test results cache to reflect new timings and potentially new/cleaner test runs.

- Refactored AISuggestionService to consolidate AI suggestion prompt into a single constant template and unified JSON parsing logic, enhancing maintainability.
- Implemented a new method `parse_poll_json` for robust multi-stage extraction of JSON from AI responses, reducing malformed suggestion fallbacks.
- Updated REST vote/results tests to use unique block IDs, ensuring test isolation and preventing residual data interference.
- Version bump to 0.8.1 in content-poll.php and readme.txt to reflect changes.
- Changelog updated to document changes and improvements.
@soderlind soderlind merged commit a768b67 into main Nov 15, 2025
3 checks passed
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