# editor-ai-sidebar: one editor sidebar with an approve step

[editor-ai-sidebar](https://github.com/IndianOpinion/editor-ai-sidebar) is a WordPress plugin for sites that add several language-model helpers to the block editor. It provides one sidebar, a fixed set of result types and an explicit approve step, and it makes no model calls of its own. It is MIT licensed, and v0.1.0 was released on 18 November 2026.

It was written from scratch from an idea, as part of a set of utilities built between 11 and 19 November 2026 by language-model coding agents under the editor's direction. It has not run on a live site, and the README records no measured result.

## The problem

A site with five AI helpers in the editor ends up with five panels, five spinners and five ideas of what "accept" means. Some write to the post the moment the model answers. An editor who has learned that one panel waits for a click assumes the next one does too, and an unchecked line goes live.

There is a quieter failure. A helper that writes to the database while the editor is open can be undone by the editor itself. The block editor keeps its own copy of the title, excerpt, registered meta and block attributes, and the next save sends that copy back. The helper's write vanishes, or half of it does.

## What it does

- Adds one sidebar to the block editor with one button per registered action.

- Defines one REST contract (version 1) that provider plugins answer, and enforces it.

- Shows results through fixed item types: text, list and fields, in a single or choices layout. Providers cannot ship their own JavaScript.

- Applies an approved result either in the editor, through its data stores, so the post is unsaved and undo works, or on the server for targets the editor does not hold.

- Supports queued runs for slow actions, which the sidebar polls and picks up again after a reload.

- Gives WP-CLI listing of actions and the event log. There is no command to run or apply an action, because an apply needs a human click.

## How it works

A provider is a plugin that adds a definition to the editor_ai_sidebar_actions filter. Registry validates each definition once per request, keeps the good ones and records the rest with a reason such as invalid_id or core_field_server_write. This is the smallest provider from the README.

add_filter('editor_ai_sidebar_actions', function (array $actions): array {
$actions['my-plugin/shout'] = [
'id' => 'my-plugin/shout',
'label' => __('Shout the title', 'my-plugin'),
'group' => 'headlines',
'needs' => ['title'],
'result' => ['layout' => 'single', 'item_type' => 'text'],
'apply' => ['mode' => 'editor', 'operation' => 'set_title'],
'run' => function (array $request): array {
return [
'layout' => 'single',
'items' => [['id' => 'a', 'type' => 'text', 'value' => strtoupper($request['context']['title'])]],
];
},
];
return $actions;
});

Opening the sidebar makes one request for the action list. A click sends only the declared context, read from the unsaved editor state. While the provider's run executes, WriteWatch watches the post and the action's targets, and a provider that writes early has its result thrown away. A valid result gets a 128-bit random id and a record holding the user, post, action, a SHA-256 hash of each item, a hash of the context and an expiry, 30 minutes by default. Records, jobs and locks share one small custom table.

Approve sends the id, approved: true, the value and the context hash. The server refuses unless the record is unexpired, unused, issued to this user for this post and action, matches the value, and the context has not changed. If the post changed, the editor must confirm "Apply anyway". The title, excerpt, content, status, date, slug and author can never be server targets, for the reason above.

## Guard rails

- The server checks the sidebar switch, user, edit_post, action, capability, selection, context size, rate limit, daily cap and availability, in that order, before any provider code runs.

- Only the user who ran an action can approve its result, within the result lifetime.

- A per-user rate limit of 30 runs per 600 seconds, and a per-action daily cap of 200 runs across the site. Both are filterable.

- A switch in Settings, Writing, a per-action switch, and the constant EDITOR_AI_SIDEBAR_DISABLED.

- Provider text renders as text nodes, and links are same-host http or https only. insert_blocks escapes its values.

- A provider exception or fatal shows a generic message. The class and message go to the event log, which holds ids and codes, never post text or model output.

- Every route answers with Cache-Control: no-store and a contract version header.

## What review changed

- The daily cap was a transient read then write, so concurrent runs could pass it. It is now a counter row taken with one conditional UPDATE ... WHERE hits < cap, tested with two store instances interleaved on MySQL.

- The open-job check ran before the run lock, and the lock was dropped before a queued job's record was stored, so a second run could slip in. The check now runs under the lock.

- A claim could match a used result, so with reapply enabled the same item could be applied twice. A claim now matches only unused, unexpired result rows, and apply re-reads the record after claiming.

- Setting a block attribute wrote the raw value. On a markup-sourced attribute, such as an image caption, provider text became markup. It is now escaped there.

- Provider exception messages in the event log could carry URL credentials or key values. Query strings, credentials and key, token, secret or password values are now dropped.

## Limits and what is next

- Block editor only. Nothing for the classic editor, the site editor or the widget editor.

- Providers cannot add their own result types.

- The scripts ship unminified, about 54 KB with the stylesheet, because there is no build step.

- The rate limit lives in a transient and is a safety net, not an exact counter under heavy concurrency.

- Cancelling a synchronous run stops the result being issued, but the provider's call still finishes on the server.

- A provider plugin is still PHP running on your site. Install only providers you trust.

There are no open issues. This is v0.1.0. The suite has 99 PHP tests and 998 assertions, including MySQL integration tests on a throwaway MySQL 8, plus 56 passing script tests under Node. Static analysis and code style checks pass. The PHP unit tests use stubs and mocks. Two example providers ship, with canned results only. No real provider has been connected, and the CI workflow has not run on GitHub yet.

## Install

Requires WordPress 6.4 or later, PHP 8.1 or later and the block editor. There are no runtime dependencies.

composer require indianopinion/editor-ai-sidebar

The package is not on Packagist yet, so add a Composer vcs repository entry for https://github.com/IndianOpinion/editor-ai-sidebar first.

Or unpack the release zip into wp-content/plugins/editor-ai-sidebar/ and activate it.

[All 47 utilities](https://indianopinion.org/blog/open-source/) · [editor-ai-sidebar on GitHub](https://github.com/IndianOpinion/editor-ai-sidebar)

Canonical: https://indianopinion.org/blog/open-source/editor-ai-sidebar/

AI disclosure: Every summary and comment here is written by AI and published automatically, without a person reviewing each article. We do no original reporting. How this works: https://indianopinion.org/ai-use-policy/
