Skip to content

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

Closed
YOMXXX wants to merge 3 commits into
anomalyco:devfrom
YOMXXX:fix/shell-preview-byte-truncation
Closed

fix(shell): truncate metadata preview by bytes#29297
YOMXXX wants to merge 3 commits into
anomalyco:devfrom
YOMXXX:fix/shell-preview-byte-truncation

Conversation

@YOMXXX
Copy link
Copy Markdown

@YOMXXX YOMXXX commented May 26, 2026

Issue for this PR

Closes #29291

Type of change

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

What does this PR do?

Shell tool metadata previews were checking text.length, which counts UTF-16 code units rather than UTF-8 bytes. Multi-byte output could exceed the metadata byte limit without being preview-truncated, and slicing by code units could start on an invalid surrogate boundary.

This PR makes metadata preview truncation use UTF-8 byte length, trims from a valid byte boundary, and reuses the same byte-tail helper in the existing shell output tail path.

How did you verify your code works?

  • bun test test/tool/shell.test.ts -t "metadata output"
  • bun test test/tool/shell.test.ts
  • bun typecheck
  • PATH="$HOME/.bun/bin:$PATH" .husky/pre-push

Screenshots / recordings

Not applicable; shell metadata behavior only.

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

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

Potential Duplicate Found

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

Why it's related: Both PRs address the same core issue—using UTF-8 byte length instead of character/code unit length for shell tool metadata preview truncation. PR #29288 appears to cover the same fix, likely related to issue #29291 that this PR is closing.

@nexxeln
Copy link
Copy Markdown
Member

nexxeln commented May 26, 2026

tests failing, could you pls fix?

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

3 participants