Repository navigation
fix(cli): clamp past-end --token-offset in truncation footer - #296
Closed
debojyoti10CC wants to merge 1 commit into
Closed
debojyoti10CC wants to merge 1 commit into
debojyoti10CC wants to merge 1 commit into
Conversation
Contributor
Author
|
Bumping this in case it got buried. It is still ready for review, and I am happy to make any changes you would like. Thanks! |
Member
|
Thanks so much for the fix and the clear before/after, @debojyoti10CC! We've folded it into #319, which combines it with #254 and ports the change to the Rust, Python, and Zig ports with differential cases. You're credited as co-author there. Closing in favor of #319. |
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.
What's wrong
If
--token-offsetis past the end of the output, the truncation footer prints a reversed range, e.g.showing tokens 100000–13 of 13. The slice is correctly empty, but the footer used the raw offset as the start while only clamping the end.Fix
Clamp the start of the footer range to the total token count, so the past-end case reads the same as the exact-end case (
13–13 of 13). The slice itself andnextOffsetare unchanged. Added a patch changeset.Testing
src/Cli.test.ts(fails on main, passes now).src/Cli.test.ts: 469 of 470 pass. The one failure is the symlinked-entrypoint test, which needs symlink privileges on my Windows machine and is unrelated. oxlint and oxfmt are clean on the touched files.Before / After
Output of
hello --token-offset 100000on a command returning a 13-token message.Before (main):
After:
Controls unchanged:
--token-offset 13gives13–13 of 13,--token-offset 0gives the full message,--token-limit 5gives0–5 of 13.Fixes #273