Repository navigation
fix(sessions): keep a matched rg path even at the repo root - #2639
Conversation
_rewrite_search_output required a separator in the candidate before keeping it as a file, so a root-level rg match like app.py:12: was dropped even though _RG_MATCH_RE had already confirmed it was a path. Bare rg --files/-l output for a root-level file (setup.py) was dropped too. Keep a matched path unconditionally, since the :line: suffix already proves it is a path and not prose. For an unmatched bare line, loosen the filter with _looks_like_a_bare_path: admit it when it has no whitespace and either a separator or a "." after the first character, which still drops stray prose like "No files were searched".
|
Reviewed the whole diff: nothing to fix. 📊 See the full report for this PR |
|
Review please? |
RaghavChamadiya
left a comment
There was a problem hiding this comment.
Thanks @drakeo338, and sorry this sat a couple of days after your ping. Trusting the :\d+: match as proof of a path and only applying the bare-path heuristic to unmatched lines is the right split, and the prose-is-still-dropped test keeps the heuristic honest. Not a blocker: an extensionless root file like Makefile is still dropped, which is fine to leave for another day.
Summary
The Codex adapter's
_rewrite_search_outputdropped every root-level file (app.py,setup.py) fromrgsearch results, because it kept a candidate only when it contained a path separator, even for lines_RG_MATCH_REhad already matched aspath:line:content. That leftsearch_codebaseresults empty for root-level matches, so_bind_first_filehad nothing to bind the search call's path to. The fix keeps a regex-matched path unconditionally and loosens the bare-line fallback to admit a root-level filename (no separator but a "." after the first character) while still dropping stray prose lines.Related Issues
Fixes #2623.
Test Plan
pytest) — ranuv run pytest tests/unit/sessions/test_codex_adapter.py -k codex -qon this branch's HEAD: 22 passed, 0 failed. Did not run the fulltests/providers/ tests/unit/suite.ruff check .) — ranruff checkon the two changed files only, not the whole repo: no findings.npm run build) (if frontend changes) — no frontend changes, not run.Checklist
ruff checkon the touched files is clean (see Test Plan).tests/unit/sessions/test_codex_adapter.py.