// ========================================== // TASK DRAWER RENDERERS // ========================================== // Detailed content renderers and helper functions for task drawer function renderPreAnalysisSteps(preAnalysis) { if (!Array.isArray(preAnalysis) || preAnalysis.length === 0) { return '
No pre-analysis steps
'; } return `
๐Ÿ”

Pre-Analysis Steps

${preAnalysis.length}
${preAnalysis.map((item, idx) => `
${idx + 1}

${escapeHtml(item.step || item.action || 'Step ' + (idx + 1))}

${item.action && item.action !== item.step ? `
Action: ${escapeHtml(item.action)}
` : ''} ${item.commands?.length ? `
${item.commands.map(c => `${escapeHtml(typeof c === 'string' ? c : JSON.stringify(c))}`).join('')}
` : ''} ${item.output_to ? `
Output: ${escapeHtml(item.output_to)}
` : ''}
`).join('')}
`; } function renderImplementationStepsList(steps) { if (!Array.isArray(steps) || steps.length === 0) { return '
No implementation steps
'; } return `
๐Ÿ“‹

Implementation Approach

${steps.length}
${steps.map((step, idx) => { const hasMods = step.modification_points?.length; const hasFlow = step.logic_flow?.length; return `
${step.step || idx + 1}
${escapeHtml(step.title || 'Untitled Step')}
${step.description ? `
${escapeHtml(step.description)}
` : ''} ${hasMods ? `
${step.modification_points.map(mp => `
${typeof mp === 'string' ? `${escapeHtml(mp)}` : ` ${escapeHtml(mp.file || mp.path || '')} ${mp.changes ? `${escapeHtml(mp.changes)}` : ''} `}
`).join('')}
` : ''} ${hasFlow ? `
${step.logic_flow.map((lf, lfIdx) => `
${lfIdx + 1} ${escapeHtml(typeof lf === 'string' ? lf : lf.action || JSON.stringify(lf))}
`).join('')}
` : ''} ${step.depends_on?.length ? `
Dependencies:
${step.depends_on.map(d => `${escapeHtml(d)}`).join('')}
` : ''}
`}).join('')}
`; } function renderTargetFiles(files) { if (!Array.isArray(files) || files.length === 0) { return '
No target files
'; } // Get current project path for building full paths const projectPath = window.currentProjectPath || ''; return `
๐Ÿ“

Target Files

${files.length}
${files.map(f => { const filePath = typeof f === 'string' ? f : (f.path || JSON.stringify(f)); // Build full path for vscode link const fullPath = filePath.startsWith('/') || filePath.includes(':') ? filePath : (projectPath ? `${projectPath}/${filePath}` : filePath); const vscodeUri = `vscode://file/${fullPath.replace(/\\/g, '/')}`; return ` ๐Ÿ“„ ${escapeHtml(filePath)} โ†— `; }).join('')}
`; } function renderTestCommands(testCommands) { if (!testCommands || typeof testCommands !== 'object') return ''; const entries = Object.entries(testCommands); if (entries.length === 0) return ''; return `
๐Ÿงช

Test Commands

${entries.length}
${entries.map(([key, val]) => `
${escapeHtml(key)} ${escapeHtml(typeof val === 'string' ? val : JSON.stringify(val))}
`).join('')}
`; } function renderTaskDetail(sessionId, task) { // Get raw task data for JSON view const rawTask = task._raw || task; const taskJsonId = `task-json-${sessionId}-${task.id}`.replace(/[^a-zA-Z0-9-]/g, '-'); // Store JSON in memory instead of inline script tag taskJsonStore[taskJsonId] = rawTask; return `
${escapeHtml(task.id)} ${escapeHtml(task.title || 'Untitled')} ${task.status}
โ–ถ ${escapeHtml((task.meta?.type || task.meta?.action || '') + (task.meta?.scope ? ' | ' + task.meta.scope : ''))}
โ–ถ ${escapeHtml(getContextPreview(task.context, rawTask))}
โ–ถ ${escapeHtml(getFlowControlPreview(task.flow_control, rawTask))}
`; } function getContextPreview(context, rawTask) { const items = []; if (context?.requirements?.length) items.push(`${context.requirements.length} reqs`); if (context?.acceptance?.length) items.push(`${context.acceptance.length} acceptance`); if (context?.focus_paths?.length) items.push(`${context.focus_paths.length} paths`); if (rawTask?.modification_points?.length) items.push(`${rawTask.modification_points.length} mods`); return items.join(' | ') || 'No context'; } function getFlowControlPreview(flowControl, rawTask) { const steps = flowControl?.implementation_approach?.length || rawTask?.implementation?.length || 0; return steps > 0 ? `${steps} steps` : 'No steps'; } function renderDynamicFields(obj, priorityKeys = []) { if (!obj || typeof obj !== 'object') return '
null
'; const entries = Object.entries(obj).filter(([k, v]) => v !== null && v !== undefined && k !== '_raw'); if (entries.length === 0) return '
Empty
'; // Sort: priority keys first, then alphabetically entries.sort(([a], [b]) => { const aIdx = priorityKeys.indexOf(a); const bIdx = priorityKeys.indexOf(b); if (aIdx !== -1 && bIdx !== -1) return aIdx - bIdx; if (aIdx !== -1) return -1; if (bIdx !== -1) return 1; return a.localeCompare(b); }); return `
${entries.map(([key, value]) => renderFieldRow(key, value)).join('')}
`; } function renderFieldRow(key, value) { return `
${escapeHtml(key)}:
${renderFieldValue(key, value)}
`; } function renderFieldValue(key, value) { if (value === null || value === undefined) { return 'null'; } if (typeof value === 'boolean') { return `${value}`; } if (typeof value === 'number') { return `${value}`; } if (typeof value === 'string') { // Check if it's a path if (key.includes('path') || key.includes('file') || value.includes('/') || value.includes('\\')) { return `${escapeHtml(value)}`; } return `${escapeHtml(value)}`; } if (Array.isArray(value)) { if (value.length === 0) return '[]'; // Check if array contains objects or strings if (typeof value[0] === 'object') { return `
${value.map((item, i) => `
[${i + 1}]
${renderDynamicFields(item)}
`).join('')}
`; } // Array of strings/primitives const isPathArray = key.includes('path') || key.includes('file'); return `
${value.map(v => `${escapeHtml(String(v))}` ).join('')}
`; } if (typeof value === 'object') { return renderDynamicFields(value); } return escapeHtml(String(value)); } function renderContextFields(context, rawTask) { const sections = []; // Requirements / Description const requirements = context?.requirements || []; const description = rawTask?.description; if (requirements.length > 0 || description) { sections.push(`
${description ? `

${escapeHtml(description)}

` : ''} ${requirements.length > 0 ? `` : ''}
`); } // Focus paths / Modification points const focusPaths = context?.focus_paths || []; const modPoints = rawTask?.modification_points || []; if (focusPaths.length > 0 || modPoints.length > 0) { sections.push(`
${modPoints.length > 0 ? `
${modPoints.map(m => `
${escapeHtml(m.file || m)} ${m.target ? `โ†’ ${escapeHtml(m.target)}` : ''} ${m.change ? `

${escapeHtml(m.change)}

` : ''}
`).join('')}
` : `
${focusPaths.map(p => `${escapeHtml(p)}`).join('')}
`}
`); } // Acceptance criteria const acceptance = context?.acceptance || rawTask?.acceptance || []; if (acceptance.length > 0) { sections.push(`
`); } // Dependencies const depends = context?.depends_on || rawTask?.depends_on || []; if (depends.length > 0) { sections.push(`
${depends.map(d => `${escapeHtml(d)}`).join('')}
`); } // Reference const reference = rawTask?.reference; if (reference) { sections.push(`
${renderDynamicFields(reference)}
`); } return sections.length > 0 ? `
${sections.join('')}
` : '
No context data
'; } function renderFlowControlDetails(flowControl, rawTask) { const sections = []; // Pre-analysis const preAnalysis = flowControl?.pre_analysis || rawTask?.pre_analysis || []; if (preAnalysis.length > 0) { sections.push(`
`); } // Target files const targetFiles = flowControl?.target_files || rawTask?.target_files || []; if (targetFiles.length > 0) { sections.push(`
${targetFiles.map(f => `${escapeHtml(f)}`).join('')}
`); } return sections.join(''); }