anomalyco / anomalyco/opencode

TUI: typing large amounts of text into the chat input causes severe lag

Open
#49,635 1 comment 0 reactions 1 assignee View on GitHub

@kommander is already working on this.

Since Sep 17, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Typing (or dictating) a large amount of text into the TUI chat input (the prompt box) makes the UI lag heavily and effectively stop responding as the buffer grows. Pasting large blobs is usually collapsed into a "[Pasted ~N lines]" summary, so this is most visible when typing or voice-dictating directly into the input.

Root cause found while profiling: mentionTriggerIndex runs on every keystroke (onContentChange → autocomplete onInput) and performs two full-buffer Intl.Segmenter passes per keystroke. Measured per-keystroke cost:

  • 5 KB buffer: ~3.1 ms
  • 20 KB: ~13 ms
  • 100 KB: ~65 ms

The underlying opentui textarea is not the bottleneck (~0.2 ms/keystroke into a 20 KB buffer).

Waiting on PR #49634 which adds cheap raw-string gates so the display-aware scan only runs when an actual @ trigger needs resolving.

Plugins

None

OpenCode version

1.18.31

Steps to reproduce
  1. Open the opencode TUI
  2. Type or dictate a large amount of text into the chat input (tens of KB)
  3. Observe keystroke latency climbing as the buffer grows until the UI appears frozen
Expected behavior

Keystroke latency stays roughly constant regardless of how much text is in the input box.

Operating System

Linux

Terminal

Any

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.