Skip to content

🐛 fix(chat-input): memoize mentionOption/slashOption to prevent freeze on paste#13551

Merged
arvinxx merged 3 commits intocanaryfrom
fix/autocomplete-freeze-on-paste
Apr 4, 2026
Merged

🐛 fix(chat-input): memoize mentionOption/slashOption to prevent freeze on paste#13551
arvinxx merged 3 commits intocanaryfrom
fix/autocomplete-freeze-on-paste

Conversation

@arvinxx
Copy link
Copy Markdown
Member

@arvinxx arvinxx commented Apr 3, 2026

Summary

  • Fix: Memoize mentionOption and slashOption props in InputEditor to stabilize object references across re-renders

  • Root cause: Inline objects and arrow functions caused new references every render → Editor.memoSlash recomputed → ReactSlashPlugin re-registered the slash plugin → update listener fired → triggerOpen called again → infinite loop when paste triggers autocomplete

  • Changes: Extract markdownWriter and onSelect into useCallback, wrap both option objects with useMemo

  • Fixes LOBE-6684

  • fix LOBE-6693

Test plan

  • Paste text containing @ or / into chat input — page should not freeze
  • Verify mention autocomplete still works (type @ then search)
  • Verify slash command autocomplete still works (type / at line start)
  • Verify paste file upload still works

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

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

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Apr 4, 2026 8:56am

Request Review

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.

We've reviewed this pull request using the Sourcery rules engine

@lobehubbot
Copy link
Copy Markdown
Member

@canisminor1990 - This is an editor/chat-input bug fix. Please take a look.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.63%. Comparing base (dbdbe16) to head (c1d8238).
⚠️ Report is 5 commits behind head on canary.

❗ There is a different number of reports uploaded between BASE (dbdbe16) and HEAD (c1d8238). Click for more details.

HEAD has 13 uploads less than BASE
Flag BASE (dbdbe16) HEAD (c1d8238)
packages/file-loaders 2 1
packages/prompts 2 1
packages/model-runtime 2 1
packages/web-crawler 2 1
packages/python-interpreter 2 1
packages/context-engine 2 1
packages/utils 2 1
packages/agent-runtime 2 1
packages/conversation-flow 2 1
packages/ssrf-safe-fetch 2 1
packages/model-bank 2 1
database 2 1
packages/memory-user-memory 2 1
Additional details and impacted files
@@             Coverage Diff             @@
##           canary   #13551       +/-   ##
===========================================
- Coverage   86.00%   66.63%   -19.37%     
===========================================
  Files         609     1996     +1387     
  Lines       49045   165640   +116595     
  Branches     7596    16076     +8480     
===========================================
+ Hits        42179   110367    +68188     
- Misses       6742    55149    +48407     
  Partials      124      124               
Flag Coverage Δ
app 58.49% <ø> (?)
database 92.57% <ø> (ø)
packages/agent-runtime 88.98% <ø> (ø)
packages/context-engine 85.39% <ø> (ø)
packages/conversation-flow 92.36% <ø> (ø)
packages/file-loaders 87.02% <ø> (ø)
packages/memory-user-memory 66.68% <ø> (ø)
packages/model-bank 99.85% <ø> (ø)
packages/model-runtime 84.66% <ø> (ø)
packages/prompts 65.80% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/utils 90.02% <ø> (ø)
packages/web-crawler 88.82% <ø> (ø)

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

Components Coverage Δ
Store 67.09% <ø> (∅)
Services 51.53% <ø> (∅)
Server 65.98% <ø> (∅)
Libs 51.03% <ø> (∅)
Utils 91.01% <ø> (-2.46%) ⬇️
🚀 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.

arvinxx and others added 2 commits April 3, 2026 23:57
…age freeze on paste

Stabilize mentionOption and slashOption references with useMemo/useCallback to break the
infinite re-render loop that occurs when pasting text triggers autocomplete.

Fixes LOBE-6684

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… prevent empty lines

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t interrupting Chinese input

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arvinxx arvinxx merged commit a7e3d19 into canary Apr 4, 2026
34 checks passed
@arvinxx arvinxx deleted the fix/autocomplete-freeze-on-paste branch April 4, 2026 12:09
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.

2 participants