# Implementation Plan: Context Preview & Slice Editor Fixes ## Phase 1: Fix Context Preview Button Focus: Synchronize `App.context_files` to `AppController.context_files` before calling `_do_generate()` and add empty-state handling. - [ ] Task 1.1: Audit where AppController.context_files gets assigned vs App.context_files (gui_2.py vs app_controller.py) - [ ] Task 1.2: Add `_sync_context_files_to_controller` method or inline sync in Preview button handler (gui_2.py:2839-2841) - [ ] 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."` - [ ] Task 1.N: Write tests for Preview button behavior with empty and populated context - [ ] Task 1.X: Conductor - User Manual Verification ## Phase 2: Fix Slices Button (Text Viewer Window) Focus: Add `render_text_viewer_window` call to the render loop so Slices button properly opens the Text Viewer. - [ ] Task 2.1: Find where `render_text_viewer_window` should be called in render loop (currently defined but never invoked) - [ ] 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) - [ ] Task 2.3: Verify Slices button at gui_2.py:3148-3158 sets all required state (`show_text_viewer`, `text_viewer_content`, `text_viewer_title`, `text_viewer_type`) - [ ] Task 2.N: Write tests for Slices button opening Text Viewer - [ ] Task 2.X: Conductor - User Manual Verification ## Phase 3: Fix Inspect Button (AST Inspector Modal) Focus: Verify `render_ast_inspector_modal` is called correctly and integrates with the popup pattern. - [ ] Task 3.1: Audit `render_ast_inspector_modal` popup pattern (gui_2.py:2900-3036) vs `_render_window_if_open` patterns - [ ] Task 3.2: Ensure `render_ast_inspector_modal(app)` is called in `render_context_modals` and uses correct popup lifecycle - [ ] Task 3.3: Test Inspect button with a .cpp file to verify AST tree renders - [ ] Task 3.N: Write tests for Inspect button opening AST Inspector modal - [ ] Task 3.X: Conductor - User Manual Verification ## Phase 4: Integration & Regression Testing Focus: Ensure all three buttons work in concert and no regressions in context composition panel. - [ ] Task 4.1: Run existing context composition tests to verify no regressions - [ ] Task 4.2: Verify batch operations (Full/Summary/Skeleton/Outline/Masked/None) still work - [ ] 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