context preview fixes
This commit is contained in:
+5
-1
@@ -50,7 +50,11 @@ This file tracks all major tracks for the project. Each track has its own detail
|
||||
*Link: [./tracks/context_comp_slices_20260510/](./tracks/context_comp_slices_20260510/)*
|
||||
*Goal: Enhance slice visualization with visual editor, annotation support (tags/comments), and view presets.*
|
||||
|
||||
12. [~] **Track: GUI Architecture Refinement & AI-Friendliness**
|
||||
14. [ ] **Track: Context Preview & Slice Editor Fixes**
|
||||
*Link: [./tracks/context_preview_fixes_20260516/](./tracks/context_preview_fixes_20260516/)*
|
||||
*Goal: Fix Preview button generating empty content, and Inspect/Slices buttons failing to open their respective editor panels.*
|
||||
|
||||
15. [ ] **Track: GUI Architecture Refinement & AI-Friendliness**
|
||||
*Link: [./tracks/gui_architecture_refinement_20260512/](./tracks/gui_architecture_refiinement_20260512/)*
|
||||
*Goal: Reduce nesting and compactness of ImGui code in `gui_2.py`, and formalize ImGui Defer patterns.*
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "context_preview_fixes_20260516",
|
||||
"title": "Context Preview & Slice Editor Fixes",
|
||||
"type": "fix",
|
||||
"status": "planned",
|
||||
"priority": "high",
|
||||
"created": "2026-05-16",
|
||||
"depends_on": [],
|
||||
"blocks": []
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
# 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
|
||||
@@ -0,0 +1,64 @@
|
||||
# Track Specification: Context Preview & Slice Editor Fixes
|
||||
|
||||
## Overview
|
||||
|
||||
Fix critical failures in the context composition feature: Preview button generates no content, and Inspect/Slices buttons fail to open their respective editor panels.
|
||||
|
||||
## Current State Audit (as of 7f40630)
|
||||
|
||||
### Already Implemented (DO NOT re-implement)
|
||||
|
||||
1. **Context Preview Window** (`gui_2.py:5308-5320`): `render_context_preview_window` function exists and renders markdown via `markdown_helper.render(app.context_preview_text, context_id="ctx_preview")`. The window is opened via `app._render_window_if_open("Context Preview", lambda: render_context_preview_window(app))` at line 1238.
|
||||
|
||||
2. **Context Batch Actions with Preview** (`gui_2.py:2805-2843`): `render_context_batch_actions` contains the Preview button at line 2839:
|
||||
```python
|
||||
if imgui.button("Preview##ctx"):
|
||||
app.context_preview_text = app.controller._do_generate()[0]
|
||||
app.show_windows["Context Preview"] = True
|
||||
```
|
||||
|
||||
3. **AST Inspector Modal** (`gui_2.py:2900-3036`): `render_ast_inspector_modal` exists with dual-pane layout (tree + content). Triggered via `app._show_ast_inspector = True` and `app.ui_inspecting_ast_file = f_item` set in `render_context_files_table` at lines 3145-3146.
|
||||
|
||||
4. **Text Viewer Window** (`gui_2.py:4077-4145`): `render_text_viewer_window` function exists with syntax highlighting via `ImGuiColorTextEdit`. Triggered via `app.show_text_viewer = True` and content set via `app.text_viewer_content`, `app.text_viewer_title`, `app.text_viewer_type`.
|
||||
|
||||
5. **Context Files Table** (`gui_2.py:3090-3198`): `render_context_files_table` with Inspect and Slices buttons at lines 3143-3158.
|
||||
|
||||
6. **AppController._do_generate** (`app_controller.py:3433-3468`): Returns `(full_md, path, file_items, stable_md, discussion_text)`. Used by Preview button at `gui_2.py:2840`.
|
||||
|
||||
7. **render_context_modals** (`gui_2.py:5275-5306`): Calls `render_add_context_files_modal`, `render_ast_inspector_modal`.
|
||||
|
||||
### Gaps to Fill (This Track's Scope)
|
||||
|
||||
1. **Gap 1**: The Preview button at `gui_2.py:2840` calls `app.controller._do_generate()[0]` but `AppController` at line 991 shows `self.context_files: List[models.FileItem] = []`. The controller's `context_files` is NEVER synchronized with `App.context_files` from `gui_2.py`. The Preview therefore shows empty content.
|
||||
|
||||
2. **Gap 2**: `render_context_modals` at line 5275 calls `render_ast_inspector_modal` but **never actually calls** `render_text_viewer_window`. The Slices button sets `app.show_text_viewer = True` and populates `app.text_viewer_content`, but `render_text_viewer_window` is NOT invoked in the main render loop.
|
||||
|
||||
3. **Gap 3**: `render_ast_inspector_modal` uses `app._show_ast_inspector` flag and `imgui.open_popup` pattern, but this is not integrated into `render_context_modals` properly (modal rendering may conflict with window rendering timing).
|
||||
|
||||
## Goals
|
||||
|
||||
- Fix Preview button to show actual aggregated context content from context_files
|
||||
- Fix Inspect button to open AST Inspector modal properly
|
||||
- Fix Slices button to open Text Viewer window with file content
|
||||
|
||||
## Functional Requirements
|
||||
|
||||
1. **Synchronize context_files between App and AppController**: The Preview button calls `app.controller._do_generate()` which reads `self.context_files` (controller's empty list). Must sync `App.context_files` → `AppController.context_files` before calling `_do_generate()`.
|
||||
|
||||
2. **Add Text Viewer Window to render loop**: `render_text_viewer_window(app)` must be called in the main render loop (after line 1238 or in `render_context_modals`).
|
||||
|
||||
3. **Fix AST Inspector modal integration**: Ensure `render_ast_inspector_modal` is properly called in `render_context_modals` and uses correct popup pattern.
|
||||
|
||||
4. **Add defensive empty-state handling**: If `context_files` is empty, Preview should show "No files in context composition" message.
|
||||
|
||||
## Architecture Reference
|
||||
|
||||
- docs/guide_architecture.md#render-loop - Main render loop structure
|
||||
- docs/guide_architecture.md#modal-patterns - Modal and window rendering patterns
|
||||
- docs/guide_tools.md#mcp-bridge - Tool execution flow
|
||||
|
||||
## Out of Scope
|
||||
|
||||
- Changes to aggregation logic (only fixing invocation, not the aggregation itself)
|
||||
- Changes to the FileItem model structure
|
||||
- Changes to view_mode handling (only fixing the buttons that trigger editors)
|
||||
Reference in New Issue
Block a user