admin08077/Githubgemini
0
1{"version":3,"file":"BugReproducer-DLaQepRF.js","sources":["../../components/features/BugReproducer.tsx"],"sourcesContent":["import React, { useState, useCallback } from 'react';\nimport { generateBugReproductionTestStream } from '../../services/aiService.ts';\nimport { BugAntIcon } from '../icons.tsx';\nimport { LoadingSpinner, MarkdownRenderer } from '../shared/index.tsx';\n\nconst exampleStackTrace = `TypeError: Cannot read properties of undefined (reading 'name')\n at UserProfile (UserProfile.jsx:5:21)\n at renderWithHooks (react-dom.development.js:14985:18)\n at mountIndeterminateComponent (react-dom.development.js:17811:13)\n at beginWork (react-dom.development.js:19049:16)`;\n\nexport const BugReproducer: React.FC = () => {\n const [stackTrace, setStackTrace] = useState(exampleStackTrace);\n const [context, setContext] = useState('// The UserProfile component code:\\nconst UserProfile = ({ user }) => <div>{user.name}</div>;');\n const [generatedTest, setGeneratedTest] = useState('');\n const [isLoading, setIsLoading] = useState(false);\n const [error, setError] = useState('');\n\n const handleGenerate = useCallback(async () => {\n if (!stackTrace.trim()) {\n setError('Please provide a stack trace.');\n return;\n }\n setIsLoading(true);\n setError('');\n setGeneratedTest('');\n try {\n const stream = generateBugReproductionTestStream(stackTrace, context);\n let fullResponse = '';\n for await (const chunk of stream) {\n fullResponse += chunk;\n setGeneratedTest(fullResponse);\n }\n } catch (err) {\n setError(err instanceof Error ? err.message : 'An unknown error occurred.');\n } finally {\n setIsLoading(false);\n }\n }, [stackTrace, context]);\n\n return (\n <div className=\"h-full flex flex-col p-4 sm:p-6 lg:p-8 text-text-primary\">\n <header className=\"mb-6\">\n <h1 className=\"text-3xl font-bold flex items-center\">\n <BugAntIcon />\n <span className=\"ml-3\">Automated Bug Reproducer</span>\n </h1>\n <p className=\"text-text-secondary mt-1\">Paste a stack trace to automatically generate a failing unit test.</p>\n </header>\n <div className=\"flex-grow grid grid-cols-1 lg:grid-cols-2 gap-6 min-h-0\">\n <div className=\"flex flex-col gap-4\">\n <div className=\"flex flex-col flex-1 min-h-0\">\n <label htmlFor=\"stack-trace\" className=\"text-sm font-medium mb-2\">Stack Trace</label>\n <textarea id=\"stack-trace\" value={stackTrace} onChange={e => setStackTrace(e.target.value)} className=\"flex-grow p-2 bg-surface border rounded font-mono text-xs\"/>\n </div>\n <div className=\"flex flex-col flex-1 min-h-0\">\n <label htmlFor=\"context\" className=\"text-sm font-medium mb-2\">Relevant Code / Context (Optional)</label>\n <textarea id=\"context\" value={context} onChange={e => setContext(e.target.value)} className=\"flex-grow p-2 bg-surface border rounded font-mono text-xs\"/>\n </div>\n <button onClick={handleGenerate} disabled={isLoading} className=\"btn-primary w-full py-3\">{isLoading ? <LoadingSpinner/> : 'Generate Test'}</button>\n </div>\n <div className=\"flex flex-col\">\n <label className=\"text-sm font-medium mb-2\">Generated Test File</label>\n <div className=\"flex-grow p-1 bg-background border rounded overflow-auto\">\n {isLoading && !generatedTest && <div className=\"flex justify-center items-center h-full\"><LoadingSpinner /></div>}\n {error && <p className=\"text-red-500 p-4\">{error}</p>}\n {generatedTest && <MarkdownRenderer content={generatedTest} />}\n </div>\n </div>\n </div>\n </div>\n );\n};\n"],"names":["exampleStackTrace","BugReproducer","stackTrace","setStackTrace","useState","context","setContext","generatedTest","setGeneratedTest","isLoading","setIsLoading","error","setError","handleGenerate","useCallback","stream","generateBugReproductionTestStream","fullResponse","chunk","err","jsxs","jsx","BugAntIcon","e","LoadingSpinner","MarkdownRenderer"],"mappings":"8nFAKA,MAAMA,EAAoB;AAAA;AAAA;AAAA;AAAA,sDAMbC,GAA0B,IAAM,CACzC,KAAM,CAACC,EAAYC,CAAa,EAAIC,EAAAA,SAASJ,CAAiB,EACxD,CAACK,EAASC,CAAU,EAAIF,EAAAA,SAAS;AAAA,0DAA+F,EAChI,CAACG,EAAeC,CAAgB,EAAIJ,EAAAA,SAAS,EAAE,EAC/C,CAACK,EAAWC,CAAY,EAAIN,EAAAA,SAAS,EAAK,EAC1C,CAACO,EAAOC,CAAQ,EAAIR,EAAAA,SAAS,EAAE,EAE/BS,EAAiBC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