Skip to content

Conversation

@abdulrehmann231
Copy link
Collaborator

@abdulrehmann231 abdulrehmann231 commented Jan 22, 2026

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-preview component even though all blocks were resolved.

Root Cause

Path normalization mismatch between:

  • File paths stored in fileActionStatuses (normalized)
  • File paths used in generated-files-preview.tsx for comparison (not normalized)

This caused the filter to miss resolved files because the paths didn't match exactly.

Solution

  1. Consistent Path Normalization: Use normalizePath utility consistently across all relevant files

    • useCodeDiffer.ts: Normalize paths when calling onDiffResolved and onDiffChange
    • project-layout.tsx: Use normalizePath in DiffSessionHandler
    • generated-files-preview.tsx: Normalize file.path when checking fileActionStatuses
  2. Code Cleanup: Removed debug console.log statements

Changes Made

web/components/project/hooks/useCodeDiffer.ts

  • Import normalizePath utility
  • Use normalizePath(model.uri.fsPath) instead of manual path replacement
  • Normalize paths in both checkAndResolve callbacks (in handleApplyCode and restoreFromSnapshot)
  • Remove debug console.log statements

web/components/project/chat/components/generated-files-preview.tsx

  • Import normalizePath utility
  • Normalize file.path when checking fileActionStatuses to ensure proper matching

web/components/project/project-layout.tsx

  • Import normalizePath utility
  • Use normalizePath in DiffSessionHandler.markResolved for consistency
  • Remove debug console.log statements

How It Works Now

  1. User resolves last diff block → WidgetManager calls onWidgetsChanged(0)
  2. useCodeDiffer detects count = 0 → calls onDiffResolved(normalizePath(model.uri.fsPath), status)
  3. DiffSessionHandler.markResolved normalizes path → calls markFileActionStatus
  4. markFileActionStatus stores normalized path in fileActionStatuses[messageId][normalizedPath]
  5. generated-files-preview.tsx checks fileActionStatuses[messageId]?.[normalizePath(file.path)] → correctly filters out resolved files

Issue

Closes #214

@vercel
Copy link

vercel bot commented Jan 22, 2026

@abdulrehmann231 is attempting to deploy a commit to the jamesmurdza's projects Team on Vercel.

A member of the Team first needs to authorize it.

@abdulrehmann231 abdulrehmann231 mentioned this pull request Jan 22, 2026
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.

[AI Chat] : preview section not being updated

1 participant