chore(conductor): Add new track 'text_viewer_and_tool_call_fixes_20260601'

This commit is contained in:
ed
2026-06-01 23:46:05 -04:00
parent 6f733a64fa
commit b33a213697
9 changed files with 156 additions and 27 deletions
@@ -1,18 +1,22 @@
# Implementation Plan: Context Preservation and Empty Warning
# Implementation Plan: Context Preservation and Warnings
## Phase 1: Context State Synchronization
- [ ] Task: Sync UI state on discussion switch
- [ ] Add a `_sync_context_selection_from_controller()` method to `App` in `src/gui_2.py`. This method should clear `self.ui_selected_context_files` and repopulate it with the paths of all `FileItem`s in `self.context_files` that have `auto_aggregate == True`.
- [ ] Wrap the `AppController._switch_discussion` call in `App._switch_discussion` within `src/gui_2.py`. Update all GUI call sites to use `app._switch_discussion` instead of `app.controller._switch_discussion`.
## Phase 1: Context Inheritance on Creation
- [ ] Task: Update `_create_discussion`
- [ ] In `src/app_controller.py`, modify `_create_discussion`. Before switching, capture the current `context_files` (with their current `auto_aggregate` states).
- [ ] When initializing the new discussion via `project_manager.default_discussion()`, immediately set its `context_snapshot` to a serialization of the current `context_files`.
## Phase 2: Empty Context Warning
- [ ] Task: Implement warning on generate
- [ ] In `src/gui_2.py`, within `_handle_generate_send`, add a check: if `len(self.ui_selected_context_files) == 0`, set a new flag `self.show_empty_context_warning_modal = True` and return early instead of calling `self.controller._handle_generate_send()`.
- [ ] Create a `render_empty_context_warning_modal(app: App)` function that displays an ImGui popup warning the user. It should offer "Proceed Anyway" (which then calls `app.controller._handle_generate_send()`) and "Cancel" buttons.
- [ ] Add the modal render call to `render_context_modals` (or similar modal rendering loop).
## Phase 2: Empty Context Warning Modal
- [ ] Task: Implement Warning Logic in App
- [ ] In `src/gui_2.py`, add `self.show_empty_context_modal = False` and `self._pending_generation_action = None` (to store whether 'generate' or 'md_only' was requested) to `App.__init__`.
- [ ] In `App._handle_generate_send` and `App._handle_md_only`, check if `self.ui_selected_context_files` is empty.
- [ ] If empty, set `self.show_empty_context_modal = True` and store the action type. If not empty, call the respective controller method directly.
- [ ] Task: Render Modal
- [ ] In `src/gui_2.py`, add a new function `render_empty_context_modal(app: App)`.
- [ ] The modal should display a warning and have "Proceed Anyway" (which calls the controller based on `_pending_generation_action`) and "Cancel" buttons.
- [ ] Call this new render function inside the main UI loop, likely near where `render_missing_files_modal` is called.
## Phase 3: Verification
- [ ] Task: Verification
- [ ] Create a discussion, select some files, create a new discussion, and verify the selection is preserved.
- [ ] Attempt to generate a response with no files selected and verify the warning modal appears.
- [ ] Task: Manual Verification
- [ ] Verify creating a new discussion preserves checked files.
- [ ] Verify the warning modal appears when generating with no files, and that "Proceed Anyway" works correctly.
- [ ] Task: Conductor - User Manual Verification 'Phase 3: Verification' (Protocol in workflow.md)
@@ -1,16 +1,18 @@
# Specification: Context Preservation and Empty Warning
# Specification: Context Preservation and Warnings
## 1. Overview
When a user creates a new discussion or switches to an existing one, the selection state of the context files (which files are checked) is lost. This happens because the GUI's `ui_selected_context_files` set is not synchronized with the newly loaded `context_files` from the discussion snapshot. Additionally, the user requested a warning if they attempt to generate an AI response when no context files are selected.
Currently, creating a new discussion drops all currently selected files because the new discussion is initialized without a `context_snapshot`. Additionally, attempting to generate a response without any selected context files provides no user feedback. We need to inherit the current context composition when a new discussion is created and add a warning mechanism for empty contexts.
## 2. Functional Requirements
* **State Synchronization:** When `_switch_discussion` is called in `AppController`, it must signal the GUI to reconstruct its `ui_selected_context_files` set based on the `auto_aggregate` flag of the newly loaded `FileItem` objects.
* **Empty Context Warning:** When the user clicks "Generate Response" (via `_handle_generate_send` or similar trigger), the system should check if any files are selected for aggregation. If not, it should display a warning or confirmation modal alerting the user that the context is empty.
* **Context Inheritance:** When a new discussion is created via `_create_discussion` in `src/app_controller.py`, the active discussion's `context_files` (or the current `ui_selected_context_files` state) MUST be saved into the new discussion's `context_snapshot`.
* **Empty Context Warning:** When `_handle_generate_send` or `_handle_md_only` is triggered in `src/gui_2.py`, it must verify if `ui_selected_context_files` is empty. If empty, it MUST display a warning modal instead of immediately calling the controller.
* **Modal Actions:** The warning modal should offer "Proceed Anyway" (which continues the generation) and "Cancel" buttons.
## 3. Non-Functional Requirements
* **Performance:** The state sync should be a lightweight operation during the discussion switch lifecycle.
* **Consistency:** The new empty context modal must match the style of existing warnings (like `show_missing_files_modal`).
* **ImGui Stability:** Ensure the modal rendering does not violate ImGui stack scoping.
## 4. Acceptance Criteria
* Creating a new discussion correctly copies over the checked/unchecked state of all files in the Context Composition panel.
* Switching between past discussions restores their specific checked/unchecked file states.
* Attempting to generate a response with 0 selected files displays a clear warning in the GUI.
* Creating a new discussion with 3 files checked results in the new discussion also having those 3 files checked.
* Clicking "Generate Response" with 0 files checked opens a warning modal.
* Clicking "Proceed Anyway" successfully generates the response (with 0 files).