Jetpack AI: show block edit outcomes with Undo - #113317
Conversation
|
WordPress.com
Automattic for Agencies
|
|
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/34662396 Some locales (Hebrew, Japanese) have been temporarily machine-translated due to translator availability. All other translations are usually ready within a few days. Untranslated and machine-translated strings will be sent for translation next Monday and are expected to be completed by the following Friday. Thank you @kat3samsin for including a screenshot in the description! This is really helpful for our translators. |
There was a problem hiding this comment.
Pull request overview
Updates Jetpack AI block-edit messaging and Agents Manager checkpoint handling so the UI shows only authoritative post-execution outcomes, with an “Updated” status + Undo for applied edits and a clear “No changes needed” for true no-ops. It also fixes multi-provider checkpoint composition so Undo resolves through the provider that owns the checkpoint.
Changes:
- Jetpack sidebar
update-block-contentnow emits structuredupdated/no-changesoutcomes and stores restorable block snapshots keyed by tool call id. - Agents Manager tool-message rendering now prefers authoritative tool outcomes (and suppresses request-shaped/duplicate/prose messages accordingly).
- Agents Manager now composes
useCheckpointhooks across providers and introduces a dedicated “Updated + Undo” action UI.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/jetpack-ai-sidebar/src/utils/block-actions.ts | Treats true no-op block edits as successful without mutating the block. |
| packages/jetpack-ai-sidebar/src/index.ts | Wraps update-block-content to produce structured outcomes and registers block snapshots for Undo via checkpoints. |
| packages/jetpack-ai-sidebar/src/index.test.ts | Adds tool-provider tests for updated/no-changes outcomes and checkpoint behavior. |
| packages/agents-manager/src/utils/tool-message-utils.ts | Adds block-edit tool id helpers and extracts structured updated / no-changes outcomes (with legacy fallback). |
| packages/agents-manager/src/utils/load-external-providers.ts | Composes useCheckpoint across multiple providers so id-based lookups search all stores. |
| packages/agents-manager/src/utils/convert-tool-messages-to-components.ts | Renders only authoritative block-edit outcomes, adds “✓ No changes needed”, and suppresses trailing prose/duplicates. |
| packages/agents-manager/src/utils/tests/load-external-providers.test.ts | Tests composed checkpoint hook behavior across multiple providers. |
| packages/agents-manager/src/hooks/use-checkpoint-action.ts | Adds resolved “Updated + Undo” action UI and derives checkpoint ids from structured outcomes/tool call ids. |
| packages/agents-manager/src/hooks/tests/use-checkpoint-action.test.ts | New tests validating resolved Undo action behavior and outcome-based visibility. |
| packages/agents-manager/src/components/resolved-edit-action.tsx | New component rendering “Updated” status + Undo button with disable/retry behavior. |
| packages/agents-manager/src/components/orchestrator-chat/index.tsx | Precomputes/dedupes checkpoint actions for streaming/synthetic messages and removes stale checkpoint actions. |
| packages/agents-manager/src/components/agent-dock/chat-ui.scss | Styles the new resolved edit action UI. |
| packages/agents-manager/src/components/tests/orchestrator-chat.test.tsx | Adjusts mocks and adds coverage for deduped checkpoint actions on synthetic streaming messages. |
Suppressed comments (1)
packages/jetpack-ai-sidebar/src/index.test.ts:2999
- This test enables fake timers (
jest.useFakeTimers()) but doesn’t restore real timers afterward, which can leak fake-timer state into subsequent tests in this file.
expect( checkpoint.hasCheckpoint( 'call-no-block-change' ) ).toBe( false );
} );
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated no new comments.
Suppressed comments (2)
packages/jetpack-ai-sidebar/src/index.ts:688
- For a true no-op (
outcome === 'no-changes'), this still prefersinput.summaryas themessage. That summary describes the requested edit, not the authoritative outcome, and can cause the tool result payload to say e.g. “Proofread…” even when no changes were applied. It should ignoresummaryfor no-op outcomes and emit a consistent no-change message.
let message = typeof input?.summary === 'string' ? input.summary.trim() : '';
if ( ! message ) {
message =
outcome === 'updated'
? __( 'Updated the selected block.', __i18n_text_domain__ )
packages/agents-manager/src/utils/convert-tool-messages-to-components.ts:186
followsTerminalApplyBlockEditsOutcomereturnsfalseon the first JSON parse failure while scanning backward. If an agent emits multiple consecutive prose messages after a terminal block-edit outcome, only the first one will be suppressed; later ones will slip through because the previous prose isn’t JSON and the scan stops early. On parse errors, this shouldcontinuescanning until it finds a relevant tool message or a user boundary.
earlierData.data?.followUpTasks !== true
);
} catch ( _error ) {
return false;
}
Part of FORNO-451
Proposed Changes
No changes neededfor a true no-op.Updatedstatus with adjacentUndo, while keeping feedback and Copy actions on the following row.update-block-contentclient ability a restorable block snapshot and structuredupdated/no-changesresult.update-block-contentsummary to name concrete spelling or grammar corrections, follow the request language, and report when no changes were needed.Why are these changes being made?
wpcom/update-block-contentand render its summary directly. The old schema only asked for a brief description, so a realstuffstostuffcorrection could still showCorrected spelling and grammar in the selected paragraph.Testing Instructions
yarn test-packages packages/agents-manager/src/components/__tests__/orchestrator-chat.test.tsx packages/agents-manager/src/hooks/__tests__/use-checkpoint-action.test.ts packages/agents-manager/src/utils/__tests__/convert-tool-messages-to-components.test.ts packages/agents-manager/src/utils/__tests__/load-external-providers.test.ts packages/jetpack-ai-sidebar/src/index.test.ts --runInBand --no-watchmanyarn workspace @automattic/jetpack-ai-sidebar typecheck.git diff --checkfor the changed files.yarn workspace @automattic/agents-manager-app build.concrete completed editand no longer containsA brief user-friendly description of what was changed.no-changes. ConfirmNo changes neededappears with no Undo.Pre-merge Checklist
Related