import React, { useState, useEffect, useContext, useCallback } from 'react'; import { VSCodeContext, TaskMasterTask } from '../webview/index'; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbSeparator } from '@/components/ui/breadcrumb'; import { Label } from '@/components/ui/label'; import { Textarea } from '@/components/ui/textarea'; import { Badge } from '@/components/ui/badge'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Separator } from '@/components/ui/separator'; import { Button } from '@/components/ui/button'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { ChevronRight, ChevronDown, Plus, Wand2, PlusCircle, Loader2 } from 'lucide-react'; interface TaskDetailsViewProps { taskId: string; onNavigateBack: () => void; onNavigateToTask: (taskId: string) => void; } // Markdown renderer component to handle code blocks const MarkdownRenderer: React.FC<{ content: string; className?: string }> = ({ content, className = '' }) => { // Parse content to separate code blocks from regular text const parseMarkdown = (text: string) => { const parts = []; const lines = text.split('\n'); let currentBlock = []; let inCodeBlock = false; let codeLanguage = ''; for (let i = 0; i < lines.length; i++) { const line = lines[i]; if (line.startsWith('```')) { if (inCodeBlock) { // End of code block if (currentBlock.length > 0) { parts.push({ type: 'code', content: currentBlock.join('\n'), language: codeLanguage }); currentBlock = []; } inCodeBlock = false; codeLanguage = ''; } else { // Start of code block if (currentBlock.length > 0) { parts.push({ type: 'text', content: currentBlock.join('\n') }); currentBlock = []; } inCodeBlock = true; codeLanguage = line.substring(3).trim(); // Get language after ``` } } else { currentBlock.push(line); } } // Handle remaining content if (currentBlock.length > 0) { parts.push({ type: inCodeBlock ? 'code' : 'text', content: currentBlock.join('\n'), language: codeLanguage }); } return parts; }; const parts = parseMarkdown(content); return (
{part.content}
);
} else {
// Handle inline code (single backticks) in text blocks
const textWithInlineCode = part.content
.split(/(`[^`]+`)/g)
.map((segment, segIndex) => {
if (segment.startsWith('`') && segment.endsWith('`')) {
const codeContent = segment.slice(1, -1);
return (
{codeContent}
);
}
return segment;
});
return (
Task not found
{currentTask.description || 'No description available.'}
Add Notes: Appends timestamped implementation notes, progress updates, or findings to this subtask's details
) : ( <>Regenerate: Completely rewrites the task description and subtasks based on your prompt
Append: Adds new content to the existing task description based on your prompt
> )}