diff --git a/TASKS.md b/TASKS.md index d0d83f0..6b6aedc 100644 --- a/TASKS.md +++ b/TASKS.md @@ -3,7 +3,7 @@ ## Active Tracks -_None currently active._ +- `feature_bleed_cleanup_20260302` — Dead code & conflicting design state cleanup (Phase 1-3) ## Completed This Session - `context_token_viz_20260301` — Token budget panel (color bar, breakdown table, trim warning, cache status, auto-refresh). All phases verified. Commit: d577457. diff --git a/conductor/tracks/feature_bleed_cleanup_20260302/index.md b/conductor/tracks/feature_bleed_cleanup_20260302/index.md new file mode 100644 index 0000000..440bb7e --- /dev/null +++ b/conductor/tracks/feature_bleed_cleanup_20260302/index.md @@ -0,0 +1,5 @@ +# Track feature_bleed_cleanup_20260302 Context + +- [Specification](./spec.md) +- [Implementation Plan](./plan.md) +- [Metadata](./metadata.json) diff --git a/conductor/tracks/feature_bleed_cleanup_20260302/metadata.json b/conductor/tracks/feature_bleed_cleanup_20260302/metadata.json new file mode 100644 index 0000000..6c4f3c5 --- /dev/null +++ b/conductor/tracks/feature_bleed_cleanup_20260302/metadata.json @@ -0,0 +1,8 @@ +{ + "track_id": "feature_bleed_cleanup_20260302", + "type": "fix", + "status": "new", + "created_at": "2026-03-02T00:00:00Z", + "updated_at": "2026-03-02T00:00:00Z", + "description": "Audit-driven removal of dead duplicate code, conflicting menu bar design, and layout regressions introduced by feature bleed across multiple tracks." +} diff --git a/conductor/tracks/feature_bleed_cleanup_20260302/plan.md b/conductor/tracks/feature_bleed_cleanup_20260302/plan.md new file mode 100644 index 0000000..8a30279 --- /dev/null +++ b/conductor/tracks/feature_bleed_cleanup_20260302/plan.md @@ -0,0 +1,111 @@ +# Implementation Plan: Feature Bleed Cleanup + +Architecture reference: [docs/guide_architecture.md](../../../docs/guide_architecture.md) + +--- + +## Phase 1: Dead Code Removal +Focus: Delete the two confirmed dead code blocks — no behavior change, pure deletion. + +- [ ] Task 1.1: In `gui_2.py`, delete the first `_render_comms_history_panel` definition. + - **Location**: Lines 3041-3073 (use `py_get_code_outline` to confirm current line numbers before editing). + - **What**: The entire method body from `def _render_comms_history_panel(self) -> None:` through `imgui.end_child()` and the following blank line. The live version begins at ~line 3435 after this deletion shifts lines. + - **How**: Use `set_file_slice` to delete lines 3041-3073 (replace with empty string). Then run `py_get_code_outline` to confirm only one `_render_comms_history_panel` remains. + - **Verify**: `grep -n "_render_comms_history_panel" gui_2.py` should show exactly 2 hits: the `def` line and the call site in `_gui_func`. + +- [ ] Task 1.2: In `gui_2.py` `__init__`, delete the duplicate state variable assignments. + - **Location**: Second occurrences of `ui_conductor_setup_summary`, `ui_new_track_name`, `ui_new_track_desc`, `ui_new_track_type`. Currently at lines 308-311 (grep to confirm exact lines before editing: `grep -n "ui_conductor_setup_summary" gui_2.py`). + - **What**: Delete these 4 lines. The first correct assignments remain at lines 218-221. + - **How**: Use `set_file_slice` to remove lines 308-311 (replace with empty string). + - **Verify**: Each variable should appear exactly once in `__init__` (grep to confirm). + +- [ ] Task 1.3: Write/run tests to confirm no regressions. + - Run `uv run pytest tests/ -x -q` and confirm all tests pass. + - Run `uv run python -c "from gui_2 import App; print('import ok')"` to confirm no syntax errors. + +- [ ] Task 1.4: Conductor — User Manual Verification + - Start the app with `uv run python gui_2.py` and confirm it launches without error. + - Open "Operations Hub" → "Comms History" tab and confirm the comms panel renders (color legend visible). + +--- + +## Phase 2: Menu Bar Consolidation +Focus: Remove the dead inline menubar block and add a working Quit item to `_show_menus`. + +- [ ] Task 2.1: Delete the dead `begin_main_menu_bar()` block from `_gui_func`. + - **Location**: `gui_2.py` lines 1679-1705 (the comment `# ---- Menubar` through `imgui.end_main_menu_bar()`). Use `get_file_slice(1676, 1712)` to confirm exact boundaries before editing. + - **What**: Delete the `# ---- Menubar` comment line and the entire `if imgui.begin_main_menu_bar(): ... imgui.end_main_menu_bar()` block (~27 lines total). The `# --- Hubs ---` comment and hub rendering that follows must be preserved. + - **How**: Use `set_file_slice` to replace lines 1679-1705 with a single blank line. + - **Verify**: `grep -n "begin_main_menu_bar" gui_2.py` returns 0 hits. + +- [ ] Task 2.2: Add working "Quit" to `_show_menus`. + - **Location**: `gui_2.py` `_show_menus` method (lines 1620-1647 — confirm with `py_get_definition`). + - **What**: Before the existing `if imgui.begin_menu("Windows"):` line, insert: + ```python + if imgui.begin_menu("manual slop"): + if imgui.menu_item("Quit", "Ctrl+Q", False)[0]: + self.runner_params.app_shall_exit = True + imgui.end_menu() + ``` + - **Note**: `self.runner_params` is set in `run()` before `immapp.run()` is called, so it is valid here. + - **How**: Use `set_file_slice` or `Edit` to insert the block before the "Windows" menu. + - **Verify**: Launch app, confirm "manual slop" > "Quit" appears in menubar and clicking it closes the app cleanly. + +- [ ] Task 2.3: Write/run tests. + - Run `uv run pytest tests/ -x -q`. + +- [ ] Task 2.4: Conductor — User Manual Verification + - Launch app. Confirm menubar has: "manual slop" (with Quit), "Windows", "Project". + - Confirm "View" menu is gone (was dead duplicate of "Windows"). + - Confirm Quit closes the app. + +--- + +## Phase 3: Token Budget Layout Fix +Focus: Give the token budget panel its own collapsing header in AI Settings; remove the double label from the provider panel. + +- [ ] Task 3.1: Remove the double label + embedded call from `_render_provider_panel`. + - **Location**: `gui_2.py` `_render_provider_panel` (lines ~2687-2746 — use `py_get_definition` to confirm). The block to remove is: + ```python + imgui.text("Token Budget:") + imgui.separator() + imgui.text("Token Budget") + self._render_token_budget_panel() + ``` + These are 4 consecutive lines at the end of the method (before `if self._gemini_cache_text:`). + - **What**: Delete those 4 lines. The `if self._gemini_cache_text:` block that follows them must be preserved in place. + - **How**: Use `Edit` with `old_string` set to those exact 4 lines. + - **Verify**: `_render_provider_panel` ends with the `if self._gemini_cache_text:` block and no "Token Budget" text labels. + +- [ ] Task 3.2: Add `collapsing_header("Token Budget")` to AI Settings in `_gui_func`. + - **Location**: `gui_2.py` `_gui_func`, AI Settings window block (currently lines ~1719-1723 — `get_file_slice(1715, 1730)` to confirm). Current content: + ```python + if imgui.collapsing_header("Provider & Model"): + self._render_provider_panel() + if imgui.collapsing_header("System Prompts"): + self._render_system_prompts_panel() + ``` + - **What**: Add after the System Prompts header: + ```python + if imgui.collapsing_header("Token Budget"): + self._render_token_budget_panel() + ``` + - **How**: Use `Edit` to insert after the `_render_system_prompts_panel()` call. + - **Verify**: AI Settings window now shows three collapsing sections: "Provider & Model", "System Prompts", "Token Budget". + +- [ ] Task 3.3: Write/run tests. + - Run `uv run pytest tests/ -x -q`. + +- [ ] Task 3.4: Conductor — User Manual Verification + - Launch app. Open "AI Settings" window. + - Confirm "Token Budget" appears as a collapsing header (expand it — panel renders correctly). + - Confirm "Provider & Model" section no longer shows any "Token Budget" label. + +--- + +## Phase Completion Checkpoint +After all phases pass manual verification: +- Run `uv run pytest tests/ -x -q` one final time. +- Commit: `fix(bleed): remove dead comms panel dup, consolidate menubar, fix token budget layout` +- Update TASKS.md to mark this track complete. +- Update JOURNAL.md with What/Why/How/Issues/Result. diff --git a/conductor/tracks/feature_bleed_cleanup_20260302/spec.md b/conductor/tracks/feature_bleed_cleanup_20260302/spec.md new file mode 100644 index 0000000..91318fa --- /dev/null +++ b/conductor/tracks/feature_bleed_cleanup_20260302/spec.md @@ -0,0 +1,67 @@ +# Track Specification: Feature Bleed Cleanup + +## Overview +Multiple tracks added code to `gui_2.py` without removing the old versions, leaving +dead duplicate methods, conflicting menu bar designs, and redundant state initializations. +This track removes confirmed dead code, resolves the two-menubar conflict, and cleans +up the token budget layout regression — restoring a consistent, non-contradictory design state. + +## Current State Audit (as of 0ad47af) + +### Already Implemented (DO NOT re-implement) +- **Live comms history panel** (`_render_comms_history_panel`, `gui_2.py:3435-3560`): Full-featured version with color legend, blink effects, prior-session tinted background, correct `entry.get('kind')` data key. **This is the version Python actually uses.** +- **`_show_menus` callback** (`gui_2.py:1620-1647`): HelloImGui-registered menu callback. Has "Windows" and "Project" menus. This is what actually renders in the app menubar. +- **Token budget panel** (`_render_token_budget_panel`, `gui_2.py:2748-2819`): Fully implemented with color bar, breakdown table, trim warning, cache status. Called from within `_render_provider_panel`. +- **`__init__` first-pass state vars** (`gui_2.py:218-221`): `ui_new_track_name`, `ui_new_track_desc`, `ui_new_track_type`, `ui_conductor_setup_summary` — correct first assignment. + +### Gaps / Confirmed Bugs (This Track's Scope) + +1. **Dead `_render_comms_history_panel` at lines 3041-3073**: Python silently discards the first definition when the second (3435) is encountered. The dead version uses the stale `entry.get('type')` key (current data model uses `kind`), calls `self._cb_load_prior_log()` (method does not exist — correct name is `cb_load_prior_log`), and uses `begin_child("scroll_area")` which collides with the ID used in `_render_tool_calls_panel`. This is ~33 lines of noise that misleads future workers. + +2. **Dead inline `begin_main_menu_bar()` block at lines 1680-1705**: HelloImGui renders the main menu bar before invoking `show_gui` (`_gui_func`). By the time `_gui_func` runs, the menubar is already committed; `imgui.begin_main_menu_bar()` returns `False`, so the entire 26-line block never executes. Consequences: + - The "manual slop" > "Quit" menu item (sets `self.should_quit = True`) is dead — `should_quit` is never checked anywhere else, so even if it ran, the app would not quit. + - The "View" menu (toggling `show_windows`) duplicates the live "Windows" menu in `_show_menus`. + - The "Project" menu duplicates the live "Project" menu in `_show_menus`, with a slightly different `_handle_reset_session()` call vs direct `ai_client.reset_session()` call. + +3. **Duplicate `__init__` state assignments at lines 308-311**: `ui_conductor_setup_summary`, `ui_new_track_name`, `ui_new_track_desc`, `ui_new_track_type` are each assigned twice — first at lines 218-221, then again at 308-311. The second assignments are harmless (same values) but create false ambiguity about initialization order and intent. + +4. **Redundant double "Token Budget" labels in `_render_provider_panel` (lines 2741-2743)**: `imgui.text("Token Budget:")` followed by `imgui.separator()` followed by `imgui.text("Token Budget")` followed by the panel call. Two labels appear before the panel, one with trailing colon and one without. The journal entry says "Token panel visible in AI Settings under 'Token Budget'" — but there is no `collapsing_header("Token Budget")` in `_gui_func`; the panel is embedded inside the "Provider & Model" collapsing section with duplicate labels. + +5. **Missing "Quit" in live `_show_menus`**: The only functional quit path is the window close button. HelloImGui's proper quit API is `runner_params.app_shall_exit = True` (accessible via `self.runner_params.app_shall_exit`). + +## Goals +1. Remove dead `_render_comms_history_panel` duplicate (lines 3041-3073). +2. Remove dead inline `begin_main_menu_bar()` block (lines 1680-1705). +3. Add working "Quit" to `_show_menus` using `self.runner_params.app_shall_exit = True`. +4. Remove duplicate `__init__` state assignments (lines 308-311). +5. Fix double "Token Budget" labels; give the panel its own `collapsing_header` in AI Settings. + +## Functional Requirements + +### Phase 1 — Dead Code Removal +- Delete lines 3041-3073 (`_render_comms_history_panel` first definition) from `gui_2.py` entirely. Do not replace — the live version at (renumbered) ~3400 is the only version needed. +- Delete lines 308-311 (second assignments of `ui_new_track_name`, `ui_new_track_desc`, `ui_new_track_type`, `ui_conductor_setup_summary`) from `__init__`. Keep the first assignments at lines 218-221. + +### Phase 2 — Menu Bar Consolidation +- Delete lines 1680-1705 (the dead `if imgui.begin_main_menu_bar(): ... imgui.end_main_menu_bar()` block) from `_gui_func`. The `# ---- Menubar` comment at line 1679 must also be removed. +- In `_show_menus` (lines 1620-1647), add a "manual slop" menu before the existing menus, containing a "Quit" item that sets `self.runner_params.app_shall_exit = True`. + +### Phase 3 — Token Budget Layout Fix +- In `_render_provider_panel` (lines ~2741-2744): remove the two text labels (`imgui.text("Token Budget:")`, `imgui.separator()`, `imgui.text("Token Budget")`) and the `self._render_token_budget_panel()` call. The separator before them (line ~2740) should remain to close off the Telemetry section cleanly. +- In `_gui_func` AI Settings window (around lines 1719-1723), add a new `collapsing_header("Token Budget")` section that calls `self._render_token_budget_panel()`. It should appear after the "System Prompts" header. + +## Non-Functional Requirements +- Zero behavior change to any feature that currently works. +- No new dependencies. +- After Phase 1-2, run `uv run pytest tests/ -x -q` to verify no test regressions. +- Each phase should be committed independently for clean git history. + +## Architecture Reference +- [docs/guide_architecture.md](../../../docs/guide_architecture.md): HelloImGui runner params, callback lifecycle +- [conductor/workflow.md](../../workflow.md): Task lifecycle and TDD protocol + +## Out of Scope +- Refactoring `_render_mma_dashboard` content organization. +- Changing `mma_tier_usage` default model names (runtime concern, not code quality). +- The `mma_agent_focus_ux` track (planned separately in TASKS.md). +- Any new feature work.