Skip to content

🐛 fix(editor): prevent crash when toggling enableInputMarkdown setting#11755

Merged
Innei merged 1 commit intonextfrom
fix/editor-rich-render-toggle-crash
Jan 23, 2026
Merged

🐛 fix(editor): prevent crash when toggling enableInputMarkdown setting#11755
Innei merged 1 commit intonextfrom
fix/editor-rich-render-toggle-crash

Conversation

@Innei
Copy link
Copy Markdown
Member

@Innei Innei commented Jan 23, 2026

💻 Change Type

  • 🐛 fix

🔗 Related Issue

Fixes LOBE-2663

🔀 Description of Change

Fix "Node TableNode has not been registered" error that occurred when switching the enableInputMarkdown setting from disabled to enabled.

Root Cause:
Lexical editor nodes must be registered at editor creation time. When enableRichRender was toggled from false to true, plugins (like ReactTablePlugin) tried to register nodes (like TableNode) on an already-created editor instance, causing the crash.

Solution:
Use key-based re-mounting with content preservation via ref:

  • Outer component holds contentRef to persist content across re-mounts
  • Inner component re-mounts when enableRichRender changes (via React key)
  • Content is restored from ref on editor initialization

Files Changed:

  • ChatInputProvider.tsx - Split into outer/inner components with ref-based content preservation
  • InputEditor/index.tsx - Save content to ref on change, restore on init
  • store/initialState.ts - Add contentRef type
  • CronJobContentEditor.tsx - Same pattern for cron job editor

🧪 How to Test

  1. Go to Settings > Labs
  2. Find "Enable Input Markdown" toggle
  3. Toggle it off, type some text in chat input
  4. Toggle it back on
  5. Verify: No crash, and text content is preserved
  • Tested locally
  • Added/updated tests
  • No tests needed

📝 Additional Information

This fix ensures seamless switching between plain text and rich markdown editing modes without data loss or crashes.

Fix "Node TableNode has not been registered" error that occurred when
switching enableInputMarkdown from disabled to enabled.

Root cause: Lexical editor nodes must be registered at creation time.
When enableRichRender toggled, plugins tried to register nodes on an
existing editor instance, causing a crash.

Solution: Use key-based re-mounting with content preservation via ref.
- Outer component holds contentRef to persist content across re-mounts
- Inner component re-mounts when enableRichRender changes (via key)
- Content restored from ref on editor initialization
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 23, 2026

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

Project Deployment Review Updated (UTC)
lobehub Building Building Preview, Comment Jan 23, 2026 3:41pm

Request Review

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jan 23, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @Innei, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@gru-agent
Copy link
Copy Markdown
Contributor

gru-agent bot commented Jan 23, 2026

TestGru Assignment

Summary

Link CommitId Status Reason
Detail e395684 🚫 Skipped No files need to be tested {"src/app/[variants]/(main)/agent/cron/[cronId]/features/CronJobContentEditor.tsx":"File path does not match include patterns.","src/features/ChatInput/ChatInputProvider.tsx":"File path does not match include patterns.","src/features/ChatInput/InputEditor/index.tsx":"File path does not match include patterns.","src/features/ChatInput/store/initialState.ts":"File path does not match include patterns."}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

@dosubot dosubot bot added the 🐛 Bug label Jan 23, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3956848fa

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +79 to +82
if (contentRef?.current) {
editor.setDocument(enableRichRender ? 'markdown' : 'text', contentRef.current);
} else if (initialValue) {
editor.setDocument(enableRichRender ? 'markdown' : 'text', initialValue);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve cleared cron content on rich-render toggle

When contentRef.current is an empty string (e.g., the user deletes all content), the truthy check falls through to initialValue and rehydrates the editor with the previously saved cron content on remount. This means toggling enableRichRender can resurrect deleted content and lead to saving stale data. Consider explicitly checking for contentRef.current !== undefined (or tracking a separate “hasValue” flag) so empty strings are treated as valid content.

Useful? React with 👍 / 👎.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.16%. Comparing base (ad34072) to head (e395684).
⚠️ Report is 18 commits behind head on next.

Additional details and impacted files
@@             Coverage Diff             @@
##             next   #11755       +/-   ##
===========================================
- Coverage   86.89%   74.16%   -12.73%     
===========================================
  Files         410     1193      +783     
  Lines       33584    94972    +61388     
  Branches     5856    10925     +5069     
===========================================
+ Hits        29183    70437    +41254     
- Misses       4311    24445    +20134     
  Partials       90       90               
Flag Coverage Δ
app 67.21% <ø> (?)
database 91.48% <ø> (ø)
packages/agent-runtime 90.20% <ø> (ø)
packages/context-engine 85.36% <ø> (ø)
packages/conversation-flow 92.28% <ø> (ø)
packages/file-loaders 87.04% <ø> (ø)
packages/memory-user-memory 69.30% <ø> (ø)
packages/model-bank 100.00% <ø> (ø)
packages/model-runtime 86.72% <ø> (ø)
packages/prompts 79.33% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 93.22% <ø> (ø)
packages/web-crawler 95.62% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 67.96% <ø> (∅)
Services 50.58% <ø> (∅)
Server 67.71% <ø> (∅)
Libs 40.36% <ø> (∅)
Utils 93.60% <ø> (+0.13%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Innei Innei merged commit ea5eed8 into next Jan 23, 2026
50 of 51 checks passed
@Innei Innei deleted the fix/editor-rich-render-toggle-crash branch January 23, 2026 16:11
@lobehubbot
Copy link
Copy Markdown
Member

❤️ Great PR @Innei ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world.

lobehubbot pushed a commit that referenced this pull request Jan 23, 2026
## [Version&nbsp;2.0.0-next.356](v2.0.0-next.355...v2.0.0-next.356)
<sup>Released on **2026-01-23**</sup>

#### ✨ Features

- **misc**: Remove NextAuth.

#### 🐛 Bug Fixes

- **editor**: Prevent crash when toggling enableInputMarkdown setting.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: Remove NextAuth, closes [#11732](#11732) ([1eff864](1eff864))

#### What's fixed

* **editor**: Prevent crash when toggling enableInputMarkdown setting, closes [#11755](#11755) ([ea5eed8](ea5eed8))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobehubbot
Copy link
Copy Markdown
Member

🎉 This PR is included in version 2.0.0-next.356 🎉

The release is available on:

Your semantic-release bot 📦🚀

@Zhouguanyang
Copy link
Copy Markdown
Contributor

Zhouguanyang commented Jan 23, 2026

Hello, the fix seems ineffective. Typing is still stuttering and intermittent. Whether the input box markdown rendering is enabled or not, it's the same.


This comment was translated by Claude.

Original Content 你好,修复似乎无效,打字依旧断断续续,开与不开输入框markdown渲染都一样

JamieStivala pushed a commit to jaworldwideorg/OneJA-Bot that referenced this pull request Jan 23, 2026
## [Version&nbsp;1.154.0](v1.153.1...v1.154.0)
<sup>Released on **2026-01-23**</sup>

#### ♻ Code Refactoring

- **misc**: Migrate AI Rules to Claude Code Skills.

#### ✨ Features

- **database**: Extended async task with metadata and parent id, added index.
- **misc**: Remove NextAuth.

#### 🐛 Bug Fixes

- **copilot**: History popover not refreshing when agentId changes.
- **editor**: Prevent crash when toggling enableInputMarkdown setting.
- **home**: Use correct CreateGroupModal for session group creation.
- **model-runtime**: Handle null content in anthropic message builder.
- **ModelSelect**: Resolve tooltip hover causing popup to close.
- **pdf**: Ensure worker config before Document render.
- **store**: Delete message before regeneration.
- **misc**: Fix auto scroll, fix favorite refresh bug and group topic refresh issue, fixed the agent group builder tools excaution edge case crash, page content switch mismatch, when use market group, the group sys role was not used.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### Code refactoring

* **misc**: Migrate AI Rules to Claude Code Skills, closes [lobehub#11737](https://github.com/jaworldwideorg/OneJA-Bot/issues/11737) ([346fc46](346fc46))

#### What's improved

* **database**: Extended async task with metadata and parent id, added index, closes [lobehub#11712](https://github.com/jaworldwideorg/OneJA-Bot/issues/11712) ([31d2f26](31d2f26))
* **misc**: Remove NextAuth, closes [lobehub#11732](https://github.com/jaworldwideorg/OneJA-Bot/issues/11732) ([1eff864](1eff864))

#### What's fixed

* **copilot**: History popover not refreshing when agentId changes, closes [lobehub#11731](https://github.com/jaworldwideorg/OneJA-Bot/issues/11731) ([64f39e7](64f39e7))
* **editor**: Prevent crash when toggling enableInputMarkdown setting, closes [lobehub#11755](https://github.com/jaworldwideorg/OneJA-Bot/issues/11755) ([ea5eed8](ea5eed8))
* **home**: Use correct CreateGroupModal for session group creation, closes [lobehub#11752](https://github.com/jaworldwideorg/OneJA-Bot/issues/11752) ([36bcc50](36bcc50))
* **model-runtime**: Handle null content in anthropic message builder, closes [lobehub#11756](https://github.com/jaworldwideorg/OneJA-Bot/issues/11756) ([539753a](539753a))
* **ModelSelect**: Resolve tooltip hover causing popup to close, closes [lobehub#11742](https://github.com/jaworldwideorg/OneJA-Bot/issues/11742) ([1b73f14](1b73f14))
* **pdf**: Ensure worker config before Document render, closes [lobehub#11746](https://github.com/jaworldwideorg/OneJA-Bot/issues/11746) ([ad34072](ad34072))
* **store**: Delete message before regeneration, closes [lobehub#11760](https://github.com/jaworldwideorg/OneJA-Bot/issues/11760) ([a8a6300](a8a6300))
* **misc**: Fix auto scroll, closes [lobehub#11734](https://github.com/jaworldwideorg/OneJA-Bot/issues/11734) ([892fa9f](892fa9f))
* **misc**: Fix favorite refresh bug and group topic refresh issue, closes [lobehub#11745](https://github.com/jaworldwideorg/OneJA-Bot/issues/11745) ([5d115ef](5d115ef))
* **misc**: Fixed the agent group builder tools excaution edge case crash, closes [lobehub#11735](https://github.com/jaworldwideorg/OneJA-Bot/issues/11735) ([5de4742](5de4742))
* **misc**: Page content switch mismatch, closes [lobehub#11758](https://github.com/jaworldwideorg/OneJA-Bot/issues/11758) ([fdc8f95](fdc8f95))
* **misc**: When use market group, the group sys role was not used, closes [lobehub#11739](https://github.com/jaworldwideorg/OneJA-Bot/issues/11739) ([afc76f9](afc76f9))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
arvinxx added a commit that referenced this pull request Jan 24, 2026
arvinxx added a commit that referenced this pull request Jan 24, 2026
Revert "🐛 fix(editor): prevent crash when toggling enableInputMarkdown setting (#11755)"

This reverts commit ea5eed8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 Bug released on @next size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants