@@ -76,18 +76,41 @@ export default (detectionType: CliScanType) => `
7676 hideElement('ai-apply-fix-btn');
7777 hideElement('ai-remediation');
7878 ge('ai-remediation-text').innerText = 'None';
79+ ge('ai-remediation-diff').innerText = '';
7980 }
8081
81- const renderAiRemediation = (remediation, isFixAvailable) => {
82+ const renderAiRemediation = (remediation, unifyDiff, isFixAvailable) => {
8283 isFixAvailable = false; // disable fix for now; not ready for production
8384
8485 hideElement('ai-remediation-btn');
85- showElement('ai-remediation');
8686 ge('ai-remediation-text').innerHTML = remediation;
87+ showElement('ai-remediation');
8788
8889 if (isFixAvailable) {
8990 showElement('ai-apply-fix-btn');
9091 }
92+
93+ if (!unifyDiff) {
94+ return;
95+ }
96+
97+ const configuration = {
98+ drawFileList: false,
99+ fileListToggle: false,
100+ fileListStartVisible: false,
101+ fileContentToggle: false,
102+ matching: 'words',
103+ outputFormat: 'line-by-line',
104+ synchronisedScroll: true,
105+ highlight: true,
106+ renderNothingWhenEmpty: false,
107+ colorScheme: isDarkTheme ? 'dark' : 'light',
108+ };
109+ const diff2htmlUi = new Diff2HtmlUI(ge('ai-remediation-diff'), unifyDiff, configuration);
110+
111+ diff2htmlUi.draw();
112+ diff2htmlUi.highlightCode();
113+ showElement('ai-remediation-diff');
91114 };
92115
93116 const registerAiButtonCallbacks = () => {
@@ -133,7 +156,7 @@ export default (detectionType: CliScanType) => `
133156 }
134157
135158 if (aiRemediation) {
136- renderAiRemediation(aiRemediation.remediation, aiRemediation.isFixAvailable);
159+ renderAiRemediation(aiRemediation.remediation, aiRemediation.unifyDiff, aiRemediation. isFixAvailable);
137160 }
138161 };
139162
0 commit comments