Skip to content

[Bug]: TUI word wrap, LaTeX parsing, and bracketed paste can run without a bound #613

Open

Description

@Coff0xc

Summary

Three interactive TUI paths can run without a bound and take down the client. External pull requests are not accepted from this account. The fix branch is linked below.

Searched existing issues first. #32 is a LaTeX display question, and #491 is a clipboard-paste contribution question. Neither is this recursion or buffer bound.

Product or interface

CLI - interactive TUI. Source build.

Version

Source main at 3c21163 (chore(sdk-python): release 0.1.1). Node.js v24.19.0. pnpm 9.12.0.

Platform

Windows 11 Pro, build 26200.

Issue area

UI / UX.

Steps to reproduce

On 3c21163:

  1. Word wrap: render a line that contains one wide grapheme, such as a CJK character or an emoji, with wordWrapLine when the terminal content width is 1 column.
  2. LaTeX: call renderLatex with a few hundred unmatched { characters, or with environments nested a few hundred levels deep.
  3. Paste: send a bracketed-paste start (ESC [200~) and keep sending data with no end marker until the buffer passes 1 MiB. The same buffer exists in StdinBuffer, Input, and Editor.

Expected and actual behavior

  • Expected: a single wide grapheme is emitted as its own visual chunk; LaTeX deeper than a small fixed depth is treated as unsupported; an oversized or unterminated paste is dropped and the input path accepts later keystrokes.
  • Actual: wordWrapLine recurses on that same grapheme until the stack overflows; renderLatex recurses once per nested group or environment until the stack overflows; the paste buffer grows for as long as the end marker is absent.

Branch

https://github.com/Coff0xc/minimax-code/tree/fix/code-defects

Head b1bfc9a. Commits from 203278f through b1bfc9a, based on 3c21163.

  • wordWrapLine recurses only when a segment contains more than one grapheme.
  • LaTeX parsing shares a depth of 64 across nested braces and nested environment parsers.
  • StdinBuffer, Input, and Editor drop a bracketed paste larger than 1 MiB and leave paste mode.

Validation

Windows, Node.js v24.19.0, Vitest 4.1.11, on the committed sources:

npx --yes pnpm@9.12.0 exec vitest run --config vitest.oss.config.mjs packages/tui/test/unit/tui-word-wrap-wide-grapheme.test.ts packages/tui/test/unit/tui-latex-parse-depth.test.ts packages/tui/test/unit/tui-terminal-text-paste.test.ts

21 passed: word wrap 5, LaTeX depth 3, paste 13.

NOT RUN: pnpm verify, and Linux or macOS CI. The paste cap was exercised with synthetic input, not a physical terminal paste.

Checklist

  • I have searched existing issues.
  • I have included the version and removed sensitive information.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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