# Specification: Discussion Hub Panel Reorganization

## 1. Overview

This track addresses the fragmented implementation of Session Context Snapshots and Discussion Takes & Timeline Branching tracks (2026-03-11). Those tracks were marked complete but the UI panel layout was not properly reorganized.

**Goal:** Create a coherent Discussion Hub that absorbs Session Hub functionality, establishes Files & Media as project-level file inventory, and properly implements Context Composition and DAW-style Takes branching.

## 2. Current State Audit (as of 2026-03-22)

### Already Implemented (DO NOT re-implement)
- `ui_summary_only` checkbox in Projects panel
- Session Hub as separate window with tabs: Aggregate MD | System Prompt
- Context Hub with tabs: Projects | Paths | Context Presets
- Context Presets save/load mechanism in project TOML
- `_render_synthesis_panel()` method (gui_2.py:2612-2643) - basic synthesis UI
- Takes data structure in `project['discussion']['discussions']`
- Per-file `Auto-Aggregate` and `Force Full` flags in Files & Media

### Gaps to Fill (This Track's Scope)
1. `ui_summary_only` is redundant with per-file flags - deprecate it
2. Context Hub renamed to "Project Settings" (remove Context Presets tab)
3. Session Hub merged into Discussion Hub as tabs
4. Files & Media stays separate as project-level inventory
5. Context Composition tab in Discussion Hub for per-discussion filter
6. Context Presets accessible via Context Composition (save/load filters)
7. DAW-style Takes timeline properly integrated into Discussion Hub
8. Synthesis properly integrated with Take selection

## 3. Panel Layout Target

| Panel | Location | Purpose |
|-------|----------|---------|
| **AI Settings** | Separate dockable | Provider, model, system prompts, tool presets, bias profiles |
| **Files & Media** | Separate dockable | Project-level file inventory (addressable files) |
| **Project Settings** | Context Hub → rename | Git dir, paths, project list (NO context stuff) |
| **Discussion Hub** | Main hub | All discussion-related UI (tabs below) |
| **MMA Dashboard** | Separate dockable | Multi-agent orchestration |
| **Operations Hub** | Separate dockable | Tool calls, comms history, external tools |
| **Diagnostics** | Separate dockable | Telemetry, logs |

**Discussion Hub Tabs:**
1. **Discussion** - Main conversation view (current implementation)
2. **Context Composition** - File/screenshot filter + presets (NEW)
3. **Snapshot** - Aggregate MD + System Prompt preview (moved from Session Hub)
4. **Takes** - DAW-style timeline branching + synthesis (integrated, not separate panel)

## 4. Functional Requirements

### 4.1 Deprecate ui_summary_only
- Remove `ui_summary_only` checkbox from Projects panel
- Per-file flags (`Auto-Aggregate`, `Force Full`) are the intended mechanism
- Document migration path for users

### 4.2 Rename Context Hub → Project Settings
- Context Hub tab bar: Projects | Paths
- Remove "Context Presets" tab
- All context-related functionality moves to Discussion Hub → Context Composition

### 4.3 Merge Session Hub into Discussion Hub
- Session Hub window eliminated
- Its content becomes tabs in Discussion Hub:
  - **Snapshot tab**: Aggregate MD preview, System Prompt preview, "Copy" buttons
  - These were previously in Session Hub

### 4.4 Context Composition Tab (NEW)
- Shows currently selected files/screenshots for THIS discussion
- Per-file flags: Auto-Aggregate, Force Full
- **"Save as Preset"** / **"Load Preset"** buttons
- Dropdown to select from saved presets
- Relationship to Files & Media:
  - Files & Media = the inventory (project-level)
  - Context Composition = selected filter for current discussion

### 4.5 Takes Timeline (DAW-Style)
- **New Take**: Start fresh discussion thread
- **Branch Take**: Fork from any discussion entry
- **Switch Take**: Make a take the active discussion
- **Rename/Delete Take**
- All takes share the same Files & Media (not duplicated)
- Non-destructive branching
- Visual timeline showing divergence points

### 4.6 Synthesis Integration
- User selects 2+ takes via checkboxes
- Click "Synthesize" button
- AI generates "resolved" response considering all selected approaches
- Result appears as new take
- Accessible from Discussion Hub → Takes tab

## 5. Data Model Changes

### 5.1 Discussion State Structure
```python
# Per discussion in project['discussion']['discussions']
{
    "name": str,
    "history": [
        {"role": "user"|"assistant", "content": str, "ts": str, "files_injected": [...]}
    ],
    "parent_entry": Optional[int],  # index of parent message if branched
    "parent_take": Optional[str],   # name of parent take if branched
}
```

### 5.2 Context Preset Format
```toml
[context_preset.my_filter]
files = ["path/to/file_a.py"]
auto_aggregate = true
force_full = false
screenshots = ["path/to/shot1.png"]
```

## 6. Non-Functional Requirements
- All changes must not break existing tests
- New tests required for new functionality
- Follow 1-space indentation Python code style
- No comments unless explicitly requested

## 7. Acceptance Criteria

- [ ] `ui_summary_only` removed from Projects panel
- [ ] Context Hub renamed to Project Settings
- [ ] Session Hub window eliminated
- [ ] Discussion Hub has 4 tabs: Discussion, Context Composition, Snapshot, Takes
- [ ] Context Composition allows save/load of filter presets
- [ ] Takes can be branched from any entry
- [ ] Takes timeline shows divergence visually
- [ ] Synthesis works with 2+ selected takes
- [ ] All existing tests still pass
- [ ] New tests cover new functionality

## 8. Out of Scope
- Aggregation improvements (sub-agent summarization, hash-based caching) - separate future track
- System prompt exposure (`_SYSTEM_PROMPT` in ai_client.py) - separate future track
- Session sophistication (Session as container for multiple discussions) - deferred
