Logging: replace "Purge All Logs" with age-based delete control#735
Open
i-anubhav-anand wants to merge 2 commits into
Open
Logging: replace "Purge All Logs" with age-based delete control#735i-anubhav-anand wants to merge 2 commits into
i-anubhav-anand wants to merge 2 commits into
Conversation
Closes WordPress#689. Replaces the single "Purge All Logs" button in the AI Request Logs settings panel with a SelectControl offering four options: - Older than 30 days - Older than 90 days - Older than 1 year - All logs The two-step confirmation flow is preserved; the message adapts to the selected threshold. Nothing is scheduled or persisted — every delete action is manual and explicit. On the PHP side, the existing DELETE /ai/v1/logs REST route now accepts an optional before_days integer (default 0 = purge all). A new delete_logs_older_than() manager method routes to the already-batched cleanup_by_retention() when days > 0, or purge_all() when days = 0.
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
dkotter
requested changes
Jun 17, 2026
dkotter
left a comment
Collaborator
There was a problem hiding this comment.
E2E tests and ESlint are failing on this PR. Those will need cleaned up before we proceed with a review here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #689
Replaces the single "Purge All Logs" button in the Manage Logs panel with an age-based delete control: a dropdown (Older than 30 days / 90 days / 1 year / All logs) followed by a "Delete" button.
Why?
The existing "Purge All Logs" button is too blunt — it forces users to delete their entire log history even when they only want to remove old entries. This change gives users meaningful control over how much history to keep, while still allowing a full purge via the "All logs" option.
How?
PHP:
AI_Request_Log_Manager::delete_logs_older_than(int $days): int— delegates to the existingAI_Request_Log_Repository::cleanup_by_retention()for the batched SQL delete, or falls back topurge_all_logs()when$days === 0.DELETE /ai/v1/logsREST endpoint with an optionalbefore_daysinteger param (minimum: 0). When omitted or 0, all logs are purged (backwards-compatible). Negative values are rejected with a 400.React:
SettingsPanelto use aSelectControl(30 / 90 / 365 / 0 days) and a "Delete" button with a contextual confirmation message.handleDeleteLogsinindex.tsxto acceptdays: number, pass it asbefore_daysin the DELETE request, and callfetchLogs()after deletion so the table immediately reflects actual remaining entries.Tests:
AI_Request_Log_ManagerTest:test_delete_logs_older_than_removes_only_old_entries,test_delete_logs_older_than_zero_purges_allAI_Request_Log_ControllerTest:test_purge_logs_with_before_days_removes_only_old_entries,test_purge_logs_rejects_negative_before_daysUse of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Sonnet 4.6
Used for: Code scaffolding and test suggestions; all implementation details, logic, and tests were reviewed, tested locally, and edited by me.
Testing Instructions
Screenshots or screencast
Changelog Entry