webdrop-bridge/WEBAPP_LOADING_FIX.md
claudi f0c96f15b8 feat: Implement default welcome page for missing web application
- Added a professional HTML welcome page displayed when no web application is configured.
- Enhanced `_load_webapp()` method to support improved path resolution for both development and bundled modes.
- Updated error handling to show the welcome page instead of a bare error message when the webapp file is not found.
- Modified unit tests to verify the welcome page is displayed in error scenarios.

build: Complete Windows and macOS build scripts

- Created `build_windows.py` for building Windows executable and optional MSI installer using PyInstaller.
- Developed `build_macos.sh` for creating macOS application bundle and DMG image.
- Added logging and error handling to build scripts for better user feedback.

docs: Add build and icon requirements documentation

- Created `PHASE_3_BUILD_SUMMARY.md` detailing the build process, results, and next steps.
- Added `resources/icons/README.md` outlining icon requirements and creation guidelines.

chore: Sync remotes script for repository maintenance

- Introduced `sync_remotes.ps1` PowerShell script to fetch updates from origin and upstream remotes.
2026-01-28 12:59:33 +01:00

4.3 KiB

WebApp Loading - Issue & Fix Summary

Problem

When running the Windows executable, the embedded web view displayed:

Error
Web application file not found: C:\Development\VS Code Projects\webdrop_bridge\file:\webapp\index.html

Root Causes

  1. Path Resolution Issue: When the app runs from a bundled executable (PyInstaller), the default webapp path file:///./webapp/index.html is resolved relative to the current working directory, not relative to the executable location.

  2. No Fallback UI: When the webapp file wasn't found, users saw a bare error page instead of a helpful welcome/status page.

Solution

1. Improved Path Resolution (main_window.py)

Enhanced _load_webapp() method to:

  • First try the configured path as-is
  • If not found, try relative to the application package root
  • Handle both development mode and PyInstaller bundled mode
  • Work with file:// URLs and relative paths
def _load_webapp(self) -> None:
    if not file_path.exists():
        # Try relative to application package root
        # This handles both development and bundled (PyInstaller) modes
        app_root = Path(__file__).parent.parent.parent.parent
        relative_path = app_root / webapp_url.lstrip("file:///").lstrip("./")
        
        if relative_path.exists():
            file_path = relative_path

2. Beautiful Default Welcome Page

Created DEFAULT_WELCOME_PAGE constant with professional UI including:

  • Status message: Shows when no web app is configured
  • Application info: Name, version, description
  • Key features: Drag-drop, validation, cross-platform support
  • Configuration guide: Instructions to set up custom webapp
  • Professional styling: Gradient background, clean layout, accessibility

3. Updated Error Handling

When webapp file is not found, the app now:

  • Shows the welcome page instead of a bare error message
  • Provides clear instructions on how to configure a web app
  • Displays the version number
  • Gives users a professional first impression

Files Modified

src/webdrop_bridge/ui/main_window.py

  • Added DEFAULT_WELCOME_PAGE HTML constant with professional styling
  • Enhanced _load_webapp() method with multi-path resolution
  • Added welcome page as fallback for missing/error conditions

tests/unit/test_main_window.py

  • Renamed test: test_load_nonexistent_file_shows_errortest_load_nonexistent_file_shows_welcome_page
  • Updated assertions to verify welcome page is shown instead of error

How It Works

Development Mode

User runs: python -m webdrop_bridge
Config: WEBAPP_URL=file:///./webapp/index.html
Resolution: C:\...\webdrop_bridge\webapp\index.html
Result: ✅ Loads local webapp from source

Bundled Executable (PyInstaller)

User runs: WebDropBridge.exe
PyInstaller unpacks to: _internal/webapp/
Resolution logic:
  1. Try: C:\current\working\dir\webapp\index.html (fails)
  2. Try: C:\path\to\executable\webapp\index.html (succeeds!)
Result: ✅ Loads bundled webapp from PyInstaller bundle

No Webapp Configured

User runs: WebDropBridge.exe
No WEBAPP_URL or file not found
Display: Beautiful welcome page with instructions
Result: ✅ Professional fallback instead of error

Testing

All 99 tests pass:

  • 99 passed in 2.26s
  • Coverage: 84%

User Experience

Before:

Error
Web application file not found: C:\...\file:\webapp\index.html

After:

🌉 WebDrop Bridge
Professional Web-to-File Drag-and-Drop Bridge

✓ Application Ready
No web application is currently configured.
Configure WEBAPP_URL in your .env file to load your custom application.

[Features list]
[Configuration instructions]
[Version info]

Configuration for Users

To use a custom web app:

# Create .env file in application directory
WEBAPP_URL=file:///path/to/your/app.html
# Or use remote URL
WEBAPP_URL=http://localhost:3000

Technical Notes

  • CSS selectors escaped with double braces {{ }} for .format() compatibility
  • Works with both relative paths (./webapp/) and absolute paths
  • Handles file:// URLs and raw file paths
  • Graceful fallback when webapp is missing
  • Professional welcome page generates on-the-fly from template

Version

  • Date Fixed: January 28, 2026
  • Executable Built: WebDropBridge.exe (195.7 MB)
  • Tests: 99/99 passing
  • Coverage: 84%