All files / src/components/chat ReportBugPreview.tsx

8% Statements 4/50
100% Branches 0/0
0% Functions 0/1
8% Lines 4/50

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 851x 1x           1x                                                                                                                                                       1x  
import React from "react"
import MarkdownBlock from "../common/MarkdownBlock"
 
interface ReportBugPreviewProps {
	data: string
}
 
const ReportBugPreview: React.FC<ReportBugPreviewProps> = ({ data }) => {
	// Parse the JSON data from the context string
	const bugData = React.useMemo(() => {
		try {
			return JSON.parse(data || "{}")
		} catch (e) {
			console.error("Failed to parse bug report data", e)
			return {}
		}
	}, [data])
 
	return (
		<div className="bg-[var(--vscode-badge-background)] text-[var(--vscode-badge-foreground)] rounded-[3px] p-[14px]">
			<h3 className="font-bold text-base mb-3 mt-0">{bugData.title || "Bug Report"}</h3>
 
			<div className="space-y-3 text-sm">
				{bugData.what_happened && (
					<div>
						<div className="font-semibold">What Happened?</div>
						<MarkdownBlock markdown={bugData.what_happened} />
					</div>
				)}
 
				{bugData.steps_to_reproduce && (
					<div>
						<div className="font-semibold">Steps to Reproduce</div>
						<MarkdownBlock markdown={bugData.steps_to_reproduce} />
					</div>
				)}
 
				{bugData.api_request_output && (
					<div>
						<div className="font-semibold">Relevant API Request Output</div>
						<MarkdownBlock markdown={bugData.api_request_output} />
					</div>
				)}
 
				{bugData.provider_and_model && (
					<div>
						<div className="font-semibold">Provider/Model</div>
						<MarkdownBlock markdown={bugData.provider_and_model} />
					</div>
				)}
 
				{bugData.operating_system && (
					<div>
						<div className="font-semibold">Operating System</div>
						<MarkdownBlock markdown={bugData.operating_system} />
					</div>
				)}
 
				{bugData.system_info && (
					<div>
						<div className="font-semibold">System Info</div>
						<MarkdownBlock markdown={bugData.system_info} />
					</div>
				)}
 
				{bugData.cline_version && (
					<div>
						<div className="font-semibold">AI-Hydro Version</div>
						<MarkdownBlock markdown={bugData.cline_version} />
					</div>
				)}
 
				{bugData.additional_context && (
					<div>
						<div className="font-semibold">Additional Context</div>
						<MarkdownBlock markdown={bugData.additional_context} />
					</div>
				)}
			</div>
		</div>
	)
}
 
export default ReportBugPreview