Repository navigation
Conversation
KuSh
marked this pull request as draft
November 5, 2026 23:42
📊 Automated PR Analysis
SummaryFixes rtk discover and rtk session to count every line of a multi-line call instead of only the first line, by sharing a new block_lines helper with the rewrite logic so lines are split the same way the hook rewrites them. Adds a joined_or_as_written lexer helper, updates total_commands/session adoption counting, and documents known limits (CRLF blocks, quoted newlines, comment-only blocks, quadratic cost on very long blocks). Review Checklist
Analyzed automatically by wshm · This is an automated analysis, not a human review. |
KuSh
force-pushed
the
fix/report-reads-every-line
branch
from
November 6, 2026 00:18
126ed0d to
5fda834
Compare
`rtk discover` and `rtk session` read a multi-line call as one command, so only its first line was classified: `git status\ngit log` counted one command, and `cd x\ngit status` none it could offer a saving on, although the rewrite acts on each line. A session's adoption now also counts the lines rtk does not handle. The report now reads a block as the rewrite does, through one entry check, `read_line`, and one `block_lines`: a line is a command, a trailing operator joins the next line, a blank or comment-only line is no command. A block the rewrite refuses to read line by line, such as a loop, stays one text as before, and so does a CRLF block. A heredoc with an fd number in front (`cat 0<<EOF`) is a heredoc too. Each command of a call is read once, for its share of the output and for its row. A call has one measured output, which went to its last command and was lost when that was an `echo`. Which command wrote what of it cannot be told apart, so the commands that may have written it now share it by category average, marked estimated, and one alone takes it whole: `cargo test; echo done` keeps its measurement. Both stages of a pipeline share it. A command that writes next to nothing, such as `echo` or `cd`, takes no share, and one that sends both its streams elsewhere (`cargo test > test.log 2>&1`) takes zero. A line left inside a backquote now refuses its block in `rewrite_command` too. The hook's answer does not change, as it already leaves any substitution alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KuSh
force-pushed
the
fix/report-reads-every-line
branch
from
November 8, 2026 17:13
5fda834 to
dd2e469
Compare
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
rtk discoverandrtk sessionread a multi-line call as one command and classified only its first line.git status\ngit logcounted one command, andcd x\ngit statusoffered no saving at all, although the rewrite acts on each line.The report now reads a block as the rewrite does. Both go through one entry check,
read_line, and oneblock_lines: a line is a command, a trailing operator joins the next line, and a blank or comment-only line is no command. A block the rewrite refuses to read line by line, such as a loop, stays one text as before. Each command of a call is read once, for its share of the output and for its row.Built on #4401. It uses that stack's lexer.
Behaviour changes
total_commandsand session adoption now count every line, including lines rtk doesn't handle, so a multi-line setup script lowers a session's adoption.cargo test\necho donekeeps its measurement. Both stages of a pipeline share it. A command that writes next to nothing (echo,cd) takes none, one that sends both its streams elsewhere (cargo test > test.log 2>&1) takes zero, and any other command with no row, as ingit status && ./build.sh, takes a share no row shows. This also changes;and&&: develop gives the number to the last command, and drops it if that is anecho.cat 0<<EOF), now refuses its block inrewrite_command. The hook's answer doesn't change: it already leaves any substitution or heredoc alone.Known limits
(cargo test) > test.log 2>&1) is read as its own part, so the command inside keeps a share of what came back.setalone,cp -v); its output then goes to the commands around it. One behind a wrapper (command -v,sudo mkdir) is read as a writer.exec > log 2>&1does not reach the commands after it.Test plan
cargo fmt --all,cargo clippy --all-targets,cargo test --all, and both with--no-default-features🤖 Generated with Claude Code