// ========================================== // Tab Content Renderers - Other Tabs // ========================================== // Functions for rendering Summary, IMPL Plan, Review, and Lite Context tabs // ========================================== // Summary Tab Rendering // ========================================== function renderSummaryContent(summaries) { if (!summaries || summaries.length === 0) { return `
No Summaries
No summaries found in .summaries/
`; } // Store summaries in global variable for modal access window._currentSummaries = summaries; return `
${summaries.map((s, idx) => { const normalizedContent = normalizeLineEndings(s.content || ''); // Extract first 3 lines for preview const previewLines = normalizedContent.split('\n').slice(0, 3).join('\n'); const hasMore = normalizedContent.split('\n').length > 3; return `

${escapeHtml(s.name || 'Summary')}

${escapeHtml(previewLines)}${hasMore ? '\n...' : ''}
`; }).join('')}
`; } // ========================================== // IMPL Plan Tab Rendering // ========================================== function renderImplPlanContent(implPlan) { if (!implPlan) { return `
No IMPL Plan
No IMPL_PLAN.md found for this session.
`; } // Normalize and store in global variable for modal access const normalizedContent = normalizeLineEndings(implPlan); window._currentImplPlan = normalizedContent; // Extract first 5 lines for preview const previewLines = normalizedContent.split('\n').slice(0, 5).join('\n'); const hasMore = normalizedContent.split('\n').length > 5; return `

Implementation Plan

${escapeHtml(previewLines)}${hasMore ? '\n...' : ''}
`; } // ========================================== // Review Tab Rendering // ========================================== // NOTE: Enhanced review tab with multi-select, filtering, and preview panel // is now in _review_tab.js - renderReviewContent() function defined there // ========================================== // Lite Context Tab Rendering // ========================================== function renderLiteContextContent(context, explorations, session, diagnoses) { const plan = session.plan || {}; let sections = []; // Render explorations if available (from exploration-*.json files) if (explorations && explorations.manifest) { sections.push(renderExplorationContext(explorations)); } // Render diagnoses if available (from diagnosis-*.json files) if (diagnoses && diagnoses.manifest) { sections.push(renderDiagnosisContext(diagnoses)); } // If we have context from context-package.json if (context) { sections.push(`
`); } // Fallback: show context from plan if (plan.focus_paths?.length || plan.summary) { sections.push(`
${plan.summary ? `

Summary

${escapeHtml(plan.summary)}

` : ''} ${plan.focus_paths?.length ? `

Focus Paths

${plan.focus_paths.map(p => `${escapeHtml(p)}`).join('')}
` : ''}
`); } // If we have any sections, wrap them if (sections.length > 0) { return `
${sections.join('')}
`; } return `
No Context Data
No context-package.json, exploration files, or diagnosis files found for this session.
`; } // ========================================== // Exploration Context Rendering // ========================================== function renderExplorationContext(explorations) { if (!explorations || !explorations.manifest) { return ''; } const manifest = explorations.manifest; const data = explorations.data || {}; let sections = []; // Header with manifest info sections.push(`

${escapeHtml(manifest.task_description || 'Exploration Context')}

Complexity: ${escapeHtml(manifest.complexity || 'N/A')} Explorations: ${manifest.exploration_count || 0}
`); // Render each exploration angle as collapsible section const explorationOrder = ['architecture', 'dependencies', 'patterns', 'integration-points', 'testing']; const explorationTitles = { 'architecture': 'Architecture', 'dependencies': 'Dependencies', 'patterns': 'Patterns', 'integration-points': 'Integration Points', 'testing': 'Testing' }; // Collect all angles from data (in case there are exploration angles not in our predefined list) const allAngles = [...new Set([...explorationOrder, ...Object.keys(data)])]; for (const angle of allAngles) { const expData = data[angle]; if (!expData) { continue; } const angleContent = renderExplorationAngle(angle, expData); sections.push(`
`); } return `
${sections.join('')}
`; } function renderExplorationAngle(angle, data) { let content = []; // Project structure - handle string or object if (data.project_structure) { content.push(renderExpField('Project Structure', data.project_structure)); } // Relevant files if (data.relevant_files && data.relevant_files.length) { content.push(`
${data.relevant_files.slice(0, 10).map(f => `
${escapeHtml(f.path || '')}
Relevance: ${f.relevance ? (f.relevance * 100).toFixed(0) : 0}%
${f.rationale ? `
${escapeHtml((f.rationale || "").substring(0, 200))}...
` : ''}
`).join('')} ${data.relevant_files.length > 10 ? `
... and ${data.relevant_files.length - 10} more files
` : ''}
`); } // Patterns - handle string or object if (data.patterns) { content.push(renderExpField('Patterns', data.patterns)); } // Dependencies - handle string or object if (data.dependencies) { content.push(renderExpField('Dependencies', data.dependencies)); } // Integration points - handle string or object if (data.integration_points) { content.push(renderExpField('Integration Points', data.integration_points)); } // Constraints - handle string or object if (data.constraints) { content.push(renderExpField('Constraints', data.constraints)); } // Clarification needs - handle array or object if (data.clarification_needs) { content.push(renderExpField('Clarification Needs', data.clarification_needs)); } return content.join('') || '

No data available

'; } // ========================================== // Diagnosis Context Rendering // ========================================== function renderDiagnosisContext(diagnoses) { if (!diagnoses || !diagnoses.manifest) { return ''; } const manifest = diagnoses.manifest; const data = diagnoses.data || {}; let sections = []; // Header with manifest info sections.push(`

${escapeHtml(manifest.task_description || 'Diagnosis Context')}

Diagnoses: ${manifest.diagnosis_count || 0}
`); // Render each diagnosis angle as collapsible section const diagnosisOrder = ['root-cause', 'api-contracts', 'dataflow', 'performance', 'security', 'error-handling']; const diagnosisTitles = { 'root-cause': 'Root Cause', 'api-contracts': 'API Contracts', 'dataflow': 'Data Flow', 'performance': 'Performance', 'security': 'Security', 'error-handling': 'Error Handling' }; // Collect all angles from data (in case there are diagnosis angles not in our predefined list) const allAngles = [...new Set([...diagnosisOrder, ...Object.keys(data)])]; for (const angle of allAngles) { const diagData = data[angle]; if (!diagData) { continue; } const angleContent = renderDiagnosisAngle(angle, diagData); sections.push(`
`); } return `
${sections.join('')}
`; } function renderDiagnosisAngle(angle, data) { let content = []; // Summary/Overview if (data.summary || data.overview) { content.push(renderExpField('Summary', data.summary || data.overview)); } // Root cause analysis if (data.root_cause || data.root_cause_analysis) { content.push(renderExpField('Root Cause', data.root_cause || data.root_cause_analysis)); } // Issues/Findings if (data.issues && Array.isArray(data.issues)) { content.push(`
${data.issues.map(issue => { if (typeof issue === 'string') { return `
${escapeHtml(issue)}
`; } else { return `
${escapeHtml(issue.title || issue.description || 'Unknown')}
${issue.location ? `
${escapeHtml(issue.location)}
` : ''} ${issue.severity ? `${escapeHtml(issue.severity)}` : ''}
`; } }).join('')}
`); } // Affected files if (data.affected_files && Array.isArray(data.affected_files)) { content.push(`
${data.affected_files.map(f => { const filePath = typeof f === 'string' ? f : (f.path || f.file || ''); return `${escapeHtml(filePath)}`; }).join('')}
`); } // Recommendations if (data.recommendations && Array.isArray(data.recommendations)) { content.push(`
    ${data.recommendations.map(rec => { const recText = typeof rec === 'string' ? rec : (rec.description || rec.action || ''); return `
  1. ${escapeHtml(recText)}
  2. `; }).join('')}
`); } // API Contracts (specific to api-contracts diagnosis) if (data.contracts && Array.isArray(data.contracts)) { content.push(renderExpField('API Contracts', data.contracts)); } // Data flow (specific to dataflow diagnosis) if (data.dataflow || data.data_flow) { content.push(renderExpField('Data Flow', data.dataflow || data.data_flow)); } return content.join('') || '

No diagnosis data available

'; }