Skip to content

bug(user-input-fold): prose cutoff splits supplementary characters #585

Description

@ooiuuii

Problem

A long finalized user message can acquire a replacement character in its folded terminal preview when the first prose line is cut between the two UTF-16 halves of an emoji or other supplementary character.

Current main: f6b49ae59605b1276b8267f2886d22c03f01533c. Reproduced on the source checkout with Node 22.22.3 on Windows.

Reproduction

Send a user message with a first line consisting of 1,199 ASCII characters followed by an emoji and more text, followed by at least 21 additional lines. This reaches the normal finalized-user Markdown transformer and its 1,200-code-unit prose cutoff.

The returned preview ends that prefix with an orphaned high surrogate. Encoding the rendered text as UTF-8 and reading it back introduces a replacement character. An astral CJK character at the same boundary reproduces the same failure.

Expected: omit the entire boundary character if it cannot fit, without increasing the existing preview budget. A complete pair that fits should remain intact.

This affects the folded display only; the original message sent to the model and stored in the Session is not claimed corrupted. No changes to folding thresholds, code fences, or grapheme-cluster policy are proposed.

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