# SQLite-Granularity Inline Docs for gui_2.py — Implementation Plan

> **For agentic workers:** Use task-by-task execution. Steps use checkbox (`- [ ]`) syntax for tracking.

**Goal:** Implement SQLite-granularity docstrings with embedded ASCII layouts and DAG relationships for `src/gui_2.py` panel-by-panel. Ensure zero functional regression.

---

## File Structure

| File | Action | Purpose |
|---|---|---|
| `src/gui_2.py` | Modify | Add SQLite-style docstrings with ASCII wireframes to all main classes, methods, and functions. |
| `conductor/tracks/sqlite_docs_gui_2_20260612/state.toml` | Modify | Track implementation state. |
| `conductor/tracks.md` | Modify | Register the new track. |

---

# Phase 1: App Lifecycle & Setup

## Task 1.1: Document App class constructor and lifecycle entry points
- [x] **Step 1: Document `App.__init__`** (99e7b6e)
  Add docstring detailing setup sequence (event listeners, thread initialization, window default states, preset loading).
- [x] **Step 2: Document `App.run`** (99e7b6e)
  Add docstring detailing hello_imgui initialization, window setup, styling profile setup, and running loop entrance.
- [x] **Step 3: Document `App._gui_func`** (99e7b6e)
  Add docstring detailing main viewport render loop dispatch, hotkey intercepts (palette, reloading), layout presets, and viewport frame rendering. Include a high-level ASCII mockup of the entire dock layout.
- [x] **Step 4: Document `App.shutdown`** (99e7b6e)
  Add docstring detailing file cache flush, background worker termination, profile dump, and clean exit procedures.
- [x] **Step 5: Verify syntax and run existing tests** (99e7b6e)
  Run: `pytest tests/test_gui_window_controls.py`
  Expected: Success.

## Task 1.2: Document state preservation, undo/redo, and profiles
- [x] **Step 1: Document `App._take_snapshot` and `_apply_snapshot`** (6d408c4d)
- [x] **Step 2: Document `App._capture_workspace_profile` and `_apply_workspace_profile`** (6d408c4d)
- [x] **Step 3: Document `App._handle_undo` and `_handle_redo`** (6d408c4d)
- [x] **Step 4: Verify syntax and run tests** (6d408c4d)
  Run: `pytest tests/` (verified via test_gui_window_controls)

---

# Phase 2: Discussion Panel & Controls

## Task 2.1: Document discussion entry renderer
- [x] **Step 1: Document `render_discussion_entry`** (2d8e166b)
  Add detailed docstring. Include an ASCII layout map showing how individual bubbles appear (role select, token stats, edit buttons, expand/collapse toggles).
- [x] **Step 2: Document `render_discussion_entry_controls`** (2d8e166b)
  Add detailed docstring. Include ASCII map of discussion bottom-bar controls (Truncate, Keep Pairs, Compress, Save).
- [x] **Step 3: Verify syntax and run discussion tests** (2d8e166b)
  Run: `pytest tests/test_log_management_ui.py` (or other relevant UI tests)

---

# Phase 3: Context Panel & AST Inspector

## Task 3.1: Document context composition panels
- [x] **Step 1: Document `render_context_composition_panel`** (92cff705)
  Include ASCII showing Context Preset loading, batch action headers, Collapsible Directory grouped tree, and screenshot list.
- [x] **Step 2: Document `render_context_files_table`** (92cff705)
  Include ASCII layout showing file row controls (Def, Sig, Hide, Slice editor triggers).
- [x] **Step 3: Document `render_ast_inspector_modal`** (92cff705)
  Include ASCII layout of the tree-sitter AST inspector modal.
- [x] **Step 4: Verify syntax and run tests** (92cff705)
  Run: `pytest tests/test_gui_window_controls.py` (passed)

---

# Phase 4: Settings & Hubs

- [x] **Step 1: Document project settings & paths panel** (Completed via reduced granularity target `render_ai_settings_hub`)
- [x] **Step 2: Document AI settings hubs & tools panel** (Completed via `render_ai_settings_hub`, `render_agent_tools_panel`)
- [x] **Step 3: Document preset managers** (Skipped per user instruction to reduce granularity)
- [x] **Step 4: Verify syntax and run tests** (Completed)

---

# Phase 5: Diagnostics, Analytics, Modals & final wrap

## Task 5.1: Document diagnostics, palette, and approval modals
- [x] **Step 1: Document diagnostics & analytics** (Completed via `render_diagnostics_panel`)
- [x] **Step 2: Document command palette** (Skipped per user instruction to reduce granularity)
- [x] **Step 3: Document approval modals** (Skipped per user instruction to reduce granularity)
- [x] **Step 4: Verify syntax and run tests** (Completed)

## Task 5.2: Register track and update status
- [x] **Step 1: Update `conductor/tracks.md`**
- [x] **Step 2: Mark track as complete in state.toml**
