Skip to content

fix(tui): reconstruct pasted prompt text after wide characters#20987

Open
zcarc wants to merge 1 commit intoanomalyco:devfrom
zcarc:fix/prompt-paste-offset
Open

fix(tui): reconstruct pasted prompt text after wide characters#20987
zcarc wants to merge 1 commit intoanomalyco:devfrom
zcarc:fix/prompt-paste-offset

Conversation

@zcarc
Copy link
Copy Markdown

@zcarc zcarc commented Apr 4, 2026

Issue for this PR

Closes #20986

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Fixes a prompt reconstruction bug in the TUI when multiline pasted text is summarized and the prompt contains wide characters before the pasted token.
Before this change, the submit path used terminal-width offsets as JavaScript string indices when expanding [Pasted ~N lines] back into the original text. That caused the submitted prompt to be corrupted for Korean characters.
This change converts width-based extmark offsets to string indices before reconstructing the final prompt text, so the pasted content and trailing input are restored in the correct position.

How did you verify your code works?

  • Reproduced the bug locally in the TUI with Korean text before a multiline paste summary
  • Confirmed the submitted prompt was previously corrupted
  • Confirmed the submitted prompt now matches the original pasted text plus trailing input

Screenshots / recordings

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

The following comment was made by an LLM, it may be inaccurate:

I found a potentially related PR:

Related PR:

The PR #20987 appears to be a more recent fix that addresses a similar but distinct issue: while #17034 handled pasted preview replacement for multi-width characters, #20987 specifically fixes the prompt reconstruction after pasted text summaries when wide characters appear before the pasted content.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TUI multiline paste reconstruction breaks after wide characters

1 participant