docs/plans/2026-03-26-ai-preview-localized-rollback.md
Replace full-document AI preview snapshotting with localized insert-mode rollback so preview accept/cancel only touch the preview block range, while preserving current undo/redo and selection behavior.
check, then create or update the PRbun test packages/ai/src/lib/transforms/aiStreamSnapshot.spec.ts packages/ai/src/lib/transforms/undoAI.spec.ts apps/www/src/__tests__/package-integration/ai-chat-streaming/streamHistory.slow.tsxpnpm installpnpm turbo build --filter=./packages/ai --filter=./apps/wwwpnpm turbo typecheck --filter=./packages/aipnpm buildpnpm turbo typecheck --filter=./packages/ai --filter=./apps/www after root buildpnpm lint:fixagent-browser open http://localhost:3100/blocks/editor-aipnpm check still fails outside this diff in existing fast AI chat tests:
packages/ai/src/react/ai-chat/hooks/useAIChatEditor.spec.tsxpackages/ai/src/react/ai-chat/hooks/useEditorChat.spec.tsxpackages/ai/src/react/ai-chat/utils/getLastAssistantMessage.spec.tsSyntaxError from missing exports in packages/plate/src/react/index.tsx, so PR creation is blocked by repo rules.tf.ai.*beginPreview accepts { originalBlocks }selectionBefore is still captured inside beginPreviewcancelPreview restores the exact original block slice plus selectionacceptPreview localizes cleanup/commit and never rebuilds the whole documentsetValueaiPreview: trueaiChat anchor block as preview-ownedoriginalBlocks[]