Skip to content

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

Closed as not planned

Description

@deadadm1n

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

Activity

  1. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    This issue might be related to existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions