Skip to content

Latest commit

 

History

History
166 lines (126 loc) · 5.93 KB

File metadata and controls

166 lines (126 loc) · 5.93 KB

UI Cleanup and Default Settings Update

Summary

Removed old AST diff components and updated default filtering/sorting to improve user experience.

Changes Made

1. Removed Old AST Diff Components

Deleted Files:

  • nextjs-frontend/src/components/diff/ModernASTDiffViewer.tsx - Old broken AST diff viewer
  • nextjs-frontend/src/components/diff/InteractiveDiffViewer.tsx - Unused interactive diff viewer

Rationale:

  • The ModernASTDiffViewer was using the old broken AST diff algorithm
  • Now that AST diff is fixed and integrated into the main diff viewer, these separate components are redundant
  • Simplifies the codebase and reduces confusion

2. Updated BeyondCompareFunctionDiff Component

File: nextjs-frontend/src/components/diff/BeyondCompareFunctionDiff.tsx

Removed:

  • Import of ModernASTDiffViewer
  • Import of Zap icon (was only used for AST Diff button)
  • showModernDiff state variable
  • handleModernDiffClick function
  • "AST Diff" buttons (2 instances)
  • ModernASTDiffViewer modal at the end of the component

Changed:

  • Default filter: Changed from 'all' to 'modified'

    // Before:
    const [filterType, setFilterType] = useState<string>('all');
    
    // After:
    const [filterType, setFilterType] = useState<string>('modified');
  • Button labels: Changed "AST Diff" buttons to "View Diff"

    • More intuitive - users just want to see the diff, not worry about the algorithm
    • Consistent with the single unified diff viewer approach

Added:

  • Sorting by similarity: Functions are now sorted by most different first

    // Sort filtered pairs by similarity (most different first)
    filtered.sort((a, b) => {
      const simA = a.similarity ?? 1.0;
      const simB = b.similarity ?? 1.0;
      return simA - simB; // Lower similarity first (most different)
    });
    
    // Sort function pairs within each file group by similarity
    filteredGroups.forEach(pairs => {
      pairs.sort((a, b) => {
        const simA = a.similarity ?? 1.0;
        const simB = b.similarity ?? 1.0;
        return simA - simB; // Lower similarity first (most different)
      });
    });
  • Empty file filtering: Files with no functions matching the current filter are hidden

    // Remove empty file groups (files with no functions matching the filter)
    const nonEmptyGroups = new Map<string, FunctionPair[]>();
    filteredGroups.forEach((pairs, fileKey) => {
      if (pairs.length > 0) {
        nonEmptyGroups.set(fileKey, pairs);
      }
    });
    • When viewing "Modified" functions, files with only unchanged functions are hidden
    • Reduces clutter and focuses attention on relevant files
    • Files reappear when filter is changed to "All" or other types

3. Updated page.tsx

File: nextjs-frontend/src/app/page.tsx

Removed:

  • Import of InteractiveDiffViewer (no longer exists)

User Experience Improvements

Before:

  1. Overwhelming: All functions shown by default (including unchanged)
  2. Cluttered: All files shown even if they have no matching functions
  3. Confusing: Two diff buttons ("Details" and "AST Diff")
  4. Poor prioritization: Functions shown in arbitrary order
  5. Redundant components: Multiple diff viewers doing similar things

After:

  1. Focused: Only modified functions shown by default
  2. Clean: Only files with matching functions are displayed
  3. Simple: Single "View Diff" button
  4. Smart prioritization: Most different functions shown first
  5. Streamlined: One unified diff viewer with algorithm toggle

Default Behavior

When users open the comparison view:

  1. Filter: Only "Modified" functions are shown

    • Users can still click "All" to see everything
    • Other filters: Added, Deleted, Moved, Renamed, Unchanged
  2. Sort: Functions sorted by lowest similarity first

    • Most different (and likely most important) changes appear at the top
    • Within each file, functions also sorted by difference
  3. Diff Viewer: Single unified viewer with:

    • LCS algorithm by default (fast, reliable)
    • AST algorithm toggle available (adds semantic context)
    • Ignore Whitespace option
    • Unified and Side-by-Side view modes

Benefits

For Users:

  • Less overwhelming - Focus on what changed
  • Better prioritization - See biggest changes first
  • Simpler interface - One button, clear purpose
  • Faster workflow - Default settings match common use case

For Developers:

  • Less code - Removed ~500 lines of redundant components
  • Easier maintenance - Single diff viewer to maintain
  • Clearer architecture - One way to view diffs
  • Better tested - Focus testing on one component

Migration Notes

No breaking changes - All functionality is preserved:

  • AST diff is still available (via algorithm toggle in the unified viewer)
  • All view modes still work (unified, side-by-side)
  • All filters still available (just different default)
  • Sorting can be changed if needed (future enhancement)

Future Enhancements

Potential improvements based on this foundation:

  1. User preferences - Remember filter/sort settings in localStorage
  2. Sort options - Add UI to toggle between different sort orders
  3. Smart defaults - Auto-expand files with most changes
  4. Keyboard shortcuts - Navigate between functions quickly
  5. Diff presets - Save common filter/sort combinations

Testing

To verify the changes:

  1. Start comparison - Should show only modified functions by default
  2. Check order - Most different functions should appear first
  3. Click "View Diff" - Should open the unified diff viewer
  4. Toggle filters - All filter options should still work
  5. No errors - Console should be clean (no missing component errors)

Conclusion

These changes make the UI more focused and user-friendly while simplifying the codebase. The default settings now match the most common use case: reviewing what changed, starting with the biggest differences.