4.2 KiB
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)
-
Context Preview Window (
gui_2.py:5308-5320):render_context_preview_windowfunction exists and renders markdown viamarkdown_helper.render(app.context_preview_text, context_id="ctx_preview"). The window is opened viaapp._render_window_if_open("Context Preview", lambda: render_context_preview_window(app))at line 1238. -
Context Batch Actions with Preview (
gui_2.py:2805-2843):render_context_batch_actionscontains the Preview button at line 2839:if imgui.button("Preview##ctx"): app.context_preview_text = app.controller._do_generate()[0] app.show_windows["Context Preview"] = True -
AST Inspector Modal (
gui_2.py:2900-3036):render_ast_inspector_modalexists with dual-pane layout (tree + content). Triggered viaapp._show_ast_inspector = Trueandapp.ui_inspecting_ast_file = f_itemset inrender_context_files_tableat lines 3145-3146. -
Text Viewer Window (
gui_2.py:4077-4145):render_text_viewer_windowfunction exists with syntax highlighting viaImGuiColorTextEdit. Triggered viaapp.show_text_viewer = Trueand content set viaapp.text_viewer_content,app.text_viewer_title,app.text_viewer_type. -
Context Files Table (
gui_2.py:3090-3198):render_context_files_tablewith Inspect and Slices buttons at lines 3143-3158. -
AppController._do_generate (
app_controller.py:3433-3468): Returns(full_md, path, file_items, stable_md, discussion_text). Used by Preview button atgui_2.py:2840. -
render_context_modals (
gui_2.py:5275-5306): Callsrender_add_context_files_modal,render_ast_inspector_modal.
Gaps to Fill (This Track's Scope)
-
Gap 1: The Preview button at
gui_2.py:2840callsapp.controller._do_generate()[0]butAppControllerat line 991 showsself.context_files: List[models.FileItem] = []. The controller'scontext_filesis NEVER synchronized withApp.context_filesfromgui_2.py. The Preview therefore shows empty content. -
Gap 2:
render_context_modalsat line 5275 callsrender_ast_inspector_modalbut never actually callsrender_text_viewer_window. The Slices button setsapp.show_text_viewer = Trueand populatesapp.text_viewer_content, butrender_text_viewer_windowis NOT invoked in the main render loop. -
Gap 3:
render_ast_inspector_modalusesapp._show_ast_inspectorflag andimgui.open_popuppattern, but this is not integrated intorender_context_modalsproperly (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
-
Synchronize context_files between App and AppController: The Preview button calls
app.controller._do_generate()which readsself.context_files(controller's empty list). Must syncApp.context_files→AppController.context_filesbefore calling_do_generate(). -
Add Text Viewer Window to render loop:
render_text_viewer_window(app)must be called in the main render loop (after line 1238 or inrender_context_modals). -
Fix AST Inspector modal integration: Ensure
render_ast_inspector_modalis properly called inrender_context_modalsand uses correct popup pattern. -
Add defensive empty-state handling: If
context_filesis 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)