Skip to content

Conversation

Copy link

Copilot AI commented Jul 15, 2025

Problem

The TaskHub application was previously only functional in browsers supporting the File System Access API (Chrome, Edge), effectively blocking users on Firefox, Safari, and other browsers. Users would see a warning message stating the app was incompatible with their browser.

Before: Browser incompatibility warning

Solution

Implemented a hybrid file system approach that automatically detects browser capabilities and seamlessly switches between modern and fallback file operations:

Modern Browsers (Chrome, Edge)

  • Uses File System Access API for direct file system integration
  • Auto-saving with persistent file handles
  • No downloads folder clutter

Modern Mode: File System Access API

Legacy Browsers (Firefox, Safari, others)

  • Uses traditional <input type="file"> for opening files
  • Downloads files to default download folder
  • Clear user feedback about compatibility mode
  • Added download button for manual file saving

Fallback Mode: Universal compatibility

Key Changes

1. Cross-Browser File Utilities (FileUtils.ts)

export const isFileSystemAccessSupported = (): boolean => {
  return 'showOpenFilePicker' in window && 'showSaveFilePicker' in window;
};

export const downloadFile = (content: string, filename: string) => {
  // Creates blob and triggers download for fallback mode
};

export const createFileInput = (accept: string): Promise<FileList | null> => {
  // Creates traditional file input for opening files
};

2. Hybrid File Service (FileService.ts)

  • Automatic Detection: Detects browser capabilities on initialization
  • Modern Mode: Uses File System Access API when available
  • Fallback Mode: Uses traditional file input/download when needed
  • Seamless Switching: No user action required

3. Updated UI (FileSelector.tsx)

  • Smart Messaging: Shows "Compatibility Mode" instead of warning
  • Context-Aware Controls: Displays appropriate buttons for each mode
  • Download Button: Added for fallback mode file saving
  • Improved Styling: Better visual feedback for both modes

Benefits

Universal Compatibility: Now works on all modern browsers
Seamless Experience: Automatic mode detection and switching
No Breaking Changes: Existing Chrome/Edge users unaffected
Full Functionality: All features work in both modes
Better UX: Clear messaging instead of blocking warnings

Testing

  • ✅ Build successfully compiles
  • ✅ Modern mode tested with File System Access API
  • ✅ Fallback mode tested with file download/upload
  • ✅ Task creation and file operations work in both modes
  • ✅ Downloaded files contain correct JSON structure

Files Modified

  • src/app/utils/FileUtils.ts - New cross-browser file utilities
  • src/app/services/FileService.ts - Hybrid file service implementation
  • src/app/components/FileSelector/component.tsx - Updated UI with fallback support
  • src/app/components/FileSelector/style.css - Enhanced styling for new elements

Result: File upload now works on every browser with an optimal experience tailored to each platform's capabilities.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: tjarkpr <56918325+tjarkpr@users.noreply.github.com>
Copilot AI changed the title [WIP] Please ensure that the file upload is possible on every browser. Fix: Ensure file upload compatibility across all browsers Jul 15, 2025
Copilot AI requested a review from tjarkpr July 15, 2025 13:31
@tjarkpr tjarkpr closed this Oct 6, 2025
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.

2 participants