Skip to content

fix(shell): use byte length for preview truncation (fixes #29291)#29372

Open
levgiorg wants to merge 1 commit into
anomalyco:devfrom
levgiorg:fix/issue-29291-shell-preview-truncation
Open

fix(shell): use byte length for preview truncation (fixes #29291)#29372
levgiorg wants to merge 1 commit into
anomalyco:devfrom
levgiorg:fix/issue-29291-shell-preview-truncation

Conversation

@levgiorg
Copy link
Copy Markdown

Issue for this PR

Closes #29291

Type of change

  • Bug fix

What does this PR do?

Fix shell tool preview truncation which used UTF-16 code unit length instead of byte length, causing incorrect truncation for multi-byte characters.

How did you verify your code works?

  • TypeScript typecheck passes
  • Existing tests pass
  • Code pattern matches tail() function in same file

Checklist

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

Previously preview() used text.length (UTF-16 code units) which caused incorrect truncation for multi-byte characters. Changed to use Buffer.byteLength() matching the tail() function pattern.

Fixes anomalyco#29291
@github-actions
Copy link
Copy Markdown
Contributor

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

Potential Duplicate PRs Found

PR #29297: fix(shell): truncate metadata preview by bytes
#29297

  • Addresses the same byte-length truncation issue for shell preview

PR #29288: fix(shell): preview Unicode truncation uses byte length instead of char length
#29288

  • Also fixes Unicode/byte-length truncation in shell preview

Both of these PRs appear to be addressing the same issue as PR #29372 (the current PR) — fixing shell tool preview truncation to use byte length instead of character/UTF-16 code unit length. You may want to review these existing PRs to determine if they've already been merged or closed, and whether your PR is redundant.

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.

shell tool preview truncation uses char length instead of byte length

1 participant