diff --git a/src/features/pr-review/PRDescription.svelte b/src/features/pr-review/PRDescription.svelte index 77831ba..44f0590 100644 --- a/src/features/pr-review/PRDescription.svelte +++ b/src/features/pr-review/PRDescription.svelte @@ -10,42 +10,9 @@ let expanded = $state(false); - // Check if this looks like a dependabot or automated PR - const isAutomatedPR = $derived.by(() => { - const lowerTitle = title.toLowerCase(); - const lowerBody = body.toLowerCase(); - return ( - lowerTitle.includes('dependabot') || - lowerTitle.includes('bump') || - lowerBody.includes('dependabot') || - body.includes('## ') || // Has markdown headers - body.includes('| ') || // Has tables - body.length > 500 - ); // Very long description - }); - - // For automated PRs, show a much shorter preview - const previewLength = $derived.by(() => (isAutomatedPR ? 100 : 200)); - const shouldShowToggle = $derived.by(() => body.length > previewLength); + const COLLAPSED_HEIGHT = 150; // px - const displayText = $derived.by(() => { - if (!shouldShowToggle || expanded) return body; - return body.substring(0, previewLength) + '...'; - }); - - // Simple markdown-to-text converter for preview - function stripMarkdown(text: string): string { - return text - .replace(/#{1,6}\s/g, '') // Remove headers - .replace(/\*\*(.*?)\*\*/g, '$1') // Remove bold - .replace(/\*(.*?)\*/g, '$1') // Remove italic - .replace(/\[(.*?)\]\(.*?\)/g, '$1') // Remove links, keep text - .replace(/`(.*?)`/g, '$1') // Remove code formatting - .replace(/\|.*\|/g, '') // Remove table rows - .replace(/---+/g, '') // Remove horizontal rules - .replace(/\n{3,}/g, '\n\n') // Normalize line breaks - .trim(); - } + const shouldShowToggle = $derived.by(() => body.length > 200); // Configure marked options for security and styling marked.setOptions({ @@ -53,13 +20,13 @@ gfm: true, // GitHub Flavored Markdown }); - const cleanText = $derived.by(() => stripMarkdown(displayText)); + // Always render the full markdown so tables/structure are never broken const renderedMarkdown = $derived.by(() => { try { - return marked.parse(displayText); + return marked.parse(body); } catch (error) { console.error('Error rendering markdown:', error); - return displayText; + return body; } }); @@ -80,18 +47,43 @@