# Implementation Plan: Manual Ticket Queue Management (ticket_queue_mgmt_20260306)

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

## Phase 1: Priority Field
Focus: Add priority to Ticket model

- [x] Task 1.1: Initialize MMA Environment
    - Run `activate_skill mma-orchestrator` before starting

- [x] Task 1.2: Add priority field to Ticket (035c74e)
    - WHERE: `src/models.py` `Ticket` dataclass
    - WHAT: Add `priority: str = "medium"` field
    - HOW:
      ```python
      @dataclass
      class Ticket:
       # ... existing fields ...
       priority: str = "medium"  # "high" | "medium" | "low"
      ```
    - CODE STYLE: 1-space indentation

- [x] Task 1.3: Update Ticket serialization (035c74e)
    - WHERE: `src/models.py` `Ticket.to_dict()` and `from_dict()`
    - WHAT: Include priority in serialization
    - HOW: Add `priority` to dict conversion

## Phase 2: Priority UI
Focus: Add priority dropdown to ticket display

- [x] Task 2.1: Add priority dropdown (a22603d)
    - WHERE: `src/gui_2.py` ticket rendering
    - WHAT: Dropdown for priority selection
    - HOW:
      ```python
      priorities = ["high", "medium", "low"]
      current_idx = priorities.index(ticket.priority) if ticket.priority in priorities else 1
      if imgui.begin_combo("Priority", priorities[current_idx]):
       for i, p in enumerate(priorities):
        if imgui.selectable(p, i == current_idx):
         ticket.priority = p
       imgui.end_combo()
      ```

- [x] Task 2.2: Add color coding (a22603d)
    - WHERE: `src/gui_2.py` ticket rendering
    - WHAT: Color-code priority display
    - HOW:
      ```python
      priority_colors = {"high": vec4(255, 100, 100, 255), "medium": vec4(255, 200, 100, 255), "low": vec4(150, 150, 150, 255)}
      imgui.text_colored(priority_colors.get(ticket.priority, vec4(200, 200, 200, 255)), f"[{ticket.priority.upper()}]")
      ```

## Phase 3: Multi-Select
Focus: Enable ticket selection for bulk operations

- [x] Task 3.1: Add selection state (a22603d)
    - WHERE: `src/gui_2.py` or `src/app_controller.py`
    - WHAT: Track selected ticket IDs
    - HOW:
      ```python
      self._selected_tickets: set[str] = set()
      ```

- [x] Task 3.2: Add checkbox per ticket (a22603d)
    - WHERE: `src/gui_2.py` ticket list rendering
    - WHAT: Checkbox for selection
    - HOW:
      ```python
      selected = ticket.id in self._selected_tickets
      if imgui.checkbox(f"##select_{ticket.id}", selected):
       if selected:
        self._selected_tickets.discard(ticket.id)
       else:
        self._selected_tickets.add(ticket.id)
      imgui.same_line()
      ```

- [x] Task 3.3: Add select all/none buttons (a22603d)
    - WHERE: `src/gui_2.py` ticket list header
    - WHAT: Buttons to select/deselect all
    - HOW:
      ```python
      if imgui.button("Select All"):
       self._selected_tickets = {t.id for t in self.track.tickets}
      imgui.same_line()
      if imgui.button("Select None"):
       self._selected_tickets.clear()
      ```

## Phase 4: Bulk Actions
Focus: Execute bulk operations on selected tickets

- [x] Task 4.1: Add bulk action buttons (a22603d)
    - WHERE: `src/gui_2.py` ticket list area
    - WHAT: Execute, Skip, Block buttons
    - HOW:
      ```python
      if imgui.button("Bulk Execute"):
       for tid in self._selected_tickets:
        self.engine.approve_task(tid)
      imgui.same_line()
      if imgui.button("Bulk Skip"):
       for tid in self._selected_tickets:
        self.engine.update_task_status(tid, "completed")
      imgui.same_line()
      if imgui.button("Bulk Block"):
       for tid in self._selected_tickets:
        self.engine.update_task_status(tid, "blocked")
      ```

## Phase 5: Drag-Drop (Optional)
Focus: Allow ticket reordering

- [x] Task 5.1: Implement drag-drop reordering (a22603d)
    - WHERE: `src/gui_2.py` ticket list
    - WHAT: Drag tickets to reorder
    - HOW: Use imgui drag-drop API
    - SAFETY: Validate DAG after reorder (no dependency violations)

## Phase 6: Testing
Focus: Verify all functionality

- [x] Task 6.1: Write unit tests (a22603d)
    - WHERE: `tests/test_ticket_queue.py` (new file)
    - WHAT: Test priority serialization, bulk operations
    - HOW: Create mock tickets, verify state changes

- [x] Task 6.2: Conductor - Phase Verification (a22603d)
    - Run: `uv run pytest tests/test_ticket_queue.py -v`
    - Manual: Verify UI controls work
