[Bug]: Typing after a selected skill lags, worse on long prompts#30657
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Open any project whose provider offers skills.
- In the composer, pick a skill from the
$or/menu so it becomes a chip. - Keep typing after the chip, ideally until the prompt is a few hundred characters long.
Expected behavior
Typing after a skill chip costs the same as typing plain text.
Actual behavior
Each keystroke gets slower once a skill is selected, and the gap grows with prompt length.
Median time per keystroke (dev build, e68e19d605, measured in the browser):
| Prompt | Per keystroke |
|---|---|
| plain, short | 18.3 ms |
| skill chip, short | 19.5 ms |
| plain, ~800 chars | 21.7 ms |
| skill chip, ~800 chars | 31.7 ms |
A skill chip is serialized as $name. mayContainMath in packages/shared/src/markdownMath.ts treats any $ as possible math, so collectComposerInlineTokens and buildTiptapContent run the full remark + GFM + math parser over the whole prompt. That happens several times per keystroke: cursor conversions in ComposerPromptEditorTiptap and ChatComposer, plus buildDocJson passed as useEditor's content option, which is rebuilt on every render although it is only read on mount. splitPromptIntoComposerSegments goes from 3 µs on plain text to about 250 µs with one $skill.
Impact
Typing visibly lags after selecting a skill, worse on long prompts.
Version or commit
e68e19d605 (main)
Environment
Web, Linux, Chromium-based browser, dev build.