Open
Conversation
Byte-based string slicing in generateContextFromPrompts and TruncateDescription split multi-byte UTF-8 sequences at arbitrary byte boundaries, producing mojibake in context.md and commit messages. Replace byte slicing with rune-based truncation using the existing stringutil.TruncateRunes helper throughout. Closes #419 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 3d5fd4d46a16
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes UTF-8 corruption (mojibake) caused by byte-based truncation when generating human-readable prompt/context summaries, by switching truncation to rune-safe logic and adding regression tests (CJK/emoji/ASCII). This aligns with the CLI’s goal of producing readable, searchable session metadata without mangling user content.
Changes:
- Replace byte slicing with rune-based truncation in
generateContextFromPrompts. - Update
TruncateDescriptionto truncate by runes (UTF-8 safe) viastringutil.TruncateRunes. - Add tests covering CJK, emoji, ASCII truncation and UTF-8 validity.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/entire/cli/strategy/messages.go | Switch description truncation to rune-safe truncation helper to prevent UTF-8 splitting. |
| cmd/entire/cli/strategy/manual_commit_condensation.go | Use rune-based truncation for prompt rendering in generated context.md output. |
| cmd/entire/cli/strategy/manual_commit_condensation_test.go | Add regression tests ensuring truncation remains valid UTF-8 for CJK/emoji/ASCII. |
evisdren
previously approved these changes
Feb 20, 2026
Add fast path using utf8.RuneCountInString() in TruncateRunes so no []rune is allocated when the string is already within the limit. Simplify TruncateDescription to delegate entirely to TruncateRunes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 2693007f15fb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
generateContextFromPromptsandTruncateDescriptionwith rune-based truncation using the existingstringutil.TruncateRuneshelperCloses #419
Test plan
TestTruncateDescriptionandTestFormatIncrementalMessagetests pass unchangedmise run fmt && mise run lint— no new issuesgo test -race ./cmd/entire/cli/strategy/— all tests pass🤖 Generated with Claude Code