# Changelog All notable changes to WP Agentic Writer are documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [Unreleased] ### Fixed - **Sidebar logger recursion**: Fixed wpawLog.error/log/warn calling themselves recursively (now call console.* directly) - **Sidebar syntax**: Restored valid JavaScript syntax after debug logger conversion damaged string literals - **Cost tracker backward compatibility**: Added `record_usage()` method to match WP AI Client wrapper contract - **Cost attribution**: Added `record_usage_full()` method for accurate model/provider attribution in cost records - **Cost table self-heal**: Added `SHOW TABLES LIKE` guard before `DESCRIBE` to handle missing table scenario - **Conversation table versioning**: Fixed independent version tracking for conversations table vs. main plugin version - **Clear context behavior**: Context service now clears all active sessions for a post when sessionId is not provided - **Deactivation cleanup**: Now clears `wpaw_cleanup_old_sessions` scheduled hook - **Legacy chat history migration**: `migrate_legacy_chat_history()` now deletes legacy meta and writes migration marker; `get_context()` performs migrate-on-read for posts with unmigrated legacy data - **Legacy chat history deprecated**: `update_post_chat_history()` no longer writes to post meta; endpoint returns deprecation notice ### Added - **Post-scoped authorization (complete sweep)**: Added `edit_post` capability checks to ALL post-scoped REST endpoints: - `handle_clear_context`, `handle_revise_plan`, `handle_block_refine`, `handle_refine_from_chat` - `handle_seo_audit`, `handle_suggest_keywords`, `handle_suggest_improvements` - Plus all previously fixed endpoints (chat, generate-plan, execute-article, reformat-blocks, regenerate-block, meta, image ops) - **Frontend debug logging**: Added centralized debug logging utility (`wpawLog`) that respects the `wpAgenticWriter.debug` flag - **Schema sync**: Cost tracking table `CREATE` statement now includes all columns (`provider`, `session_id`, `status`) with runtime migration fallback - **Uninstall cleanup**: Consolidated uninstall hooks and removed redundant code paths ### Changed - **record_usage() deprecated**: Marked `record_usage()` as deprecated in docblock; use `record_usage_full()` for accurate provider attribution ### Removed - **Legacy chat history**: Post meta `_wpaw_chat_history` is deleted after successful migration (replaced by `_wpaw_chat_history_migrated` marker) ## [0.1.3] - 2025-05-24 ### Added - **Provider transparency**: Provider selection now returns structured result with `selected_provider`, `actual_provider`, and `fallback_used` flags - **Cost tracking enhancements**: Extended cost tracking to capture provider name, session ID, and request status - **Authorization hardening**: Added `edit_post` capability checks to REST API endpoints for writing state and conversations ### Fixed - **OpenRouter cache conflict**: Split single transient into separate keys for model IDs and model objects - **Provider contract mismatch**: All provider calls now properly unwrap the `WPAW_Provider_Selection_Result` object - **Streaming chat variables**: Added proper initialization for `accumulated_content`, `chunks_emitted`, `total_cost` before closure use - **Post meta bloat**: Stopped writing `_wpaw_chat_history` to post meta (conversations table is now the source of truth) ## [0.1.2] - 2025-05-17 ### Fixed - Clarification quiz flow improvements - Block refinement hybrid implementation - Language detection for multilingual content ## [0.1.1] - 2025-05-10 ### Added - Context optimization with summarization - Intent detection for writing modes - Block-based article structure with outline panel ### Fixed - Writing state persistence - Session management improvements ## [0.1.0] - 2025-05-01 ### Added - Initial release of WP Agentic Writer - Plan-first AI writing workflow: Scribble → Research → Plan → Execute → Revise - Integration with OpenRouter API - Gutenberg sidebar for AI assistance - Cost tracking for API usage - Image generation support