Skip to content

fix: address PR #26 code review comments - memory, accessibility, and performance improvements#27

Merged
rodrigogs merged 2 commits into
devfrom
copilot/sub-pr-26
Dec 26, 2025
Merged

fix: address PR #26 code review comments - memory, accessibility, and performance improvements#27
rodrigogs merged 2 commits into
devfrom
copilot/sub-pr-26

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 26, 2025

Implements 17 code review suggestions from PR #26 focusing on memory management, accessibility, and performance optimizations for the media gallery enhancement.

Memory & Performance

Video frame extraction

  • Cap canvas dimensions to 512×512 max (prevents unbounded memory usage on 4K+ videos)
  • Implement LRU cache with 20-video limit and automatic eviction
  • Fix timestamp calculation to avoid seeking to 100% (prevents codec failures):
    // Before: const timestamp = (duration / (frameCount - 1)) * currentFrameIndex;
    // After: Use 99% bounds
    const progress = currentFrameIndex / frameCount;
    timestamp = duration * progress * 0.99;

Media matching optimization

  • Strip invisible Unicode characters once during map building (was: per-message in loop)
  • Lower filename matching threshold from 10→8 chars (catches "document.pdf" without extension)

Accessibility

Keyboard navigation for video scrubbing

  • Arrow Left/Right: Navigate between frames
  • Enter/Space: Open video
  • Added onfocus/onblur handlers to trigger frame loading

Screen reader support

  • Added aria-label="Open {item.name}" to all media buttons
  • Video-specific cursor (hover:cursor-ew-resize) indicates scrubbing capability

Bug Fixes

JSZip internal property access

// Added try-catch with fallback
const zipData = (zipEntry as any)._data;
if (zipData && typeof zipData.uncompressedSize === 'number') {
  size = zipData.uncompressedSize;
}

File extension handling

  • Return empty string (not "FILE") when no extension exists
  • UI shows generic document icon for extensionless files

Frame cache cleanup

  • Call clearFrameCache() in component onDestroy (prevents memory leak on navigation)

Code Quality

  • Added duplicate filename detection with console warnings
  • Clarified SVG categorization comments (images vs documents context)
  • Fixed event listener cleanup ({ once: true } where applicable)
  • Improved file size formatting (rounded values, no decimals for bytes)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Dec 26, 2025
Co-authored-by: rodrigogs <2362425+rodrigogs@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance media gallery with video, audio, and document features fix: address PR #26 code review comments - memory, accessibility, and performance improvements Dec 26, 2025
Copilot AI requested a review from rodrigogs December 26, 2025 03:01
@rodrigogs rodrigogs marked this pull request as ready for review December 26, 2025 03:08
@rodrigogs rodrigogs merged commit 7538e53 into dev Dec 26, 2025
4 checks passed
@rodrigogs rodrigogs deleted the copilot/sub-pr-26 branch December 26, 2025 03:08
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.21.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants