import React, { useState, useMemo } from "react"; import type { Phase } from "../types"; interface DocumentPaneProps { content: string; onChange: (content: string) => void; phase: Phase; disabled: boolean; } function renderMarkdown(md: string): string { return ( md // Headers .replace(/^### (.*$)/gm, "

$1

") .replace(/^## (.*$)/gm, "

$1

") .replace(/^# (.*$)/gm, "

$1

") // Bold/italic .replace(/\*\*([^*]+)\*\*/g, "$1") .replace(/\*([^*]+)\*/g, "$1") // Code blocks .replace( /```(\w*)\n([\s\S]*?)```/g, '
$2
' ) .replace(/`([^`]+)`/g, "$1") // Lists .replace(/^- \[x\] (.*$)/gm, '
  • ☑ $1
  • ') .replace(/^- \[ \] (.*$)/gm, '
  • ☐ $1
  • ') .replace(/^- (.*$)/gm, "
  • $1
  • ") // Review comments (highlight them) .replace(/(\/\/ REVIEW:.*$)/gm, '$1') .replace(/(\/\/ NOTE:.*$)/gm, '$1') // Paragraphs .replace(/\n\n/g, "

    ") .replace(/^(.+)$/gm, "

    $1

    ") // Clean up .replace(/

    <\/p>/g, "") .replace(/

    ()/g, "$1") .replace(/(<\/h[1-3]>)<\/p>/g, "$1") .replace(/

    (

    )/g, "$1")
          .replace(/(<\/pre>)<\/p>/g, "$1")
          .replace(/

    ()<\/p>/g, "$1") ); } export function DocumentPane({ content, onChange, phase, disabled, }: DocumentPaneProps) { const [isEditing, setIsEditing] = useState(false); const renderedHtml = useMemo(() => renderMarkdown(content), [content]); if (phase === "implement") { return (

    plan.md Implementing...
    ); } const filename = phase === "research" ? "research.md" : "plan.md"; return (
    {filename}
    {isEditing ? (