# Implementation Plan: Enhanced Context Control & Cache Awareness (enhanced_context_control_20260307) > **Reference:** [Spec](./spec.md) | [Architecture Guide](../../../docs/guide_architecture.md) ## Phase 1: Data Model & Project Configuration Focus: Update the underlying structures to support per-file flags. - [ ] Task 1.1: Update `FileItem` dataclass/model to include `auto_aggregate` and `force_full` flags. - [ ] Task 1.2: Modify `project_manager.py` to parse and serialize these new flags in `manual_slop.toml` or `project.toml`. Ensure backward compatibility with existing simple file lists. ## Phase 2: Context Builder Updates Focus: Make the context aggregation logic respect the new flags. - [ ] Task 2.1: Update `aggregate.py` to filter out files where `auto_aggregate` is False. - [ ] Task 2.2: Modify skeleton generation logic in `aggregate.py` to send full content when `force_full` is True. - [ ] Task 2.3: Add support for manual 'Context' role injections to bypass `auto_aggregate` restrictions for specific turns. ## Phase 3: Gemini Cache Tracking Focus: Track and expose API cache state. - [ ] Task 3.1: Modify `ai_client.py`'s Gemini cache logic to record which file paths/hashes are currently in the active server-side cache. - [ ] Task 3.2: Create an event payload (e.g., via `comms_log_callback` or a dedicated queue event) to push the active cache state to the GUI. ## Phase 4: UI Refactoring Focus: Update the Files & Media panel and event handlers. - [ ] Task 4.1: Refactor the Files & Media panel in `gui_2.py` from a list to an ImGui table displaying the files, their checkboxes (Auto-Aggregate, Force Full), and the Cached indicator dot. - [ ] Task 4.2: Implement handlers in `_process_pending_gui_tasks` to receive cache state updates and render the indicator dots. - [ ] Task 4.3: Wire the table checkboxes to update the in-memory models and trigger project saves (`_save_active_project()`). ## Phase 5: Testing & Verification Focus: Ensure stability and adherence to the architecture. - [ ] Task 5.1: Write unit tests verifying configuration parsing, flag-respecting context aggregation, and cache tracking. - [ ] Task 5.2: Perform a manual UI walkthrough to confirm the table displays correctly, checkboxes toggle state, and cache indicators light up when the Gemini API responds.