Repository navigation
fix(plan): slice task commands by byte offsets - #861
Merged
wan9chi merged 5 commits intoOct 19, 2026
Merged
Conversation
Command spans from the shell parser are sliced out of the script to display each command. These cases put multi-byte UTF-8 characters before span boundaries, where `vp run` currently panics or truncates the displayed command (voidzero-dev#719). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
`brush_parser` reports source positions as character indices, but the command spans were used as byte ranges into the script. A script with a multi-byte UTF-8 character before a span boundary made `vp run` panic before running it, or display a truncated command. Convert the parser's character indices to byte indices before returning the spans. Fixes voidzero-dev#719 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The comment relied on an open brush PR that renames `index`. If a brush release switches to byte offsets without the rename, the unit test for multi-byte characters is what detects the double conversion. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
wan9chi
approved these changes
Oct 19, 2026
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.
Motivation
The
vp runcommand panics before it runs a script that contains multi-byte UTF-8 characters, for exampleecho ああ. To display each command, the planner slices the script with the command spans from thebrush-parsercrate. These spans are character indices (SourcePosition::index), but the planner uses them as byte ranges. If an index falls inside a character, the slice panics. If an index falls on a character boundary, the planner displays a truncated command: it displaysecho あああasecho あ.The brush project tracks this bug in reubeno/brush#1127. The fix in reubeno/brush#1144 is still open.
Fixes #719.
Changes
vt_shellcrate converts the character indices from thebrush-parsercrate to byte indices before it returns the command spans. Each conversion counts characters from the start of the script, which takes about 0.2 µs for a 150-byte script.non_ascii_commandsfixture for plan snapshots.