Skip to content

xl-ai: Array.from called on filtered iterator — tool calls never marked complete #2933

Description

@gitfromwildan

What's broken?

In packages/xl-ai/src/streamTool/vercelAiSdk/util/chatHandlers.ts line 147:

const toolCalls = Array.from(
    toolCallStreams.values().filter((data) => data.complete),
);

Map.prototype.values() returns a MapIterator, not an array. Iterators do not have a .filter() method. This throws TypeError: toolCallStreams.values(...).filter is not a function at runtime, causing all tool calls to never be detected as complete — AI tool call suggestions never appear in the UI.

In the bundled output (dist/server-CafGbRLa.js line 479) this becomes:

let p = !1, m = Array.from(s.values().filter((e) => e.complete)); // ❌

What did you expect to happen?

Tool calls that have finished streaming should be detected and shown as suggestions via the AIMenuController.

Steps to reproduce

  1. Use a BlockNote editor with @blocknote/xl-ai AI extension
  2. Send messages that trigger tool calls from the model
  3. Observe that tool call suggestions never appear in the UI

BlockNote version

v0.52.1 (latest)

Fix

 const toolCalls = Array.from(
-    toolCallStreams.values().filter((data) => data.complete),
-);
+    toolCallStreams.values(),
+).filter((data) => data.complete);

Environment

All runtimes — this is a pure JavaScript bug, not environment-specific.

Contribution

  • I'd be interested in contributing a fix for this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions