talk2me/diagnose-pwa.py
Adolfo Delorenzo d818ec7d73 Major PWA and mobile UI improvements
- Fixed PWA installation on Android by correcting manifest.json icon configuration
- Made UI mobile-friendly with compact layout and sticky record button
- Implemented auto-translation after transcription stops
- Updated branding from 'Voice Translator' to 'Talk2Me' throughout
- Added reverse proxy support with ProxyFix middleware
- Created diagnostic tools for PWA troubleshooting
- Added proper HTTP headers for service worker and manifest
- Improved mobile CSS with responsive design
- Fixed JavaScript bundling with webpack configuration
- Updated service worker cache versioning
- Added comprehensive PWA documentation

These changes ensure the app works properly as a PWA on Android devices
and provides a better mobile user experience.
2025-06-03 12:28:09 -06:00

121 lines
4.4 KiB
Python
Executable File

#!/usr/bin/env python3
"""
PWA Diagnostic Script for Talk2Me
Checks common PWA installation issues
"""
import requests
import json
import sys
from urllib.parse import urljoin
def check_pwa(base_url):
"""Check PWA requirements for the given URL"""
if not base_url.startswith(('http://', 'https://')):
base_url = 'https://' + base_url
if not base_url.endswith('/'):
base_url += '/'
print(f"Checking PWA for: {base_url}\n")
# Check HTTPS
if not base_url.startswith('https://'):
print("❌ PWA requires HTTPS (except for localhost)")
return
else:
print("✅ HTTPS is enabled")
# Check main page
try:
response = requests.get(base_url, timeout=10)
if response.status_code == 200:
print("✅ Main page loads successfully")
else:
print(f"❌ Main page returned status code: {response.status_code}")
except Exception as e:
print(f"❌ Error loading main page: {e}")
return
# Check manifest
manifest_url = urljoin(base_url, '/static/manifest.json')
print(f"\nChecking manifest at: {manifest_url}")
try:
response = requests.get(manifest_url, timeout=10)
if response.status_code == 200:
print("✅ Manifest file found")
# Parse manifest
try:
manifest = response.json()
print(f" - Name: {manifest.get('name', 'Not set')}")
print(f" - Short name: {manifest.get('short_name', 'Not set')}")
print(f" - Display: {manifest.get('display', 'Not set')}")
print(f" - Start URL: {manifest.get('start_url', 'Not set')}")
print(f" - Icons: {len(manifest.get('icons', []))} defined")
# Check icons
for icon in manifest.get('icons', []):
icon_url = urljoin(base_url, icon['src'])
try:
icon_response = requests.head(icon_url, timeout=5)
if icon_response.status_code == 200:
print(f"{icon['sizes']}: {icon['src']}")
else:
print(f"{icon['sizes']}: {icon['src']} (Status: {icon_response.status_code})")
except:
print(f"{icon['sizes']}: {icon['src']} (Failed to load)")
except json.JSONDecodeError:
print("❌ Manifest is not valid JSON")
else:
print(f"❌ Manifest returned status code: {response.status_code}")
except Exception as e:
print(f"❌ Error loading manifest: {e}")
# Check service worker
sw_url = urljoin(base_url, '/service-worker.js')
print(f"\nChecking service worker at: {sw_url}")
try:
response = requests.get(sw_url, timeout=10)
if response.status_code == 200:
print("✅ Service worker file found")
content_type = response.headers.get('Content-Type', '')
if 'javascript' in content_type:
print("✅ Service worker has correct content type")
else:
print(f"⚠️ Service worker content type: {content_type}")
else:
print(f"❌ Service worker returned status code: {response.status_code}")
except Exception as e:
print(f"❌ Error loading service worker: {e}")
# Check favicon
favicon_url = urljoin(base_url, '/static/icons/favicon.ico')
print(f"\nChecking favicon at: {favicon_url}")
try:
response = requests.head(favicon_url, timeout=5)
if response.status_code == 200:
print("✅ Favicon found")
else:
print(f"⚠️ Favicon returned status code: {response.status_code}")
except Exception as e:
print(f"⚠️ Error loading favicon: {e}")
print("\n" + "="*50)
print("PWA Installation Tips:")
print("1. Clear browser cache and app data")
print("2. Visit the site in Chrome on Android")
print("3. Wait a few seconds for the install prompt")
print("4. Or tap menu (⋮) → 'Add to Home screen'")
print("5. Check Chrome DevTools → Application → Manifest")
print("="*50)
if __name__ == "__main__":
if len(sys.argv) > 1:
url = sys.argv[1]
else:
url = input("Enter the URL to check (e.g., talk2me.dr74.net): ")
check_pwa(url)