fix: preview section not being updated #215
Open
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.
Fix: Remove files from preview when all diff blocks are resolved
Problem
When accepting or rejecting the last diff block (either manually via widget buttons or via Accept All/Reject All from the diff navigator), files were not being removed from the
generated-files-previewcomponent even though all blocks were resolved.Root Cause
Path normalization mismatch between:
fileActionStatuses(normalized)generated-files-preview.tsxfor comparison (not normalized)This caused the filter to miss resolved files because the paths didn't match exactly.
Solution
Consistent Path Normalization: Use
normalizePathutility consistently across all relevant filesuseCodeDiffer.ts: Normalize paths when callingonDiffResolvedandonDiffChangeproject-layout.tsx: UsenormalizePathinDiffSessionHandlergenerated-files-preview.tsx: Normalizefile.pathwhen checkingfileActionStatusesCode Cleanup: Removed debug
console.logstatementsChanges Made
web/components/project/hooks/useCodeDiffer.tsnormalizePathutilitynormalizePath(model.uri.fsPath)instead of manual path replacementcheckAndResolvecallbacks (inhandleApplyCodeandrestoreFromSnapshot)web/components/project/chat/components/generated-files-preview.tsxnormalizePathutilityfile.pathwhen checkingfileActionStatusesto ensure proper matchingweb/components/project/project-layout.tsxnormalizePathutilitynormalizePathinDiffSessionHandler.markResolvedfor consistencyHow It Works Now
WidgetManagercallsonWidgetsChanged(0)useCodeDifferdetects count = 0 → callsonDiffResolved(normalizePath(model.uri.fsPath), status)DiffSessionHandler.markResolvednormalizes path → callsmarkFileActionStatusmarkFileActionStatusstores normalized path infileActionStatuses[messageId][normalizedPath]generated-files-preview.tsxchecksfileActionStatuses[messageId]?.[normalizePath(file.path)]→ correctly filters out resolved filesIssue
Closes #214