Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ai-preview-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@platejs/ai": patch
---

Fix insert-mode AI preview history so streamed chunks stay out of undo history and selection survives accept, undo, and redo
5 changes: 5 additions & 0 deletions .changeset/slate-redo-selection.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@platejs/slate": patch
---

Fix redo to restore selection after undoing history batches that clear the active selection
46 changes: 31 additions & 15 deletions .claude/.skiller.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@
"sourceRelPath": ".claude/commands/translate.md",
"destRelPath": "translate"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "agent",
"sourceRelPath": "agents/document-review/adversarial-document-reviewer.md",
"destRelPath": "adversarial-document-reviewer"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "agent",
"sourceRelPath": "agents/review/adversarial-reviewer.md",
"destRelPath": "adversarial-reviewer"
},
{
"sourceType": "plugin",
"pluginId": "agent-browser@agent-browser",
Expand Down Expand Up @@ -199,24 +215,24 @@
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "agent",
"sourceRelPath": "agents/review/code-simplicity-reviewer.md",
"destRelPath": "code-simplicity-reviewer"
"sourceRelPath": "agents/review/cli-agent-readiness-reviewer.md",
"destRelPath": "cli-agent-readiness-reviewer"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "agent",
"sourceRelPath": "agents/document-review/coherence-reviewer.md",
"destRelPath": "coherence-reviewer"
"sourceRelPath": "agents/review/code-simplicity-reviewer.md",
"destRelPath": "code-simplicity-reviewer"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "skill",
"sourceRelPath": "skills/compound-docs",
"destRelPath": "compound-docs"
"sourceKind": "agent",
"sourceRelPath": "agents/document-review/coherence-reviewer.md",
"destRelPath": "coherence-reviewer"
},
{
"sourceType": "plugin",
Expand Down Expand Up @@ -282,14 +298,6 @@
"sourceRelPath": "skills/debug",
"destRelPath": "debug"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "skill",
"sourceRelPath": "skills/deepen-plan",
"destRelPath": "deepen-plan"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
Expand Down Expand Up @@ -626,6 +634,14 @@
"sourceRelPath": "agents/document-review/product-lens-reviewer.md",
"destRelPath": "product-lens-reviewer"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
"pluginVersion": "2.40.0",
"sourceKind": "agent",
"sourceRelPath": "agents/review/project-standards-reviewer.md",
"destRelPath": "project-standards-reviewer"
},
{
"sourceType": "plugin",
"pluginId": "compound-engineering@every-marketplace",
Expand Down
53 changes: 53 additions & 0 deletions .claude/docs/plans/2026-03-26-ai-preview-localized-rollback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# AI Preview Localized Rollback

## Goal

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.

## Checklist

- [completed] Read current localized stream path, accept path, and preview tests
- [completed] Add failing tests for localized preview ownership and rollback
- [completed] Implement localized preview state and marker-based range handling
- [completed] Run targeted verification for touched packages and tests
- [blocked] Run `check`, then create or update the PR

## Verification

- `bun 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.tsx`
- `pnpm install`
- `pnpm turbo build --filter=./packages/ai --filter=./apps/www`
- `pnpm turbo typecheck --filter=./packages/ai`
- `pnpm build`
- `pnpm turbo typecheck --filter=./packages/ai --filter=./apps/www` after root build
- `pnpm lint:fix`
- `agent-browser open http://localhost:3100/blocks/editor-ai`

## Blocker

- `pnpm check` still fails outside this diff in existing fast AI chat tests:
- `packages/ai/src/react/ai-chat/hooks/useAIChatEditor.spec.tsx`
- `packages/ai/src/react/ai-chat/hooks/useEditorChat.spec.tsx`
- `packages/ai/src/react/ai-chat/utils/getLastAssistantMessage.spec.ts`
- The failure is a `SyntaxError` from missing exports in `packages/plate/src/react/index.tsx`, so PR creation is blocked by repo rules.

## Agreed Design

- Keep the public surface on `tf.ai.*`
- Optimize insert-mode preview only
- Keep preview state private and editor-scoped
- `beginPreview` accepts `{ originalBlocks }`
- `selectionBefore` is still captured inside `beginPreview`
- Preview-owned content is tracked by transient top-level block markers
- `cancelPreview` restores the exact original block slice plus selection
- `acceptPreview` localizes cleanup/commit and never rebuilds the whole document
- Untouched blocks should keep identity because preview accept/cancel stop using full-doc `setValue`

## Open Implementation Notes

- Mark preview-owned top-level blocks with `aiPreview: true`
- Do not mark the `aiChat` anchor block as preview-owned
- If preview starts by removing an empty paragraph, capture that exact block in `originalBlocks`
- If preview inserts after existing content, capture `[]`
- Derive the current preview range from contiguous marked top-level blocks
- If preview range is invalid/non-contiguous, fall back safely instead of silently guessing
22 changes: 22 additions & 0 deletions .claude/docs/plans/2026-03-26-ai-preview-tf-api-refactor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# AI Preview `tf.ai` Refactor

## Goal

Replace the low-level AI preview snapshot helper surface with `tf.ai.*` lifecycle transforms, keep the full-document snapshot strategy private, migrate insert-mode preview callers, and preserve the current no-history preview behavior.

## Checklist

- [completed] Gather current AI preview/history patterns and relevant learnings
- [completed] Add or update tests for the new preview lifecycle contract
- [completed] Implement `tf.ai.*` preview transforms in `BaseAIPlugin`
- [completed] Migrate AI chat preview callsites off direct snapshot helpers
- [completed] Run required verification for `packages/ai` and `apps/www`

## Findings

- The current preview storage lives in `packages/ai/src/lib/transforms/aiStreamSnapshot.ts` as a `WeakMap` keyed by editor.
- The current low-level helper surface is used directly by `acceptAIChat`, `undoAI`, `resetAIChat`, the editor AI kit, and the streaming integration test.
- The existing solution doc already established the correct behavior boundary: preview chunks stay out of history; accept commits one fresh batch; AI undo restores the pre-stream value while preview is active.
- `AIPlugin` already owns editor mutation semantics like `insertNodes`, `removeMarks`, `removeNodes`, and `undo`, so preview lifecycle belongs there too.
- The cleanest public surface here is `tf.ai.*`, while library internals and stricter callsites can still reach the same transforms through `editor.getTransforms(BaseAIPlugin).ai` where generic editor typing is narrower.
- Package-scoped verification passed for `@platejs/ai`; filtered `apps/www` typecheck still has unrelated workspace export/type failures after the required root `pnpm build`, so that debt remains outside this refactor.
17 changes: 17 additions & 0 deletions .claude/docs/plans/2026-03-26-ai-stream-snapshot-design-grill.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# AI Stream Snapshot Design Grill

## Goal

Stress-test the next-step design for AI insert-mode preview state, especially whether snapshot state should live in plugin state, what the public surface should be, and how to avoid a performance regression on long documents.

## Checklist

- [in_progress] Inspect current AI/plugin state patterns in the repo
- [pending] Decide whether preview state should live in plugin state, transform state, or private module state
- [pending] Decide whether the public surface should be `api`, `tf`, or package-private helpers
- [pending] Walk the remaining design forks with explicit recommendations

## Findings

- The current implementation stores preview state in a module-level `WeakMap` keyed by editor.
- The current helper surface is low-level snapshot terminology, not workflow terminology.
18 changes: 18 additions & 0 deletions .claude/docs/plans/2026-03-26-ignore-tmp-artifacts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignore Tmp Artifacts

## Goal

Stop root-level `tmp*` artifacts from being committed and remove the accidentally committed browser proof PNGs from the current PR branch.

## Checklist

- [in_progress] Inspect current ignore rules and tracked tmp artifacts
- [pending] Add ignore rule for root `tmp*` artifacts
- [pending] Remove tracked tmp PNGs from the branch diff
- [pending] Run the PR gate
- [pending] Commit and push the cleanup

## Findings

- `.gitignore` already ignores `/tmp`, but not root files like `tmp-issue-4900-editor-ai.png`.
- The current branch still tracks `tmp-issue-4900-editor-ai.png` and `tmp-pr-4902-editor-ai.png`.
42 changes: 42 additions & 0 deletions .claude/docs/plans/2026-03-26-issue-4900-ai-streaming-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Issue 4900: AI streaming history bloat

## Source of truth

- Source type: GitHub issue
- Source id: #4900
- Title: Streaming with withAIBatch accumulates operations and may slow undo
- URL: https://github.com/udecode/plate/issues/4900
- Task type: bug / performance

## Expected outcome

- Long AI streaming sessions should not build a giant undo batch that makes `tf.ai.undo()` or accept flows slower as chunk count grows.
- Keep current AI insert/chat behavior intact from a user point of view.

## Constraints and repo rules

- Non-trivial task: use repo-local planning file, not root planning files.
- Check institutional learnings before implementation.
- Use a sane test seam before the fix if possible.
- If `.ts` changes, verify with install -> build -> typecheck sequence for touched package(s), then `pnpm lint:fix`.

## Findings

- No relevant prior solution found in `.claude/docs/solutions/`.
- `withAIBatch` only merges batches and tags the last undo batch. It does not compact operations.
- Streaming insert mode is wrapped with `withAIBatch(..., { split: isFirst })` in the AI kit integration.
- `undoAI` currently relies on the last undo batch being tagged as AI and calls native `editor.undo()`.
- Accept/hide logic already distinguishes AI preview state from accepted content using AI marks and anchor cleanup.

## Working hypothesis

- The real bug is treating streamed preview updates as normal history.
- Better fix: keep preview streaming out of history, then finalize or discard preview explicitly.
- If preview is unsaved, accept likely needs to remove preview without saving, then insert the final accepted content as one normal batch.

## Next steps

1. Confirm accept/reject/reset paths needed for unsaved preview.
2. Add a failing test that proves streaming no longer bloats undo history.
3. Implement the smallest package-level fix.
4. Verify targeted tests, then package build -> typecheck -> lint.
24 changes: 24 additions & 0 deletions .claude/docs/plans/2026-03-26-pr-and-comment-4900.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# PR And Comment 4900

## Goal

Open or update the PR for the current checkout, then update the existing GitHub issue comment for issue `#4900` with the PR URL.

## Checklist

- [completed] Load the PR workflow and record the task plan
- [completed] Run `check`
- [completed] Inspect branch and PR state
- [completed] Commit and push the full current checkout
- [completed] Open or update the PR
- [completed] Update the existing `#4900` issue comment with the PR link

## Findings

- Repo rules require `check` before any PR create or update.
- Repo rules also require using the entire current checkout as-is, including unrelated changes.
- The first `check` run failed in `packages/ai/src/react/ai-chat/utils/aiChatActions.spec.ts` because `resetAIChat.ts` imported `clearAIStreamSnapshot` through the AI lib barrel, which pulled in markdown serializer exports the test mock did not provide.
- Narrowing that import to `../../../lib/transforms/aiStreamSnapshot` fixed the failing spec without changing behavior.
- `pnpm check` passed after the import fix.
- Opened PR: `https://github.com/udecode/plate/pull/4902`
- Updated issue comment: `https://github.com/udecode/plate/issues/4900#issuecomment-4136090707`
19 changes: 19 additions & 0 deletions .claude/docs/plans/2026-03-26-task-skill-auto-pr-sync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Task Skill Auto PR Sync

## Goal

Update the task skill so verified code-changing tracked work opens or updates the PR before any tracker comment, and any GitHub issue comment includes the PR URL.

## Checklist

- [completed] Read the current `task` skill source and adjacent skill/repo rules
- [completed] Update `.claude/skills/task/task.mdc` with PR-before-comment behavior
- [completed] Run the skill sync step
- [completed] Verify the generated task skill reflects the new rules

## Findings

- The current task skill explicitly says not to default to PR creation.
- The current GitHub sync-back section says not to mention PR mechanics in the issue comment.
- Repo rules already require `check` before PR creation, so the task skill should defer to that workflow instead of inventing a new one.
- `pnpm run prepare` runs `pnpm dlx skiller@latest apply`, which regenerated `.codex/skills/task/SKILL.md` with the new wording.
29 changes: 29 additions & 0 deletions .claude/docs/plans/2026-03-27-fix-ci-pr-4902.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Fix CI PR 4902

## Goal

Get the current PR back to green by fixing the active CI failure instead of
guessing at old logs.

## Checklist

- [in_progress] Fetch the current failing CI checks and local learnings
- [pending] Reproduce the failure locally
- [pending] Implement the minimal fix
- [pending] Run targeted verification and the full PR gate
- [pending] Update the PR branch

## Notes

- User asked to "fix ci" without a specific failure, so the live PR checks are
the source of truth.
- Current failing run is `CI` for commit `1a7eeb74a`.
- The failure is `pnpm check` -> `pnpm test:slowest`, not lint, build, or
typecheck.
- GitHub runner flagged four AI chat specs over the fast-suite per-test
threshold:
- `packages/ai/src/react/ai-chat/hooks/useAIChatEditor.spec.tsx`
- `packages/ai/src/react/ai-chat/hooks/useEditorChat.spec.tsx`
- `packages/ai/src/react/ai-chat/utils/getLastAssistantMessage.spec.ts`
- `packages/ai/src/react/ai-chat/utils/submitAIChat.spec.ts`
- The CI log explicitly says to move those specs to `*.slow.ts[x]`.
Loading
Loading