# Specification: Advanced Log Management and Session Restoration

## Overview
This track focuses on centralizing log management, improving the reliability and scope of session restoration, and optimizing log storage by offloading large data blobs (scripts and tool outputs) to external files. It also aims to "clean" the discussion history by moving transient system warnings to a dedicated diagnostic log.

## Functional Requirements

### 1. Centralized Log Management
- Move the "Load Log" functionality from the Comms Log panel to the **Log Management** panel.
- Update the "Load Log" action to load an **entire session** (Comms, MMA Agent logs, and Tool Execution logs) instead of just the Comms log.

### 2. Session Replay Mode
- When a previous session is loaded, the UI should enter a "Historical/Replay" mode:
    - Apply a visual tint to the UI to clearly distinguish it from an active session.
    - Populate all respective panels (Discussion, MMA Dashboard, Operation Logs) with the data from the loaded session logs as if they were live.
- Fix the existing broken implementation for loading and parsing historical comms logs.

### 3. Log Storage Optimization
- **Script Offloading:** AI-generated PowerShell scripts must be saved into the session's directory with a unique identifier naming scheme.
- **Output Offloading:** Output from tool executions (e.g., shell command results) must be saved to separate files within the session directory.
- **ID Referencing:** Log entries in the `.jsonl` files should reference these external files by their filenames instead of embedding the full content.

### 4. MMA Agent Log Integration
- Ensure MMA sub-agent communications are correctly captured and filterable within the main Comms Log view.
- Utilize existing filter criteria (e.g., role, status) to manage the display of these logs.

### 5. Diagnostic Log Rework
- Remove system performance warnings and transient notifications from the **Discussion History**.
- Relocate these warnings to a new **Diagnostic Tab** within the Log Management panel.
- **Transient Diagnostics:** Diagnostic logs should not be restored or re-populated during session history loads; they are relevant only to the active runtime environment.

## Non-Functional Requirements
- **Efficiency:** Significantly reduce the size of individual log files by offloading large content strings.
- **Maintainability:** Decouple log visualization from the main execution logic to ensure robust session replay.

## Acceptance Criteria
- [ ] The "Load Log" button is successfully relocated and initiates a full session restoration.
- [ ] Loaded sessions correctly tint the UI and populate historical data into their original panels.
- [ ] Comms logs contain filename references for scripts and outputs rather than the raw text.
- [ ] Discussion history remains clear of performance-related system messages.
- [ ] MMA sub-agent logs are visible and correctly filtered in the Comms view.
- [ ] The new Diagnostic Tab correctly displays real-time system warnings.

## Out of Scope
- Real-time "playback" (animating the session as it happened); only static restoration is required.
- Editing or modifying historical session logs.
- Exporting sessions to formats other than the native log structure.
