Skip to content

fix(pipe): support Windows drive paths and tee recovery hints in grep filter - #5066

Merged
pszymkowiak merged 1 commit into
rtk-ai:developfrom
larancibia:fix/pipe-grep-windows-paths-and-tee-hint
Nov 22, 2026
Merged

pszymkowiak merged 1 commit into
rtk-ai:developfrom
larancibia:fix/pipe-grep-windows-paths-and-tee-hint

Conversation

@larancibia

@larancibia larancibia commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem

While running rtk pipe --filter grep (and rtk pipe auto-detection) in coding-agent workflows, we hit two silent failure modes where an agent loses search results without realizing it:

  1. Windows absolute paths are silently dropped:
    When rg or grep emits paths with a drive letter (e.g. C:\proj\src\main.rs:42:fn main() or D:/repo/lib.rs:7:let x = 1;), pipe_cmd splits on the first : (C:), treats \proj\src\main.rs as the line number, fails numeric parsing, and drops the line. Auto-detection fails to recognize the stream, and in mixed output (Windows absolute + relative paths), all drive-prefixed matches disappear silently.

  2. Truncated matches (> 10 per file) cannot be recovered in pipe mode:
    Direct rtk grep appends a recovery hint when capping past 10 matches per file (matching CONTRIBUTING.md: "capping output at N items is only acceptable if accompanied by a hint that lets the agent recover the hidden data"). In contrast, rtk pipe --filter grep printed a bare +240 with no rtk recall / tee hint, leaving the agent with no way to inspect the omitted matches.

Before / After

Before:

# 1) Windows paths in `rtk pipe --filter grep` (mixed with a relative path):
# C:\proj\src\main.rs:42:fn main()   <-- silently dropped!
[file] src/unix.rs (1):
    19: pub fn run() {}

# 2) File with 15 matches in `rtk pipe --filter grep`:
  +5

After:

# 1) Windows + Unix paths preserved and auto-detected:
[file] C:\proj\src\main.rs (1):
    42: fn main()
[file] src/unix.rs (1):
    19: pub fn run() {}

# 2) File with 15 matches includes the standard RTK recovery hint:
  +5 [+5 hidden: rtk recall <id>]

Fix

  • Add parse_pipe_grep_line in src/cmds/system/pipe_cmd.rs to skip an initial Windows drive prefix (X:\ or X:/) before splitting :line_num:content, and use it in both grep_wrapper and auto_detect_filter (preserving Unix paths and colons inside matched code).
  • Call crate::core::tee::force_tee_tail_hint in grep_wrapper when a file exceeds MAX_PIPE_MATCHES (CAP_WARNINGS = 10), falling back to bare +N when recovery is disabled (RTK_RECALL=0).

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo test
  • Manual testing: rtk pipe --filter grep and auto-detect output inspected on C:\..., D:/..., Unix paths, and >10 match truncation (rtk recall, RTK_TEE_DIR, and RTK_RECALL=0)
  • Unit tests added in src/cmds/system/pipe_cmd.rs

@CLAassistant

CLAassistant commented Nov 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added bug Something isn't working grep pipe windows labels Nov 11, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

🐛 Type bug-fix
🟢 Risk low

Summary

Fixes grep pipe filter parsing to support Windows absolute drive paths (e.g. C:... or D:/...) without misparsing the drive-letter colon as a line-number delimiter, via a new parse_pipe_grep_line helper used in both grep_wrapper and auto_detect_filter. Also adds truncation recovery hints (tee tail / rtk recall) when matches exceed MAX_PIPE_MATCHES, mirroring existing behavior in search.rs.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@pszymkowiak pszymkowiak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @larancibia. Tested natively on Windows (merged onto develop): the 54 pipe_cmd tests pass, including the new ones.

With real Git for Windows grep -rn output on an absolute path (2 files, 16 matches), rtk pipe and rtk pipe --filter grep now group by file (16 matches in 2F:), where develop passed the whole output through unfiltered. The file with 15 matches shows 10 plus +5 [+5 hidden: rtk recall <id>], and rtk recall <id> returns exactly lines 11 to 15.

One small note for later, not blocking: src/cmds/README.md asks for the recall blob to match what was displayed, and here it stores the raw file:line:content form. That's arguably more useful for the agent, since each line keeps its path.

@pszymkowiak
pszymkowiak merged commit 75d1249 into rtk-ai:develop Nov 22, 2026
3 checks passed
@rtk-release-bot rtk-release-bot Bot mentioned this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working grep pipe windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants