From 1b59045889a0144300e10d05a4d73776236e1c2b Mon Sep 17 00:00:00 2001 From: george-lhj Date: Mon, 18 Aug 2025 14:05:18 -0700 Subject: [PATCH 1/2] add number/lines in generated code --- src/components/YamlPanel.tsx | 88 +++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/src/components/YamlPanel.tsx b/src/components/YamlPanel.tsx index c6741e0..ac967e5 100644 --- a/src/components/YamlPanel.tsx +++ b/src/components/YamlPanel.tsx @@ -52,7 +52,7 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa const activeFile = allFileNames.indexOf(activeTab) const [showLineNumbers, setShowLineNumbers] = useState(true) const [copiedFile, setCopiedFile] = useState(null) - const [showDiff, setShowDiff] = useState(true) + const [showDiff, setShowDiff] = useState(false) const [validationResult, setValidationResult] = useState(null) const [isValidating, setIsValidating] = useState(false) const prevYamlRef = useRef<{ [name: string]: string }>({}) @@ -68,6 +68,16 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa yamlFiles.find(f => f.name === name) || { name, content: '', language: 'yaml' as const } ) + // Ensure line numbers are properly aligned after content changes + useEffect(() => { + if (showLineNumbers && filesToShow.some(f => f.content.trim())) { + const codeBlocks = document.querySelectorAll('code.language-yaml') + codeBlocks.forEach(block => { + Prism.highlightElement(block) + }) + } + }, [filesToShow.map(f => f.content).join(''), showLineNumbers]) + // Track changes for diff - store the previous version before updating useEffect(() => { filesToShow.forEach(file => { @@ -109,19 +119,51 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa } const renderLineNumbers = (content: string) => { - const lines = content.split('\n') + const decodedContent = decodeEscaped(content) + const lines = decodedContent.split('\n') + + if (!decodedContent.trim()) { + return ( +
+          {decodedContent}
+        
+ ) + } + return ( -
-
+
+
{lines.map((_, index) => ( -
- {index + 1} -
+
{index + 1}
))}
-
-
-            {decodeEscaped(content)}
+        
+        
+
+            {decodedContent}
           
@@ -130,7 +172,6 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa const renderDiff = (oldContent: string, newContent: string) => { if (oldContent === newContent || oldContent === '') { - // No diff to show, just render the new content return (
           {decodeEscaped(newContent)}
@@ -145,19 +186,19 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa
         
Showing changes (green = added, red = removed)
-
+
{lines.map((line, idx) => { const lineStyle = line.type === 'insert' - ? { backgroundColor: '#dcfce7', color: '#166534' } // green-100 bg, green-800 text + ? { backgroundColor: '#dcfce7', color: '#166534' } : line.type === 'delete' - ? { backgroundColor: '#fee2e2', color: '#991b1b' } // red-100 bg, red-800 text - : { color: '#1f2937' } // gray-800 text + ? { backgroundColor: '#fee2e2', color: '#991b1b' } + : { color: '#1f2937' } return (
{line.type === 'insert' ? '+' : line.type === 'delete' ? '-' : ' '} {decodeEscaped(line.text)}
@@ -312,7 +353,6 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa return (
- {/* Header */}

Generated Files

@@ -339,7 +379,6 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa
- {/* File Tabs */}
{filesToShow.map((file, index) => { const hasFileContent = file.content.trim() !== '' @@ -365,11 +404,9 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa })}
- {/* File Content */}
{filesToShow.length > 0 && hasContent ? (
- {/* File Actions */}
{filesToShow[activeFile].name} @@ -411,7 +448,6 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa > - {/* Direct Edit Button */}
- {/* Validation Result */} {validationResult && (
)} - {/* YAML Content */}
{filesToShow[activeFile].content.trim() === '' ? (
@@ -505,16 +539,16 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa
) : showDiff ? ( -
+
{renderDiff(prevYamlRef.current[filesToShow[activeFile].name] || '', filesToShow[activeFile].content)}
) : showLineNumbers ? ( -
+
{renderLineNumbers(filesToShow[activeFile].content)}
) : ( -
-
+                
+
                     {decodeEscaped(filesToShow[activeFile].content)}
                   
From b2c498e51682e611debe802fb1bfcaf6b6d8a912 Mon Sep 17 00:00:00 2001 From: george-lhj Date: Mon, 18 Aug 2025 14:41:56 -0700 Subject: [PATCH 2/2] 60/40 split view --- src/App.tsx | 2 +- src/components/YamlPanel.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index e7a62f9..ab238b9 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -364,7 +364,7 @@ function App() { /> {/* Main Chat Area */} -
+
diff --git a/src/components/YamlPanel.tsx b/src/components/YamlPanel.tsx index ac967e5..203a297 100644 --- a/src/components/YamlPanel.tsx +++ b/src/components/YamlPanel.tsx @@ -352,7 +352,7 @@ export function YamlPanel({ yamlFiles, isLoading = false, activeTab, setActiveTa } return ( -
+

Generated Files