# Implementation Plan: Context Preview & Slice Editor Fixes

## Phase 1: Fix Context Preview Button [checkpoint: 9ea20d0]

Focus: Synchronize `App.context_files` to `AppController.context_files` before calling `_do_generate()` and add empty-state handling.

- [x] Task 1.1: Audit where AppController.context_files gets assigned vs App.context_files (gui_2.py vs app_controller.py)
- [x] Task 1.2: Add `_sync_context_files_to_controller` method or inline sync in Preview button handler (gui_2.py:2839-2841)
- [x] Task 1.3: Add empty-state guard - if context_files is empty, set `app.context_preview_text = "# Context Composition Empty\n\nNo files have been added to the context composition yet."`
- [x] Task 1.N: Write tests for Preview button behavior with empty and populated context
## Phase 2: Fix Slices Button (Text Viewer Window) [checkpoint: 9ea20d0]

Focus: Add `render_text_viewer_window` call to the render loop so Slices button properly opens the Text Viewer.

- [x] Task 2.1: Find where `render_text_viewer_window` should be called in render loop (currently defined but never invoked)
- [x] Task 2.2: Add `render_text_viewer_window(app)` to render_context_modals or main render loop (gui_2.py:5275+ or after line 1238)
- [x] Task 2.N: Write tests for Slices button opening Text Viewer

## Phase 3: Fix Inspect Button (AST Inspector Modal) [checkpoint: b807c03]

Focus: Verify `render_ast_inspector_modal` is called correctly and integrates with the popup pattern.

- [x] Task 3.1: Audit `render_ast_inspector_modal` popup pattern (gui_2.py:2900-3036) vs `_render_window_if_open` patterns
- [x] Task 3.2: Ensure `render_ast_inspector_modal(app)` is called in `render_context_modals` and uses correct popup lifecycle
- [x] Task 3.N: Write tests for Inspect button opening AST Inspector modal

## Phase 4: Integration & Regression Testing [in_progress]

Focus: Ensure all three buttons work in concert and no regressions in context composition panel.

- [x] Task 4.1: Run existing context composition tests to verify no regressions
- [x] Task 4.2: Verify batch operations (Full/Summary/Skeleton/Outline/Masked/None) still work
- [x] Task 4.3: Verify Add Files, Del buttons still work
- [ ] Task 4.4: Full render test suite (batch of 4)
- [ ] Task 4.X: Conductor - User Manual Verification