# Implementation Plan: Advanced Log Management and Session Restoration ## Phase 1: Storage Optimization (Offloading Data) [checkpoint: de5b152] - [x] Task: Implement file-based offloading for scripts and tool outputs. 7063bea - [ ] Update `src/session_logger.py` to include `log_tool_output(session_id, output)` which saves output to a unique file in the session directory and returns the filename. - [ ] Modify `src/session_logger.py:log_tool_call` to ensure scripts are consistently saved and return a unique filename/ID. - [ ] Update `src/app_controller.py` to use these unique IDs/filenames in the `payload` of comms and tool logs instead of raw content. - [x] Task: Verify that logs are smaller and scripts/outputs are correctly saved to the session directory. 7063bea - [ ] Task: Conductor - User Manual Verification 'Phase 1: Storage Optimization' (Protocol in workflow.md) ## Phase 2: Session-Level Restoration & UI Relocation - [ ] Task: Relocate the "Load Log" button. - [ ] Remove the "Load Log" button from `_render_comms_history_panel` in `src/gui_2.py`. - [ ] Add the "Load Log" button to the "Log Management" panel in `src/gui_2.py`. - [ ] Task: Rework `cb_load_prior_log` for session-level loading. - [ ] Update `src/app_controller.py:cb_load_prior_log` to allow selecting a session directory or the main session log file. - [ ] Implement logic to load all related logs (comms, mma, tools) for that session. - [ ] Ensure that for entries referencing external files (scripts/outputs), the content is loaded on-demand or during the restoration process. - [ ] Task: Implement "Historical Replay" UI mode. - [ ] In `src/gui_2.py`, implement logic to tint the UI (as already partially done for comms) when `is_viewing_prior_session` is True. - [ ] Populate `disc_entries`, `_comms_log`, and MMA Dashboard states from the loaded session logs. - [ ] Task: Conductor - User Manual Verification 'Phase 2: Session-Level Restoration' (Protocol in workflow.md) ## Phase 3: Diagnostic Log & Discussion Cleanup - [ ] Task: Clean up discussion history and implement Diagnostic Tab. - [ ] Add `self.diagnostic_log` (a list of transient messages) to `AppController`. - [ ] Update `src/app_controller.py:_on_performance_alert` to append to `self.diagnostic_log` instead of `disc_entries`. - [ ] Update `src/ai_client.py` (and other areas) to redirect "SYSTEM WARNING" and similar performance-related messages to the diagnostic log via a new event type. - [ ] Add a "Diagnostics" tab to the Log Management panel in `src/gui_2.py` to render `self.diagnostic_log`. - [ ] Ensure `diagnostic_log` is NOT persisted to `manual_slop.toml` or restored during session loads. - [ ] Task: Conductor - User Manual Verification 'Phase 3: Diagnostic Log & Cleanup' (Protocol in workflow.md) ## Phase 4: MMA Log Integration & Filtering - [ ] Task: Improve MMA log visibility and filtering. - [ ] Ensure MMA sub-agent `log_comms` calls include sufficient metadata (tier, role) for filtering. - [ ] Update `_render_comms_history_panel` in `src/gui_2.py` to ensure MMA logs are clearly distinct and correctly filtered based on existing UI toggles. - [ ] Task: Final end-to-end verification of session restoration and log management. - [ ] Task: Conductor - User Manual Verification 'Phase 4: MMA Log Integration' (Protocol in workflow.md)