Skip to content

fix: bn- table crash with static toolbar - #25076

Merged
ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
GuiLeme:fix-bn-table-crash
May 14, 2026
Merged

ramonlsouza merged 1 commit into
bigbluebutton:v3.0.x-developfrom
GuiLeme:fix-bn-table-crash

Conversation

@GuiLeme

@GuiLeme GuiLeme commented May 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

The issue that generated this problem in BBB is described in BlockNote, see issue here.

This PR is just a temporary, but robust fix. (we'd still need to wait for the correct approach from BN).

Motivation

The error crashes the entire client.

How to test

See steps in the issue from BN

More

See video of the reproduction of the bug down here:

Bug:

bn-table-crash-bbb.mp4

Fixed:

bn-table-crash-fix-bbb.mp4

@GuiLeme
GuiLeme requested a review from ramonlsouza May 14, 2026 15:22
@coderabbitai

coderabbitai Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 113079c8-6385-4afb-8493-1df83dda825b

📥 Commits

Reviewing files that changed from the base of the PR and between 1d11436 and 3bc6b7f.

📒 Files selected for processing (1)
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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

@sonarqubecloud

Copy link
Copy Markdown

@antobinary antobinary added this to the Release 3.0 milestone May 14, 2026
@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx`:
- Around line 79-88: The appendTransaction hook sets a safe selection using
TextSelection.near but doesn't guard against re-entry; after you call
newState.tr.setSelection(safeSelection) the plugin is invoked again and will
create an identical transaction. Update appendTransaction (the appendTransaction
function in this file) to compare the proposed safeSelection to the current
selection (newState.selection) and return null if they are equal (e.g., compare
positions or use TextSelection.eq semantics) before returning the new
transaction, so you only dispatch when the selection actually changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 113079c8-6385-4afb-8493-1df83dda825b

📥 Commits

Reviewing files that changed from the base of the PR and between 1d11436 and 3bc6b7f.

📒 Files selected for processing (1)
  • bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx

Comment on lines +79 to +88
appendTransaction(_transactions, _oldState, newState) {
const { selection } = newState;
if (selection.$from.pos > 2 || selection.$to.pos > 2) return null;
const firstBlockContent = newState.doc.firstChild?.firstChild?.firstChild;
if (!firstBlockContent || firstBlockContent.type.name !== 'table') return null;
if (newState.doc.content.size < 1) return null;
const safeSelection = TextSelection.near(newState.doc.resolve(1), 1);
if (safeSelection.from === 0) return null;
return newState.tr.setSelection(safeSelection);
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

❓ Verification inconclusive

ProseMirror Plugin appendTransaction recursive re-entry behavior documentation


ProseMirror's PluginSpec.appendTransaction method allows plugins to append additional transactions after an initial set of transactions are applied to the editor state. The official documentation describes its re-entry (recursive) behavior as follows: "Allows the plugin to append another transaction to be applied after the given array of transactions. When another plugin appends a transaction after this was called, it is called again with the new state and new transactions—but only the new transactions, i.e. it won't be passed transactions that it already saw."[1][2][3] This design enables iterative refinement where multiple plugins can chain appends, but prevents infinite recursion for a single plugin by only passing newly appended transactions in subsequent calls. Appended transactions are marked with an 'appendedTransaction' meta key referencing the root transaction (fixed in 2018 to avoid circular references).[4][5][6] No explicit depth limit or stack overflow guard is documented in the core implementation, but the mechanism relies on plugins conditionally returning transactions (e.g., only when specific conditions like schema violations are met) to terminate the chain.[7] Infinite loops can occur in edge cases like collaborative editing races or history interactions, requiring workarounds such as splitting transactions or using filterTransaction.[8][7] Primary sources: Official ProseMirror reference manual[1][3], prosemirror-state plugin.ts source code[2], and related GitHub issues/PRs on history and meta handling[4][8][5][6]. The repository has moved to https://code.haverbeke.berlin/prosemirror/prosemirror-state, but documentation remains at prosemirror.net.[9]

Citations:


Guard against re-entry: compare the proposed selection to the current one.

ProseMirror's appendTransaction is re-invoked after the plugin appends a transaction. Per the official ProseMirror documentation: "When another plugin appends a transaction after this was called, it is called again with the new state and new transactions." This means after your plugin calls setSelection, the hook will be invoked again with the updated state. If TextSelection.near(doc.resolve(1), 1) still resolves to a position matching the current selection (which it will, after the first invocation), the plugin will dispatch an identical setSelection transaction again, creating redundant emissions. The current guard safeSelection.from === 0 only covers the degenerate case and does not prevent re-entry.

Add an equality check to stop re-entry:

Proposed fix
         appendTransaction(_transactions, _oldState, newState) {
           const { selection } = newState;
           if (selection.$from.pos > 2 || selection.$to.pos > 2) return null;
           const firstBlockContent = newState.doc.firstChild?.firstChild?.firstChild;
           if (!firstBlockContent || firstBlockContent.type.name !== 'table') return null;
           if (newState.doc.content.size < 1) return null;
           const safeSelection = TextSelection.near(newState.doc.resolve(1), 1);
           if (safeSelection.from === 0) return null;
+          if (safeSelection.eq(selection)) return null;
           return newState.tr.setSelection(safeSelection);
         },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
appendTransaction(_transactions, _oldState, newState) {
const { selection } = newState;
if (selection.$from.pos > 2 || selection.$to.pos > 2) return null;
const firstBlockContent = newState.doc.firstChild?.firstChild?.firstChild;
if (!firstBlockContent || firstBlockContent.type.name !== 'table') return null;
if (newState.doc.content.size < 1) return null;
const safeSelection = TextSelection.near(newState.doc.resolve(1), 1);
if (safeSelection.from === 0) return null;
return newState.tr.setSelection(safeSelection);
},
appendTransaction(_transactions, _oldState, newState) {
const { selection } = newState;
if (selection.$from.pos > 2 || selection.$to.pos > 2) return null;
const firstBlockContent = newState.doc.firstChild?.firstChild?.firstChild;
if (!firstBlockContent || firstBlockContent.type.name !== 'table') return null;
if (newState.doc.content.size < 1) return null;
const safeSelection = TextSelection.near(newState.doc.resolve(1), 1);
if (safeSelection.from === 0) return null;
if (safeSelection.eq(selection)) return null;
return newState.tr.setSelection(safeSelection);
},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bigbluebutton-html5/imports/ui/components/bn-shared-notes/component.tsx`
around lines 79 - 88, The appendTransaction hook sets a safe selection using
TextSelection.near but doesn't guard against re-entry; after you call
newState.tr.setSelection(safeSelection) the plugin is invoked again and will
create an identical transaction. Update appendTransaction (the appendTransaction
function in this file) to compare the proposed safeSelection to the current
selection (newState.selection) and return null if they are equal (e.g., compare
positions or use TextSelection.eq semantics) before returning the new
transaction, so you only dispatch when the selection actually changes.

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@ramonlsouza
ramonlsouza merged commit 039f96a into bigbluebutton:v3.0.x-develop May 14, 2026
36 checks passed
antobinary added a commit that referenced this pull request May 14, 2026
antobinary added a commit that referenced this pull request May 29, 2026
@antobinary antobinary mentioned this pull request May 29, 2026
16 of 17 tasks
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.

3 participants