GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(shared): ripgrep matches open the right file when a heading looks like a note by saphid · Pull Request #44627 · pingdotgg/t3code

Conversation

@saphid

@saphid saphid commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Problem

When ripgrep --heading output includes a file whose name looks like a parenthesized note (such as (draft)) or a decoration (such as ---), parseGrepOutput consumes the heading as a note/decoration while keeping the previous file active and attributes that file's numbered matches to the preceding file.

Deterministic repro on origin/main (241d46c562fa9a0e1bfc58de181a704dd43ac8f7):

  1. In a temporary directory, write hit\n to normal.ts and (draft). Running rg --color never -j1 -nH --heading hit -- normal.ts '(draft)' emits "normal.ts\n1:hit\n\n(draft)\n1:hit\n".
  2. Pass that output through parseGrepOutput(output, ".") or openCodeToolTurnItem from packages/provider-opencode:
    cd packages/provider-opencode && node --input-type=module -e '
    import { parseGrepOutput } from "@t3tools/shared/grepOutput";
    import { openCodeToolTurnItem } from "./src/server/toolItems.ts";
    const output = "normal.ts\n1:hit\n\n(draft)\n1:hit\n";
    console.log(JSON.stringify({
      parsed: parseGrepOutput(output, "."),
      openCodeResults: openCodeToolTurnItem(
        { id: "grep-1", turnId: "t-1", threadId: "th-1", providerItemId: null, nativeItemRef: null, parentItemId: null, ordinal: 0, status: "completed", title: "grep", startedAt: null, completedAt: null, updatedAt: "2026-01-01T00:00:00.000Z" },
        { name: "grep", input: { pattern: "hit", path: "." }, output, completedMetadata: undefined },
      ).results,
    }, null, 2));
    '
  • Observed on origin/main: Both parseGrepOutput and openCodeToolTurnItem return two normal.ts:1 results plus a root note { fileName: ".", preview: "(draft)" }, with no result for (draft):1.
  • Expected: One result each for normal.ts:1 and (draft):1 (preview: "hit"), with no note; a genuine trailing parenthesized warning (e.g. (Results are truncated.)) remains a root note.

Change

In packages/shared/src/grepOutput.ts, recognize a non-inline ripgrep heading at a file-block boundary ((lines[index - 1] ?? "").trim() === "") when the next line is a ripgrep numbered match (^\d+:), before interpreting the line as a decoration or parenthesized note. Genuine trailing provider notes have no following numbered match and continue to parse as root notes. Both packages/provider-opencode and packages/provider-acp consume parseGrepOutput, so server, web, desktop, and mobile surfaces receive the corrected file/line attributions automatically without contract or UI changes. Extended packages/shared/src/grepOutput.test.ts with regression assertions covering (draft), a trailing truncation note control, and a --- heading.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Base failure (origin/main 241d46c562fa9a0e1bfc58de181a704dd43ac8f7): vp test run packages/shared/src/grepOutput.test.ts -t "heading looks like a note" failed with 2 normal.ts:1 matches and a root (draft) note instead of normal.ts:1 and (draft):1.
  • Head verification: vp test run packages/shared/src/grepOutput.test.ts passed 2/2 consecutive runs (13/13 tests each).
  • Changed-files gate: vp run check:changed exited 0 (format, lint, knip 1/2 & 2/2, typecheck across 38 packages, and 2 affected test files / 15 tests).
  • Before/after runtime transcript: https://gist.github.com/saphid/c63b959bdf3235da6174fcb7582d4cb6
  • Not shown: End-to-end UI rendering in web/desktop/mobile clients (no UI code modified; only the shared grep output parser changed) and live rg binary invocation in this container (exact rg --color never -j1 -nH --heading stdout was fed directly into parseGrepOutput and openCodeToolTurnItem).

Authored by Gemini 4 Neon (Antigravity); reviewed by Kimi K3.1 Pro (Model Hub).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 28, 2026
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

parseGrepOutput now checks for file headings after blank lines before processing notes or separators. Tests cover (draft) and --- headings, and a truncation note associated with ".".

Changes: Grep heading recognition

Layer / File(s) Summary
Recognize file headings at block boundaries
packages/shared/src/grepOutput.ts, packages/shared/src/grepOutput.test.ts
The parser recognizes a heading when a blank line precedes it and a numbered match follows, with an exception for ambiguous inline matches while the format is undetermined. Tests cover (draft) and --- headings, and a truncation note associated with ".".

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: stienswout, jadelike-wine, yash-singh1

Merge Risk: Minimal · up to 91604

This fixes grep results being attributed to the wrong file when a filename looks like a note or decoration, such as (draft) or ---. The change is small and covered by regression tests, and no actionable merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: ripgrep matches are attributed to the correct file when a heading looks like a parenthesized note. It follows the conventional commit form and is specific. It is 81 ch…
Description check Passed The description follows the template sections: Problem, Change, Scope, and Verification. It gives a deterministic repro, expected and observed results, the specific change, why no issue is needed for …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: ripgrep matches are attributed to the correct file when a heading looks like a parenthesized note. It follows the conventional commit form and is specific. It is 81 characters, which is slightly long but readable.

Full details: Description check

Explanation

The description follows the template sections: Problem, Change, Scope, and Verification. It gives a deterministic repro, expected and observed results, the specific change, why no issue is needed for a small obvious bug, and focused test results with an explicit list of what was not checked. The template's optional agent attribution line is present. The Problem section is longer than the template's one-or-two-sentence guidance, but the content is relevant and complete.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: pingdotgg/t3code
  • Branch: main
  • File: .coderabbit.config.ts
  • Commit: 1b12bcd
  • Layers: Repository TS config
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c0981e28-5195-4141-853a-3f3ce73881c0
Commits

Reviewing files that changed from the base of the PR and between e371d9f and 916049d.

Files selected for processing: 2

  • packages/shared/src/grepOutput.test.ts
  • packages/shared/src/grepOutput.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@saphid
fix(shared): ripgrep matches open the right file when a heading looks…
916049d
… like a note
@saphid
saphid force-pushed the hunter/c-0d3495faea branch from e371d9f to 916049d Compare November 28, 2026 04:19
@StiensWout StiensWout mentioned this pull request Nov 28, 2026
fix(shared): keep grouped grep matches when later rows clarify the format #44847
Open

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@saphid
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.