# Implementation Plan: Visual DAG Ticket Editing (visual_dag_ticket_editing_20260306)

> **Reference:** [Spec](./spec.md) | [Architecture Guide](../../../docs/guide_architecture.md)

## Phase 1: Node Editor Setup
Focus: Verify ImGui Bundle node editor

- [x] Task 1.1: Initialize MMA Environment
- [x] Task 1.2: Verify imgui_bundle node editor available
    - WHERE: Check imports
    - HOW: `import imgui_bundle.node_editor as ed`

## Phase 2: Basic Node Rendering
Focus: Render tickets as nodes

- [x] Task 2.1: Create node editor context
    - WHERE: `src/gui_2.py` MMA dashboard
    - WHAT: Begin/end node editor
    - HOW:
      ```python
      ed.begin("Ticket DAG")
      for ticket in self.track.tickets:
       ed.begin_node(ticket.id)
       imgui.text(ticket.id)
       imgui.text(ticket.status)
       ed.end_node()
      ed.end()
      ```

- [x] Task 2.2: Set node positions
    - WHERE: `src/gui_2.py`
    - WHAT: Position nodes in grid
    - HOW:
      ```python
      # Auto-layout: grid positions
      col = i % 4
      row = i // 4
      ed.set_node_position(ticket.id, col * 200, row * 150)
      ```

- [x] Task 2.3: Add status colors
    - WHERE: `src/gui_2.py`
    - WHAT: Color nodes by status
    - HOW:
      ```python
      status_colors = {"todo": vec4(150, 150, 150, 255), "in_progress": vec4(255, 200, 100, 255),
       "completed": vec4(100, 255, 100, 255), "blocked": vec4(255, 100, 100, 255)}
      color = status_colors.get(ticket.status, vec4(200, 200, 200, 255))
      ed.push_style_color(ed.StyleColor.node_bg, color)
      ```

## Phase 3: Dependency Links
Focus: Draw lines between nodes

- [x] Task 3.1: Create links for dependencies
    - WHERE: `src/gui_2.py`
    - WHAT: Draw lines from dependency to dependent
    - HOW:
      ```python
      for ticket in self.track.tickets:
       for dep_id in ticket.depends_on:
        # Create link: dep_id -> ticket.id
        ed.link(f"link_{dep_id}_{ticket.id}", dep_id, ticket.id)
      ```

## Phase 4: Interactive Editing
Focus: Allow creating/removing dependencies

- [x] Task 4.1: Handle link creation
    - WHERE: `src/gui_2.py`
    - WHAT: Detect new links and update Ticket
    - HOW:
      ```python
      # Check for new links
      if ed.begin_create():
       created = ed.get_created_link()
       if created:
        # Add dependency to ticket
        pass
       ed.end_create()
      ```

- [ ] Task 4.2: Handle link deletion
    - WHERE: `src/gui_2.py`
    - WHAT: Detect deleted links
    - HOW: `ed.begin_delete()`, `ed.get_deleted_link()`

- [ ] Task 4.3: Validate DAG after edit
    - WHERE: `src/gui_2.py`
    - WHAT: Check for cycles
    - HOW:
      ```python
      from src.dag_engine import TrackDAG
      temp_dag = TrackDAG(updated_tickets)
      if temp_dag.has_cycle():
       imgui.open_popup("Cycle Detected!")
       # Revert change
      ```

## Phase 5: Testing
- [x] Task 5.1: Write unit tests
- [ ] Task 5.2: Conductor - Phase Verification
