# Changelog

## [2025-01-XX] - VPC Endpoints Documentation

### Added
- **VPC Endpoints Setup Guide**: Created comprehensive documentation for configuring VPC endpoints for private subnet deployment
- **Infrastructure Documentation**: Documented required VPC endpoints for AWS services (S3, Secrets Manager, SSM, Rekognition)
- **Cost Analysis**: Added cost comparison between VPC endpoints and NAT Gateway

### Technical Details
- Application deployed in private subnet requires VPC endpoints to access AWS services
- Required endpoints: S3 Gateway Endpoint (free), Secrets Manager, SSM, and Rekognition Interface Endpoints
- Estimated monthly cost: ~$21.60/month (vs ~$32.40/month for NAT Gateway)
- All AWS service calls stay within AWS network (more secure, lower latency)

### Files Added
- `VPC_ENDPOINTS_SETUP.md`: Complete guide for VPC endpoint configuration

## [Latest] - Auto-Launch Applications Feature

### Added
- **Auto-launch applications on playlist load**: Applications now automatically launch when playlists are loaded based on platform and start_point
- **Platform-specific launching**: 
  - Web applications: Launches in Google Chrome kiosk mode (`google-chrome --kiosk <start_point>`)
  - Desktop applications: Launches using shell execution (`subprocess.run([start_point], shell=True)`)
- **MySQL function enhancement**: Added `get_playlist_names_with_app_details()` to fetch playlists with application details
- **Application details storage**: Playlist manager now stores application start_point, platform, and app_name for each playlist
- **Manual launch method**: Added `launch_application_for_playlist()` method for manual application launching

### Technical Details
- Applications launch automatically on program startup (first playlist)
- Applications launch when a playlist is selected from the dropdown
- Fallback handling for Chrome launch failures (regular mode if kiosk fails)
- Comprehensive error handling and logging for all launch scenarios
- Maintains backward compatibility with existing playlist functionality

### Files Modified
- `autoclicker/playlist_manager.py`: Added auto-launch functionality and application details fetching
- `mysql/mysql_client.py`: Added `get_playlist_names_with_app_details()` function

## [2025-11-12] - Rekognition result reuse across Xero flows

### Changed
- **Single Rekognition pass per page**: Payment precheck, Batch precheck, and Xero Attach Files label detection now share one Rekognition tile result for the same screen.
- **Tile cache**: Introduced a tile `detect_text` cache built once and reused for multiple queries on the identical screenshot.

### Technical Details
- Added `build_tile_detect_text_cache` and `find_text_coordinates_from_tile_cache` in `autoclicker/rekognition_tiler.py`.
- Payment/Batch prechecks build or reuse `analyzer._last_rekognition_tile_cache` and search phrases from the cache.
- Attach-files flow prefers the existing cache before creating a new one, reducing redundant Rekognition calls.

### Files Modified
- `autoclicker/rekognition_tiler.py`
- `autoclicker/xero_supporting_docs.py`
- `autoclicker/xero_util/attach_files_flow.py`

### Follow-up [2025-11-12] - File dialog optimization

### Changed
- **Single Rekognition pass for filenames**: Within the files dialog, only the first filename search builds a tile cache; all subsequent filenames reuse the cached results. Separate Rekognition is still used for Download/Save/Close steps.

### Files Modified
- `autoclicker/xero_util/attach_files_dialog_utils.py`

### Fix [2025-11-12] - Ensure first filename always triggers Rekognition

### Changed
- The first filename in the dialog now always performs a Rekognition tiling pass (builds cache and anchor), even if a previous screen-level cache exists from prechecks. Subsequent filenames reuse that cache.

### Enhancement [2025-11-12] - Reuse Download/Save/Close coordinates within dialog

### Changed
- After the first successful click of Download, Save, and Close 'X' in the file dialog, their screen coordinates are cached and reused for the remaining files in the same dialog. This avoids repeated searches and speeds up processing.

### Tweak [2025-11-12] - Delay before cached clicks

### Changed
- Added a 0.5s delay before clicking cached Download/Save/Close coordinates to improve stability on slower UIs.

### Requirements
- MySQL database must have `application` table with `start_point` and `platform` columns
- For web applications: Google Chrome must be installed and accessible via PATH
- For desktop applications: Executable paths must be valid and accessible 

## [2025-11-13] - Fix: Click wrapped (two-line) filenames in Xero Files dialog

### Changed
- Enabled partial LINE fallback for every filename in the dialog, not just the first.
- Cached the full `detect_text` result per dialog so subsequent files reuse it without extra Rekognition calls.

### Why
- Some long filenames wrap onto two lines in the dialog; exact/regex matches may fail because no single LINE contains the whole name.
- We now accept the longest LINE that is a soft-normalized substring of the filename and click it reliably.

### Files Modified
- `autoclicker/xero_util/attach_files_dialog_utils.py`

## [2025-12-10] - Fix: MySQL password rotation without restart

### Changed
- **Live MySQL config usage**: `mysql/mysql_client.py` now reads `MYSQL_CONFIG` directly from the `mysql.config` module on every connection.
- **Credential refresh behavior**: When `refresh_mysql_config()` runs after an auth/connection error (for example, after RDS password rotation), new connections automatically use the rotated password without needing to restart the app.

### Why
- Previously, `mysql/mysql_client.py` imported a copy of `MYSQL_CONFIG` at import time; when `refresh_mysql_config()` replaced the config dict, the MySQL client kept using the old credentials until process restart.
- This change ensures the watcher’s “refresh credentials and retry” logic works as intended and removes the need to stop/start the app after password rotation.