Skip to content

refactor: remove AI Lodash dependencies and simplify workspace code - #3119

Open
nperez0111 wants to merge 3 commits into
split/esm-package-sizefrom
split/ai-dependency-cleanup
Open

nperez0111 wants to merge 3 commits into
split/esm-package-sizefrom
split/ai-dependency-cleanup

Conversation

@nperez0111

@nperez0111 nperez0111 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Second PR in the stack: #3118 → this PR → core emoji data → React picker.

These changes were done by the e18e cli

Removes the direct Lodash equality and merge dependencies in the AI package. The request-composition change replaces document snapshots and tool definitions without recursive array merges. Includes targeted AI regression tests, the small source cleanups from #2903, and aligned Vitest workspace dependency metadata. Preserves the keyboard-shortcut fix already present on main.

Verified: core, React, and xl-ai builds; 12 targeted AI tests.

Original work: #2903.

Summary by CodeRabbit

  • Bug Fixes
    • Preserved valid document positions at the start of a document when locating the nearest block.
    • Improved handling of AI message metadata and options: arrays are now replaced as a whole rather than merged item by item.
    • Added safeguards for cases where expected blocks or comments are missing, reducing the chance of unexpected failures.
  • Improvements
    • Updated how AI tool schemas compare shared definitions, while continuing to flag conflicting definitions.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 40da41c8-5ed7-4866-bc7f-3f0706f7af72

📥 Commits

Reviewing files that changed from the base of the PR and between aa1933e and 341700e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (35)
  • packages/core/src/api/blockManipulation/commands/moveBlocks/moveBlocks.ts
  • packages/core/src/api/blockManipulation/commands/updateBlock/updateBlock.test.ts
  • packages/core/src/api/blockManipulation/tables/tables.test.ts
  • packages/core/src/api/getBlockInfoFromPos.ts
  • packages/core/src/api/getBlocksChangedByTransaction.ts
  • packages/core/src/api/nodeConversions/nodeToBlock.ts
  • packages/core/src/api/parsers/markdown/markdownToHtml.ts
  • packages/core/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts
  • packages/core/src/comments/threadstore/TipTapThreadStore.ts
  • packages/core/src/editor/managers/BlockManager.ts
  • packages/core/src/editor/managers/ExtensionManager/index.ts
  • packages/core/src/editor/transformPasted.ts
  • packages/core/src/extensions/SideMenu/SideMenu.ts
  • packages/core/src/extensions/Versioning/Versioning.ts
  • packages/core/src/extensions/tiptap-extensions/Link/helpers/autolink.ts
  • packages/core/src/extensions/tiptap-extensions/Link/helpers/linkDetector.ts
  • packages/core/src/extensions/tiptap-extensions/UniqueID/UniqueID.ts
  • packages/core/src/util/string.ts
  • packages/core/src/y/extensions/YCursorPlugin.ts
  • packages/core/src/yjs/extensions/YCursorPlugin.ts
  • packages/react/src/components/Comments/ThreadsSidebar.tsx
  • packages/react/src/components/Versioning/CurrentSnapshot.tsx
  • packages/react/src/hooks/useStore.ts
  • packages/xl-ai-server/src/routes/mock.ts
  • packages/xl-ai-server/src/routes/serverPersistence.ts
  • packages/xl-ai/package.json
  • packages/xl-ai/src/api/aiRequest/sendMessageWithAIRequest.test.ts
  • packages/xl-ai/src/api/aiRequest/sendMessageWithAIRequest.ts
  • packages/xl-ai/src/api/formats/base-tools/createAddBlocksTool.ts
  • packages/xl-ai/src/components/FormattingToolbar/AIToolbarButton.tsx
  • packages/xl-ai/src/prosemirror/changeset.ts
  • packages/xl-ai/src/streamTool/jsonSchema.test.ts
  • packages/xl-ai/src/streamTool/jsonSchema.ts
  • pnpm-workspace.yaml
  • tests/package.json
💤 Files with no reviewable changes (1)
  • packages/xl-ai/package.json

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

This PR updates array and object handling across editor and AI packages. It adds checks for missing block positions, inline content, comments, and selected blocks. AI request construction now uses shallow spreads, and stream-tool schema comparison uses local recursive equality.

Changes

Editor and shared utilities

Layer / File(s) Summary
Block positions and content conversion
packages/core/src/api/blockManipulation/..., packages/core/src/api/getBlockInfoFromPos.ts, packages/core/src/api/getBlocksChangedByTransaction.ts, packages/core/src/api/nodeConversions/nodeToBlock.ts, packages/core/src/api/parsers/markdown/markdownToHtml.ts, packages/core/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts, packages/core/src/editor/BlockManager.ts, packages/core/src/editor/transformPasted.ts
Core block APIs and conversion code use .at(-1) and related array syntax. Position and link-content paths now check for missing values. Block traversal uses toReversed().
Editor and extension utilities
packages/core/src/editor/managers/ExtensionManager/index.ts, packages/core/src/extensions/..., packages/core/src/util/string.ts, packages/core/src/y/..., packages/core/src/yjs/..., packages/react/src/hooks/useStore.ts
Editor and extension helpers update array construction, sorting, distance calculations, link handling, own-property checks, and color calculations.
Comments and snapshot handling
packages/core/src/comments/threadstore/TipTapThreadStore.ts, packages/core/src/extensions/Versioning/Versioning.ts, packages/react/src/components/Comments/ThreadsSidebar.tsx, packages/react/src/components/Versioning/CurrentSnapshot.tsx
Comment insertion checks for an empty thread. Recent-activity sorting falls back to the thread creation time when there are no comments. Snapshot access and sorting use updated array methods.

AI requests and stream tools

Layer / File(s) Summary
AI request metadata and dependencies
packages/xl-ai/src/api/aiRequest/sendMessageWithAIRequest.ts, packages/xl-ai/src/api/aiRequest/sendMessageWithAIRequest.test.ts, packages/xl-ai/package.json
Request metadata and options are rebuilt with shallow spreads instead of deep merges. Tests cover stale document state, custom options, non-object metadata, and omitted inputs. The lodash merge and equality packages and their type packages are removed.
Stream-tool schema comparison
packages/xl-ai/src/streamTool/jsonSchema.ts, packages/xl-ai/src/streamTool/jsonSchema.test.ts, pnpm-workspace.yaml, tests/package.json
Schema definitions use local recursive equality to compare duplicate $defs. Tests cover equivalent and conflicting definitions. The @vitest/ui version is updated in the workspace and test package.
AI tool and message access
packages/xl-ai/src/api/formats/base-tools/createAddBlocksTool.ts, packages/xl-ai/src/components/FormattingToolbar/AIToolbarButton.tsx, packages/xl-ai/src/prosemirror/changeset.ts, packages/xl-ai-server/src/routes/*
AI tools, toolbar actions, change sets, and server routes update last-element access. The toolbar and tool paths now check for missing selected or added blocks.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: matthewlipski, yousefed

Merge Risk: ⚪ Minimal · up to 34170

No identified issue blocks merging after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 32 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main changes: removing AI Lodash dependencies and simplifying workspace code.
Description check ✅ Passed The description covers the PR context, rationale, major changes, compatibility impact, and reported testing. It omits the template headings, checklist, and screenshots section, but the key information…
Full details: Docstring Coverage

Explanation

Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 32 functions across 32 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each block in line,
Then gathers schemas, neat and fine.
The last item rests within .at(-1),
Fresh tests hop in when work is done.
The burrow hums with cleaner code.

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Sep 24, 2026 4:17pm UTC
blocknote-website Ready Ready Preview Sep 24, 2026 4:17pm UTC

Request Review

@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3119

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3119

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3119

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3119

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3119

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3119

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3119

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3119

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3119

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3119

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3119

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3119

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3119

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3119

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3119

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3119

commit: bb54d74

@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-3119/

Built to branch gh-pages at 2026-09-24 16:32 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@nperez0111
nperez0111 added this pull request to stack #3123 September 24, 2026 14:03

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — bb54d744 Deployed Sep 24, 2026 by vercel[bot]
Preview – blocknote — bb54d744 Deployed Sep 24, 2026 by vercel[bot]
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.

1 participant