Skip to content

AI Workspace: propose changes to existing posts and the site title, applied on approval - #1314

Merged
whyisjake merged 25 commits into
feat/ai-workspacefrom
feat/agent-approval-writes
Nov 13, 2026
Merged

whyisjake merged 25 commits into
feat/ai-workspacefrom
feat/agent-approval-writes

Conversation

@whyisjake

@whyisjake whyisjake commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

What?

Related: #1287

The AI Workspace can now change things that already exist, not only create drafts and templates. The assistant can propose a new title, excerpt or content for a post, or a new site title or tagline. Nothing changes until you approve, and the card shows each current value next to the proposed one. You can edit a value before approving it.

This is the first of the stacked PRs that build #1287's single agent on top of feat/ai-workspace (#1004). It ports #1214's write actions. The next PRs add site info and screen finding, then the Command Palette entry, then audit and privacy hooks, then the docs pass for the name.

Why?

#1287's first version needs the agent to finish tasks like "change my tagline to fit what I write about" instead of telling the person how. Before this, the workspace's approval flow could only create new posts. Its single-approval guarantee rested on a per-post token, which doesn't exist when you're editing something that's already there.

How?

Writes are proposal types, not abilities. ai/propose-post-changes and ai/propose-site-identity only store a proposal. The write happens when the person approves it in the card. #1214 registered ai/site-agent-update-post and ai/site-agent-update-setting as abilities instead. In this plugin every ai/* ability is offered over MCP by default, so those would have been callable by any MCP client with no approval step. #1214's validation rules are ported into the two new writers.

The approval flow is now safe for editing existing content:

  • One approval: approving takes a lock with a single INSERT IGNORE into the options table, the pattern core's WP_Upgrader::create_lock() uses. add_option() won't do here: it writes with ON DUPLICATE KEY UPDATE, which lets a second claim with a different value succeed.
  • Partial results kept: each item's result is saved as soon as it's written. An approval still running after five minutes reads as failed and keeps its partial results.
  • Expired and deleted: an expired proposal is reported as expired, not "not found". A proposal whose chat was deleted can't be approved.
  • Checked at approval: a field that changed since it was proposed is left alone and reported as changed. One already at the new value is reported as unchanged. A post someone else is editing is reported as locked.
  • Edits re-checked: an edited value runs through the same server-side rules as the assistant's value, and it can change only the value, never which post, field or option is targeted.

Content stays intact:

  • Plain titles: a title with any markup is refused. Core skips title kses for admins with unfiltered_html, so this check is the only one.
  • No silent stripping: a content change is refused when kses would strip something from the post's current content, such as an iframe or an embed saved by an admin. Ordinary block markup like images and separators is fine.
  • One field at a time: writing one field leaves the post's other text columns exactly as stored.
  • Block markup kept: ai/read-content-bodies gains raw: true. It returns the stored markup, only for posts the user can edit, so a content change can keep the post's blocks.

The card hides nothing that would publish. Content is parsed in an inert DOMParser document and drawn through the transcript's existing renderer. Self-closing blocks (core/rss, core/latest-posts), media, embeds and form controls show in place as plain text, so a person sees everything they're approving. Nothing is fetched or run, and links are live only on the site's own host.

Workspace-only abilities are off MCP. ai/propose-* and ai/ask-user now declare meta.mcp.public as false. Before, MCP clients were offered tools that always refused outside a workspace turn. An override on the MCP Access screen still wins.

Filters:

  • wpai_workspace_write_proposals_enabled (default true) turns these two proposal types off. That's New Experiment: One AI agent across wp-admin #1287's "allow writes" question: on by default, with no settings toggle.
  • wpai_workspace_proposal_kinds is the list of proposal types. The tool list, the turn-ending rules and the system instruction are now all built from it.

Code from #1214 is credited to @Vrishabhsk with Co-authored-by on the two writer commits.

Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: planning, implementing the changes and tests, and code review.

I've reviewed the changes, understand them and can explain them under review. They have all been tested locally.

Testing Instructions

  1. Enable AI Workspace under Settings → AI and connect a provider.
  2. In Tools → AI Workspace, ask "Make my tagline fit what I write about".
    • The card shows the current tagline beside the proposed one.
    • Edit the proposed tagline, then apply. Settings → General shows your edited tagline.
  3. Ask for a new title for one of your published posts. The card says the change is live as soon as you approve it.
  4. Open the same chat in a second tab and approve in the first. The second tab shows the outcome, not an Apply button.

Tests run (all passing):

  • PHPUnit, full suite: 3306 tests on WordPress latest, on both single site and multisite, at 4f6931b. Before the first round of review fixes, the full suite also passed on trunk (7.2-beta4), at 3286 tests.
  • PHPUnit, new tests:
    • Proposal_StoreTest: lock, failed window, expiry grace, edits, kind registry, write gate, and client/server ability parity. Includes test_a_lock_row_written_outside_the_cache_blocks_the_claim, which failed against the old add_option() lock.
    • Post_Field_ProposalTest, including test_a_title_changed_since_the_proposal_is_stale, test_two_fields_of_one_post_both_write, test_a_post_locked_by_another_user_is_locked, test_content_with_an_iframe_is_refused_but_other_fields_work, test_content_with_an_image_block_accepts_a_change, test_content_with_a_separator_block_accepts_a_change, test_content_kses_would_strip_from_is_refused, test_an_edit_cannot_retarget_the_item, test_a_duplicate_field_of_one_post_is_refused, test_a_model_supplied_snapshot_is_ignored and test_a_title_with_a_backslash_survives_the_write.
    • Site_Identity_ProposalTest: 16 tests.
    • Proposal_ControllerTest: test_approval_while_another_request_holds_the_lock_writes_nothing, test_an_interrupted_write_keeps_partial_results_and_reads_as_failed, test_approving_after_the_chat_was_deleted_is_refused and test_get_returns_the_stored_results_once_approved.
    • MCP_AdapterTest: test_plugin_ability_declared_hidden_stays_hidden, test_workspace_only_abilities_are_hidden_from_mcp, test_override_exposes_a_plugin_ability_declared_hidden and test_workspace_only_ability_refuses_outside_a_turn.
    • Read_Content_BodiesTest: test_raw_returns_stored_markup_to_an_editor_of_the_post, test_raw_is_withheld_from_a_user_who_can_only_read_the_post and test_raw_is_off_by_default.
  • e2e (Chromium): all tests/e2e/specs/experiments/ai-workspace* specs, 135 passed at 4f6931b. They were run with this branch merged into AI Workspace: answer site questions and link to the right admin screen #1315, because this PR's own test site holds the live-check data.
    • New ai-workspace-update-proposals.spec.ts (8 tests): current next to new, plus editing; the server's message on an invalid edit; a second page after approving; approving in a second page while the first is still writing; a stale field; deselecting one of three changes; a reopened discarded proposal; the tagline.
    • New ai-workspace-html.spec.ts for the content renderer. It covers every element shown as plain text instead of rendered, and the notice naming blocks whose settings a content change alters.
    • From the second review round: "an approval whose answer is lost after it wrote shows what was applied" and "discarding a change another page already applied shows what was applied".
  • Test-first: tests written before their change failed before it.
  • Other checks: PHPStan finds no errors. phpcs is clean on the changed plugin PHP. tsc, lint-js and the build are clean.
  • Live check with a real provider (on a separate test site, not the demo one), one 19-turn chat: 7 proposals and 9 changes approved, all reported as updated, none stale, locked or failed.
    • The site title and tagline were both changed.
    • A published post's title and the excerpts of the three latest posts were updated.
    • The same post's content was rewritten four times: separators, headings and lists added, sections filled in, the intro changed, and Ctrl to Ctrl/Cmd. After each rewrite the post was still valid block markup, with every block parsed and 6 revisions kept. Rewrites after the first one added separators were still accepted.
    • When asked to fill in sections it had no facts for, the assistant asked which ones to use rather than inventing them.
  • Second live check (2026-11-07, Anthropic claude-sonnet-5, at 4f6931b, through the workspace REST routes as an administrator): one turn and one approval per write kind, with the posts and options read straight from the database before and after.
    • A post title, an excerpt approved with the person's edited value in place of the model's, block content with a paragraph added, and the site title and tagline together. Each was reported as updated.
    • After each turn the database was unchanged. Approving changed only the field proposed (plus post_modified), and the edited excerpt was written as edited.
    • The block content kept its existing blocks byte for byte, and the new paragraph was a wp:paragraph block.
    • A second approval of the same proposal returned the stored results and wrote nothing.
  • Found in that run and fixed in 36820b2: an applied card no longer showed what the field now held. It now shows "Now: …". The tool-steps summary also said "1 steps".
  • PHPUnit added in the second review round, each failing before its fix: test_a_stale_lock_replaced_before_the_delete_is_not_deleted, test_a_writer_that_throws_part_way_leaves_the_proposal_failed, test_discarding_while_an_approval_holds_the_lock_is_refused, test_an_executed_proposal_read_after_expiry_shows_its_outcome, test_approving_with_nothing_selected_is_refused_for_any_kind, test_a_post_another_hook_updates_during_the_write_keeps_its_own_columns and test_content_proposed_after_the_post_changed_since_it_was_read_is_refused.

Code review, two rounds:

  • Round one (run 20261106-154448-0faae422): 8 reviewers and an independent validator. A bug in how the reviewer prompts were built cut off the PR's intent and the location of its diff, so each reviewer worked out the scope on its own. Its findings were checked against the code and are fixed in 25748bd:
    • content changes were refused for posts with image or separator blocks;
    • the card dropped markup that would publish;
    • content could only be read as stripped text;
    • a proposal could name the same field twice;
    • missing tests and a docs line.
  • Round two (run 20261106-212611-pra2rerun): the same 8 reviewers on the full diff at 36820b2, with the intent and diff in every prompt. Each finding was reproduced or traced in the code before being fixed, rather than going through the separate validator. Fixed in 476784a to 4f6931b:
    • after a lost or 5xx approval response, the card said nothing was changed without checking (three reviewers found this). It now reads the proposal back and shows what was applied;
    • a writer that threw left the proposal executing and the lock held. It now settles as failed, keeps the partial results and tells the model;
    • a discard didn't take the approval lock, and could land during an approval;
    • two requests reclaiming a dead lock could both get it;
    • an applied proposal opened after its expiry showed as expired instead of showing what was applied;
    • discarding in a second window after the first applied said nothing was changed;
    • the "select at least one item to create" message was shown on update cards;
    • the column pin leaked into other posts written by hooks during the save;
    • a change to a wrapping block's settings, such as a Query Loop's arguments, was invisible in the card. The card now names those blocks;
    • an edit made to a post between the assistant reading it and proposing a change could be overwritten. A content change based on an older read is now refused;
    • one interrupted-approval path re-ticked items the person had unticked.

The cross-model pass didn't run, because no model CLI from another provider is installed.

Unapplied review findings

  • P2: includes/Experiments/AI_Workspace/Propose_Post_Changes.php: the four propose abilities repeat the same setup code (turn check, meta block, proposal envelope). A shared base would remove it. Deferred: it follows the existing pattern, and it's a refactor outside this PR's scope.
  • P2: Propose_Post_Changes and Propose_Site_Identity each check for a duplicate target themselves. The kind could own a target key, and the store could refuse duplicates once. Deferred: same refactor scope as above.
  • P2: src/experiments/ai-workspace/utils/proposal-card.ts: the client works out which proposal types are updates (UPDATE_KINDS, SITE_FIELDS) on its own. The server could send is_update and the target instead. Deferred: it changes the contract between client and server.
  • Residual risk (fixed in 22d5d2c): decline_proposal() doesn't take the approval lock, so a discard can interleave with an approval that has claimed the lock but not yet saved.
  • Residual risk (fixed in 3c4cd75): keep_other_columns() pins the *_save_pre filters for the whole wp_update_post() call. A save_post hook that writes a different post would receive this post's columns.
  • Residual risk: approving while the same user has the post open in the block editor passes their own post lock. A later autosave from that tab could revert the change.

Screenshots or screencast

Post changes: each current value beside the proposed one

Post changes: each current value beside the proposed one

Editing a proposed value before approving

Editing a proposed value before approving

A tagline proposal

A tagline proposal

After approval: the post is updated

After approval: the post is updated

After approval: the new tagline is live

After approval: the new tagline is live

A field changed since the proposal is left alone and reported

A field changed since the proposal is left alone and reported

Changelog Entry

Added - AI Workspace can propose changes to a post's title, excerpt or content, and to the site title and tagline, applied only after approval, with current and new values shown side by side.

Post-deploy monitoring: no additional operational monitoring is required. This is an experiment behind the AI Workspace toggle, off by default, and every write needs explicit approval.


Compound Engineering

🤖 Generated with Claude Code

Open WordPress Playground Preview

whyisjake and others added 8 commits November 6, 2026 12:58
…ng content

Part of #1287 (PR A, U1). The proposal flow only ever created things, and
relied on a per-item token to survive a second approval. Updates to
existing content need stronger guarantees.

- Approval takes a per-proposal lock with one INSERT IGNORE into the
  options table, as WP_Upgrader::create_lock() does, and saves each
  item's result as it is written. add_option() is not used: its ON
  DUPLICATE KEY UPDATE lets a second claim of a different value succeed.
  A second approval returns the stored results. A proposal still
  executing after five minutes reads as failed with its partial results
  and cannot be approved again.
- Approval is refused once the proposal's chat no longer exists.
- Proposals are stored past their expiry with a grace period, so an
  expired one is reported as expired rather than not found.
- An optional `edits` argument re-runs edited items through the kind's
  normalize_item(); kinds that create things reject edits.
- Result counts gain updated, unchanged, stale and locked.
- Each kind names its propose ability, capability and instruction, and
  the tool list, turn-ending list and follow-up stripping are built from
  the kind registry (`wpai_workspace_proposal_kinds`). Update kinds can be
  turned off with `wpai_workspace_write_proposals_enabled`.
- A reopened chat now reports discarded proposals as discarded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #1287 (PR A, U2). ai/propose-drafts, ai/propose-template and
ai/ask-user only work inside an AI Workspace turn, and their comments
said they were withheld from MCP. They only set show_in_rest to false,
though, and the MCP Access experiment exposes every ai/* ability by
default regardless of show_in_rest, so MCP clients were offered tools
that always refused with workspace_context_required.

- Exposure_Overrides::default_exposure() now respects a plugin ability's
  explicit meta.mcp.public of false. A saved override from the MCP
  Access screen still wins.
- The three workspace-only abilities declare meta.mcp.public as false.
- The docs say how they are withheld.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tent

Part of #1287 (PR A, U3). The assistant can now propose new values for
existing posts through ai/propose-post-changes. Nothing is written until
the person approves, as with drafts and templates. This ports #1214's
update rules as a proposal kind rather than a registered write ability,
which MCP clients could call with no approval.

- One item is one field of one post. Published posts can be changed;
  the card is told the change is live.
- Titles must contain no markup and are capped at 500 characters.
  Excerpt and content go through wp_kses_post for every user.
- Content changes are refused for a post whose current content kses
  would alter (iframes, embeds saved with unfiltered_html), so a rewrite
  can't silently strip them from a live post.
- Writing one field keeps every other text column exactly as stored, so
  wp_update_post() re-running kses can't strip an iframe when only the
  title changes.
- At approval: a field changed since the proposal is stale, one already
  at the new value is unchanged, and a post locked by someone else is
  locked. Capability is re-checked.
- An edit may change only the proposed value, never which post or field
  an item targets.
- The model hears the written title or excerpt in full, and content as
  updated with its length.
- The ability is withheld from MCP and REST and refuses outside a turn.

Co-authored-by: Vrishabhsk <vrishabhsk@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #1287 (PR A, U4). The assistant can now propose a new site title
or tagline through ai/propose-site-identity, for administrators, and
nothing changes until the person approves. This ports #1214's settings
allowlist as a proposal kind rather than a registered write ability.

- Only blogname and blogdescription, at most one item each, and
  manage_options at propose time and again at approval.
- Values are plain text: HTML is stripped, and a value over 200
  characters (title) or 300 (tagline) is refused rather than cut.
  An empty title is refused; an empty tagline is allowed.
- At approval: a value changed in Settings since the proposal is stale,
  and one already at the new value is unchanged (compared as core stores
  it, so an ampersand doesn't read as a change).
- An edit may change only the proposed value.
- The ability is withheld from MCP and REST and refuses outside a turn.

Co-authored-by: Vrishabhsk <vrishabhsk@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #1287 (PR A, U5). Approval cards for post-field and site
identity proposals:

- Each change shows the current value next to the proposed one, with
  content rendered rather than shown as HTML, a notice when the change
  goes live immediately, and a checkbox. Update cards start with every
  change selected; the button counts them ("Apply 3 changes").
- Edit turns the proposed value into a field: a text input for titles
  and the tagline, a textarea for the excerpt, and a markup textarea
  with a live rendered preview for content. A value the server refuses
  keeps the card editable, with the server's message by the field.
- Outcomes read updated, unchanged, changed since proposed (with a link
  to the post or Settings) or locked.
- A second window shows the stored outcome instead of Apply. An approval
  refused because another window is applying shows "Applying in another
  window" and waits for that outcome. A failed approval shows its
  partial results. A reopened chat shows a discarded change as
  discarded.
- Post content is parsed in an inert DOMParser document and mapped onto
  the existing markdown node tree through an allowlist, so no markup is
  handed to the browser and no image is fetched; links are live only on
  this site's host.
- The proposal GET route now returns stored results once a proposal is
  no longer pending, and an edit error names the item it belongs to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #1287 (PR A). Covers ai/propose-post-changes and
ai/propose-site-identity, how changes to existing content are shown,
edited and checked at approval, the single-approval lock, and the
wpai_workspace_write_proposals_enabled and wpai_workspace_proposal_kinds
filters.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #1287 (PR A). No behavior change.

- The write loop, log envelope and field reader the three writers
  copied now live in one Proposal_Writes trait; each kind keeps its own
  write_item(), its deselected outcome and its log details.
- The stale check stores a SHA-256 of the value it was proposed over,
  rather than the whole value, so a proposal of content changes no
  longer carries up to 20 post bodies through every save.
- The tool selector builds its curated list once per pass, and the
  system instruction computes the proposal abilities once.
- The update card memoizes its rendered HTML, so typing in one edit
  field no longer re-parses every item's content.
- Small cleanups: a capability constant instead of a repeated literal,
  a simpler results tally, one field-label table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Part of #1287 (PR A). From the ce-code-review run 20261106-154448-0faae422.

- #1: content changes were refused for any post with an image or
  separator block, because the "kses would damage this" check compared
  bytes and kses re-serializes void tags. It now compares tags,
  attributes, comments and text, and refuses only when kses would remove
  something (iframes, scripts, event handlers, disallowed protocols).
- #2: the approval card dropped markup that survives kses and renders on
  the live site. Self-closing blocks (rss, latest-posts, ...), media,
  embeds and form controls are now described in place as inert text, so
  the person sees what they are approving. Nothing is fetched or run.
- #7: the assistant could read post content only as stripped text, so a
  content change would have dropped the post's blocks.
  ai/read-content-bodies takes `raw: true` and returns the stored markup
  for posts the user can edit, and the propose instruction tells the
  model to build changes from it.
- #6: a proposal can no longer name the same field of one post twice.
- A model-supplied stale-check snapshot is ignored; the server takes it.
- #4: tests for the empty title and content refusals. #10: docs list the
  two new abilities among those not available over REST or MCP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.47115% with 69 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.54%. Comparing base (d1b8ba2) to head (de66f8c).

Files with missing lines Patch % Lines
...des/Experiments/AI_Workspace/Post_Field_Writer.php 95.36% 12 Missing ⚠️
.../Experiments/AI_Workspace/Propose_Post_Changes.php 92.46% 11 Missing ⚠️
.../Experiments/AI_Workspace/Site_Identity_Writer.php 92.96% 9 Missing ⚠️
...cludes/Experiments/AI_Workspace/Proposal_Store.php 93.93% 8 Missing ⚠️
...eriments/AI_Workspace/REST/Proposal_Controller.php 94.36% 8 Missing ⚠️
includes/Experiments/AI_Workspace/Turn_Context.php 53.84% 6 Missing ⚠️
...s/Experiments/AI_Workspace/Prompt_Model_Client.php 78.26% 5 Missing ⚠️
includes/Experiments/AI_Workspace/Draft_Writer.php 50.00% 4 Missing ⚠️
...ludes/Experiments/AI_Workspace/Proposal_Writes.php 97.01% 2 Missing ⚠️
...ludes/Experiments/AI_Workspace/Template_Writer.php 66.66% 2 Missing ⚠️
... and 2 more
Additional details and impacted files
@@                   Coverage Diff                   @@
##             feat/ai-workspace    #1314      +/-   ##
=======================================================
+ Coverage                86.06%   86.54%   +0.48%     
- Complexity                5848     6190     +342     
=======================================================
  Files                      215      220       +5     
  Lines                    21250    22321    +1071     
=======================================================
+ Hits                     18289    19318    +1029     
- Misses                    2961     3003      +42     
Flag Coverage Δ
unit 86.54% <94.47%> (+0.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Found in a live run of #1314. Once an update was applied, its card
collapsed to "Tagline - Updated" and no longer said what the field now
holds; only the assistant's follow-up text did. Each updated or
unchanged item now shows "Now: <value>" for titles, excerpts, the site
title and the tagline. Content is reported by length only, so it shows
nothing extra.

Also pluralize the tool-steps summary: "Looked up site content (1 step)"
rather than "(1 steps)", which predates this branch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whyisjake
whyisjake marked this pull request as ready for review November 7, 2026 02:09
@whyisjake
whyisjake requested review from a team and jeffpaul as code owners November 7, 2026 02:09
@github-actions

github-actions Bot commented Nov 7, 2026 •

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @Vrishabhsk.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: Vrishabhsk.

Co-authored-by: whyisjake <whyisjake@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

whyisjake and others added 7 commits November 6, 2026 21:38
Two approvals that both read the same stale lock could each delete the
other's fresh one with delete_option() and both claim the proposal. The
stale row is now deleted only while it still holds the value read, and
the claim is taken only when that delete removed a row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… outcomes

- A writer that throws part way now leaves the proposal failed with the
  results it saved, releases the lock, reports those results to the
  model, and answers 500 with the stored outcome in the error data.
- A discard takes the approval lock and re-reads the proposal before it
  deletes, so it cannot interleave with an approval that has claimed the
  proposal but not yet saved it as executing.
- Only a pending proposal expires on read. One an approval started on is
  returned past its expiry, so reopening an applied change shows what was
  written instead of "expired". Its record is still removed: save()
  stores the transient for TTL + GRACE after its last save, and the
  transient lapses on its own after that, so no extra delete is needed.
- "Select at least one item." no longer says "to create" for updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tent reads

- The other columns of a post-field write are put back on
  wp_insert_post_data for that post's ID only, so a save_post hook that
  saves another post during the write keeps that post's own columns.
- The turn context remembers a hash of each post's content_raw that
  ai/read-content-bodies returned this turn. A content change proposed
  for a post saved since that read is refused, telling the model to read
  it again. Outside a turn, or with no raw read, nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nged

- An approval that fails with a 5xx, no answer, or an answer that cannot
  be read may have written, so the card reads the proposal back and shows
  its stored outcome when it is no longer pending. "Nothing was changed"
  is kept for a 4xx, which the server sends before it claims, and for a
  proposal still pending. If the read back fails too, the card says the
  outcome could not be confirmed.
- A failed discard reads the proposal back as well, so one another window
  already applied shows what was applied.
- Returning to the card after another window let go keeps the person's
  selection instead of re-ticking what they unticked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Block settings sit in their delimiters and are not rendered, so a content
change that only alters a wrapping block, such as a Query Loop's query or
a binding, looked the same in Current and New. The card now compares the
block delimiters of both versions and names the blocks whose settings
differ.

Also covers the withheld svg, math, canvas, select, input, form, embed
and track elements in the renderer spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The card now reads a proposal back before saying nothing was created.
The test aborted every proposal request, read-back included, so the
card rightly said the outcome could not be confirmed. Aborting only
the execute request keeps the test about an approval that never got
there, and covers the read-back finding the proposal still pending.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeffpaul

jeffpaul commented Nov 9, 2026

Copy link
Copy Markdown
Member

I'm not seeing any proposals to approve from the agent:

Screenshot 2026-11-09 at 1 54 08 PM

The OpenAI connector returns each item of a Responses API reply as its
own candidate. When the model says what it is about to do and then calls
a tool, the sentence and the call arrive as two candidates, and the
client read only the first with toMessage(). The model announced a
proposal, the call was lost, and the turn ended with no approval card.
Parallel calls after the first were lost the same way.

The client now returns every candidate's message, in order, when there
is more than one. The turn loop adds each to the history and answers
each message's calls in a message of its own, because that connector
refuses a function call or result that shares a message when the history
is replayed. A reply in one candidate, as Anthropic and Google send, is
handled as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
whyisjake and others added 2 commits November 9, 2026 23:23
When the OpenAI connector returns a sentence and a tool call as separate
messages, the turn's text was read from the last model message only,
which is the call, so the sentence ("Your site is running PHP 8.3") was
saved and shown as nothing. The text now comes from the whole run of
model messages that makes up the last reply.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Asking for 50 posts cut the request off at core's 30 second default
before any reply arrived; in the browser it showed as a network error.

- A workspace round now waits at least 120 seconds. The raise is scoped
  to building that round's request and never shortens a longer default a
  site set. `wpai_workspace_request_timeout` changes it.
- The drafts instruction states that one proposal holds at most 20
  drafts, to propose the first 20 when asked for more, and to keep
  bodies short when proposing many.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm still getting those NetworkError messages, so not sure if there's something amiss in the Playground environment (compared to say a local env) that may be causing this?

whyisjake and others added 5 commits November 12, 2026 09:31
WordPress Playground gives up on any request after 25 seconds, and a
proxy in front of a site can give up before PHP does. The turn keeps
running and is saved, but the browser only saw a network error
("NetworkError when attempting to fetch resource").

Each turn now carries an ID the client chose, kept on its saved entry,
and a first turn names the chat it creates. When the request fails in
transit, the stream breaks, or a gateway answers 502/503/504/524, the
client reads the saved chat every 3 seconds, for up to 10 minutes,
until the turn's entry appears, and shows that instead. Stop still
works while it waits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Waiting for a saved reply made a request that never left the browser
look like a turn still running, for up to 10 minutes. The turn route
now marks a named turn running while it runs and done when it ends,
and GET /workspace/messages/<turn_id> reports running, done or
unknown, for the current user only. The client checks it straight
away: a turn the server never saw fails after a second check, about
3 seconds; one that is running is waited on; one that is done is read
from the saved chat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whyisjake

whyisjake commented Nov 12, 2026 •

Copy link
Copy Markdown
Member Author

Thanks, Jeff, you were right that it's Playground. Playground's service worker gives up on any request after 25 seconds (DEFAULT_RESPONSE_TIMEOUT in php-wasm/web-service-worker), whatever PHP is doing. Writing a long proposal takes longer than that, so the browser got "NetworkError when attempting to fetch resource" while WordPress kept running the turn and saved it. A host whose proxy gives up before PHP does would hit the same thing as a 504.

The workspace now recovers that reply instead of showing the error:

  • each turn carries an ID the browser chose, and a first turn names the chat it creates;
  • while the turn runs, the server marks it running, then done;
  • if the response is lost (a dropped connection, a broken stream, or a 502/503/504/524 from a proxy), the browser asks whether the turn is running, waits while it is, and shows the reply from the saved chat once it's done;
  • a request that never reached the server still fails right away, after about 3 seconds.

Earlier fixes on this PR, in case you didn't see them: the tagline proposal that never arrived was the OpenAI connector splitting the reply into separate pieces (391fb52, 35f756f), and a round now waits up to 120 seconds and proposes at most 20 drafts at a time (0da9f4d).

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: diagnosing the Playground timeout, writing the fix and tests, and drafting this reply.
Tests run: full PHPUnit suite (3418 tests, 0 failures), including new test_a_first_turn_is_saved_under_the_id_the_client_chose, test_a_turn_entry_keeps_the_turn_id, test_a_turn_without_an_id_saves_no_turn_id, test_ids_that_are_not_uuids_are_refused, test_a_new_chat_id_with_an_existing_chat_is_refused, test_a_new_chat_id_already_in_use_is_refused, test_a_new_chat_id_owned_by_someone_else_is_not_written, test_the_state_route_reports_a_turn_as_unknown_or_done, test_a_turn_is_running_while_the_model_answers, test_the_state_route_needs_a_uuid and test_the_state_route_refuses_a_subscriber; all AI Workspace and Command Palette e2e specs (167 passed), including the new ai-workspace-dropped-connection.spec.ts (a lost first turn, a lost later turn, a 504 from a proxy); PHPStan. Not yet run in Playground itself.

I've reviewed the changes, understand them and can explain them under review.

The Anthropic connector caps a reply at 4,096 tokens when the caller
sets no limit, and a proposal of twenty drafts stopped partway with
"Generation stopped due to token limit (4096) with stop reason
max_tokens". Workspace rounds now ask for up to 16,384 output tokens
on every provider, filterable with wpai_workspace_max_output_tokens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@whyisjake

whyisjake commented Nov 12, 2026 •

Copy link
Copy Markdown
Member Author

One more fix, found while testing the Playground preview with an Anthropic key. After the reply came back, the 50-post prompt failed with "Generation stopped due to token limit (4096) with stop reason "max_tokens"". The Anthropic connector caps a reply at 4,096 tokens unless the caller asks for more, and a 20-draft proposal is longer than that. OpenAI sets no cap, which is why it only showed up with Anthropic.

Fixed in de66f8c: workspace turns now ask every provider for up to 16,384 output tokens, filterable with wpai_workspace_max_output_tokens.

In the preview for de66f8c, "generate 50 posts about traveling to each US state and then publish them" now ends with a proposal for the first 20 states, Alabama through Maryland, with the remaining 30 offered in two more batches. No NetworkError and no token-limit error. Ready for another look when you have a minute.

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for: diagnosing the token limit, writing the fix and tests, and drafting this reply.
Tests run: full PHPUnit suite (3445 tests, 0 failures), including new test_a_round_asks_for_enough_output_tokens and test_the_output_token_limit_is_filterable; all AI Workspace and Command Palette e2e specs (167 passed); PHPStan; and the 50-post prompt in the Playground preview for de66f8c with an Anthropic key.

I've reviewed the changes, understand them and can explain them under review.

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When there are multiple potential changes, we render different checkboxes but no way to "select all". So on a prompt where there are many items to check, it would be ideal to have a select all/none sort of option somewhere.

Screenshot 2026-11-12 at 9 35 11 PM

@jeffpaul jeffpaul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving and we can come back later to look at how better to handle a response with MANY checkboxes to sort through

@whyisjake
whyisjake merged commit 57fcee7 into feat/ai-workspace Nov 13, 2026
37 checks passed
@whyisjake
whyisjake deleted the feat/agent-approval-writes branch November 13, 2026 18:08
whyisjake added a commit that referenced this pull request Nov 13, 2026
#1315)

## What?

Related: #1287

The AI Workspace assistant can now answer questions about the site
itself, and point people to the right admin screen:
- **"What PHP version am I running?"** It reads the site's name,
tagline, language, timezone, theme and, for admins, the WordPress and
PHP versions.
- **"Where do I hide my site from Google?"** It answers with a link to
Settings → Reading.

This is the second stacked PR for #1287, on top of #1314. In a live run
of #1314, the assistant proposed a new tagline and site title without
being able to read the current ones ("I can't see your current site
title"). This PR fixes that.

## Why?

#1287's first version needs the agent to answer site questions and
navigation questions directly. Before this, the workspace could read
posts but nothing about the site. It also had no way to know which admin
screen handles which job.

## How?

**`ai/get-site-info`** returns these fields, and no others:
- the site name, tagline and home URL;
- the language and timezone;
- the date and time formats;
- the active theme, and whether it's a block theme.

The WordPress and PHP versions are included only for users who can see
Site Health (`view_site_health_checks`), which on multisite means super
admins, as in core. It never returns the admin email, database details
or the plugin list. Core's own `core/get-site-info` returns the admin
email, so it joins the workspace's `NEVER_ADMITTED` list next to the
environment and settings readers.

**`ai/find-admin-screens`** matches a request against a curated map of
33 core admin screens on the server, using titles and keywords. There's
no model call inside it. It returns up to five screens, best match
first, and only screens the current user can open, as `admin_url()`
links on the site's own host.
- Sites and plugins can add or remove entries with the new
`wpai_admin_screens` filter. A filtered entry whose path has a scheme, a
leading slash or `..` is dropped.
- The Site Editor is offered only on block themes, and the Customizer
only on classic ones.

**Both are plain read abilities.** Any logged-in user can call them,
they're annotated read-only and not open-world, and they're listed over
MCP like the content reads. Both join the workspace's curated tool list,
because policy admission is off by default.

#1250's palette ability, which makes a nested model call over the
palette's own commands, stays separate. It comes with the Command
Palette PR.

Site-info field choices are ported from #1214's `Read_Site`, credited to
@Vrishabhsk with Co-authored-by.

### Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for:
planning, implementing the changes and tests, and code review.

I've reviewed the changes, understand them and can explain them under
review. They have all been tested locally.

## Testing Instructions

1. Enable AI Workspace and connect a provider.
2. Ask "What PHP version am I running?". The assistant answers with your
PHP version.
3. Ask "Where do I hide my site from Google?". The reply links Settings
→ Reading, and following the link opens it.
4. As an editor, call `ai/get-site-info` through the Abilities Explorer
or REST. The response has no version fields.

**Tests run** (all passing):
- **PHPUnit, full suite:** 3325 tests on WordPress latest.
- **`Get_Site_InfoTest`:**
`test_administrator_gets_every_field_including_versions`,
`test_editor_gets_the_fields_without_versions`,
`test_manage_options_without_site_health_access_gets_no_versions`,
`test_no_response_carries_admin_email_siteurl_database_or_plugins`,
`test_executes_without_any_input`, `test_name_and_tagline_are_decoded`,
`test_timezone_falls_back_to_the_utc_offset`,
`test_logged_out_visitor_is_refused`,
`test_output_schema_marks_the_versions_optional`,
`test_registration_has_a_category_and_read_only_annotations`,
`test_declared_to_the_model_for_administrator_and_editor_with_admission_off`
and `test_listed_for_mcp`.
- **`Find_Admin_ScreensTest`:**
- Queries:
`test_hiding_the_site_from_google_finds_reading_settings_first`,
`test_stopping_spam_comments_finds_discussion_settings_first`,
`test_changing_the_timezone_finds_general_settings_first`,
`test_singular_and_plural_settings_match_alike`,
`test_returns_at_most_five_screens` and
`test_stopword_only_query_returns_an_empty_list`.
- Access:
`test_editor_asking_for_plugins_gets_no_plugins_or_settings_screen`,
`test_filter_added_screen_appears_only_for_users_with_its_capability`,
`test_filter_can_remove_a_core_screen` and
`test_every_url_is_on_the_admin_host`.
- Themes and matching:
`test_block_theme_offers_the_site_editor_not_the_customizer`,
`test_classic_theme_offers_the_customizer_not_the_site_editor` and
`test_stem_is_idempotent_for_every_word_in_the_map`.
- Registration: `test_logged_out_visitor_is_refused`,
`test_registration_has_a_category_and_read_only_annotations`,
`test_declared_to_the_model_for_administrator_and_editor_with_admission_off`
and `test_listed_for_mcp`.
- **`Tool_PolicyTest`:**
`test_core_get_site_info_is_withheld_with_perfect_annotations`. It
failed before `core/get-site-info` was added to `NEVER_ADMITTED`.
- **e2e (Chromium):** all `tests/e2e/specs/experiments/ai-workspace*`
specs, 126 passed. That includes the new
`ai-workspace-navigate.spec.ts`: asking where to change the timezone
links Settings → General, and the link opens it.
- **Test-first:** tests written before their change failed before it.
- **Other checks:** PHPStan finds no errors, phpcs is clean on the
changed plugin PHP, and the build passes.
- **Not run yet:** a live check against a real provider.

**Code review:** six reviewers ran: correctness, security, adversarial,
testing, maintainability and agent-native. The orchestrator then
reproduced each finding on a test site, instead of running the skill's
separate validator. Four reviewers found nothing. The confirmed findings
are fixed in 21cf902:
- a call with no input failed;
- the name and tagline came back HTML-escaped;
- the versions were visible to sub-site admins on multisite;
- the screen matcher missed singular words;
- the theme branch had no test.

## Known limits

- An entry a plugin adds through `wpai_admin_screens` is trusted to name
the capability its screen needs. A weaker capability gives users a link
they can't open. It never gives a link off the site's host.
- Keywords are English only. A query in another language matches only
the translated screen titles.
- The navigation e2e test's link comes from the mocked model reply, so
it proves the tool round trip and the link working, while the ranking
itself is covered by `Find_Admin_ScreensTest`.

## Screenshots

**Asking where to change the timezone links Settings → General**

![Asking where to change the timezone links Settings →
General](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1315-5-navigate-timezone.png)

## Changelog Entry

> Added - AI Workspace can answer questions about the site (name,
tagline, theme, and WordPress and PHP versions for admins) and link to
the admin screen for a request.

**Post-deploy monitoring:** no additional operational monitoring is
required. This is an experiment behind the AI Workspace toggle, off by
default, and it adds read-only abilities.

---

[![Compound
Engineering](https://img.shields.io/badge/Built_with-Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- wp-playground-preview:start -->
<a
href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1315-2113f328ff63bca3163299767db00d0699313222.zip%22%7D%7D%5D%7D"
target="_blank" rel="noopener noreferrer">
<img
src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg"
alt="Open WordPress Playground Preview" width="220" height="57" />
</a>
<!-- wp-playground-preview:end -->

---------

Co-authored-by: Vrishabhsk <vrishabhsk@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
whyisjake added a commit that referenced this pull request Nov 13, 2026
## What?

Related: #1287, #1250

The Command Palette joins the AI Workspace:
- **AI suggestions when a search finds nothing.** Type "hide my site
from google" into the palette (Cmd/Ctrl+K). If the palette has no match
of its own, it asks the model which of its commands fit and shows up to
three, such as Settings → Reading.
- **"Ask AI" for bigger questions.** For people who can use the AI
Workspace, the palette also offers "Ask AI: <your search>". Choosing it
opens the AI Workspace with that text in the composer, ready to send.

This is the third stacked PR for #1287, on top of #1315 and #1314.

## Why?

#1287 asks for one agent surface, with the palette's "Ask AI" (#1250)
folded in rather than shipped as a separate experiment. Before this, a
plain-language palette search with no match just showed "No results
found", and there was no route from the palette into a conversation.

## How?

**AI suggestions** port #1250's ability and loader, credited to @JDeepD
with Co-authored-by.
- When the palette has settled with no results, its search is at least 3
characters, and the person has stopped typing for 450 ms, the loader
sends the search and the palette's own command list (names, labels and
keywords) to `ai/command-palette-ai-search`. The model picks up to three
command IDs. IDs that weren't sent are dropped, on the server and again
in the browser. Failures stay silent, and the palette shows its own
empty state.
- "Settled" means core's own post and page search has finished too. The
loader waits for the palette's empty state, which core shows only once
its search loaders are done, so an AI request never races a slow post
search.
- The payload is cut to the ability's limits (500 commands, and caps on
label and keyword length), so a large site doesn't fail validation. A
search longer than the ability accepts gets no AI request, but still
gets the Ask AI row.
- Editors and above get suggestions (`edit_posts`); subscribers don't.
- #1250's separate experiment and toggle are gone. The loader is
enqueued by the AI Workspace experiment, on screens that load the
Command Palette.
- The ability is hidden from MCP (`meta.mcp.public = false`), and the
workspace's tool policy refuses it as an agent tool. It's annotated
non-destructive and idempotent, but not read-only: core's REST run route
accepts only GET for read-only abilities, and the palette's command list
is too long for a URL.

**Ask AI** is offered only to workspace users (`manage_options`, the AI
Workspace screen's capability).
- It appears under the same conditions as the suggestions, after them,
and it stays when the AI request fails.
- Choosing it opens the AI Workspace with a `wpai-prompt` query arg. The
text is seeded into the composer as plain text, cut to 500 characters,
and never sent automatically. The arg is removed from the URL after
load, so a reload doesn't seed it again.
- A notice above the composer says the message came from a link and
should be checked before sending. Anyone can send an admin a link like
that.
- `get_seed()` gains a prompt field. A prompt seed takes precedence over
a post seed.

Adds `@wordpress/commands` 1.57.0 as a dependency.

### Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for:
porting #1250, implementing the changes and tests, and code review.

I've reviewed the changes, understand them and can explain them under
review. They have all been tested locally.

## Testing Instructions

1. Enable AI Workspace and connect a provider.
2. Press Cmd/Ctrl+K and type "hide my site from google". After a moment,
Settings → Reading appears selected, and Enter opens it.
3. Type "which of my posts are missing featured images" and choose "Ask
AI: …". The AI Workspace opens with that text in the composer, unsent,
with a notice above it.
4. As an editor, repeat step 2: you get suggestions but no Ask AI row.
5. Search for one of your post titles. The palette shows the post, and
no AI request is made.

**Tests run** (all passing):
- **PHPUnit, full suite:** 3376 tests, single site and multisite, on
WordPress latest.
- **`Command_Palette_AI_SearchTest`** (ported from #1250, extended):
including
`test_ability_is_hidden_from_mcp_and_refused_as_an_agent_tool`,
`test_execute_callback_drops_an_id_that_was_not_sent`,
`test_execute_callback_drops_invalid_ids_and_caps_results`,
`test_permission_callback_for_subscriber` and
`test_choose_commands_falls_back_without_structured_output`.
- **`Command_PaletteTest`:**
`test_palette_search_has_no_experiment_of_its_own`,
`test_loader_is_enqueued_with_the_command_palette_for_an_editor`,
`test_loader_is_not_enqueued_for_a_subscriber`,
`test_loader_offers_ask_ai_to_a_workspace_user`,
`test_loader_does_not_offer_ask_ai_to_an_editor` and
`test_loader_is_not_enqueued_when_the_experiment_is_disabled`.
- **`Admin_PageTest`:** `test_prompt_seed_carries_the_query`,
`test_prompt_seed_is_cut_to_the_cap`, `test_prompt_seed_is_plain_text`,
`test_empty_or_whitespace_prompt_gives_no_seed`,
`test_non_string_prompt_gives_no_seed`,
`test_prompt_seed_takes_precedence_over_a_post_seed` and
`test_post_seed_has_an_empty_prompt`.
- **e2e (Chromium):** all `ai-workspace*` specs plus the palette spec,
157 passed.
- `command-palette-ai-search.spec.js`: finds the right screen when the
palette has no results; no suggestions when no screen fits; no AI search
when the palette has results; a one or two character search makes no
request; only the last search is sent and answered when the search
changes; an answer naming a command the palette didn't send is dropped;
waits for slow post results before searching with AI; a search longer
than the ability accepts shows only Ask AI; the palette's own empty
state when the request fails; an editor gets suggestions; a subscriber
gets none; no AI row and no request when the experiment is disabled.
- `ai-workspace-palette-handoff.spec.ts`: Ask AI opens the workspace
with the query in the composer, unsent; after a reload the composer is
empty and the URL has no prompt; Ask AI comes after the suggestions; an
editor sees suggestions but no Ask AI row; a 2,000-character query is
cut to the cap; a prompt from a link shows a notice until it's edited;
opening the workspace directly shows no notice; a query with markup
arrives as plain text; an empty or whitespace query shows no Ask AI row;
when the AI request fails, a workspace user sees only Ask AI.
  - The timing tests were also run three times each, 21 of 21 passing.
- **Test-first:** every new PHPUnit test, and 6 of the 8 first Ask AI
e2e tests, failed before their change.
- **Other checks:** PHPStan finds no errors, phpcs is clean on the
changed plugin PHP, and tsc, lint-js and the build are clean. Style lint
reports two errors in `ai-workspace/index.scss` that are already on the
base branch.
- **Not run yet:** a live check against a real provider, and the PHPUnit
suite on WordPress trunk.

**Code review:** six reviewers ran on this PR's own diff: correctness,
security, adversarial, frontend races, testing and maintainability. Each
finding was checked in the code before being fixed. Fixed in a4a84fb
and a0d7830:
- the AI request could fire before core's post and page search finished,
showing AI rows next to real results (two reviewers found this);
- "Searching with AI…" could stay on screen after an early exit or a
changed search;
- a cached answer could show for a search that now has real results;
- the command list wasn't cut to the ability's limits, so a large site
would fail validation, silently;
- a composer filled in from a link had no notice;
- test gaps: short searches, a changed search, an unsent command name, a
slow post search.

## Known limits

- Choosing an AI suggestion records it among the palette's recent
commands, where it doesn't resolve, so it can take one of the five
recent slots.
- A cached answer can name a command that was unregistered after a
context change. Selecting it runs the original callback.
- Suggestions come from the palette's own command list, as in #1250, not
from #1315's admin-screen map.

## Screenshots

**A palette search with no match gets an AI suggestion**

![A palette search with no match gets an AI
suggestion](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1316-1-palette-ai-suggestion.png)

**Searching with AI**

![Searching with
AI](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1316-2-palette-searching.png)

**Ask AI opens the workspace with the query in the composer, unsent**

![Ask AI opens the workspace with the query in the composer,
unsent](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1316-3-ask-ai-composer.png)

**An editor gets suggestions but no Ask AI row**

![An editor gets suggestions but no Ask AI
row](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1316-4-palette-editor.png)

## Changelog Entry

> Added - The Command Palette suggests admin screens with AI when a
search finds nothing, and offers "Ask AI" to continue the question in
the AI Workspace.

**Post-deploy monitoring:** no additional operational monitoring is
required. This is an experiment behind the AI Workspace toggle, off by
default.

---

[![Compound
Engineering](https://img.shields.io/badge/Built_with-Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- wp-playground-preview:start -->
<a
href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1316-3b897cb8a6b06ce6e099c27b86176305ebc64e54.zip%22%7D%7D%5D%7D"
target="_blank" rel="noopener noreferrer">
<img
src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg"
alt="Open WordPress Playground Preview" width="220" height="57" />
</a>
<!-- wp-playground-preview:end -->

---------

Co-authored-by: Jaydeep Das <jaydeep.das@rtcamp.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
whyisjake added a commit that referenced this pull request Nov 13, 2026
…ase, Wapuu busy states (#1317)

## What?

Related: #1287

The AI Workspace gains an audit trail, personal-data export and erase,
and Wapuu busy states:
- **One audit trail.** Every agent event is one `agent` row in the AI
Request Log and one call of a new `wpai_agent_event` action. Events are
tool calls (including withheld ones), each item an approval writes, and
each step in a proposal's life: created, edited, declined, expired,
failed, or refused because its chat was deleted. The action fires even
when AI Request Logging is off.
- **Chats are personal data.** Tools → Export Personal Data includes the
person's saved chats, and Tools → Erase Personal Data deletes them. This
works with the experiment off.
- **Wapuu.** While a turn runs, the transcript shows a working Wapuu
instead of a spinner, then a celebrating one for a moment when the turn
finishes, or an oops one next to an error.

This is the fourth stacked PR for #1287, on top of #1316, #1315 and
#1314.

## Why?

#1287 asks that a site owner can see everything the agent did, was asked
and was refused, in one place, and that audit plugins can hook it.
Before this, workspace rows were mixed in with every other `ability`
row, proposal events weren't logged at all, and nothing fired with
logging off. Saved chats are personal data that core's export and erase
tools didn't know about. And Jeff posted a Wapuu set on #1287 so a long
turn looks busy rather than stuck.

## How?

**`Agent_Audit`** is the one place agent events are recorded.
- It fires `wpai_agent_event( $operation, $status, $context, $error )`,
then writes the row through `log_ai_request()` with the new `agent`
type.
- The two existing log calls, for tool calls in `Turn_Runner` and for
written items in `Proposal_Writes`, now go through it. Proposal events
are recorded in `Proposal_Store` and `Proposal_Controller`:
  - created, when a proposal is stored;
  - edited, when an approval carries edits, naming the edited items;
  - declined;
- expired, once, when an expired proposal is next read, since it's
deleted then;
- failed, when a write throws or is interrupted for longer than the
approval lock;
  - refused, when an approval comes after its chat was deleted.
- Context names the conversation, the proposal and its item keys, the
post and field, or the option. It never carries post content or option
values.
- The hook covers agent turns and approvals only. A direct MCP call to
an ability doesn't fire it. Docs say so.
- The log screen gains the `denied` status, ported from #1214, and agent
rows are labelled "Agent". Rows logged before this keep the `ability`
type.
- #1214's `wp_after_execute_ability` listener isn't ported:
`Turn_Runner` already logs each call, so it would log them twice.

**`Conversation_Privacy`** registers an "AI chats" exporter and eraser.
- They're hooked from `Main`, next to the chat ownership filter, so they
work while the experiment is off.
- The export has one item per chat: name, created and updated dates,
whether it's archived, and each turn's message and reply. Tool results
are left out. It pages at 20 chats.
- The eraser deletes all the person's chats.
- Chat IDs are read straight from the posts table, as the user-deletion
cleanup already does, so archived chats are found even while their
status isn't registered. That reader is now shared, as
`Conversation_Store::chat_ids()`.
- A proposal from an erased chat can't be approved, because an approval
is refused once its chat is gone.

**Wapuu** sprites replace the transcript's spinner.
- **Sprites:** `working` while a turn runs, `celebrating` for 1.8
seconds after one finishes, and `oops` next to an error. They come from
the set @jeffpaul posted on #1287.
- **Accessibility:** each sprite is an `<img alt="">`. The existing
"Responding…" text and error text stay as the status.
- **Reduced motion:** an SVG inside an `<img>` doesn't reliably follow
the page's setting. So with reduced motion on, the component switches
each sprite's animations off in its markup, which gives the same still
pose.
- **Scope:** only busy, done and error states ship. Per-tool sprites
need streaming to know which tool is running.
- **Credit:** the sprites are derived from Kazuko Kaneuchi's original
Wapuu, GPL-2.0-or-later, and credited in `CREDITS.md`.

### Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for:
implementing the changes and tests, and code review.

I've reviewed the changes, understand them and can explain them under
review. They have all been tested locally.

## Testing Instructions

1. Enable AI Workspace and AI Request Logging, and connect a provider.
2. Send a message. A Wapuu shows beside "Responding…", then a
celebrating Wapuu for a moment when the reply arrives.
3. Ask for a new tagline. Edit the proposed value and approve it. Ask
for a draft and discard it.
4. Open Tools → AI Request Logs and filter by type `agent`. The tool
calls, `proposal_created`, `proposal_edited` and `proposal_declined`
rows are there, none of them with the tagline's text.
5. Tools → Export Personal Data for your own email: the download has an
"AI chats" section with your chats. Erase personal data for a test user
who has chats: their chats are gone.
6. With reduced motion turned on in your OS, the Wapuu is still.

**Tests run** (all passing):
- **PHPUnit, full suite:** 3398 tests, single site and multisite, on
WordPress latest.
- **`Agent_AuditTest`:** `test_agent_is_a_log_type`,
`test_an_event_writes_one_row_and_fires_the_hook`,
`test_the_hook_fires_with_logging_off`,
`test_a_proposal_event_names_the_proposal_and_its_items_only` and
`test_a_proposal_without_a_kind_is_recorded_as_drafts`.
- **`Proposal_ControllerTest`:**
`test_each_proposal_event_is_recorded_once_in_order`,
`test_events_fire_the_hook_with_logging_off`,
`test_an_expired_proposal_is_recorded_once`,
`test_an_expired_proposal_read_through_the_store_is_recorded_once`,
`test_an_interrupted_write_is_recorded_failed_once`,
`test_a_writer_that_throws_is_recorded_failed` and
`test_an_approval_for_a_deleted_chat_is_recorded_denied`.
- **`Turn_ControllerTest`:**
`test_a_turn_records_a_withheld_call_and_a_proposal_in_order`, and
`test_every_tool_call_writes_exactly_one_log_row` updated for the
`agent` type.
- **`Post_Field_ProposalTest`:**
`test_a_content_update_records_the_field_not_the_content`.
- **`AI_Request_Log_ControllerTest`:**
`test_get_logs_filters_agent_rows_by_type_and_denied_status`.
- **`Conversation_PrivacyTest`:**
`test_the_exporter_and_eraser_are_registered_without_the_experiment`,
`test_export_returns_every_chat_with_its_prompts_and_replies`,
`test_export_with_the_experiment_off_includes_archived_chats`,
`test_export_pages_at_twenty_chats`,
`test_erase_removes_the_persons_chats_only`,
`test_a_proposal_in_an_erased_chat_cannot_be_approved` and
`test_an_unknown_email_exports_and_erases_nothing`.
- **e2e (Chromium):** all `ai-workspace*` specs, the palette spec and
the request-log spec, 168 passed in one run on a fresh site. That
includes the new "AI Workspace Wapuu" tests in `ai-workspace.spec.js`: a
running turn shows the busy Wapuu beside "Responding…"; with reduced
motion the busy Wapuu is a still frame; a failed turn shows the error
Wapuu with the error; a finished turn shows the done Wapuu briefly. Each
Wapuu test also ran three more times, 12 of 12 passing.
- **Test-first:** the audit tests failed before `Agent_Audit` existed.
The privacy tests were written before `Conversation_Privacy` but first
run after it, so they have no recorded red run.
- **Other checks:** PHPStan finds no errors, phpcs is clean on the
changed plugin PHP, and tsc, lint-js and the build are clean. Style lint
reports errors in `ai-request-logs/index.scss` and
`ai-workspace/index.scss` that are already on the base branch.
- **Live check:** core's exporter and eraser lists include "AI chats" on
a running site, and the screenshots below come from one.
- **Not run yet:** a live check against a real provider, and the PHPUnit
suite on WordPress trunk.

**Code review:** seven reviewers ran on this PR's own diff (correctness,
security, adversarial, testing, maintainability, frontend races and API
contract), plus an independent validator. The verdict was "Ready to
merge" with no actionable findings. The one candidate, that the status
filter rejects `skipped`, was rejected because it's already on the base
branch. Applied afterwards in eef886a: agent rows were labelled "Text"
on the log screen, a docblock still said these rows use the `ability`
type, and the store's expiry path had no test.

**One test from #1316 hardened** (1060833): its short palette search
for "q" matched "AI Request Logs" whenever AI Request Logging was on,
which the request-log spec leaves on when both run in one session. It
now searches for "~".

## Screenshots

**A running turn**

![The working Wapuu beside
"Responding…"](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1317-1-wapuu-busy.png)

**A finished turn**

![The celebrating Wapuu under the
reply](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1317-2-wapuu-done.png)

**A failed turn**

![The oops Wapuu beside the
error](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1317-3-wapuu-error.png)

**Agent events in the AI Request Log**

![proposal_created, proposal_expired and proposal_refused rows labelled
Agent](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1317-4-log-agent-events.png)

**AI chats in a personal-data export**

![The AI chats group in an export, with each chat's name, dates,
archived flag, message and
reply](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/1317-5-export-ai-chats.png)

## Known limits

- After an erase, a pending proposal from an erased chat can still be
read by its owner, though not approved, until it expires (about 90
minutes).
- "Recorded once" for an expired or interrupted proposal holds for
requests that run one after another. Two requests reading the same
proposal at the same instant can each record it.
- A `wpai_agent_event` listener that throws during an approval write
marks the proposal failed, as any WordPress hook would. The hook isn't
wrapped.
- The log screen's status filter doesn't accept `skipped`, which item
rows have used since before this PR.
- Workspace rows written after this are `agent`, not `ability`, so a
view filtered to `ability` no longer shows them.

## Changelog Entry

> Added - AI Workspace records every agent tool call and proposal event
in the AI Request Log under an `agent` type, with a `wpai_agent_event`
hook that fires even when logging is off; saved chats are included in
personal-data export and erase; and a Wapuu shows while a turn runs,
finishes or fails.

**Post-deploy monitoring:** no additional operational monitoring is
required. This is an experiment behind the AI Workspace toggle, off by
default. The exporter and eraser run only when an administrator
processes a personal-data request.

---

[![Compound
Engineering](https://img.shields.io/badge/Built_with-Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- wp-playground-preview:start -->
<a
href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1317-77686452fbd3e34a0cb582c18648d7667c78a603.zip%22%7D%7D%5D%7D"
target="_blank" rel="noopener noreferrer">
<img
src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg"
alt="Open WordPress Playground Preview" width="220" height="57" />
</a>
<!-- wp-playground-preview:end -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
whyisjake added a commit that referenced this pull request Nov 13, 2026
## What?

Related: #1287

The docs pass for the #1287 stack. AI Workspace keeps its name and is
documented as the plugin's one agent. The experiment doc, `readme.txt`,
`README.md`, the changelog and the settings card now describe what #1314
to #1317 added. No code paths change.

This is the fifth and last stacked PR for #1287, on top of #1317, #1316,
#1315 and #1314.

## Why?

#1287 folds two planned experiments into AI Workspace: Site Agent
(#1214) and Command Palette AI Search (#1250). A reader of the docs,
readme or changelog should learn that from them. Before this, the
settings card and readme still described a workspace that only creates
drafts and templates. The changelog had nothing for the write, palette,
audit, privacy or Wapuu changes, `README.md` had no AI Workspace entry
at all, and "Site Agent" was still listed under Coming Soon.

## How?

- **`docs/experiments/ai-workspace.md`**
- The summary and key features cover changes to existing content, site
answers and screen links, the chats panel, the Wapuu, the audit log and
personal-data export.
- A new "One agent" section says what Site Agent and Command Palette AI
Search proposed and where each now lives. It also says that the name,
menu, URL and every identifier, including the experiment ID
`ai-workspace`, are unchanged.
- The entry-points list names every ability the experiment registers,
and `Conversation_Privacy`.
- A stale limitation is removed. It said chats have no history screen,
but the chats panel ships.
- **`readme.txt` and `CHANGELOG.md`**
- Added: changes to existing content, the palette's AI search and Ask
AI, the `agent` log rows, chats in export and erase, and the Wapuu.
- Developer: `wpai_agent_event`, the two new proposal filters, the MCP
visibility change, `raw: true`, and the `ability` to `agent` log type
change.
- `CHANGELOG.md` also gains the two ability lines #1315 added only to
`readme.txt`.
- **`README.md`:** adds the missing AI Workspace entry.
- **Both readme files:** "Site Agent" leaves Coming Soon.
- **Settings card:** the AI Workspace description says it answers site
questions, proposes changes to posts and the site title and tagline, and
adds AI to the command palette.

The name stays "AI Workspace". Nothing on #1287 has settled on another
name.

### Use of AI Tools

AI assistance: Yes. Tool(s): Claude Code (Claude Opus 5.5). Used for:
writing the documentation and changelog entries, checking them against
the code, and code review.

I've reviewed the changes, understand them and can explain them under
review. They have all been tested locally.

## Testing Instructions

1. Open Settings → AI. The AI Workspace card reads as in the screenshot
below.
2. Read `docs/experiments/ai-workspace.md` → "One agent", and the
Unreleased changelog in `readme.txt` and `CHANGELOG.md`.

**Tests run** (all passing):
- **PHPUnit, full suite:** 3398 tests, single site and multisite, on
WordPress latest. Only the settings-card string is code, and no test
asserts it.
- **Other checks:** phpcs and `php -l` are clean on `AI_Workspace.php`.
- **Name check:** a grep for "Site Agent" and "Wordspace" across
`includes/`, `src/` and the built assets finds nothing user-visible.
- **Claims checked against the code:**
  - the abilities `AI_Workspace::register()` registers;
  - `meta.mcp.public` false on the propose and ask-user abilities;
- the `wpai_workspace_write_proposals_enabled` and
`wpai_workspace_proposal_kinds` filters;
  - `raw` on `ai/read-content-bodies`;
  - the chats panel's rename, archive and delete actions;
  - the three in-page anchors the doc links to.
- **Not run:** e2e. No script, style or behavior changes.

**Code review:** `ce-code-review` sized this diff to a single-context
review: 51 changed lines, two of them code. It found nothing and gave
"Ready to merge". Its one residual is applied in 0b06540: the doc's
feature bullet now says rows are written while AI Request Logging is on.

## Screenshots

**The settings card**

![The AI Workspace card on Settings →
AI](https://gist.githubusercontent.com/whyisjake/f358b73180d8e893eec6624fd1e50ded/raw/pr-e-settings-card.png)

## Known limits

- The changelog lines for #1314, #1316 and #1317 are added here rather
than in those PRs, so they land only when this one merges after them.

## Changelog Entry

> Changed - AI Workspace is documented as the plugin's one agent: it now
includes what the Site Agent and Command Palette AI Search proposals
planned, under its existing name.

**Post-deploy monitoring:** no additional operational monitoring is
required. Documentation and one settings-card string.

---

[![Compound
Engineering](https://img.shields.io/badge/Built_with-Compound_Engineering-6366f1)](https://github.com/EveryInc/compound-engineering-plugin)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- wp-playground-preview:start -->
<a
href="https://playground.wordpress.net?blueprint-url=data:application/json,%7B%22preferredVersions%22%3A%7B%22wp%22%3A%22latest%22%7D%2C%22login%22%3Atrue%2C%22landingPage%22%3A%22%2Fwp-admin%2Fadmin.php%3Fpage%3Dai-wp-admin%22%2C%22steps%22%3A%5B%7B%22step%22%3A%22installPlugin%22%2C%22pluginData%22%3A%7B%22resource%22%3A%22url%22%2C%22url%22%3A%22https%3A%2F%2Fgithub.com%2FWordPress%2Fai%2Freleases%2Fdownload%2Fci-artifacts%2Fpr-1318-aa0faf515572fcec68b35f0b8a0634d387875fd1.zip%22%7D%7D%5D%7D"
target="_blank" rel="noopener noreferrer">
<img
src="https://raw.githubusercontent.com/adamziel/playground-preview/refs/heads/trunk/assets/playground-preview-button.svg"
alt="Open WordPress Playground Preview" width="220" height="57" />
</a>
<!-- wp-playground-preview:end -->

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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