# New Knowledge Base

## 2025-01-XX — VPC Endpoints for Private Subnet Deployment
- The application is deployed in a private subnet and requires VPC endpoints to access AWS services.
- Required AWS services: Secrets Manager (RDS credentials), SSM Parameter Store (RDS connection details), S3 (screenshots/files), and Rekognition (text detection).
- VPC endpoints are required because private subnets don't have direct internet access.
- Required endpoints:
  - S3 Gateway Endpoint (free) - for S3 access
  - Secrets Manager Interface Endpoint - for credential retrieval
  - SSM Interface Endpoint - for parameter store access
  - Rekognition Interface Endpoint - for image analysis
- Estimated cost: ~$21.60/month (vs ~$32.40/month for NAT Gateway).
- Benefits: Traffic stays within AWS network (more secure), lower latency, no data transfer charges for AWS-to-AWS traffic.
- See `VPC_ENDPOINTS_SETUP.md` for complete configuration guide.

## Playback: Merged Click and Keyboard Event Timeline
- Playback loads both Clicks and KeyboardEvents from the database for a playlist.
- Events are merged and sorted by timestamp, so playback order matches original recording.
- Mouse clicks are simulated with pyautogui.click.
- Keyboard events are simulated with pyautogui.keyDown (for 'press') and pyautogui.keyUp (for 'release').
- This ensures accurate reproduction of user input. 
- Playlist loading is now cloud-first: playlists are loaded only from Supabase, and SQLite is disabled for playlist loading.

## UI/UX Knowledge
- A screenshot (📸) icon button was added to the minimized view, next to the record/play/stop/maximize icons. It calls on_manual_screenshot for quick manual screenshot capture from the compact UI. 
- Adding a playlist is now cloud-only: duplicate checks and creation are performed exclusively in Supabase, with all SQLite logic disabled for this action. 

## 2025-11-12 — Rekognition result reuse for Xero flows
- We added a reusable Rekognition tile `detect_text` cache per screenshot to avoid multiple calls on the same page.
- Payment precheck, Batch precheck, and Xero Attach Files label checks reuse a single cache (`analyzer._last_rekognition_tile_cache`) so “Transaction: Payment”, “Transaction: Spend Money”, “Attach files/Files” all search the same Rekognition response.
- This improves speed and reduces AWS Rekognition usage without changing the click behavior or matching strictness.

### 2025-11-12 — Filenames in dialog reuse
- When clicking filenames inside the Xero files dialog, only the first filename triggers a Rekognition tiling pass to build the cache; the rest reuse the same cached responses for coordinate lookup.
- Download, Save modal, and Close X retain their own dedicated Rekognition checks as they occur on different screens or states.

### 2025-11-13 — Wrapped filename clicking reliability
- Long filenames in the Xero Files dialog can wrap across two lines, so no single LINE equals the full filename.
- We now perform a partial-LINE fallback for every file: choose the longest LINE whose soft-normalized text is a substring of the filename (without extension).
- To keep it efficient, the full `detect_text` response is computed once per dialog and cached on `analyzer._last_rekognition_tile_cache["full_detect_text"]` for reuse by the remaining files.

### 2024-06-09
- All Supabase-related popups (info, error, and text popups) have been disabled for production use. To re-enable, uncomment the relevant messagebox or popup code in `main.py`. 
- Minimized view refactored: playlist selection removed, layout is now smaller and vertical, and buttons are stacked vertically under the logo. 
- Minimized view buttons made smaller for a more compact UI. 
- App now starts in the middle of the left side of the screen for both minimized and full views. 
- Blue indicator bar is now shown at the top of the minimized view when the app is playing. 

## 2025-12-10 — MySQL password rotation & live config behavior
- `mysql.config.refresh_mysql_config()` refreshes RDS credentials (host, user, password, etc.) from AWS or local `.env` and replaces the global `MYSQL_CONFIG` dict.
- To ensure all new DB connections use the rotated password without an app restart, `mysql/mysql_client.get_mysql_connection()` now reads `MYSQL_CONFIG` directly from the `mysql.config` module on every call instead of keeping its own copy.
- This means that when the watcher in `autoclicker/direct_integration.py` catches an auth/connection error and calls `refresh_mysql_config()`, subsequent `get_mysql_connection()` calls immediately pick up the new password.