Problem: Old session data had wrong format, showing count but no images
Solution:
- Added cleanupImageHistory() method
- Runs on SessionManager initialization
- Removes history items without 'filename' key
- Removes items where file doesn't exist
- Validates file paths (not directories)
Result:
- "Recent Images (4/10)" now correctly shows only valid entries
- Old/invalid history entries automatically removed
- Gallery only displays images that actually exist
- No more empty gallery with non-zero count
Backwards Compatibility:
- Handles migration from old session format
- Gracefully removes corrupted history data
- Fresh sessions start with clean history
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
Fixed two errors in Recent Images gallery:
1. Undefined array key "filename" (index.php:1053)
- Added check: isset($historyItem['filename'])
- Skip history items without filename key
- Prevents warning on legacy session data
2. file_get_contents() reading directory (session_manager.php:123)
- Added is_file() check before file_exists()
- Ensures path is a file, not directory
- Returns null for invalid paths
- Also added is_file() check for metadata file
Additional Improvements:
- Added isset() check for expires_at in metadata
- More robust error handling in getImage()
- Graceful degradation for corrupted history data
Result: No more PHP warnings in Recent Images section
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
New Features:
- Track last 10 generated images per session
- Display thumbnail gallery below main image
- Click any thumbnail to download that image
- Timestamps show when each image was created
- Hover effects highlight thumbnails
UI Components:
- Responsive grid layout (auto-fill 120px thumbnails)
- Hover overlay with timestamp
- Golden border on hover
- Shows count: "Recent Images (X/10)"
SessionManager Updates:
- addToImageHistory() - Track images (max 10)
- getImageHistory() - Retrieve history array
- restoreImageFromHistory() - Restore previous image
- Auto-adds to history when setCurrentImage() called
User Experience:
- Easy access to recent generations
- Quick downloads without re-generating
- Visual timeline of session work
- 24-hour persistence (with images)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>