# 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.

- [x] Task 1.1: Update `FileItem` dataclass/model to include `auto_aggregate` and `force_full` flags. (d7a6ba7)
- [x] Task 1.2: Modify `project_manager.py` to parse and serialize these new flags. (d7a6ba7)

## Phase 2: Context Builder Updates
Focus: Make the context aggregation logic respect the new flags.

- [x] Task 2.1: Update `aggregate.py` to filter out files where `auto_aggregate` is False. (d7a6ba7)
- [x] Task 2.2: Modify skeleton generation logic in `aggregate.py` to send full content when `force_full` is True. (d7a6ba7)
- [x] Task 2.3: Add support for manual 'Context' role injections. (d7a6ba7)

## Phase 3: Gemini Cache Tracking
Focus: Track and expose API cache state.

- [x] Task 3.1: Modify `ai_client.py`'s Gemini cache logic to record which file paths are in the active cache. (d7a6ba7)
- [x] Task 3.2: Create an event payload to push the active cache state to the GUI. (d7a6ba7)

## Phase 4: UI Refactoring
Focus: Update the Files & Media panel and event handlers.

- [x] Task 4.1: Refactor the Files & Media panel in `gui_2.py` from a list to an ImGui table. (d7a6ba7)
- [x] Task 4.2: Implement handlers in `_process_pending_gui_tasks` to receive cache state updates. (d7a6ba7)
- [x] Task 4.3: Wire the table checkboxes to update models and trigger project saves. (d7a6ba7)

## Phase 5: Testing & Verification
Focus: Ensure stability and adherence to the architecture.

- [x] Task 5.1: Write unit tests verifying configuration parsing, aggregate flags, and cache tracking. (d7a6ba7)
- [x] Task 5.2: Perform a manual UI walkthrough. (d7a6ba7)
