Skip to content

fix(gradlew): collapse consecutive blank lines in build filter output#1940

Open
luinstra wants to merge 1 commit into
rtk-ai:developfrom
luinstra:fix/gradle-collapse-consecutive-blanks
Open

fix(gradlew): collapse consecutive blank lines in build filter output#1940
luinstra wants to merge 1 commit into
rtk-ai:developfrom
luinstra:fix/gradle-collapse-consecutive-blanks

Conversation

@luinstra
Copy link
Copy Markdown

Summary

  • BuildLineFilter::feed_line was stateless: every line filter_build_line accepted got emitted as-is, including blanks intentionally kept as section separators.
  • On real kotlin/JVM builds — which emit groups of w: warnings separated by blank lines — this produced multi-screen runs of blank lines between groups of warnings, drowning the actual signal.
  • Make BuildLineFilter stateful with last_emitted_was_blank: bool. Single-blank separators are preserved; runs of 2+ collapse to one. Non-blank lines unaffected.

Note on the "fix" framing: BPE tokenizers fully collapse whitespace runs, so this patch saves ~0 tokens. The win is human readability (tee files, debug sessions, scrollback). Filed as fix because it removes pathological output noise that hides the actual build signal.

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo test — all pass
  • Four new tests use byte-exact assert_eq! via a run_build_filter helper:
    • test_build_filter_collapses_consecutive_blanks — runs of \n\n\n\n collapse to \n\n
    • test_build_filter_preserves_single_blank_separator — single \n\n survives
    • test_build_filter_collapse_survives_dropped_lines_between_blanks> Task :… stripped between blanks still collapses (regression for the "state only tracks emitted lines" decision)
    • test_build_filter_leading_blanks_collapsed — initial run of blanks collapses to one

Targets develop per CONTRIBUTING.md. Independent of #1939 (same file, unrelated bug).

`BuildLineFilter::feed_line` was a stateless predicate wrapper: any
line for which `filter_build_line` returned true was emitted as-is.
Because `filter_build_line` intentionally preserves blank lines as
section separators between error blocks, real kotlin/JVM builds —
which can emit hundreds of `w:` compiler warnings each separated by
blank lines from Gradle's renderer — produced multi-screen runs of
blanks between groups of warnings, overwhelming the actual signal.

Make `BuildLineFilter` stateful with a `last_emitted_was_blank: bool`
field. Single-blank separators are preserved; runs of 2+ blanks
collapse to one. Non-blank lines are unaffected.

Note: token savings from this patch are minimal — BPE tokenizers
fully collapse runs of whitespace. The win is human-readable output
(tee files, debug sessions), not API spend. Filed under fix anyway
because it removes pathological output noise.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@YOMXXX
Copy link
Copy Markdown
Contributor

YOMXXX commented May 20, 2026

LGTM as an outside reviewer 👍

The last_emitted_was_blank state-machine pattern is the right shape — preserves a single blank line as a section separator while collapsing the pathological N-blank runs that real kotlin/JVM builds emit between groups of w: warnings. State change is minimal, the flush path is unchanged, and the new tests exercise both the kept-blank and collapsed-blank paths.

Maintainers: clean targeted change. Recommend merging.

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.

2 participants