# Implementation Plan: Markdown Support & Syntax Highlighting

## Phase 1: Markdown Integration & Setup
- [x] Task: Research and configure `imgui_markdown` within the existing `imgui-bundle` environment.
    - [x] Identify required font assets for Markdown (bold, italic, headers).
    - [x] Create a `MarkdownRenderer` wrapper class in `src/markdown_helper.py` to manage styling and callbacks (links, etc.).
- [x] Task: Implement basic Markdown rendering in a test panel.
    - [x] Verify that bold, italic, and headers render correctly using the defined theme fonts.
- [x] Task: Conductor - User Manual Verification 'Phase 1: Markdown Integration' (Protocol in workflow.md)

## Phase 2: Syntax Highlighting Implementation
- [x] Task: Implement syntax highlighting for PowerShell, Python, and JSON/TOML.
    - [x] Research `imgui-bundle`'s recommended approach for syntax highlighting (e.g., using `ImGuiColorTextEdit` or specialized Markdown callbacks).
    - [x] Define language-specific color palettes that match the "Professional" theme.
- [x] Task: Implement the language resolution logic.
    - [x] Create a utility to extract language tags from code blocks and resolve file extensions.
    - [x] Implement cheap heuristic for common code patterns (e.g., matching `def `, `if $`, `{ "`).
- [x] Task: Conductor - User Manual Verification 'Phase 2: Syntax Highlighting' (Protocol in workflow.md)

## Phase 3: GUI Integration (Read-Only Views)
- [x] Task: Integrate Markdown rendering into the Discussion History.
    - [x] Replace `imgui.text_wrapped` in `_render_discussion_panel` with the `MarkdownRenderer`.
    - [x] Ensure that code blocks within AI messages are correctly highlighted.
- [x] Task: Integrate syntax highlighting into the Comms Log.
    - [x] Update `_render_comms_history_panel` to render JSON/TOML payloads with highlighting.
- [x] Task: Integrate syntax highlighting into the Operations/Tooling panels.
    - [x] Ensure PowerShell scripts and tool results are rendered with highlighting.
- [x] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration' (Protocol in workflow.md)

## Phase 4: Refinement & Final Polish
- [x] Task: Refine performance for large logs.
    - [x] Implement incremental rendering or caching for rendered Markdown blocks to maintain high FPS. (Hybrid renderer with TextEditor caching implemented).
- [x] Task: Implement clickable links.
    - [x] Handle link callbacks to open external URLs in the browser or local files in the configured text editor.
- [x] Task: Conduct a final visual audit across all read-only views.
- [x] Task: Conductor - User Manual Verification 'Phase 4: Final Polish' (Protocol in workflow.md)
