Skip to content

fix: parse-failure tracking, Windows tee path, passthrough output loss (#3339) - #3344

Open
SomSamantray wants to merge 4 commits into
rtk-ai:developfrom
SomSamantray:fix/passthrough-tracking-and-tee-path
Open

fix: parse-failure tracking, Windows tee path, passthrough output loss (#3339)#3344
SomSamantray wants to merge 4 commits into
rtk-ai:developfrom
SomSamantray:fix/passthrough-tracking-and-tee-path

Conversation

@SomSamantray

Copy link
Copy Markdown

Fixes the three related bugs reported in #3339, all rooted in how rtk's Tier-3 "parsing failed" fallback (ParseResult::Passthrough) is tracked and displayed.

1. rtk gain counted parse failures as savings

timer.track(...) was called unconditionally, even for Passthrough-tier runs. Since the passthrough content is a truncated view of the raw output, the size difference between "raw" and "shown" was counted as savings — even though nothing was parsed or summarized, and truncation only happened because parsing failed.

Fix: route genuine Tier-3 failures through the existing record_parse_failure_silent + TimedExecution::track_passthrough plumbing (already used by rtk gain --failures) instead of the generic savings timer. Applied to playwright test, pnpm list, pnpm outdated, and vitest/jest run — the four call sites sharing this pattern. Explicit user-requested passthrough (e.g. vitest's --reporter override) is untouched — it isn't a failure.

2. Tee hint path broken on Windows

[full output: ~/path/to/log] mixed a forward-slash ~ with native backslash separators, and could resolve ~ against a different home directory than the invoking Git Bash/MSYS shell's own ~ expansion uses.

Fix, in display_path:

  • Normalize the home-relative portion to forward slashes unconditionally (previously only the whitespace-quoting branch did this).
  • Prefer $HOME over the OS home-directory API when stripping the home prefix, converting Git Bash/MSYS's POSIX-style HOME (/c/Users/name) to a native path first — otherwise it would never match via strip_prefix and would silently defeat the ~ shorthand.
  • Reject an empty HOME value (an empty PathBuf's strip_prefix trivially matches everything).

This keeps the existing ~/ shorthand (per #2325's direction) rather than reverting to always-absolute paths, an approach previously tried in #2187/#2701.

3. Passthrough could silently emit nothing

When parsing failed and a command's real output was empty on stdout (diagnostic on stderr instead), the passthrough fallback was itself empty. never_worse then preferred that empty result over the real combined output, discarding it.

Fix: build the passthrough fallback content from the combined stdout+stderr instead of stdout alone, for all four call sites above.

Notes

  • No local rtk checkout existed when this was written — verified against a fresh develop clone before implementing.
  • cargo fmt --all, cargo clippy --all-targets -- -D warnings, and cargo test --all all pass (2523 tests; the only 2 failures in this environment — hooks::rewrite_cmd::tests::unattestable_passthrough::* — are pre-existing and unrelated, reproduced identically on unmodified develop).
  • pnpm list's Tier-1/Degraded guard and tracking stay anchored to stdout alone (unchanged) — only the Tier-3 arm uses the combined stream, so a stderr notice alongside a successful parse doesn't inflate the reported savings ratio.

SomSamantray added 4 commits July 31, 2026 19:20
…loss

When PlaywrightParser::parse falls back to Passthrough (all parsing
tiers failed), the run was tracked through the same savings timer used
for successful parses -- so the truncation-driven size difference was
recorded as token savings even though nothing was parsed. Route genuine
Tier-3 failures through the existing record_parse_failure_silent +
track_passthrough plumbing instead.

Also build the passthrough fallback content from the combined
stdout+stderr rather than the parser's stdout-only truncation, so a
failure reported only on stderr (empty stdout) isn't silently dropped.

Part of rtk-ai#3339.
Same fix as playwright applied to pnpm list and pnpm outdated: genuine
Tier-3 parse failures now route through record_parse_failure_silent +
track_passthrough instead of being counted as token savings, and the
passthrough fallback content is built from the combined stdout+stderr
so a stderr-only failure isn't dropped.

pnpm list's Tier-1/Degraded guard and tracking stay anchored to stdout
alone (unchanged from before this fix) -- only the Tier-3 arm uses the
combined stream, so a stderr notice alongside a successful parse
doesn't inflate the reported savings ratio. pnpm outdated's existing
"All packages up-to-date" empty-display fallback is untouched.

Part of rtk-ai#3339.
Same fix as playwright/pnpm applied to vitest/jest run. Adds an
is_parse_failure field to FormattedTestOutput, set only in the genuine
ParseResult::Passthrough arm inside format_test_output -- distinct
from the explicit user-requested passthrough path (an explicit
--reporter override), which is not a failure and keeps its existing
behavior. run_test branches its tracking call on that field: genuine
failures route through record_parse_failure_silent +
track_passthrough; everything else keeps the existing timer.track
call. The passthrough fallback content is now built from the combined
stdout+stderr instead of stdout alone.

Part of rtk-ai#3339.
…hell's HOME

The tee recovery hint (e.g. [full output: ~/path/to/log]) mixed a
forward-slash ~ with native backslash separators on Windows, and could
resolve ~ against a different home directory than the invoking Git
Bash/MSYS shell's own ~ expansion uses.

- Normalize the home-relative portion to forward slashes
  unconditionally in display_path, not only inside the
  whitespace-quoting branch that already did this for paths with
  spaces.
- Prefer the HOME environment variable over the OS home-directory API
  when stripping the home prefix, since Git Bash/MSYS set HOME
  themselves and that is the root their own ~ expansion resolves
  against. HOME is commonly MSYS-style (/c/Users/name); convert it to
  a native path (C:\Users\name) before comparing, since passed
  through unconverted it would never match a native path via
  strip_prefix and would silently defeat the ~ shorthand entirely.
  Reject an empty HOME value, since an empty PathBuf's strip_prefix
  trivially matches any path.

Part of rtk-ai#3339.
@CLAassistant

CLAassistant commented Jul 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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