Skip to content

fix(preview): collapse provider-directory rows and keep changeset order - #1242

Merged
lizhengfeng101 merged 3 commits into
alibaba:mainfrom
jimpablo:fix/preview-provider-dir-aggregate
Sep 15, 2026
Merged

lizhengfeng101 merged 3 commits into
alibaba:mainfrom
jimpablo:fix/preview-provider-dir-aggregate

Conversation

@jimpablo

@jimpablo jimpablo commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes the three --preview presentation problems that became reachable once #1223 started listing provider-directory exclusions (#1236):

  1. Column width — the path column is sized per section, from the rows that section actually prints. A long excluded path no longer pads the Will review rows.
  2. Unbounded excluded list — in text output, provider_directory entries collapse into one line that names only the directories actually matched (diff.ProviderDirPrefix). They are skipped when sizing the excluded column. --format json is unchanged and still lists every entry in files.
  3. Ordering — DiffSet records each provider exclusion's changeset position and ForEachInOrder walks Included/Excluded in Git's order instead of prepending provider entries. The terminal listing and the JSON files array follow that order.

Scope note: #1236 lists output.go, preview.go and their two test files. This also touches internal/diff, for two reasons. Once partitionDiffs splits the changeset into Included and Excluded, preview.go can no longer recover the original order, so DiffSet records where each exclusion sat. And diff.ProviderDirPrefix lets the summary line name the matched directories from the existing providerDirIgnoreDirs blocklist instead of a second copy of it.

The five FAQ locales now describe the text/JSON split: terminal preview collapses provider-directory files into one summary line; --format json still lists every entry.

Untracked provider-directory files stay with #1235 / #1241. This does not add a vendor-include override (#1197).

Example on a scratch repo with a vendored target/ tree, a vendor/ file, and a test file:

Will review (1):
  [M]  a.go                 +2    -0

Excluded from review (4):
  [M]  foo_test.go          (default_path)
  3 file(s) in provider directories (target/, vendor/) — not reviewable

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • make check passes locally
  • make coverage reports 91.5% (threshold 90%)
  • Manual testing (describe below)

New tests, covering the renderer, Preview, runPreview and internal/diff:

  • TestOutputPreviewText_ExcludedPathDoesNotWidenWillReview
  • TestOutputPreviewText_AggregatesProviderDirectories
  • TestOutputPreviewJSON_KeepsEveryFileInEntryOrder
  • TestPreviewKeepsChangesetOrder
  • TestRunPreviewJSON_ProviderDirectoryKeepsChangesetOrder
  • TestGetDiffSetWalksChangesetOrder
  • TestProviderDirPrefix

Updated: TestOutputPreviewText_WithExcludedFiles. Since #1241 its vendor/lib.go entry is provider_directory, which this PR renders as the summary line, so the test now expects that line instead of a per-row path.

Manual: built ocr and ran ocr review --preview and ocr review --preview --format json against a scratch repo containing a.go, foo_test.go, a deep target/.pnpm/... path, target/demo.go, and vendor/lib.go. Text output is shown above. The JSON files array lists all 5 paths in Git order.

Also checked against a 3,421-file provider tree (the excluded section stays at one summary line; JSON keeps all 3,423 entries in git diff order), commit and range modes, and a gitignored tracked file sitting between entries.

Pre-commit ocr review --audience agent could not run locally (no LLM endpoint configured).

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA
  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

AI/LLM disclosure: Grok 4.6 (Grok Build / xAI) was used to implement the fix and tests and to draft this description. Claude Code (Claude Opus 5) was used afterwards to check the PR against #1236 and to correct two code comments and the FAQ wording. I reviewed the diff. Commits carry no AI attribution.

Related Issues

Closes #1236

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s).

@Parikalp-Bhardwaj

Copy link
Copy Markdown
Contributor

@jimpablo I was working on the same issue as well, but you pushed the PR first.

One thing i noticed is that the FAQ still says ocr review --preview lists every candidate file.

With this change, provider-directory entries are summarized in text output, while JSON still keeps every entry.

Should we update the preview example/wording in pages/src/content/docs/*/faq.md so the docs match the new behavior? @wu21-web

@jimpablo

Copy link
Copy Markdown
Contributor Author

Thanks @Parikalp-Bhardwaj — sorry for the overlap, and thanks for reading the FAQ against this change.

I double-checked against #1236 (and the same author's follow-ups) before deciding not to touch the docs here:

So the table row for provider_directory is still the documented contract. The one sentence that is slightly stale is "lists every candidate file": text now collapses that class, while --format json still lists every entry, as #1236 required.

Happy to add a short wording note in all five faq.md locales in this PR if @wu21-web wants that here. I would keep the sample schematic rather than replacing it with a full CLI dump, unless you'd rather take the docs in a follow-up.

@wu21-web

Copy link
Copy Markdown
Contributor

@jimpablo @Parikalp-Bhardwaj You should always document these changes.

@jimpablo

Copy link
Copy Markdown
Contributor Author

Thanks @wu21-web — will do. Updating the five FAQ locales in this PR so the preview wording and sample match the new text/JSON split.

@Parikalp-Bhardwaj

Copy link
Copy Markdown
Contributor

@jimpablo @Parikalp-Bhardwaj You should always document these changes.

I agree, since this changes user-visible preview behavior, the FAQ should be updated in the same PR so the documented behavior stays accurate.

@jimpablo

Copy link
Copy Markdown
Contributor Author

Agreed — that's now in this PR. 487274f updates all five FAQ locales: the wording and sample show the terminal summary line, and note that --format json still lists every entry.

@lizhengfeng101

Copy link
Copy Markdown
Contributor

@jimpablo merge conflicts

Size the path column per section, render provider_directory entries as
one summary line in text output, and keep preview entries in Git order.
Terminal preview summarizes provider-directory files; JSON still lists
every entry. Sync the wording and sample across all five locales.
Use --format json in a test comment, separate the totals and ordering
reasons in preview.go, and stop saying preview lists every candidate file.
@jimpablo
jimpablo force-pushed the fix/preview-provider-dir-aggregate branch from b283afa to 0de1f8b Compare September 15, 2026 08:31
@wu21-web

Copy link
Copy Markdown
Contributor

Can I review this?

@jimpablo

Copy link
Copy Markdown
Contributor Author

@lizhengfeng101 Rebased on main and fixed the conflicts. Had to update one existing test after #1241 landed, see the description.

@lizhengfeng101 lizhengfeng101 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@kefu84510-cmd kefu84510-cmd left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hello

@lizhengfeng101
lizhengfeng101 merged commit 5589990 into alibaba:main Sep 15, 2026
15 checks passed
Githab-capibara added a commit to Githab-capibara/open-code-review that referenced this pull request Sep 17, 2026
…er (alibaba#1242)

* fix(preview): collapse provider-directory rows and keep changeset order

Size the path column per section, render provider_directory entries as
one summary line in text output, and keep preview entries in Git order.

* docs(faq): document collapsed provider-directory preview rows

Terminal preview summarizes provider-directory files; JSON still lists
every entry. Sync the wording and sample across all five locales.

* docs(preview): tighten comment and FAQ wording

Use --format json in a test comment, separate the totals and ordering
reasons in preview.go, and stop saying preview lists every candidate file.
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.

fix(cli): provider-directory entries flood the preview and break Will review alignment

5 participants