Fix renamed Markdown preview comparisons - #180
Conversation
Resolve the parent-side path from git rename metadata before rendering Markdown comparisons so moved pages are not treated as newly added files. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2c491b8-93bb-4880-bcfc-a3fd1f637b62
There was a problem hiding this comment.
Pull request overview
Fixes renamed Markdown previews by resolving and rendering the parent file from its previous repository path.
Changes:
- Detects renamed files using Git rename metadata.
- Uses the former path for parent-side Liquid context and rendering.
- Adds unit and integration regression coverage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/RepoSyncRadar.Core/Services/Preview/DocsWorktreeManager.cs |
Resolves previous paths from Git rename metadata. |
src/RepoSyncRadar.Core/Services/Preview/PreviewCoordinator.cs |
Loads renamed parent content from its former path. |
tests/RepoSyncRadar.Integrations.Tests/Preview/DocsWorktreeManagerTests.cs |
Tests rename-status parsing. |
tests/RepoSyncRadar.Integrations.Tests/Preview/PreviewCoordinatorTests.cs |
Tests end-to-end renamed-file comparison behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Analyze renamed Markdown files in the background and surface rename and no-body-change labels in the file list before a preview is opened. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2c491b8-93bb-4880-bcfc-a3fd1f637b62
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/RepoSyncRadar.App/Components/CommitDetail.razor:562
- This fan-out is unbounded, and every analysis that cannot read the new path at the parent calls
ResolvePreviousPathAsync, which runs and parses the same whole-commitgit diff --name-statusagain. A rename-heavy commit can therefore launch N duplicate diff processes plus N Liquid-context loads concurrently when merely selected, causing avoidable CPU/I/O spikes. Resolve/cache the rename map once per SHA pair and use bounded concurrency for the per-file body analysis.
var analyses = files.Select(async file => new
{
file.Path,
Summary = await coordinator.AnalyzeMarkdownFileChangeAsync(
src/RepoSyncRadar.Core/Services/Preview/PreviewCoordinator.cs:452
AnalyzeDetailsonly compares Liquid-expanded Markdown; it does not perform the path-dependent AUTOTITLE rewriting used byMarkdownPreviewRenderer. If an unchanged relative[AUTOTITLE](...)resolves to different target pages after moving directories, the before/after previews render different labels but this returnsHasRenderedBodyChanges: false, so the file row incorrectly says “No body changes.” Include each side's file path when normalizing rendered content (or otherwise compare path-resolved AUTOTITLE labels) before setting this flag.
var versionImpacts = DocsVersionImpactAnalyzer.AnalyzeDetails(
sources.BeforeMarkdown,
sources.BeforeLiquid,
sources.AfterMarkdown,
sources.AfterLiquid);
Reuse one rename map per commit, bound concurrent file analysis, and include path-dependent AUTOTITLE labels when deciding whether rendered body content changed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2c491b8-93bb-4880-bcfc-a3fd1f637b62
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.
Suppressed comments (1)
src/RepoSyncRadar.Core/Services/Preview/PreviewCoordinator.cs:640
- The old path is only supplied for the document currently being rendered; the comparison document still has no path of its own.
ApplyRenderedMarkdownDifftherefore rewrites both sides' relative AUTOTITLE links with the current pane'srepoPath(MarkdownPreviewRenderer.cs:2297-2301). For a path-only rename such as the new analyzer test, the analyzer reports a rendered-body change, but each pane compares both versions under one path and emits norsr-rendered-diff-*marker. Pass the counterpart repo path throughRenderDocument/ApplyRenderedMarkdownDiff(new path when rendering before, old path when rendering after) and cover this renamed-path renderer case.
sources.BeforeFilePath,
Pass the counterpart repository path through Markdown diff rendering so relative AUTOTITLE labels changed by a rename receive visible diff markers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d2c491b8-93bb-4880-bcfc-a3fd1f637b62
Summary
RenamedplusNo body changesin the file list before a preview is opened.git diff --name-status --find-renames, while reusing the same source-loading and rendered-body analysis as the preview path.Related Issues
N/A - no issue to close.
Scope
Validation
dotnet build RepoSyncRadar.sln -warnaserrordotnet test RepoSyncRadar.sln --timeout 10m -- --filter-not-trait Category=Manualdotnet test tests\RepoSyncRadar.Integrations.Tests\RepoSyncRadar.Integrations.Tests.csprojN/A - no UI/WebView changes: selected commit3de47bdandcontent/copilot/how-tos/copilot-integrations/integrate-cloud-agent-with-azure-boards.mdin the running app. Before opening WebView2, the file row showedリネームand本文変更なし; no local preview target had been opened. Opening the preview still loaded the old path, reported no rendered body difference, and reported one frontmatter addition.Risk And Rollback
+1/-0while the file row explains that the rendered body is unchanged.Release Notes
Release note draft:
Renamed documentation files now show whether their rendered body is unchanged before opening the Markdown comparison, and previews compare moved pages against their previous path.